Trait Cache

Source
pub trait Cache {
    // Required methods
    fn save<K>(&mut self, key: K, value: K::Target)
       where K::Target: Any + 'static,
             K: CacheKey;
    fn get<K>(&self, key: &K) -> Option<&K::Target>
       where K::Target: Any + 'static,
             K: CacheKey;
    fn remove<K>(&mut self, key: &K) -> Option<K::Target>
       where K::Target: Any + 'static,
             K: CacheKey;
    fn clear(&mut self);
}
Expand description

A cache that can store abitrary values and namespace them by key types.

Required Methods§

Source

fn save<K>(&mut self, key: K, value: K::Target)
where K::Target: Any + 'static, K: CacheKey,

Source

fn get<K>(&self, key: &K) -> Option<&K::Target>
where K::Target: Any + 'static, K: CacheKey,

Source

fn remove<K>(&mut self, key: &K) -> Option<K::Target>
where K::Target: Any + 'static, K: CacheKey,

Source

fn clear(&mut self)

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§