pub struct MapReadRef<'rh, K, V, M = (), S = RandomState>{ /* private fields */ }Expand description
A live reference into the read half of an evmap.
As long as this lives, changes to the map being read cannot be published. If a writer attempts
to call WriteHandle::publish, that call will block until this is dropped.
Since the map remains immutable while this lives, the methods on this type all give you unguarded references to types contained in the map.
Implementations§
Source§impl<'rh, K, V, M, S> MapReadRef<'rh, K, V, M, S>
impl<'rh, K, V, M, S> MapReadRef<'rh, K, V, M, S>
Sourcepub fn iter(&self) -> ReadGuardIter<'_, K, V, S> ⓘ
pub fn iter(&self) -> ReadGuardIter<'_, K, V, S> ⓘ
Iterate over all key + valuesets in the map.
Be careful with this function! While the iteration is ongoing, any writer that tries to publish changes will block waiting on this reader to finish.
Sourcepub fn keys(&self) -> KeysIter<'_, K, V, S>
pub fn keys(&self) -> KeysIter<'_, K, V, S>
Iterate over all keys in the map.
Be careful with this function! While the iteration is ongoing, any writer that tries to publish changes will block waiting on this reader to finish.
Sourcepub fn values(&self) -> ValuesIter<'_, K, V, S>
pub fn values(&self) -> ValuesIter<'_, K, V, S>
Iterate over all value sets in the map.
Be careful with this function! While the iteration is ongoing, any writer that tries to publish changes will block waiting on this reader to finish.
Sourcepub fn get<'a, Q>(&'a self, key: &Q) -> Option<&'a Values<V, S>>
pub fn get<'a, Q>(&'a self, key: &Q) -> Option<&'a Values<V, S>>
Returns a reference to the values corresponding to the key.
The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed
form must match those for the key type.
Note that not all writes will be included with this read – only those that have been
published by the writer. If no publish has happened, or the map has been destroyed, this
function returns None.
Sourcepub fn get_one<'a, Q>(&'a self, key: &Q) -> Option<&'a V>
pub fn get_one<'a, Q>(&'a self, key: &Q) -> Option<&'a V>
Returns a guarded reference to one value corresponding to the key.
This is mostly intended for use when you are working with no more than one value per key. If there are multiple values stored for this key, there are no guarantees to which element is returned.
The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed
form must match those for the key type.
Note that not all writes will be included with this read – only those that have been
published by the writer. If no publish has happened, or the map has been destroyed, this
function returns None.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if the map contains any values for the specified key.
The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed
form must match those for the key type.
Sourcepub fn contains_value<Q, W>(&self, key: &Q, value: &W) -> bool
pub fn contains_value<Q, W>(&self, key: &Q, value: &W) -> bool
Returns true if the map contains the specified value for the specified key.
The key and value may be any borrowed form of the map’s respective types, but Hash and
Eq on the borrowed form must match.