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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<GNStorage, GNProvider> MapStorage for GasNodesWrap<GNStorage, GNProvider>where
GNStorage: GasNodesStorage<GNProvider> + 'static,
GNProvider: GasNodesProvider + 'static,
Available on crate feature std only.
impl<GNStorage, GNProvider> MapStorage for GasNodesWrap<GNStorage, GNProvider>where
GNStorage: GasNodesStorage<GNProvider> + 'static,
GNProvider: GasNodesProvider + 'static,
Available on crate feature
std only.type Key = GasNodeId<PlainNodeId, ReservationNodeId>
type Value = GasNode<ExternalOrigin, GasNodeId<PlainNodeId, ReservationNodeId>, u64, u128>
Source§impl<T: AuxiliaryStorageWrap> MapStorage for T
Available on crate feature std only.
impl<T: AuxiliaryStorageWrap> MapStorage for T
Available on crate feature
std only.