Expand description
Diff engine and reporting primitives for netform_ir::Document.
This crate builds comparison views from lossless IR documents, applies explicit normalization and ordering policies, and emits deterministic edits.
Primary entrypoints:
§Example
use netform_diff::{diff_documents, NormalizeOptions};
use netform_ir::parse_generic;
let left = parse_generic("hostname old\n");
let right = parse_generic("hostname new\n");
let diff = diff_documents(&left, &right, NormalizeOptions::default());
assert!(diff.has_changes);Structs§
- Comparison
Line - One normalized line in the internal comparison view.
- Comparison
View - Flattened line-oriented view derived from a document.
- Diff
- Top-level diff output contract.
- Diff
Line - Serializable line payload embedded in diff edits.
- Diff
Stats - Aggregate counters for diff output.
- Edit
Anchor - Path/span anchor for edit placement and diagnostics.
- Finding
- Warning/info emitted during parse propagation or diff uncertainty handling.
- Normalize
Options - Options controlling normalization and ordering semantics for diffing.
- Order
Policy Config - Ordering policy configuration with a default and longest-prefix overrides.
- Order
Policy Override - Path-based policy override for specific subtree contexts.
- Plan
- Transport-neutral action plan derived from a
Diff. - Plan
Finding - Plan-level warning (for example missing anchors).
- Plan
Line Edit - One line-oriented edit in
apply_line_edits_under_context.
Enums§
- Edit
- Edit script operation emitted by the diff engine.
- Finding
Level - Severity level for a
Finding. - KeyKind
- Key namespace discriminator used when hashing comparison identities.
- Normalization
Step - One ordered normalization step in the comparison pipeline.
- Order
Policy - Ordering behavior used when comparing sibling lines in a context.
- Plan
Action - Action variants emitted in a
Plan. - Plan
Line Edit Kind - Line operation kind for
PlanLineEdit.
Functions§
- build_
comparison_ view - Build a flattened comparison view from a parsed document.
- build_
plan - Convert a
Diffinto a transport-neutral action plan. - derive_
content_ key - Derive a content key from parent signature, key kind, trivia, and normalized text.
- derive_
occurrence_ key - Derive an occurrence key from content key and 1-based ordinal.
- diff_
documents - Compute a deterministic diff between two parsed documents.
- format_
markdown_ report - Format a markdown-oriented human report from a diff result.