Trait frame_support::storage::StoragePrefixedMap [−][src]
pub trait StoragePrefixedMap<Value: FullCodec> { fn module_prefix() -> &'static [u8]ⓘ; fn storage_prefix() -> &'static [u8]ⓘ; fn final_prefix() -> [u8; 32] { ... } fn remove_all(limit: Option<u32>) -> KillStorageResult { ... } fn iter_values() -> PrefixIterator<Value>ⓘ{ ... } fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(Notable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T;
f: F
) { ... } }
Expand description
Trait for maps that store all its value after a unique prefix.
By default the final prefix is:
Twox128(module_prefix) ++ Twox128(storage_prefix)
Required methods
Module prefix. Used for generating final key.
Provided methods
fn final_prefix() -> [u8; 32]
fn final_prefix() -> [u8; 32]
Final full prefix that prefixes all keys.
fn remove_all(limit: Option<u32>) -> KillStorageResult
fn remove_all(limit: Option<u32>) -> KillStorageResult
Remove all value of the storage.
fn iter_values() -> PrefixIterator<Value>ⓘNotable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T;
fn iter_values() -> PrefixIterator<Value>ⓘNotable traits for PrefixIterator<T>
impl<T> Iterator for PrefixIterator<T> type Item = T;
Iter over all value of the storage.
NOTE: If a value failed to decode becaues storage is corrupted then it is skipped.
fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(f: F)
fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(f: F)
Translate the values of all elements by a function f
, in the map in no particular order.
By returning None
from f
for an element, you’ll remove it from the map.
NOTE: If a value fail to decode because storage is corrupted then it is skipped.
Warning
This function must be used with care, before being updated the storage still contains the
old type, thus other calls (such as get
) will fail at decoding it.
Usage
This would typically be called inside the module implementation of on_runtime_upgrade.
Implementors
impl<Prefix, Hasher1, Key1, Hasher2, Key2, Value, QueryKind, OnEmpty, MaxValues> StoragePrefixedMap<Value> for StorageDoubleMap<Prefix, Hasher1, Key1, Hasher2, Key2, Value, QueryKind, OnEmpty, MaxValues> where
Prefix: StorageInstance,
Hasher1: StorageHasher,
Hasher2: StorageHasher,
Key1: FullCodec,
Key2: FullCodec,
Value: FullCodec,
QueryKind: QueryKindTrait<Value, OnEmpty>,
OnEmpty: Get<QueryKind::Query> + 'static,
MaxValues: Get<Option<u32>>,
impl<Prefix, Hasher, Key, Value, QueryKind, OnEmpty, MaxValues> StoragePrefixedMap<Value> for StorageMap<Prefix, Hasher, Key, Value, QueryKind, OnEmpty, MaxValues> where
Prefix: StorageInstance,
Hasher: StorageHasher,
Key: FullCodec,
Value: FullCodec,
QueryKind: QueryKindTrait<Value, OnEmpty>,
OnEmpty: Get<QueryKind::Query> + 'static,
MaxValues: Get<Option<u32>>,
impl<Prefix, Key, Value, QueryKind, OnEmpty, MaxValues> StoragePrefixedMap<Value> for StorageNMap<Prefix, Key, Value, QueryKind, OnEmpty, MaxValues> where
Prefix: StorageInstance,
Key: KeyGenerator,
Value: FullCodec,
QueryKind: QueryKindTrait<Value, OnEmpty>,
OnEmpty: Get<QueryKind::Query> + 'static,
MaxValues: Get<Option<u32>>,