Trait CacheKey

Source
pub trait CacheKey<T: Transformer> {
    // Required methods
    fn to_id(&self) -> <T as Identifiable>::Id;
    fn to_cache_id(&self) -> <T as CachePolicy>::CacheId;

    // Provided methods
    fn eq_key(&self, cache_id: &<T as CachePolicy>::CacheId) -> bool { ... }
    fn hash_cache<H: Hasher>(&self, state: &mut H) { ... }
    fn eq_id(&self, id: &<T as Identifiable>::Id) -> bool { ... }
}
Expand description

Allows effecient cache lookups with minimal cloning

This is similar to the Equivalent trait

Default implementations have been provided and should be overridden if either to_cache_id() or to_id() are costly

Required Methods§

Source

fn to_id(&self) -> <T as Identifiable>::Id

Makes an Id

Source

fn to_cache_id(&self) -> <T as CachePolicy>::CacheId

Makes a CacheId

Provided Methods§

Source

fn eq_key(&self, cache_id: &<T as CachePolicy>::CacheId) -> bool

Determines if this is equivalent to the CacheId

Source

fn hash_cache<H: Hasher>(&self, state: &mut H)

Used for hashing the key

Source

fn eq_id(&self, id: &<T as Identifiable>::Id) -> bool

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<'a, T: Transformer, C: CacheKey<T>> CacheKey<T> for &'a C

Source§

fn eq_key(&self, cache_id: &<T as CachePolicy>::CacheId) -> bool

Source§

fn hash_cache<H: Hasher>(&self, state: &mut H)

Source§

fn to_id(&self) -> <T as Identifiable>::Id

Source§

fn eq_id(&self, id: &<T as Identifiable>::Id) -> bool

Source§

fn to_cache_id(&self) -> <T as CachePolicy>::CacheId

Implementors§