pub struct DiffConfig { /* private fields */ }Expand description
Configuration for diff computation.
§Examples
use diffo::{DiffConfig, SequenceDiffAlgorithm};
let config = DiffConfig::new()
.mask("*.password")
.mask("api.secret")
.float_tolerance("metrics.*", 1e-6)
.collection_limit(500)
.sequence_algorithm("users", SequenceDiffAlgorithm::Patience)
.default_sequence_algorithm(SequenceDiffAlgorithm::IndexBased);Implementations§
Source§impl DiffConfig
impl DiffConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new configuration with default settings.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new();Sourcepub fn ignore(self, pattern: &str) -> Self
pub fn ignore(self, pattern: &str) -> Self
Ignore changes at matching paths.
Supports glob patterns like *.password or database.*.credentials.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.ignore("internal.*")
.ignore("*.temp");Sourcepub fn mask(self, pattern: &str) -> Self
pub fn mask(self, pattern: &str) -> Self
Mask values at matching paths.
Masked values will show as “***” in output instead of actual values.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.mask("*.password")
.mask("api.secret");Sourcepub fn float_tolerance(self, pattern: &str, tolerance: f64) -> Self
pub fn float_tolerance(self, pattern: &str, tolerance: f64) -> Self
Set float tolerance for specific paths.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.float_tolerance("metrics.*.value", 1e-6);Sourcepub fn default_float_tolerance(self, tolerance: f64) -> Self
pub fn default_float_tolerance(self, tolerance: f64) -> Self
Set default float tolerance for all floats.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.default_float_tolerance(1e-9);Sourcepub fn max_depth(self, depth: usize) -> Self
pub fn max_depth(self, depth: usize) -> Self
Set maximum traversal depth.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.max_depth(32);Sourcepub fn collection_limit(self, limit: usize) -> Self
pub fn collection_limit(self, limit: usize) -> Self
Set maximum collection size to diff.
Collections larger than this limit will be elided.
§Examples
use diffo::DiffConfig;
let config = DiffConfig::new()
.collection_limit(500);Sourcepub fn sequence_algorithm(
self,
pattern: &str,
algorithm: SequenceDiffAlgorithm,
) -> Self
pub fn sequence_algorithm( self, pattern: &str, algorithm: SequenceDiffAlgorithm, ) -> Self
Set sequence diff algorithm for specific paths.
§Examples
use diffo::{DiffConfig, SequenceDiffAlgorithm};
let config = DiffConfig::new()
.sequence_algorithm("users", SequenceDiffAlgorithm::Patience)
.sequence_algorithm("logs.*", SequenceDiffAlgorithm::Myers);Sourcepub fn default_sequence_algorithm(
self,
algorithm: SequenceDiffAlgorithm,
) -> Self
pub fn default_sequence_algorithm( self, algorithm: SequenceDiffAlgorithm, ) -> Self
Set default sequence diff algorithm.
§Examples
use diffo::{DiffConfig, SequenceDiffAlgorithm};
let config = DiffConfig::new()
.default_sequence_algorithm(SequenceDiffAlgorithm::Myers);Sourcepub fn comparator(self, pattern: &str, comparator: Comparator) -> Self
pub fn comparator(self, pattern: &str, comparator: Comparator) -> Self
Add a custom comparator for a specific path pattern.
When comparing values at paths matching the pattern, the comparator
will be called first. If it returns true, values are considered equal
and no diff is recorded. If it returns false, normal diffing proceeds.
Uses glob patterns for matching. Note: Array indices like [0], [1]
require workaround patterns (e.g., ?0?, ?1?) due to glob syntax
treating [] as character classes.
§Examples
use diffo::{DiffConfig, ValueExt};
use std::rc::Rc;
let config = DiffConfig::new()
// Field-level comparison
.comparator("url", Rc::new(|old, new| {
if let (Some(a), Some(b)) = (old.as_string(), new.as_string()) {
a.to_lowercase() == b.to_lowercase()
} else {
old == new
}
}))
// Array element (workaround pattern)
.comparator("?0?", Rc::new(|old, new| {
old.get_field("id") == new.get_field("id")
}));Trait Implementations§
Source§impl Clone for DiffConfig
impl Clone for DiffConfig
Source§fn clone(&self) -> DiffConfig
fn clone(&self) -> DiffConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more