pub trait Diff: Sized {
type Repr;
fn diff(&self, other: &Self) -> Self::Repr;
fn apply(&mut self, diff: &Self::Repr);
fn identity() -> Self;
fn diff_custom<D: Differ<Self>>(&self, other: &Self, visitor: &D) -> D::Repr { ... }
fn apply_custom<D: Differ<Self>>(&mut self, diff: &D::Repr, visitor: &D) { ... }
fn apply_new(&self, diff: &Self::Repr) -> Self { ... }
fn apply_new_custom<D: Differ<Self>>(
&self,
diff: &D::Repr,
visitor: &D
) -> Self { ... }
}
Expand description
A trait to diff and apply diffs between two structs The derive macro can be used on structs when all fields of the struct implement Diff Implementations are provided for bools, numeric types, Option types, and HashMaps
Required Associated Types
Required Methods
Provided Methods
sourcefn diff_custom<D: Differ<Self>>(&self, other: &Self, visitor: &D) -> D::Repr
fn diff_custom<D: Differ<Self>>(&self, other: &Self, visitor: &D) -> D::Repr
Produces a diff between two structs, using an external diffing implementation
sourcefn apply_custom<D: Differ<Self>>(&mut self, diff: &D::Repr, visitor: &D)
fn apply_custom<D: Differ<Self>>(&mut self, diff: &D::Repr, visitor: &D)
Applies the diff directly to the struct, using an external diffing implementation
sourcefn apply_new(&self, diff: &Self::Repr) -> Self
fn apply_new(&self, diff: &Self::Repr) -> Self
Applies the diff to the struct and produces a new struct
sourcefn apply_new_custom<D: Differ<Self>>(&self, diff: &D::Repr, visitor: &D) -> Self
fn apply_new_custom<D: Differ<Self>>(&self, diff: &D::Repr, visitor: &D) -> Self
Applies the diff to the struct and produces a new struct, using an external diffing implementation