Trait CacheDiff

Source
pub trait CacheDiff {
    // Required method
    fn diff(&self, old: &Self) -> Vec<String>;

    // Provided method
    fn fmt_value<T: Display>(&self, value: &T) -> String { ... }
}
Expand description

Centralized cache invalidation logic with human readable differences

When a struct is used to represent values in a cache, this trait can be implemented to to determine whether or not that cache needs to be invalidated.

Required Methods§

Source

fn diff(&self, old: &Self) -> Vec<String>

Given another cache object, returns a list of differences between the two.

If no differences, return an empty list. An empty list should indicate that the cache should be retained (not invalidated). One or more items would indicate that the cached value should be invalidated.

Provided Methods§

Source

fn fmt_value<T: Display>(&self, value: &T) -> String

How values are displayed in the diff output, the default is to wrap them in backticks

Enable ANSI colors with features = ["bullet_stream"]

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§