isis-report-lib (Rust)
A Rust port of isis-report-lib:
tabular reports with hierarchical layouts, rendered to HTML, PDF, XLSX, CSV and
plain text.
The Python library remains the behavioral reference. The scripts in parity/
generate the golden fixtures in crates/isis-report-lib/tests/fixtures/golden/.
Features
| Feature | Enables |
|---|---|
pdf (enabled by cli) |
Chromium/CDP PDF backend (chromiumoxide + Tokio), pooled per process |
xlsx |
Native Excel workbook, charts, data bars and conditional formats |
email |
CSS inlining for email-friendly HTML |
sign |
Ed25519 signatures (HMAC-SHA256 is always available) |
arrow |
from_arrow / from_arrow_batch payload builders |
polars |
from_polars payload builder |
duckdb |
from_duckdb / from_duckdb_connection builders |
sqlite |
from_sqlite / from_sqlite_connection builders |
schema |
Payload JSON Schema (default) |
cli |
isis-report binary and all browser/export features |
weasyprint-cli |
Optional external weasyprint PDF shim |
Usage
use ;
let report = builder
.title
.locale
.layout
.data
.build?;
let html = report.render_html?;
let csv = report.export_csv?;
let xlsx = report.export_xlsx?;
# Ok::
render_html_default() uses default options; inline_css: true requires the
email feature. TextOptions controls the plain-text export and every options
struct can tighten operator limits.
PDF:
use ;
let pdf = report.export_pdf?;
let options = PdfOptions ;
let pdf = report.export_pdf_with?;
# Ok::
The sync API starts a private Tokio runtime; async callers should use
Report::export_pdf_async / export_pdf_with_async or the free
generate_pdf_async / generate_pdf_with_async functions instead. PDF
generation uses a process-wide pool of Chromium workers (one browser per
worker), so consecutive reports avoid a launch. Pages run with JavaScript disabled, service workers
bypassed and outbound HTTP(S) blocked unless allowed_hosts is set. Call
isis_report_lib::shutdown_pdf_pool() to close the workers in a long-lived
process; the CLI does this automatically. ISIS_REPORT_PDF_WORKERS (1-8)
controls the pool size and ISIS_REPORT_PDF_IDLE_SECS (default 300, 0 disables)
closes idle browsers. pdf_pool_stats() reports workers, in-flight jobs,
browser launches, renders and idle closes. Run the pdf_throughput example to
compare cold and warm renders.
debug_dir writes report.html, a full-page report.png and a real Chrome
Trace Format dump (trace.json) from CDP. It may contain report data; protect or
delete it after use.
Examples
Runnable examples are in crates/isis-report-lib/examples:
cargo run -p isis-report-lib --example quickstart
cargo run -p isis-report-lib --example inputs
cargo run -p isis-report-lib --features xlsx --example xlsx
cargo run -p isis-report-lib --example signing
cargo run -p isis-report-lib --features pdf --example pdf_throughput
The crate-level docs also include a compiling quickstart.
Input builders
#
#
from_arrow(&[RecordBatch], meta, layout)/from_arrow_batch(&RecordBatch, ...)from_polars(&DataFrame, meta, layout)from_duckdb(path, Some(query), meta, layout)orfrom_duckdb_connectionfrom_sqlite(path, query, meta, layout)orfrom_sqlite_connectionfrom_rows(columns, rows, meta, layout)for any DB-API-style driver
Reader-based variants accept any Read/BufRead source:
from_json_reader, from_jsonl_reader, from_toon_reader and
from_csv_reader_with_options. ReadOptions can enforce max_rows/max_bytes
while the input is consumed.
polars and duckdb are feature-gated and intentionally not rendered on
docs.rs; see feature-gated input adapters
for their signatures and examples.
Dates, datetimes and decimals are kept as native Value variants; NaN is
normalized to Null.
Writers
Report::write_csv, write_text and write_xlsx accept any Write sink;
write_csv and write_workbook are the free-function equivalents. The existing
export_csv, export_text and export_xlsx methods keep returning
String/Vec<u8>.
CLI
cargo install isis-report-lib --features cli
isis-report generate report.json -o report.pdf --locale pt-BR
isis-report generate report.json -o report.xlsx
isis-report generate report.json --format csv --bom
isis-report render report.json --format html -o report.html
cat rows.jsonl | isis-report generate - --input-format jsonl --format csv -o -
cat report.json | isis-report render - --input-format json -o -
isis-report schema
isis-report keygen --kind hmac -o key.bin
isis-report sign report.pdf --key-file key.bin -o report.signed.pdf
isis-report verify report.signed.pdf --key-file key.bin --json
- reads stdin; -o - writes stdout for CSV, text and HTML. Stdin requires an
explicit --input-format, and PDF/XLSX output requires a file path.
PDF flags: --page-format, --header-template, --footer-template,
--allowed-hosts (repeatable), --debug-dir.
Design
- Payload contract:
meta+ optionallayout+data, or composedsections; strict envelope validation (unknown keys fail closed). - Dynamic values: a
Valueenum compatible with JSON, with native date/datetime/decimal variants for database/columnar inputs. - Python semantics: ordering (
Nonelast), equality (10 == 10.0,True == 1),str()/repr(), truthiness andinare isolated inpyops. - Safety: no payload value is echoed in errors/logs; quotas, depth limits, data-URI-only images and strict template autoescape are part of the design.
- Locales: the 13-locale matrix (
pt-BR,en-US,pt-PT,de-DE,fr-FR,es-ES,ja-JP,ar-EG,he-IL,ru-RU,zh-CN,hi-IN,en-GB) matches Babel for numbers, currency and medium dates; locales outside the matrix use ICU4X/CLDR and may differ in edge cases.
Workspace
crates/isis-report-lib # public library + `isis-report` binary + PDF backend
crates/isis-report-pdf # compatibility facade (publish = false)
parity/ # Python fixture generators
crates/isis-report-lib/tests/fixtures/golden # generated golden fixtures
Documentation
- Python-to-Rust migration guide
- Feature-gated input adapters
- Roadmap
- 0.2.0 API plan
- Python parity audit
- Architecture Decision Records
- Release checklist
- Changelog
- Security policy
Testing
cargo test --workspace --all-features
cargo clippy --workspace --all-features --all-targets -- -D warnings
cargo fmt --all -- --check
cargo llvm-cov --workspace --all-features --summary-only -- --include-ignored --test-threads=1
The coverage command also requires Chrome because it includes the PDF e2e tests. PDF browser tests are ignored by default because they require a local Chromium/Chrome:
cargo test -p isis-report-lib --features pdf pdf_backend::tests:: -- --ignored --test-threads=1
CI runs formatting, clippy, the full test suite on Linux, the cli suite and
full Chromium PDF e2e on Windows/macOS, a dedicated Chromium PDF e2e job on
Linux, cargo-deny, and an MSRV check with Rust 1.89.
Fuzzing targets for TOON, payload/layout, HTML rendering and signatures live in
fuzz/ and run on a weekly GitHub Actions schedule.
Benchmarks
Criterion benchmarks cover shaping, HTML rendering, CSV/XLSX export, TOON parsing and 100k-row reader/writer throughput:
cargo bench -p isis-report-lib --features xlsx --bench pipeline
cargo bench -p isis-report-lib --features xlsx --bench large
The PDF benchmark needs a local Chromium/Chrome:
cargo bench -p isis-report-lib --features pdf --bench pdf
Criterion writes HTML reports under target/criterion/. The pipeline workload
matches the Python benchmark (5 orders, 300 detail rows) so medians are
comparable; large uses 100k flat rows. PDF timings include browser-pool warmup
and should be compared on the same machine.
CI also runs a smoke-level performance gate with generous budgets, including a 100k-row CSV/XLSX pass:
cargo run --release -p isis-report-lib --features cli --example perf_check
Use -- --no-pdf to skip the Chromium step locally. Budgets live in
crates/isis-report-lib/benches/budgets.json; the gate catches pathological
regressions, not small drifts.
License
MIT - see LICENSE.