pub trait Diffable<'a>: Sized {
type Diff: Replace + Apply<Parent = Self>;
// Required method
fn diff(&self, other: &'a Self) -> Self::Diff;
// Provided method
fn apply(&mut self, diff: &Self::Diff) -> Result<(), Vec<ApplyError>> { ... }
}
Expand description
The core trait of this library. Enables a value ‘A’ to be ‘diffed’ against another value ‘B’ of the same type, returning a ‘diff’ representing the difference between the two. The diff can then be applied to A to result in B.
Generally the user will implement this trait via the derive(Diffable)
macro
rather manually.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn apply(&mut self, diff: &Self::Diff) -> Result<(), Vec<ApplyError>>
fn apply(&mut self, diff: &Self::Diff) -> Result<(), Vec<ApplyError>>
Apply a diff to self to get the ‘other’ value used in the diff
call
§Errors
Returns a list of ApplyError
where the diffs could not be applied
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.