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§
fn save<K>(&mut self, key: K, value: K::Target)
fn get<K>(&self, key: &K) -> Option<&K::Target>
fn remove<K>(&mut self, key: &K) -> Option<K::Target>
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.