Crate diffo

Crate diffo 

Source
Expand description

Semantic diffing for Rust structs.

diffo computes structural differences between two values of the same type, leveraging serde for serialization. No derive macros needed - just implement Serialize and you’re ready to go.

§Examples

Basic usage:

use diffo::diff;
use serde::Serialize;

#[derive(Serialize)]
struct User {
    id: u64,
    name: String,
}

let old = User { id: 1, name: "Alice".into() };
let new = User { id: 1, name: "Bob".into() };

let d = diff(&old, &new).unwrap();
assert!(!d.is_empty());

With configuration:

use diffo::{diff_with, DiffConfig};

let config = DiffConfig::new()
    .mask("password");

let d = diff_with(&old, &new, &config).unwrap();

§Output Formats

§Performance

Complexity is O(n) for most operations, where n is the number of fields. Sequence diffing is index-based (O(n)), not LCS-based (O(n²)).

Modules§

format
Output formatters for diffs.

Structs§

Diff
Represents a complete diff between two values.
DiffConfig
Configuration for diff computation.
Path
Represents a path to a field in a nested structure.

Enums§

Change
Represents a change at a specific path in the diff.
Error
Error type for diff operations.
FormatError
Error type for formatting operations.
SequenceDiffAlgorithm
Algorithm to use for sequence diffing.

Traits§

ValueExt
Extension trait for Value to provide convenient accessor methods.

Functions§

apply
Apply a diff to a base value, producing a new value with changes applied.
diff
Compute diff between two values of the same type.
diff_with
Compute diff with custom configuration.

Type Aliases§

Comparator
Type alias for custom comparator functions.