Rust Crates
The Rust side is organized as a layered workspace with 10 crates. Each crate has a single responsibility.
Dependency graph​
docxio-types
↑
docxio-ooxml
↑
docxio-core
↑
├── docxio-wasm
├── docxio-wasm-minimal
├── docxio-napi
├── docxio-cli
├── docxio-pdf
├── docxio-bench
└── docxio-fuzz
Crate responsibilities​
docxio-types​
Shared document model types. Defines DocumentTree, DocumentNode, and all property structs (ParagraphProps, RunProps, TableProps, etc.).
- Derives
serde::Serializeandserde::Deserializewithrename_all = "camelCase"for JS interop - No XML or ZIP dependencies
- Used by every other crate in the workspace
docxio-ooxml​
OOXML XML generation using quick-xml. Stateless functions that take typed Rust structs and produce XML byte output.
Key modules:
document_xml.rs--word/document.xmlstyles_xml.rs--word/styles.xmlnumbering_xml.rs--word/numbering.xmlheader_xml.rs/footer_xml.rs-- header/footer partsdrawing_xml.rs-- image drawing elementsrelationships.rs--.relsrelationship filescontent_types.rs--[Content_Types].xmlsanitizemodule -- validates and clamps colors, sizes, dimensions to OOXML spec ranges
docxio-core​
Orchestration layer. Walks the document tree, calls docxio-ooxml to generate XML parts, and assembles them into a ZIP archive.
Key modules:
render.rs-- Tree walker, calls OOXML generatorsbuilder.rs-- Document builder APIparser.rs-- JSON-to-DocumentTree parsingtemplate.rs-- Template patching ({{placeholder}}replacement)validate.rs-- OOXML structure validationmedia.rs-- Image registry and embeddingrel_manager.rs-- Relationship ID management
docxio-wasm​
Full WebAssembly binding (~920 KB). Exposes generate(), patch(), and validate() entry points via wasm-bindgen. Includes ZIP packaging, template engine, and validator.
docxio-wasm-minimal​
Minimal WebAssembly binding (~441 KB). Exposes generate_document_parts() which returns XML parts without ZIP assembly. Used with @docxio/zip for browser-optimized builds.
docxio-napi​
Native Node.js binding via napi-rs. Exposes a #[napi] generate() function for maximum server-side performance without WASM overhead.
docxio-cli​
Command-line tool built with clap:
docxio generate -i doc.json -o output.docx-- generate from JSONdocxio patch template.docx data.json -o filled.docx-- template patchingdocxio watch -i doc.json -o output.docx-- rebuild on file changes
docxio-pdf​
PDF export via printpdf. Currently planned and not yet functional.
docxio-bench​
Benchmarks using criterion. Measures XML generation, ZIP assembly, and end-to-end rendering performance.
docxio-fuzz​
Fuzz testing targets for the document parser and renderer. Helps discover edge cases and potential panics.
Workspace configuration​
All crates inherit workspace-level lints and formatting rules:
clippy.toml+[workspace.lints]for consistent Clippy rulesrustfmt.tomlfor formattingunsafe_code = "deny"across all cratesoverflow-checks = truein release builds