tpt-doc

Rust

Pure-Rust enterprise document substrate — streaming OOXML/CSV, HL7 FHIR R5, EDIFACT/X12, PDF 1.7/2.0, PAdES/XAdES/CAdES signing, and HTML-to-PDF layout. No C-FFI. No Python. 100% MIT/Apache-2.0. NZISM · FHIR R5 · HIPC 2020 compliant.

0 stars0 forks0 watchers4 open issues

Languages

Rust100.0%
README

tpt-doc

Crates.io Docs.rs CI License: MIT OR Apache-2.0

The Enterprise Document & Data Substrate — high-assurance, pure-Rust, spec-compliant document generation and parsing for civic and enterprise platforms.

No shelling out to Python or Java. No C-FFI. No bloated dependency trees. 100% MIT/Apache-2.0 compatible.

Crates

CrateDescriptionDocsChangelog
tpt-doc-coreShared traits, zero-copy buffers, unified errorsdocs.rsCHANGELOG
tpt-doc-spreadsheetStreaming .xlsx (OOXML) and .csv parsing/generationdocs.rsCHANGELOG
tpt-doc-fhirHL7 FHIR R5 typed parsing, validation, and serializationdocs.rsCHANGELOG
tpt-doc-ediEDIFACT and X12 parsing with schema validationdocs.rsCHANGELOG
tpt-doc-hl7v2Streaming HL7 v2.x message parser and encoderdocs.rsCHANGELOG
tpt-doc-pdfPure-Rust PDF 1.7/2.0 generation and parsingdocs.rsCHANGELOG
tpt-doc-signCryptographic document signing (PAdES, XAdES, CAdES)docs.rsCHANGELOG
tpt-doc-layoutHeadless HTML/CSS-to-PDF layout enginedocs.rsCHANGELOG
tpt-doc-wordPure-Rust .docx (OOXML Word) generation and parsingdocs.rsCHANGELOG
tpt-doc-ublUBL 2.1/2.3 and PEPPOL BIS Billing 3.0 e-invoicingdocs.rsCHANGELOG

Prefer a single dependency? tpt-doc re-exports every crate behind per-format feature flags (features = ["fhir", "hl7v2"], or full).

Converters: tpt-doc-convert turns HL7 v2 ADT/ORU messages into FHIR R5 bundles.

Command line: tpt sniffs, inspects, validates and renders documents (tpt validate invoice.xml --json).

Each crate ships its own README with compiled examples and its own CHANGELOG.

Quick Start

[dependencies]
tpt-doc-fhir = "0.1"
tpt-doc-sign = "0.1"
ring = "0.17"          # supplies SecureRandom for signing
use ring::rand::SystemRandom;
use tpt_doc_fhir::prelude::*;
use tpt_doc_sign::{cades, pem, PrivateKey};

// Build a strictly typed FHIR Patient resource. `build()` only exists once
// every mandatory field is set, so an incomplete patient will not compile.
let patient = Patient::builder()
    .id("nz-12345")
    .name(HumanName::new("Smith", "John"))
    .build();

// Serialize to compliant FHIR JSON.
let json_bytes = patient.to_json()?;
assert!(String::from_utf8_lossy(&json_bytes).contains(r#""resourceType": "Patient""#));

// Detached CAdES signature over those bytes, for HIPC 2020 audit trails.
let key = PrivateKey::from_pem(&include_bytes!("key.pem")?)?;
let cert_der = pem::pem_to_der(&include_bytes!("cert.pem")?)?;
let signature =
    cades::sign_detached(&json_bytes, &key, &cert_der, &SystemRandom::new())?;
assert!(!signature.is_empty());

# Ok::<(), Box<dyn std::error::Error>>(())

See the per-crate READMEs for more examples; every one of them is compiled and run as a doctest in CI.

Compliance Targets

  • NZISM — New Zealand Information Security Manual
  • HL7 FHIR R5 — Fast Healthcare Interoperability Resources
  • HIPC 2020 — Health Information Privacy Code

Development Roadmap

  • Phase 1 (Months 1–2): tpt-doc-core + tpt-doc-spreadsheet
  • Phase 2 (Months 3–4): tpt-doc-fhir + tpt-doc-edi
  • Phase 3 (Months 5–6): tpt-doc-pdf + tpt-doc-sign + tpt-doc-layout

License

Licensed under either of:

at your option.

Copyright (c) 2026 TPT Solutions