typst-template 0.1.0

Generate PDFs with Typst straight from your Rust types: derive Typst inputs from structs and render templates, on a reusable world for cheap repeated generation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use typst::foundations::{Decimal, Value};

use crate::ToValue;

impl ToValue for rust_decimal::Decimal {
    fn into_value(self) -> Value {
        // Typst has its own 128-bit decimal; round-trip through the string form
        // to preserve the exact value.
        let decimal: Decimal = self
            .to_string()
            .parse()
            .expect("decimal string is well-formed");
        Value::Decimal(decimal)
    }
}