[][src]Trait frame_support::storage::IterableStorageMap

pub trait IterableStorageMap<K: FullEncode, V: FullCodec>: StorageMap<K, V> {
    type Iterator: Iterator<Item = (K, V)>;
    pub fn iter() -> Self::Iterator;
pub fn drain() -> Self::Iterator;
pub fn translate<O: Decode, F: Fn(K, O) -> Option<V>>(f: F); }

A strongly-typed map in storage whose keys and values can be iterated over.

Associated Types

type Iterator: Iterator<Item = (K, V)>[src]

The type that iterates over all (key, value).

Loading content...

Required methods

pub fn iter() -> Self::Iterator[src]

Enumerate all elements in the map in no particular order. If you alter the map while doing this, you'll get undefined results.

pub fn drain() -> Self::Iterator[src]

Remove all elements from the map and iterate through them in no particular order. If you add elements to the map while doing this, you'll get undefined results.

pub fn translate<O: Decode, F: Fn(K, O) -> Option<V>>(f: F)[src]

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.

Loading content...

Implementors

impl<K: FullCodec, V: FullCodec, G: StorageMap<K, V>> IterableStorageMap<K, V> for G where
    G::Hasher: ReversibleStorageHasher
[src]

type Iterator = PrefixIterator<(K, V)>

pub fn iter() -> Self::Iterator[src]

Enumerate all elements in the map.

pub fn drain() -> Self::Iterator[src]

Enumerate all elements in the map.

Loading content...