Struct evmap::ReadHandle
source · pub struct ReadHandle<K, V, M = (), S = RandomState>where
K: Eq + Hash,
S: BuildHasher,{ /* private fields */ }
Expand description
A handle that may be used to read from the eventually consistent map.
Note that any changes made to the map will not be made visible until the writer calls
refresh()
. In other words, all operations performed on a ReadHandle
will only see writes
to the map that preceeded the last call to refresh()
.
Implementations
sourceimpl<K, V, M, S> ReadHandle<K, V, M, S>where
K: Eq + Hash,
S: BuildHasher,
M: Clone,
impl<K, V, M, S> ReadHandle<K, V, M, S>where
K: Eq + Hash,
S: BuildHasher,
M: Clone,
sourcepub fn get_and<Q: ?Sized, F, T>(&self, key: &Q, then: F) -> Option<T>where
F: FnOnce(&[V]) -> T,
K: Borrow<Q>,
Q: Hash + Eq,
pub fn get_and<Q: ?Sized, F, T>(&self, key: &Q, then: F) -> Option<T>where
F: FnOnce(&[V]) -> T,
K: Borrow<Q>,
Q: Hash + Eq,
Applies a function to the values corresponding to the key, and returns the result.
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
refreshed by the writer. If no refresh has happened, this function returns None
.
If no values exist for the given key, no refresh has happened, or the map has been
destroyed, then
will not be called, and None
will be returned.
sourcepub fn meta_get_and<Q: ?Sized, F, T>(
&self,
key: &Q,
then: F
) -> Option<(Option<T>, M)>where
F: FnOnce(&[V]) -> T,
K: Borrow<Q>,
Q: Hash + Eq,
pub fn meta_get_and<Q: ?Sized, F, T>(
&self,
key: &Q,
then: F
) -> Option<(Option<T>, M)>where
F: FnOnce(&[V]) -> T,
K: Borrow<Q>,
Q: Hash + Eq,
Applies a function to the values corresponding to the key, and returns the result alongside the meta information.
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
refreshed by the writer. If no refresh has happened, or if the map has been closed by the
writer, this function returns None
.
If no values exist for the given key, then
will not be called, and Some(None, _)
is
returned.
sourcepub fn is_destroyed(&self) -> bool
pub fn is_destroyed(&self) -> bool
If the writer has destroyed this map, this method will return true.
See WriteHandle::destroy
.
sourcepub fn contains_key<Q: ?Sized>(&self, key: &Q) -> boolwhere
K: Borrow<Q>,
Q: Hash + Eq,
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> boolwhere
K: Borrow<Q>,
Q: Hash + Eq,
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.