Skip to main content

ChangeReport

Trait ChangeReport 

Source
pub trait ChangeReport:
    Default
    + Clone
    + Debug {
    // Required methods
    fn any(&self) -> bool;
    fn paths(&self) -> Vec<Vec<Cow<'static, str>>>;
    fn leaf_paths(&self) -> Vec<Vec<Cow<'static, str>>>;

    // Provided method
    fn none(&self) -> bool { ... }
}
Expand description

Trait for hierarchical change reports.

Generated *Changes types implement this trait to provide a uniform interface for inspecting what changed in a document update.

§Example

use automorph::ChangeReport;

fn handle_changes(changes: &PersonChanges) {
    if changes.any() {
        for path in changes.leaf_paths() {
            println!("Changed: {:?}", path);
        }
    }
}

Required Methods§

Source

fn any(&self) -> bool

Returns true if any field in this report (or nested reports) changed.

Source

fn paths(&self) -> Vec<Vec<Cow<'static, str>>>

Collects all changed field paths as strings.

For nested changes, returns paths at each level. For example: [["baz"], ["baz", "wombat"], ["baz", "wombat", "x"]]

Uses Cow<'static, str> to support both static field names (borrowed) and dynamic keys like HashMap keys or Vec indices (owned).

Source

fn leaf_paths(&self) -> Vec<Vec<Cow<'static, str>>>

Collects only the leaf (deepest) changed field paths.

For example: [["baz", "wombat", "x"]] (not intermediate paths)

Uses Cow<'static, str> to support both static field names (borrowed) and dynamic keys like HashMap keys or Vec indices (owned).

Provided Methods§

Source

fn none(&self) -> bool

Returns true if no fields changed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§