Diffable

Trait Diffable 

Source
pub trait Diffable {
    type Item: Storable;

    // Provided methods
    fn diff(
        record: Option<&Self::Item>,
        actual: Option<&Self::Item>,
    ) -> Diff<Self::Item> { ... }
    fn diff_superficial(
        record: &Self::Item,
        actual: &Self::Item,
    ) -> Diff<Self::Item> { ... }
    fn diff_thorough(
        record: &Self::Item,
        actual: &Self::Item,
    ) -> Diff<Self::Item> { ... }
}
Expand description

Used to find out if record and actual are different for type T

Required Associated Types§

Source

type Item: Storable

The type of the entity to compare.

Provided Methods§

Source

fn diff( record: Option<&Self::Item>, actual: Option<&Self::Item>, ) -> Diff<Self::Item>

⚠️ Usually you must update actual’s metadata and timestamp before calling this. Use diff_superficial and diff_thorough for shortcut comparisons. (e.g. when metadata is not changed, no need to compare the content. )

This is to convert optional entities to diffs. For example, a file may be missing from the disk, but it may exist in the records. ((Some(record), None) -> Diff::ActualMissing)

Source

fn diff_superficial( record: &Self::Item, actual: &Self::Item, ) -> Diff<Self::Item>

This is to compare two entities with a quick comparison. Example: metadata of a file, timestamp of a URL etc. You may need to update actual’s metadata or timestamp before calling this.

Source

fn diff_thorough(record: &Self::Item, actual: &Self::Item) -> Diff<Self::Item>

This is to calculate two entities with a thorough comparison. Example: content of a file, content of a URL etc. You may need to update actual’s content before calling this.

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.

Implementors§