[][src]Struct storage_map::StorageMap

pub struct StorageMap<L, M> { /* fields omitted */ }

StorageMap is a wrapper around HashMap that allows efficient concurrent access for the use case when only rarely the missing elements need to be created.

Implementations

impl<L, K, V, S> StorageMap<L, HashMap<K, V, S>> where
    L: RawRwLock,
    K: Clone + Eq + Hash,
    S: BuildHasher
[src]

pub fn with_hasher(hash_builder: S) -> Self[src]

Create a new storage map with the given hasher.

pub fn get_or_create_with<'a, F: FnOnce() -> V>(
    &'a self,
    key: &K,
    create_fn: F
) -> StorageMapGuard<'a, L, V>
[src]

Get a value associated with the key. The method assumes that more often then not the value is already there. If it's not - the closure will be called to create one. This closure is expected to always produce the same value given the same key.

pub fn prepare_maybe<F: FnOnce() -> Option<V>>(
    &self,
    key: &K,
    create_fn: F
) -> PrepareResult
[src]

Make sure the given key is in the map, as a way to warm up future run-time access to the map at the initialization stage.

pub fn whole_write(&self) -> WholeMapWriteGuard<'_, L, HashMap<K, V, S>>[src]

Lock the whole map for writing.

Trait Implementations

impl<L, M: Debug> Debug for StorageMap<L, M>[src]

impl<L: RawRwLock, M: Default> Default for StorageMap<L, M>[src]

impl<L: Send, M> Send for StorageMap<L, M>[src]

impl<L: Sync, M> Sync for StorageMap<L, M>[src]

Auto Trait Implementations

impl<L, M> !RefUnwindSafe for StorageMap<L, M>

impl<L, M> Unpin for StorageMap<L, M> where
    L: Unpin,
    M: Unpin

impl<L, M> UnwindSafe for StorageMap<L, M> where
    L: UnwindSafe,
    M: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.