pub struct EntryRef<'a, Cache, Key, Value>where
Cache: EntryCache<Key, Value>,{ /* private fields */ }
Expand description
A reference to an entry in a Least Recently Used map.
Implementations
sourceimpl<'a, Cache, Key, Value> EntryRef<'a, Cache, Key, Value>where
Cache: EntryCache<Key, Value>,
impl<'a, Cache, Key, Value> EntryRef<'a, Cache, Key, Value>where
Cache: EntryCache<Key, Value>,
sourcepub fn value(&mut self) -> &Value
pub fn value(&mut self) -> &Value
Returns the value of this entry.
This function touches the key, making it the most recently used key.
This function only touches the key once. Subsequent calls will return
the value without touching the key. This remains true until
move_next()
or move_previous()
are invoked.
sourcepub fn peek_value(&self) -> &Value
pub fn peek_value(&self) -> &Value
Returns the value of this entry.
This function does not touch the key, preserving its current position in the lru cache.
sourcepub fn staleness(&self) -> usize
pub fn staleness(&self) -> usize
Returns the number of changes to the cache since this key was last touched.
sourcepub fn iter(&self) -> Iter<'_, Key, Value>ⓘNotable traits for Iter<'a, Key, Value>impl<'a, Key, Value> Iterator for Iter<'a, Key, Value> type Item = (&'a Key, &'a Value);
pub fn iter(&self) -> Iter<'_, Key, Value>ⓘNotable traits for Iter<'a, Key, Value>impl<'a, Key, Value> Iterator for Iter<'a, Key, Value> type Item = (&'a Key, &'a Value);
Returns an iterator over the least-recently used keys beginning with the current entry.
sourcepub fn move_next(&mut self) -> bool
pub fn move_next(&mut self) -> bool
Updates this reference to point to the next least recently used key in the list. Returns true if a next entry was found, or returns false if the entry is the last entry in the list.
sourcepub fn move_previous(&mut self) -> bool
pub fn move_previous(&mut self) -> bool
Updates this reference to point to the next most recently used key in the list. Returns true if a previous entry was found, or returns false if the entry is the first entry in the list.
sourcepub fn take(self) -> (Key, Value)
pub fn take(self) -> (Key, Value)
Removes and returns the current entry’s key and value.
sourcepub fn take_and_move_next(self) -> ((Key, Value), Option<Self>)
pub fn take_and_move_next(self) -> ((Key, Value), Option<Self>)
Removes and returns the current entry’s key and value. If this was not
the last entry, the next entry’s EntryRef
will be returned.
sourcepub fn take_and_move_previous(self) -> ((Key, Value), Option<Self>)
pub fn take_and_move_previous(self) -> ((Key, Value), Option<Self>)
Removes and returns the current entry’s key and value. If this was not
the first entry, the previous entry’s EntryRef
will be returned.
sourcepub fn remove_moving_next(self) -> Option<Self>
pub fn remove_moving_next(self) -> Option<Self>
Removes the current entry. If this was not the last entry, the next
entry’s EntryRef
will be returned.
sourcepub fn remove_moving_previous(self) -> Option<Self>
pub fn remove_moving_previous(self) -> Option<Self>
Removes the current entry. If this was not the first entry, the previous
entry’s EntryRef
will be returned.