isis-report-lib 0.3.0

Tabular reports with hierarchical layouts: HTML, PDF, XLSX, CSV and plain text
Documentation

isis-report-lib (Rust)

CI crates.io docs.rs MSRV License

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 isis_report_lib::{CsvOptions, RenderOptions, Report, XlsxOptions};

let report = Report::builder()
    .title("Sales")
    .locale("pt-BR")
    .layout(serde_json::json!({
        "company": {"label": "Empresa", "format_mask": "str"},
        "orders": {
            "total": {"label": "Total", "format_mask": "currency", "aggregate": "sum"}
        }
    }))
    .data(serde_json::json!([
        {"company": "ACME", "orders": [{"total": 1250.5}]}
    ]))
    .build()?;

let html = report.render_html(&RenderOptions::default())?;
let csv = report.export_csv(CsvOptions::default())?;
let xlsx = report.export_xlsx(XlsxOptions::default())?;
# Ok::<(), isis_report_lib::Error>(())

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 isis_report_lib::{PdfOptions, RenderOptions};

let pdf = report.export_pdf(&PdfOptions::default())?;

let options = PdfOptions {
    landscape: true,
    page_ranges: Some("1-3".to_string()),
    ..PdfOptions::default()
};
let pdf = report.export_pdf_with(&RenderOptions::default(), &options)?;
# Ok::<(), isis_report_lib::Error>(())

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

# #[cfg(feature = "sqlite")]
# fn demo() -> isis_report_lib::Result<()> {
use isis_report_lib::from_sqlite;

let payload = from_sqlite("sales.db", "SELECT * FROM sales", None, None)?;
# Ok(())
# }
  • from_arrow(&[RecordBatch], meta, layout) / from_arrow_batch(&RecordBatch, ...)
  • from_polars(&DataFrame, meta, layout)
  • from_duckdb(path, Some(query), meta, layout) or from_duckdb_connection
  • from_sqlite(path, query, meta, layout) or from_sqlite_connection
  • from_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 + optional layout + data, or composed sections; strict envelope validation (unknown keys fail closed).
  • Dynamic values: a Value enum compatible with JSON, with native date/datetime/decimal variants for database/columnar inputs.
  • Python semantics: ordering (None last), equality (10 == 10.0, True == 1), str()/repr(), truthiness and in are isolated in pyops.
  • 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

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.