Trait gear_common::storage::MapStorage
source · pub trait MapStorage {
type Key;
type Value;
// Required methods
fn contains_key(key: &Self::Key) -> bool;
fn get(key: &Self::Key) -> Option<Self::Value>;
fn insert(key: Self::Key, value: Self::Value);
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(
key: Self::Key,
f: F,
) -> R;
fn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F);
fn remove(key: Self::Key);
fn clear();
fn take(key: Self::Key) -> Option<Self::Value>;
// Provided method
fn mutate_exists<R, F: FnOnce(&mut Self::Value) -> R>(
key: Self::Key,
f: F,
) -> Option<R> { ... }
}
Expand description
Represents logic of managing globally stored single-key map for more complicated logic.
In fact, represents custom implementation/wrapper
around of Substrate’s StorageMap
with OptionQuery
.
Required Associated Types§
Required Methods§
sourcefn contains_key(key: &Self::Key) -> bool
fn contains_key(key: &Self::Key) -> bool
Returns bool, defining does map contain value under given key.
sourcefn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(
key: Self::Key,
f: F,
) -> R
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>( key: Self::Key, f: F, ) -> R
Mutates value by Option
reference, which stored (or not
in None
case) under given key with given function.
May return generic type value.
sourcefn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F)
fn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F)
Mutates all stored values with given convert function.
Provided Methods§
Object Safety§
This trait is not object safe.