1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! 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};
//! # use serde::Serialize;
//! # #[derive(Serialize)]
//! # struct Config { password: String }
//! # let old = Config { password: "secret".into() };
//! # let new = Config { password: "new_secret".into() };
//!
//! let config = DiffConfig::new()
//! .mask("password");
//!
//! let d = diff_with(&old, &new, &config).unwrap();
//! ```
//!
//! # Output Formats
//!
//! - [`Diff::to_pretty`]: Human-readable colored output
//! - [`Diff::to_json`]: JSON representation
//! - [`Diff::to_json_patch`]: RFC 6902 JSON Patch
//! - [`Diff::to_markdown`]: Markdown table
//!
//! # 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²)).
pub use apply;
pub use Change;
pub use ;
pub use Diff;
pub use ;
pub use Path;
pub use SequenceDiffAlgorithm;
pub use ValueExt;
use Serialize;
/// Compute diff between two values of the same type.
///
/// # Examples
///
/// ```
/// use diffo::diff;
///
/// let old = vec![1, 2, 3];
/// let new = vec![1, 2, 4];
///
/// let d = diff(&old, &new).unwrap();
/// assert!(!d.is_empty());
/// ```
/// Compute diff with custom configuration.
///
/// # Examples
///
/// ```
/// use diffo::{diff_with, DiffConfig};
///
/// let config = DiffConfig::new().mask("*.password");
///
/// # let old = vec![1, 2, 3];
/// # let new = vec![1, 2, 4];
/// let d = diff_with(&old, &new, &config).unwrap();
/// ```