| Crates.io | facet-xml-diff |
| lib.rs | facet-xml-diff |
| version | 0.43.1 |
| created_at | 2026-01-22 16:54:16.105174+00 |
| updated_at | 2026-01-23 08:53:22.449189+00 |
| description | Diff-aware XML serialization for facet |
| homepage | https://facet.rs |
| repository | https://github.com/facet-rs/facet |
| max_upload_size | |
| id | 2062164 |
| size | 32,828 |
Diff-aware XML serialization—render structural diffs as readable XML.
This crate renders diffs between facet values as XML with visual diff markers. It shows what changed between two values in a format that's easy to read, with proper alignment, colored output, and collapsing of unchanged regions.
use facet::Facet;
use facet_diff::tree_diff;
#[derive(Facet)]
struct Rect {
fill: String,
x: i32,
y: i32,
}
let old = Rect { fill: "red".into(), x: 10, y: 20 };
let new = Rect { fill: "blue".into(), x: 10, y: 20 };
let xml = facet_xml_diff::diff_to_string(&old, &new)?;
Output:
<rect
← fill="red"
→ fill="blue"
x="10" y="20"
/>
←/→ (or -/+) prefix lines to show old vs new values...use facet_xml_diff::{DiffSerializeOptions, DiffSymbols, DiffTheme};
let options = DiffSerializeOptions {
symbols: DiffSymbols::ascii(), // Use -/+ instead of arrows
theme: DiffTheme::default(),
colors: true,
indent: " ",
max_line_width: 80,
collapse_threshold: 3,
..Default::default()
};
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.