[][src]Struct evmap::ReadHandle

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
[src]

pub fn factory(&self) -> ReadHandleFactory<K, V, M, S>[src]

Create a new Sync type that can produce additional ReadHandles for use in other threads.

impl<K, V, M, S> ReadHandle<K, V, M, S> where
    K: Eq + Hash,
    S: BuildHasher,
    M: Clone
[src]

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) -> Option<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]

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.

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]

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.

pub fn is_destroyed(&self) -> bool[src]

If the writer has destroyed this map, this method will return true.

See WriteHandle::destroy.

pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

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]

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]

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
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<K, V, M, S> Send for ReadHandle<K, V, M, S>

impl<K, V, M = (), S = RandomState> !Sync for ReadHandle<K, V, M, S>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]