Library API
The main types of the Rust crate. Item-level documentation, including every component builder, is on docs.rs.
renderreport::prelude::* brings the engine, the themes and all built-in components into scope.
The full API is on docs.rs/renderreport.
Engine
Engineimpl Engine {
pub fn new() -> Result<Engine>
pub fn with_config(config: EngineConfig) -> Result<Engine>
pub fn with_config_and_fonts(config: EngineConfig, extra_fonts: &[&[u8]]) -> Result<Engine>
}Holds the configuration, the font index, the component registry, loaded packs and the default
theme. Create it once and reuse it. with_config_and_fonts adds font bytes, for example from
include_bytes!, to the fonts the configuration selects.
EngineConfigpub struct EngineConfig {
pub pack_paths: Vec<PathBuf>, // ./packs, ~/.renderreport/packs
pub font_paths: Vec<PathBuf>, // none
pub use_embedded_fonts: bool, // true: bundled Fira Sans
pub use_system_fonts: bool, // true
pub cache_dir: Option<PathBuf>, // none
}Building and rendering
Engine::reportpub fn report(&self, template_id: impl Into<String>) -> ReportBuilderStarts a report. The builder sets title, subtitle, metadata, theme, pack,
page_setup and asset, appends components with add_component or add_components, and
returns a RenderRequest from build().
Engine::render_pdfpub fn render_pdf(&self, request: &RenderRequest) -> Result<Vec<u8>>Renders a request to PDF bytes with PDF/UA-1 enforced. render returns the same as a
RenderOutput.
Engine::render_typpub fn render_typ(&self, request: &RenderRequest) -> Result<String>The Typst source that render_pdf would compile, see
the generated Typst source.
Components and themes
Componentpub trait Component: Send + Sync {
fn component_id(&self) -> &str;
fn to_data(&self) -> serde_json::Value;
}Implemented by every built-in component. Implement it for your own types and register their
template with engine.components_mut().register(…), see
custom components.
Themeimpl Theme {
pub fn new(id: impl Into<String>, name: impl Into<String>) -> Theme
pub fn default_theme() -> Theme
}A named set of design tokens; set values with theme.tokens.set(key, TokenValue::…). See
themes and tokens.
AuditPattern, ExecutivePattern, MarketingPatternAuditPattern::new().add_findings(…).add_roadmap(…).to_components()Prepared report structures: each collects data for a fixed sequence of components and
returns them with to_components().