Struct evmap::ReadHandle
[−]
[src]
pub struct ReadHandle<K, V, M = (), S = RandomState> where
K: Eq + Hash,
S: BuildHasher, { /* fields omitted */ }
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()
.
Methods
impl<K, V, M, S> ReadHandle<K, V, M, S> where
K: Eq + Hash,
S: BuildHasher,
M: Clone,
[src]
K: Eq + Hash,
S: BuildHasher,
M: Clone,
pub fn len(&self) -> usize
[src]
Returns the number of non-empty keys present in the map.
pub fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
pub fn meta(&self) -> M
[src]
Get the current meta value.
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,
[src]
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, the function will not be called, and None
will be
returned.
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,
[src]
&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, this function returns None
.
If no values exist for the given key, the function will not be called, and Some(None, _)
will be returned.
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Hash + Eq,
[src]
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.
pub fn for_each<F>(&self, f: F) where
F: FnMut(&K, &[V]),
[src]
F: FnMut(&K, &[V]),
Read all values in the map, and transform them into a new collection.
Be careful with this function! While the iteration is ongoing, any writer that tries to refresh will block waiting on this reader to finish.
pub fn map_into<Map, Collector, Target>(&self, f: Map) -> Collector where
Map: FnMut(&K, &[V]) -> Target,
Collector: FromIterator<Target>,
[src]
Map: FnMut(&K, &[V]) -> Target,
Collector: FromIterator<Target>,
Read all values in the map, and transform them into a new collection.
Trait Implementations
impl<K, V, M, S> Clone for ReadHandle<K, V, M, S> where
K: Eq + Hash,
S: BuildHasher,
M: Clone,
[src]
K: Eq + Hash,
S: BuildHasher,
M: Clone,