Expand description
§Cinereus
GumTree-style tree diffing with Chawathe edit script generation.
Named after Phascolarctos cinereus (the koala), which lives in gum trees.
§Algorithm Overview
Cinereus implements a tree diff algorithm based on:
- GumTree (Falleri et al., ASE 2014) for node matching
- Chawathe algorithm (1996) for edit script generation
The algorithm works in phases:
- Top-down matching: Match identical subtrees by hash (Merkle-tree style)
- Bottom-up matching: Match remaining nodes by structural similarity (Dice coefficient)
- Edit script generation: Produce INSERT, DELETE, UPDATE, MOVE operations
§Usage
ⓘ
use cinereus::{Tree, tree_diff};
// Build trees from your data structure
let tree_a = Tree::build(/* ... */);
let tree_b = Tree::build(/* ... */);
// Compute the diff
let edit_script = tree_diff(&tree_a, &tree_b);
for op in edit_script {
println!("{:?}", op);
}Re-exports§
pub use tree::DiffTree;pub use tree::NoKey;pub use tree::NoProps;pub use tree::NoVal;pub use tree::NodeData;pub use tree::NodeHash;pub use tree::PropValue;pub use tree::Properties;pub use tree::PropertyInFinalState;pub use tree::SimpleTypes;pub use tree::Tree;pub use tree::TreeTypes;pub use tree::get_position_stats;pub use tree::reset_position_counters;pub use indextree;pub use matching::*;
Modules§
- matching
- GumTree matching algorithm GumTree node matching algorithm.
- tree
- Tree representation with properties support Tree representation for diffing.
Macros§
- debug
- Emit a debug-level log message (no-op version).
- trace
- Emit a trace-level log message (no-op version).
Enums§
- EditOp
- An edit operation in the diff.
Functions§
- diff_
trees - Compute a diff between two trees.
- diff_
trees_ with_ matching - Like
diff_trees, but also returns the node matching. - generate_
edit_ script - Generate an edit script from a matching between two trees.
Type Aliases§
- Prop
Changes - Type alias for final property states to satisfy clippy::type_complexity