pub struct TimedMap<C, K, V>{ /* private fields */ }Expand description
Associates keys of type K with values of type V. Each entry may optionally expire after a
specified duration.
Mutable functions automatically clears expired entries when called.
If no expiration is set, the entry remains constant.
Implementations§
source§impl<C: Clock, K: Copy + Eq + Ord, V> TimedMap<C, K, V>
impl<C: Clock, K: Copy + Eq + Ord, V> TimedMap<C, K, V>
sourcepub fn get(&self, k: &K) -> Option<&V>
pub fn get(&self, k: &K) -> Option<&V>
Returns the associated value if present and not expired.
sourcepub fn get_remaining_duration(&self, k: &K) -> Option<Duration>
pub fn get_remaining_duration(&self, k: &K) -> Option<Duration>
Returns the associated value’s Duration if present and not expired.
Returns None if the entry does not exist or is constant.
sourcepub fn insert_expirable(&mut self, k: K, v: V, duration: Duration) -> Option<V>
pub fn insert_expirable(&mut self, k: K, v: V, duration: Duration) -> Option<V>
Inserts a key-value pair with an expiration duration.
If a value already exists for the given key, it will be updated and then the old one will be returned.
sourcepub fn insert_constant(&mut self, k: K, v: V) -> Option<V>
pub fn insert_constant(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair with that doesn’t expire.
If a value already exists for the given key, it will be updated and then the old one will be returned.
Trait Implementations§
Auto Trait Implementations§
impl<C, K, V> Freeze for TimedMap<C, K, V>
impl<C, K, V> RefUnwindSafe for TimedMap<C, K, V>
impl<C, K, V> Send for TimedMap<C, K, V>
impl<C, K, V> Sync for TimedMap<C, K, V>
impl<C, K, V> Unpin for TimedMap<C, K, V>where
C: Unpin,
impl<C, K, V> UnwindSafe for TimedMap<C, K, V>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more