HwpForge Core: format-independent Document Object Model.
This crate defines the universal document structure used across all HwpForge format conversions. It is the Anvil in the Forge metaphor -- the surface on which all documents are shaped.
Architecture
Core sits one layer above Foundation:
foundation (primitives: HwpUnit, Color, Index<T>)
|
v
core (this crate: Document, Section, Paragraph, Run)
|
v
blueprint (styles: CharShape, ParaShape, Template)
|
v
smithy-* (format codecs: HWPX, HWP5, Markdown)
Core has zero knowledge of XML, binary formats, or Markdown.
It references style definitions by branded indices (Foundation's
CharShapeIndex,
ParaShapeIndex) without
depending on Blueprint.
Document Lifecycle (Typestate)
Document<Draft> --(validate)--> Document<Validated>
(mutable) (immutable)
- [
Draft] documents can be modified (add sections, set metadata). - [
Validated] documents are structurally sound and ready for export. - Deserialization always produces
Draft(must re-validate).
DOM Hierarchy
Document
+-- Metadata
+-- Section[]
+-- PageSettings
+-- Paragraph[]
+-- Run[]
+-- RunContent
+-- Text(String)
+-- Table(Box<Table>)
+-- Image(Image)
+-- Control(Box<Control>)
Examples
use *;
use Run;
use Section;
use Paragraph;
use ;
let mut doc = new;
doc.add_section;
let validated = doc.validate.unwrap;
assert_eq!;