Trait frame_support::storage::IterableStorageNMap

source ·
pub trait IterableStorageNMap<K: ReversibleKeyGenerator, V: FullCodec>: StorageNMap<K, V> {
    type KeyIterator: Iterator<Item = K::Key>;
    type Iterator: Iterator<Item = (K::Key, V)>;

    // Required methods
    fn iter_prefix<KP>(
        kp: KP,
    ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)> 
       where K: HasReversibleKeyPrefix<KP>;
    fn iter_prefix_from<KP>(
        kp: KP,
        starting_raw_key: Vec<u8>,
    ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)> 
       where K: HasReversibleKeyPrefix<KP>;
    fn iter_key_prefix<KP>(
        kp: KP,
    ) -> KeyPrefixIterator<<K as HasKeyPrefix<KP>>::Suffix> 
       where K: HasReversibleKeyPrefix<KP>;
    fn iter_key_prefix_from<KP>(
        kp: KP,
        starting_raw_key: Vec<u8>,
    ) -> KeyPrefixIterator<<K as HasKeyPrefix<KP>>::Suffix> 
       where K: HasReversibleKeyPrefix<KP>;
    fn drain_prefix<KP>(
        kp: KP,
    ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)> 
       where K: HasReversibleKeyPrefix<KP>;
    fn iter() -> Self::Iterator;
    fn iter_from(starting_raw_key: Vec<u8>) -> Self::Iterator;
    fn iter_keys() -> Self::KeyIterator;
    fn iter_keys_from(starting_raw_key: Vec<u8>) -> Self::KeyIterator;
    fn drain() -> Self::Iterator;
    fn translate<O: Decode, F: FnMut(K::Key, O) -> Option<V>>(f: F);
}
Expand description

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

Required Associated Types§

source

type KeyIterator: Iterator<Item = K::Key>

The type that iterates over all (key1, key2, key3, ... keyN) tuples.

source

type Iterator: Iterator<Item = (K::Key, V)>

The type that iterates over all (key1, key2, key3, ... keyN), value) tuples.

Required Methods§

source

fn iter_prefix<KP>( kp: KP, ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)>

Enumerate all elements in the map with prefix key kp in lexicographical order of the encoded key. If you add or remove values whose prefix is kp to the map while doing this, you’ll get undefined results.

source

fn iter_prefix_from<KP>( kp: KP, starting_raw_key: Vec<u8>, ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)>

Enumerate all elements in the map with prefix key kp after a specified starting_raw_key in lexicographical order of the encoded key. If you add or remove values whose prefix is kp to the map while doing this, you’ll get undefined results.

source

fn iter_key_prefix<KP>( kp: KP, ) -> KeyPrefixIterator<<K as HasKeyPrefix<KP>>::Suffix>

Enumerate all suffix keys in the map with prefix key kp in lexicographical order of the encoded key. If you add or remove values whose prefix is kp to the map while doing this, you’ll get undefined results.

source

fn iter_key_prefix_from<KP>( kp: KP, starting_raw_key: Vec<u8>, ) -> KeyPrefixIterator<<K as HasKeyPrefix<KP>>::Suffix>

Enumerate all suffix keys in the map with prefix key kp after a specified starting_raw_key in lexicographical order of the encoded key. If you add or remove values whose prefix is kp to the map while doing this, you’ll get undefined results.

source

fn drain_prefix<KP>( kp: KP, ) -> PrefixIterator<(<K as HasKeyPrefix<KP>>::Suffix, V)>

Remove all elements from the map with prefix key kp and iterate through them in lexicographical order of the encoded key. If you add elements with prefix key kp to the map while doing this, you’ll get undefined results.

source

fn iter() -> Self::Iterator

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.

source

fn iter_from(starting_raw_key: Vec<u8>) -> Self::Iterator

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.

source

fn iter_keys() -> Self::KeyIterator

Enumerate all keys 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.

source

fn iter_keys_from(starting_raw_key: Vec<u8>) -> Self::KeyIterator

Enumerate all keys in the map after 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.

source

fn drain() -> Self::Iterator

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.

source

fn translate<O: Decode, F: FnMut(K::Key, O) -> Option<V>>(f: F)

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.

Object Safety§

This trait is not object safe.

Implementors§