pub trait IterableStorageDoubleMap<K1: FullCodec, K2: FullCodec, V: FullCodec>: StorageDoubleMap<K1, K2, V> {
type PartialKeyIterator: Iterator<Item = K2>;
type PrefixIterator: Iterator<Item = (K2, V)>;
type FullKeyIterator: Iterator<Item = (K1, K2)>;
type Iterator: Iterator<Item = (K1, K2, V)>;
fn iter_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator;
fn iter_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PrefixIterator;
fn iter_key_prefix(k1: impl EncodeLike<K1>) -> Self::PartialKeyIterator;
fn iter_key_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PartialKeyIterator;
fn drain_prefix(k1: impl EncodeLike<K1>) -> Self::PrefixIterator;
fn iter() -> Self::Iterator;
fn iter_from(starting_raw_key: Vec<u8>) -> Self::Iterator;
fn iter_keys() -> Self::FullKeyIterator;
fn iter_keys_from(starting_raw_key: Vec<u8>) -> Self::FullKeyIterator;
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 PartialKeyIterator: Iterator<Item = K2>
type PartialKeyIterator: Iterator<Item = K2>
The type that iterates over all key2
.
type PrefixIterator: Iterator<Item = (K2, V)>
type PrefixIterator: Iterator<Item = (K2, V)>
The type that iterates over all (key2, value)
.
type FullKeyIterator: Iterator<Item = (K1, K2)>
type FullKeyIterator: Iterator<Item = (K1, K2)>
The type that iterates over all (key1, key2)
.
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 lexicographical order of the
encoded key. If you add or remove values whose first key is k1
to the map while doing
this, you’ll get undefined results.
fn iter_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PrefixIterator
fn iter_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PrefixIterator
Enumerate all elements in the map with first key k1
after a specified starting_raw_key
in lexicographical order of the encoded key. If you add or remove values whose first key is
k1
to the map while doing this, you’ll get undefined results.
fn iter_key_prefix(k1: impl EncodeLike<K1>) -> Self::PartialKeyIterator
fn iter_key_prefix(k1: impl EncodeLike<K1>) -> Self::PartialKeyIterator
Enumerate all second keys k2
in the map with the same first key k1
in lexicographical
order of the encoded key. If you add or remove values whose first key is k1
to the map
while doing this, you’ll get undefined results.
fn iter_key_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PartialKeyIterator
fn iter_key_prefix_from(
k1: impl EncodeLike<K1>,
starting_raw_key: Vec<u8>
) -> Self::PartialKeyIterator
Enumerate all second keys k2
in the map with the same first key k1
after a specified
starting_raw_key
in lexicographical order of the encoded key. 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
lexicographical order of the encoded key. 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 lexicographical order of the encoded key. If you add or remove values to the map while doing this, you’ll get undefined results.
Enumerate all elements in the map after a specified starting_raw_key
in lexicographical
order of the encoded key. If you add or remove values to the map while doing this, you’ll
get undefined results.
fn iter_keys() -> Self::FullKeyIterator
fn iter_keys() -> Self::FullKeyIterator
Enumerate all keys k1
and k2
in the map in lexicographical order of the encoded key. If
you add or remove values to the map while doing this, you’ll get undefined results.
fn iter_keys_from(starting_raw_key: Vec<u8>) -> Self::FullKeyIterator
fn iter_keys_from(starting_raw_key: Vec<u8>) -> Self::FullKeyIterator
Enumerate all keys k1
and k2
in the map after a specified starting_raw_key
in
lexicographical order of the encoded key. 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 lexicographical order of the encoded key. 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 lexicographical order
of the encoded key.
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.