MapReadRef

Struct MapReadRef 

Source
pub struct MapReadRef<'rh, K, V, M = (), S = RandomState>
where K: Hash + Eq, V: Eq + Hash, S: BuildHasher,
{ /* 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>
where K: Hash + Eq, V: Eq + Hash, S: BuildHasher,

Source

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.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of non-empty keys present in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Source

pub fn meta(&self) -> &M

Get the current meta value.

Source

pub fn get<'a, Q>(&'a self, key: &Q) -> Option<&'a Values<V, S>>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

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.

Source

pub fn get_one<'a, Q>(&'a self, key: &Q) -> Option<&'a V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

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.

Source

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

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.

Source

pub fn contains_value<Q, W>(&self, key: &Q, value: &W) -> bool
where K: Borrow<Q>, Aliased<V, NoDrop>: Borrow<W>, Q: Hash + Eq + ?Sized, W: Hash + Eq + ?Sized,

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.

Trait Implementations§

Source§

impl<'rh, K, V, M, S> Debug for MapReadRef<'rh, K, V, M, S>
where K: Hash + Eq + Debug, V: Eq + Hash + Debug, S: BuildHasher, M: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'rh, K, Q, V, M, S> Index<&Q> for MapReadRef<'rh, K, V, M, S>
where K: Eq + Hash + Borrow<Q>, V: Eq + Hash, Q: Eq + Hash + ?Sized, S: BuildHasher,

Source§

type Output = Values<V, S>

The returned type after indexing.
Source§

fn index(&self, key: &Q) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'rg, 'rh, K, V, M, S> IntoIterator for &'rg MapReadRef<'rh, K, V, M, S>
where K: Eq + Hash, V: Eq + Hash, S: BuildHasher,

Source§

type Item = (&'rg K, &'rg Values<V, S>)

The type of the elements being iterated over.
Source§

type IntoIter = ReadGuardIter<'rg, K, V, S>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'rh, K, V, M, S> Freeze for MapReadRef<'rh, K, V, M, S>

§

impl<'rh, K, V, M = (), S = RandomState> !RefUnwindSafe for MapReadRef<'rh, K, V, M, S>

§

impl<'rh, K, V, M = (), S = RandomState> !Send for MapReadRef<'rh, K, V, M, S>

§

impl<'rh, K, V, M = (), S = RandomState> !Sync for MapReadRef<'rh, K, V, M, S>

§

impl<'rh, K, V, M, S> Unpin for MapReadRef<'rh, K, V, M, S>

§

impl<'rh, K, V, M = (), S = RandomState> !UnwindSafe for MapReadRef<'rh, K, V, M, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V