Trait Diffable

Source
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§

Source

type Diff: Replace + Apply<Parent = Self>

Required Methods§

Source

fn diff(&self, other: &'a Self) -> Self::Diff

Provided Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl Diffable<'_> for ()

Source§

type Diff = Id<()>

Source§

fn diff(&self, (): &Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for &'static str

Source§

type Diff = AtomicDiff<'a, &'static str>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for bool

Source§

type Diff = AtomicDiff<'a, bool>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for f32

Source§

type Diff = AtomicDiff<'a, f32>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for f64

Source§

type Diff = AtomicDiff<'a, f64>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for i8

Source§

type Diff = AtomicDiff<'a, i8>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for i16

Source§

type Diff = AtomicDiff<'a, i16>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for i32

Source§

type Diff = AtomicDiff<'a, i32>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for i64

Source§

type Diff = AtomicDiff<'a, i64>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for isize

Source§

type Diff = AtomicDiff<'a, isize>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for u8

Source§

type Diff = AtomicDiff<'a, u8>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for u16

Source§

type Diff = AtomicDiff<'a, u16>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for u32

Source§

type Diff = AtomicDiff<'a, u32>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for u64

Source§

type Diff = AtomicDiff<'a, u64>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for usize

Source§

type Diff = AtomicDiff<'a, usize>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a> Diffable<'a> for String

Source§

type Diff = AtomicDiff<'a, String>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A> Diffable<'a> for (A,)
where A: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff,)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B> Diffable<'a> for (A, B)
where A: Diffable<'a>, B: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C> Diffable<'a> for (A, B, C)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D> Diffable<'a> for (A, B, C, D)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D, E> Diffable<'a> for (A, B, C, D, E)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>, E: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff, <E as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D, E, F> Diffable<'a> for (A, B, C, D, E, F)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>, E: Diffable<'a>, F: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff, <E as Diffable<'a>>::Diff, <F as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D, E, F, G> Diffable<'a> for (A, B, C, D, E, F, G)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>, E: Diffable<'a>, F: Diffable<'a>, G: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff, <E as Diffable<'a>>::Diff, <F as Diffable<'a>>::Diff, <G as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D, E, F, G, H> Diffable<'a> for (A, B, C, D, E, F, G, H)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>, E: Diffable<'a>, F: Diffable<'a>, G: Diffable<'a>, H: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff, <E as Diffable<'a>>::Diff, <F as Diffable<'a>>::Diff, <G as Diffable<'a>>::Diff, <H as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, A, B, C, D, E, F, G, H, I> Diffable<'a> for (A, B, C, D, E, F, G, H, I)
where A: Diffable<'a>, B: Diffable<'a>, C: Diffable<'a>, D: Diffable<'a>, E: Diffable<'a>, F: Diffable<'a>, G: Diffable<'a>, H: Diffable<'a>, I: Diffable<'a>,

Source§

type Diff = (<A as Diffable<'a>>::Diff, <B as Diffable<'a>>::Diff, <C as Diffable<'a>>::Diff, <D as Diffable<'a>>::Diff, <E as Diffable<'a>>::Diff, <F as Diffable<'a>>::Diff, <G as Diffable<'a>>::Diff, <H as Diffable<'a>>::Diff, <I as Diffable<'a>>::Diff)

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, K, V> Diffable<'a> for BTreeMap<K, V>
where K: Ord + Eq + Clone + 'a, V: Diffable<'a> + Clone + 'a,

Source§

type Diff = DeepDiff<'a, BTreeMap<K, V>, BTreeMap<K, KvDiff<'a, V, <V as Diffable<'a>>::Diff>>>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, K, V> Diffable<'a> for HashMap<K, V>
where K: Hash + Eq + Clone + 'a, V: Diffable<'a> + Clone + 'a,

Source§

type Diff = DeepDiff<'a, HashMap<K, V>, HashMap<K, KvDiff<'a, V, <V as Diffable<'a>>::Diff>>>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, T> Diffable<'a> for Option<T>
where T: Diffable<'a> + Clone + 'a,

Source§

type Diff = DeepDiff<'a, Option<T>, Option<<T as Diffable<'a>>::Diff>>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, T> Diffable<'a> for Box<T>
where T: Diffable<'a>,

Source§

type Diff = Box<<T as Diffable<'a>>::Diff>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Source§

impl<'a, T> Diffable<'a> for Vec<T>
where T: 'a + Clone + PartialEq + DiffKey + Diffable<'a>,

Source§

type Diff = VecDiff<'a, T, <T as Diffable<'a>>::Diff>

Source§

fn diff(&self, other: &'a Self) -> Self::Diff

Implementors§