Trait gear_common::storage::TripleMapStorage
source · pub trait TripleMapStorage {
type Key1;
type Key2;
type Key3;
type Value;
// Required methods
fn contains_keys(
key1: &Self::Key1,
key2: &Self::Key2,
key3: &Self::Key3,
) -> bool;
fn get(
key1: &Self::Key1,
key2: &Self::Key2,
key3: &Self::Key3,
) -> Option<Self::Value>;
fn insert(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
value: Self::Value,
);
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
f: F,
) -> R;
fn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F);
fn remove(key1: Self::Key1, key2: Self::Key2, key3: Self::Key3);
fn clear();
fn take(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
) -> Option<Self::Value>;
fn clear_prefix(key1: Self::Key1, key2: Self::Key2);
fn iter_prefix(
key1: &Self::Key1,
key2: &Self::Key2,
) -> impl Iterator<Item = (Self::Key3, Self::Value)>;
// Provided method
fn mutate_exists<R, F: FnOnce(&mut Self::Value) -> R>(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
f: F,
) -> Option<R> { ... }
}
Expand description
Represents logic of managing globally stored triple-key map for more complicated logic.
In fact, represents custom implementation/wrapper
around of Substrate’s StorageNMap
with OptionQuery
.
Required Associated Types§
Required Methods§
sourcefn contains_keys(
key1: &Self::Key1,
key2: &Self::Key2,
key3: &Self::Key3,
) -> bool
fn contains_keys( key1: &Self::Key1, key2: &Self::Key2, key3: &Self::Key3, ) -> bool
Returns bool, defining does map contain value under given keys.
sourcefn get(
key1: &Self::Key1,
key2: &Self::Key2,
key3: &Self::Key3,
) -> Option<Self::Value>
fn get( key1: &Self::Key1, key2: &Self::Key2, key3: &Self::Key3, ) -> Option<Self::Value>
Gets value stored under given keys, if present.
sourcefn insert(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
value: Self::Value,
)
fn insert( key1: Self::Key1, key2: Self::Key2, key3: Self::Key3, value: Self::Value, )
Inserts value with given keys.
sourcefn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
f: F,
) -> R
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>( key1: Self::Key1, key2: Self::Key2, key3: Self::Key3, f: F, ) -> R
Mutates value by Option
reference, which stored (or not
in None
case) under given keys 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.
sourcefn remove(key1: Self::Key1, key2: Self::Key2, key3: Self::Key3)
fn remove(key1: Self::Key1, key2: Self::Key2, key3: Self::Key3)
Removes value stored under the given keys.
sourcefn take(
key1: Self::Key1,
key2: Self::Key2,
key3: Self::Key3,
) -> Option<Self::Value>
fn take( key1: Self::Key1, key2: Self::Key2, key3: Self::Key3, ) -> Option<Self::Value>
Gets value stored under given keys, if present, and removes it from storage.
sourcefn clear_prefix(key1: Self::Key1, key2: Self::Key2)
fn clear_prefix(key1: Self::Key1, key2: Self::Key2)
Remove items from the map matching a key1
/key2
prefix.
fn iter_prefix( key1: &Self::Key1, key2: &Self::Key2, ) -> impl Iterator<Item = (Self::Key3, Self::Value)>
Provided Methods§
Object Safety§
This trait is not object safe.