pub trait Cache<K, V, S, M>{
Show 16 methods
// Required methods
fn with_meter_and_hasher(cap: u64, meter: M, hash_builder: S) -> Self;
fn get<'a, Q>(&'a mut self, k: &Q) -> Option<&'a V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn get_mut<'a, Q>(&'a mut self, k: &Q) -> Option<&'a mut V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn peek<'a, Q>(&'a self, k: &Q) -> Option<&'a V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn peek_mut<'a, Q>(&'a mut self, k: &Q) -> Option<&'a mut V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn peek_by_policy(&self) -> Option<(&K, &V)>;
fn put(&mut self, k: K, v: V) -> Option<V>;
fn pop<Q>(&mut self, k: &Q) -> Option<V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn pop_by_policy(&mut self) -> Option<(K, V)>;
fn contains<Q>(&self, k: &Q) -> bool
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn capacity(&self) -> u64;
fn set_capacity(&mut self, cap: u64);
fn size(&self) -> u64;
fn clear(&mut self);
}Expand description
A trait for a cache.
Required Methods§
fn with_meter_and_hasher(cap: u64, meter: M, hash_builder: S) -> Self
fn get<'a, Q>(&'a mut self, k: &Q) -> Option<&'a V>
fn get_mut<'a, Q>(&'a mut self, k: &Q) -> Option<&'a mut V>
fn peek<'a, Q>(&'a self, k: &Q) -> Option<&'a V>
fn peek_mut<'a, Q>(&'a mut self, k: &Q) -> Option<&'a mut V>
fn peek_by_policy(&self) -> Option<(&K, &V)>
fn put(&mut self, k: K, v: V) -> Option<V>
fn pop<Q>(&mut self, k: &Q) -> Option<V>
fn pop_by_policy(&mut self) -> Option<(K, V)>
fn contains<Q>(&self, k: &Q) -> bool
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn capacity(&self) -> u64
fn set_capacity(&mut self, cap: u64)
fn size(&self) -> u64
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.