pub trait IterableStorageDoubleMap<K1: FullCodec, K2: FullCodec, V: FullCodec>: StorageDoubleMap<K1, K2, V> {
type PrefixIterator: Iterator<Item = (K2, V)>;
type Iterator: Iterator<Item = (K1, K2, V)>;
fn iter_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator;
fn drain_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator;
fn iter() -> Self::Iterator;
fn drain() -> Self::Iterator;
fn translate<O: Decode, F: FnMut(K1, K2, O) -> Option<V>>(f: F);
}
Expand description
A strongly-typed double map in storage whose secondary keys and values can be iterated over.
Associated Types
type PrefixIterator: Iterator<Item = (K2, V)>
type PrefixIterator: Iterator<Item = (K2, V)>
The type that iterates over all (key2, value)
.
Required methods
fn iter_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator
fn iter_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator
Enumerate all elements in the map with first key k1
in no particular order. If you add or
remove values whose first key is k1
to the map while doing this, you’ll get undefined
results.
fn drain_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator
fn drain_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator
Remove all elements from the map with first key k1
and iterate through them in no
particular order. If you add elements with first key k1
to the map while doing this,
you’ll get undefined results.
Enumerate all elements in the map in no particular order. If you add or remove values to the map while doing this, you’ll get undefined results.
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.
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.