| Crates.io | facet-dom |
| lib.rs | facet-dom |
| version | 0.43.1 |
| created_at | 2026-01-22 16:54:03.689305+00 |
| updated_at | 2026-01-23 08:49:42.322258+00 |
| description | Tree-based (DOM) deserializer for facet - supports HTML and XML |
| homepage | https://facet.rs |
| repository | https://github.com/facet-rs/facet |
| max_upload_size | |
| id | 2062163 |
| size | 207,945 |
Tree-based (DOM) serialization and deserialization for facet.
This crate provides the core serializers and deserializers for tree-structured documents like HTML and XML. It handles the DOM-specific concerns that don't apply to flat formats like JSON:
<div>, <person>)id="main", class="active")facet-dom sits between the format-specific parsers (facet-html, facet-xml)
and the generic facet reflection system:
facet-html / facet-xml
↓
facet-dom (DOM events: StartElement, Attribute, Text, EndElement)
↓
facet-reflect (Peek/Poke)
↓
Your Rust types
Consumes DOM events and builds Rust values:
use facet_dom::{DomDeserializer, DomParser};
// Parser emits events, deserializer consumes them
let parser: impl DomParser = /* ... */;
let value: MyType = DomDeserializer::new(parser).deserialize()?;
Converts Rust values to DOM events for output.
The deserializer maps DOM concepts to Rust types using facet attributes:
| DOM Concept | Rust Representation | Attribute |
|---|---|---|
| Tag name | Struct variant | #[facet(rename = "tag")] |
| Attribute | Field | #[facet(html::attribute)] |
| Text content | String field | #[facet(html::text)] |
| Child elements | Vec field | #[facet(html::elements)] |
Handles automatic case conversion between DOM naming (kebab-case) and Rust naming (snake_case), plus singularization for collection fields.
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
The facet logo was drawn by Misiasart.
Licensed under either of:
at your option.