tpt-doc
RustPure-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.
Languages
tpt-doc
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
| Crate | Description | Docs | Changelog |
|---|---|---|---|
tpt-doc-core | Shared traits, zero-copy buffers, unified errors | CHANGELOG | |
tpt-doc-spreadsheet | Streaming .xlsx (OOXML) and .csv parsing/generation | CHANGELOG | |
tpt-doc-fhir | HL7 FHIR R5 typed parsing, validation, and serialization | CHANGELOG | |
tpt-doc-edi | EDIFACT and X12 parsing with schema validation | CHANGELOG | |
tpt-doc-hl7v2 | Streaming HL7 v2.x message parser and encoder | CHANGELOG | |
tpt-doc-pdf | Pure-Rust PDF 1.7/2.0 generation and parsing | CHANGELOG | |
tpt-doc-sign | Cryptographic document signing (PAdES, XAdES, CAdES) | CHANGELOG | |
tpt-doc-layout | Headless HTML/CSS-to-PDF layout engine | CHANGELOG | |
tpt-doc-word | Pure-Rust .docx (OOXML Word) generation and parsing | CHANGELOG | |
tpt-doc-ubl | UBL 2.1/2.3 and PEPPOL BIS Billing 3.0 e-invoicing | CHANGELOG |
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