isis-report-lib 0.2.2

Tabular reports with hierarchical layouts: HTML, PDF, XLSX, CSV and plain text
Documentation
//! `isis-report-lib` - tabular reports with hierarchical layouts.
//!
//! A Rust port of the Python library of the same name. The public surface is
//! intentionally close to the original: JSON-compatible payloads, `.toon`
//! input, hierarchical layouts, HTML/PDF/XLSX/CSV/text exports and a
//! tamper-evident signature seal.
//!
//! ## Quickstart
//!
//! ```
//! use isis_report_lib::{generate_csv, render_html, Value};
//! use serde_json::json;
//!
//! let payload = Value::from_json(json!({
//!     "meta": {"title": "Sales", "locale": "en-US"},
//!     "layout": {
//!         "name": {"label": "Name", "format_mask": "str"},
//!         "total": {"label": "Total", "format_mask": "currency"}
//!     },
//!     "data": [{"name": "Pen", "total": 12.5}]
//! }));
//!
//! let html = render_html(&payload, None, "tabular.jinja", false, None)?;
//! let csv = generate_csv(&payload, ',', false, None)?;
//! assert!(html.contains("Sales"));
//! assert!(csv.contains("Pen"));
//! # Ok::<(), isis_report_lib::Error>(())
//! ```
//!
//! Runnable examples live in `examples/`: `quickstart`, `inputs`, `xlsx`,
//! `signing` and `pdf_throughput`. The feature-gated APIs are documented under
//! their modules (`pdf_backend`, `inputs`, `signing` and `export`).
//!
//! ## Feature-gated input adapters
//!
//! `from_polars`, `from_duckdb` and `from_duckdb_connection` are compiled with
//! the `polars` and `duckdb` features. docs.rs does not build those features:
//! `libduckdb-sys` downloads a prebuilt DuckDB library at build time and the
//! docs.rs sandbox has no network, while Polars is kept out to keep the docs
//! build light. See the
//! [feature-gated input guide](https://github.com/thepaneb/rust-isis-report-lib/blob/main/docs/feature-gated-inputs.md)
//! for signatures and examples.
//!
//! For a validated report that can be rendered and exported repeatedly, start
//! with [`Report::builder`]. The free functions above remain available and
//! unchanged.

#![forbid(unsafe_code)]
#![warn(missing_docs)]

pub mod api;
pub mod charts;
#[cfg(feature = "cli")]
pub mod cli;
pub mod crosstab;
pub mod error;
pub mod export;
pub mod formatting;
pub mod inputs;
pub mod layout;
pub mod logging;
pub mod media;
pub mod options;
pub mod payload;
#[cfg(feature = "pdf")]
pub mod pdf_backend;
pub mod pyops;
pub mod rendering;
pub mod report;
pub mod service;
pub mod signing;
pub mod text;
pub mod toon;
pub mod value;

pub use api::{
    agenerate_csv, agenerate_csv_from_toon, agenerate_many, agenerate_pdf, agenerate_pdf_from_toon, agenerate_xlsx,
    agenerate_xlsx_from_toon, arender_html, arender_html_from_toon, arender_text, arender_text_from_toon, generate_csv, generate_csv_async,
    generate_csv_from_toon, generate_many, generate_pdf, generate_pdf_from_toon, generate_xlsx, generate_xlsx_async,
    generate_xlsx_from_toon, render_html, render_html_async, render_html_from_toon, render_text, render_text_async, render_text_from_toon,
};

#[cfg(feature = "pdf")]
pub use api::{
    generate_many_async, generate_many_with, generate_pdf_async, generate_pdf_from_toon_with, generate_pdf_with, generate_pdf_with_async,
};
pub use charts::{bar_chart, build_chart, line_chart, pie_chart, sparkline};
pub use crosstab::{build_crosstab, Crosstab};
pub use error::{Error, Result};
pub use export::{build_workbook, collect_tables, render_csv, Column, SummaryRow, Table};
pub use formatting::{
    cell_style, cell_style_dict, field_text, format_value, normalize_color_scale, normalize_footnote, normalize_locale, CellStyle,
    ColorScale, Footnote,
};
#[cfg(feature = "arrow")]
pub use inputs::from_arrow_batch;
#[cfg(feature = "duckdb")]
pub use inputs::from_duckdb_connection;
#[cfg(feature = "sqlite")]
pub use inputs::from_sqlite_connection;
pub use inputs::{
    from_csv, from_csv_reader, from_duckdb, from_json, from_json_str, from_json_value, from_jsonl, from_jsonl_str, from_polars, from_rows,
    from_sqlite, payload_schema,
};
pub use layout::{
    aggregate_values, assign_report_footnotes, build_report, collect_footnotes, convert_data, convert_layout, infer_layout,
    is_template_format, split_layout_node, template_header_layout, AGGREGATIONS,
};
pub use media::{normalize_image_src, normalize_watermark, Watermark};
pub use options::{CsvOptions, RenderOptions, TextOptions, XlsxOptions};
pub use payload::{
    check_quotas, normalize_limits, normalize_payload, validate_payload_shape, Limits, Meta, Payload, DEFAULT_MAX_BYTES, DEFAULT_MAX_ROWS,
};
#[cfg(feature = "pdf")]
pub use pdf_backend::{
    default_footer, is_host_allowed, pdf_pool_stats, shutdown_pdf_pool, validate_allowed_hosts, Margins, PageFormat, PdfBackend, PdfError,
    PdfOptions, PdfPoolStats,
};
pub use rendering::{render_report_html, resolve_css_vars};
pub use report::{Report, ReportBuilder};
pub use service::{prepare_report, PreparedReport, ReportService, TabularReportService};
pub use signing::{
    generate_ed25519_keypair, generate_hmac_key, sign_pdf, verify_pdf, verify_pdf_with_key, KeyMaterial, SignatureAlg, SignatureInfo,
    HMAC_MIN_KEY_BYTES,
};
pub use toon::{parse_toon, ToonParser};
pub use value::Value;