Trait frame_support::storage::StorageNMap [−][src]
pub trait StorageNMap<K: KeyGenerator, V: FullCodec> { type Query;}Show methods
fn hashed_key_for<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8>ⓘ; fn contains_key<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> bool; fn get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::Query; fn try_get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Result<V, ()>; fn swap<KOther, KArg1, KArg2>(key1: KArg1, key2: KArg2)
where
KOther: KeyGenerator,
KArg1: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
KArg2: EncodeLikeTuple<KOther::KArg> + TupleToEncodedIter; fn insert<KArg, VArg>(key: KArg, val: VArg)
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
VArg: EncodeLike<V>; fn remove<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(key: KArg); fn remove_prefix<KP>(
partial_key: KP,
limit: Option<u32>
) -> KillStorageResult
where
K: HasKeyPrefix<KP>; fn iter_prefix_values<KP>(partial_key: KP) -> PrefixIterator<V>ⓘNotable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T;
where
K: HasKeyPrefix<KP>; fn mutate<KArg, R, F>(key: KArg, f: F) -> R
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> R; fn try_mutate<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E>
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> Result<R, E>; fn mutate_exists<KArg, R, F>(key: KArg, f: F) -> R
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> R; fn try_mutate_exists<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E>
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> Result<R, E>; fn take<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::Query; fn append<Item, EncodeLikeItem, KArg>(key: KArg, item: EncodeLikeItem)
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: StorageAppend<Item>; fn migrate_keys<KArg>(key: KArg, hash_fns: K::HArg) -> Option<V>
where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter; fn decode_len<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Option<usize>
where
V: StorageDecodeLength, { ... }
Expand description
An implementation of a map with an arbitrary number of keys.
Details of implementation can be found at [generator::StorageNMap].
Associated Types
Required methods
fn hashed_key_for<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8>ⓘ
fn hashed_key_for<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Vec<u8>ⓘGet the storage key used to fetch a value corresponding to a specific key.
fn contains_key<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> bool
fn contains_key<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> boolDoes the value (explicitly) exist in storage?
fn get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::Query
fn get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::QueryLoad the value associated with the given key from the map.
fn try_get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Result<V, ()>
fn try_get<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Result<V, ()>Try to get the value for the given key from the map.
Returns Ok if it exists, Err if not.
fn swap<KOther, KArg1, KArg2>(key1: KArg1, key2: KArg2) where
KOther: KeyGenerator,
KArg1: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
KArg2: EncodeLikeTuple<KOther::KArg> + TupleToEncodedIter,
fn swap<KOther, KArg1, KArg2>(key1: KArg1, key2: KArg2) where
KOther: KeyGenerator,
KArg1: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
KArg2: EncodeLikeTuple<KOther::KArg> + TupleToEncodedIter, Swap the values of two keys.
fn insert<KArg, VArg>(key: KArg, val: VArg) where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
VArg: EncodeLike<V>,
fn insert<KArg, VArg>(key: KArg, val: VArg) where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
VArg: EncodeLike<V>, Store a value to be associated with the given key from the map.
fn remove<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(key: KArg)
fn remove<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(key: KArg)Remove the value under a key.
fn remove_prefix<KP>(partial_key: KP, limit: Option<u32>) -> KillStorageResult where
K: HasKeyPrefix<KP>,
fn remove_prefix<KP>(partial_key: KP, limit: Option<u32>) -> KillStorageResult where
K: HasKeyPrefix<KP>, Remove all values under the partial prefix key.
fn iter_prefix_values<KP>(partial_key: KP) -> PrefixIterator<V>ⓘNotable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T; where
K: HasKeyPrefix<KP>,
fn iter_prefix_values<KP>(partial_key: KP) -> PrefixIterator<V>ⓘNotable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T; where
K: HasKeyPrefix<KP>, Iterate over values that share the partial prefix key.
fn mutate<KArg, R, F>(key: KArg, f: F) -> R where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> R,
fn mutate<KArg, R, F>(key: KArg, f: F) -> R where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> R, Mutate the value under a key.
fn try_mutate<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> Result<R, E>,
fn try_mutate<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Self::Query) -> Result<R, E>, Mutate the item, only if an Ok value is returned.
fn mutate_exists<KArg, R, F>(key: KArg, f: F) -> R where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> R,
fn mutate_exists<KArg, R, F>(key: KArg, f: F) -> R where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> R, Mutate the value under a key.
Deletes the item if mutated to a None.
fn try_mutate_exists<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> Result<R, E>,
fn try_mutate_exists<KArg, R, E, F>(key: KArg, f: F) -> Result<R, E> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
F: FnOnce(&mut Option<V>) -> Result<R, E>, Mutate the item, only if an Ok value is returned. Deletes the item if mutated to a None.
fn take<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::Query
fn take<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Self::QueryTake the value under a key.
fn append<Item, EncodeLikeItem, KArg>(key: KArg, item: EncodeLikeItem) where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: StorageAppend<Item>,
fn append<Item, EncodeLikeItem, KArg>(key: KArg, item: EncodeLikeItem) where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: StorageAppend<Item>, Append the given items to the value in the storage.
V is required to implement codec::EncodeAppend.
Warning
If the storage item is not encoded properly, the storage will be overwritten
and set to [item]. Any default value set for the storage item will be ignored
on overwrite.
fn migrate_keys<KArg>(key: KArg, hash_fns: K::HArg) -> Option<V> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter,
fn migrate_keys<KArg>(key: KArg, hash_fns: K::HArg) -> Option<V> where
KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter, Migrate an item with the given key from defunct hash_fns to the current hashers.
If the key doesn’t exist, then it’s a no-op. If it does, then it returns its value.
Provided methods
fn decode_len<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Option<usize> where
V: StorageDecodeLength,
fn decode_len<KArg: EncodeLikeTuple<K::KArg> + TupleToEncodedIter>(
key: KArg
) -> Option<usize> where
V: StorageDecodeLength, Read the length of the storage value without decoding the entire value under the
given key.
V is required to implement StorageDecodeLength.
If the value does not exists or it fails to decode the length, None is returned.
Otherwise Some(len) is returned.
Warning
None does not mean that get() does not return a value. The default value is completly
ignored by this function.
Implementors
impl<K, V, G> StorageNMap<K, V> for G where
K: KeyGenerator,
V: FullCodec,
G: StorageNMap<K, V>,