[][src]Trait frame_support::storage::StorageDoubleMap

pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
    type Query;
    pub fn hashed_key_for<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8>

Notable traits for Vec<u8, Global>

impl Write for Vec<u8, Global>

    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn contains_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn try_get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Result<V, ()>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn take<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn swap<XKArg1, XKArg2, YKArg1, YKArg2>(
        x_k1: XKArg1,
        x_k2: XKArg2,
        y_k1: YKArg1,
        y_k2: YKArg2
    )
    where
        XKArg1: EncodeLike<K1>,
        XKArg2: EncodeLike<K2>,
        YKArg1: EncodeLike<K1>,
        YKArg2: EncodeLike<K2>
;
pub fn insert<KArg1, KArg2, VArg>(k1: KArg1, k2: KArg2, val: VArg)
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        VArg: EncodeLike<V>
;
pub fn remove<KArg1, KArg2>(k1: KArg1, k2: KArg2)
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
pub fn remove_prefix<KArg1: ?Sized>(k1: KArg1)
    where
        KArg1: EncodeLike<K1>
;
pub fn iter_prefix_values<KArg1: ?Sized>(k1: KArg1) -> PrefixIterator<V>

Notable traits for PrefixIterator<T>

impl<T> Iterator for PrefixIterator<T> type Item = T;

    where
        KArg1: EncodeLike<K1>
;
pub fn mutate<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        F: FnOnce(&mut Self::Query) -> R
;
pub fn try_mutate<KArg1, KArg2, R, E, F>(
        k1: KArg1,
        k2: KArg2,
        f: F
    ) -> Result<R, E>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        F: FnOnce(&mut Self::Query) -> Result<R, E>
;
pub fn mutate_exists<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        F: FnOnce(&mut Option<V>) -> R
;
pub fn try_mutate_exists<KArg1, KArg2, R, E, F>(
        k1: KArg1,
        k2: KArg2,
        f: F
    ) -> Result<R, E>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        F: FnOnce(&mut Option<V>) -> Result<R, E>
;
pub fn append<Item, EncodeLikeItem, KArg1, KArg2>(
        k1: KArg1,
        k2: KArg2,
        item: EncodeLikeItem
    )
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        Item: Encode,
        EncodeLikeItem: EncodeLike<Item>,
        V: StorageAppend<Item>
;
pub fn migrate_keys<OldHasher1: StorageHasher, OldHasher2: StorageHasher, KeyArg1: EncodeLike<K1>, KeyArg2: EncodeLike<K2>>(
        key1: KeyArg1,
        key2: KeyArg2
    ) -> Option<V>; pub fn decode_len<KArg1, KArg2>(key1: KArg1, key2: KArg2) -> Option<usize>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        V: StorageDecodeLength
, { ... } }

An implementation of a map with a two keys.

It provides an important ability to efficiently remove all entries that have a common first key.

Details on implementation can be found at [generator::StorageDoubleMap].

Associated Types

type Query[src]

The type that get/take returns.

Loading content...

Required methods

pub fn hashed_key_for<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8>

Notable traits for Vec<u8, Global>

impl Write for Vec<u8, Global>
where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Get the storage key used to fetch a value corresponding to a specific key.

pub fn contains_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Does the value (explicitly) exist in storage?

pub fn get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Load the value associated with the given key from the double map.

pub fn try_get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Result<V, ()> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Try to get the value for the given key from the double map.

Returns Ok if it exists, Err if not.

pub fn take<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Take a value from storage, removing it afterwards.

pub fn swap<XKArg1, XKArg2, YKArg1, YKArg2>(
    x_k1: XKArg1,
    x_k2: XKArg2,
    y_k1: YKArg1,
    y_k2: YKArg2
) where
    XKArg1: EncodeLike<K1>,
    XKArg2: EncodeLike<K2>,
    YKArg1: EncodeLike<K1>,
    YKArg2: EncodeLike<K2>, 
[src]

Swap the values of two key-pairs.

pub fn insert<KArg1, KArg2, VArg>(k1: KArg1, k2: KArg2, val: VArg) where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    VArg: EncodeLike<V>, 
[src]

Store a value to be associated with the given keys from the double map.

pub fn remove<KArg1, KArg2>(k1: KArg1, k2: KArg2) where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 
[src]

Remove the value under the given keys.

pub fn remove_prefix<KArg1: ?Sized>(k1: KArg1) where
    KArg1: EncodeLike<K1>, 
[src]

Remove all values under the first key.

pub fn iter_prefix_values<KArg1: ?Sized>(k1: KArg1) -> PrefixIterator<V>

Notable traits for PrefixIterator<T>

impl<T> Iterator for PrefixIterator<T> type Item = T;
where
    KArg1: EncodeLike<K1>, 
[src]

Iterate over values that share the first key.

pub fn mutate<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    F: FnOnce(&mut Self::Query) -> R, 
[src]

Mutate the value under the given keys.

pub fn try_mutate<KArg1, KArg2, R, E, F>(
    k1: KArg1,
    k2: KArg2,
    f: F
) -> Result<R, E> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    F: FnOnce(&mut Self::Query) -> Result<R, E>, 
[src]

Mutate the value under the given keys when the closure returns Ok.

pub fn mutate_exists<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    F: FnOnce(&mut Option<V>) -> R, 
[src]

Mutate the value under the given keys. Deletes the item if mutated to a None.

pub fn try_mutate_exists<KArg1, KArg2, R, E, F>(
    k1: KArg1,
    k2: KArg2,
    f: F
) -> Result<R, E> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    F: FnOnce(&mut Option<V>) -> Result<R, E>, 
[src]

Mutate the item, only if an Ok value is returned. Deletes the item if mutated to a None.

pub fn append<Item, EncodeLikeItem, KArg1, KArg2>(
    k1: KArg1,
    k2: KArg2,
    item: EncodeLikeItem
) where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    Item: Encode,
    EncodeLikeItem: EncodeLike<Item>,
    V: StorageAppend<Item>, 
[src]

Append the given item to the value in the storage.

V is required to implement StorageAppend.

Warning

If the storage item is not encoded properly, the storage will be overwritten and set to [item]. Any default value set for the storage item will be ignored on overwrite.

pub fn migrate_keys<OldHasher1: StorageHasher, OldHasher2: StorageHasher, KeyArg1: EncodeLike<K1>, KeyArg2: EncodeLike<K2>>(
    key1: KeyArg1,
    key2: KeyArg2
) -> Option<V>
[src]

Migrate an item with the given key1 and key2 from defunct OldHasher1 and OldHasher2 to the current hashers.

If the key doesn't exist, then it's a no-op. If it does, then it returns its value.

Loading content...

Provided methods

pub fn decode_len<KArg1, KArg2>(key1: KArg1, key2: KArg2) -> Option<usize> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    V: StorageDecodeLength
[src]

Read the length of the storage value without decoding the entire value under the given key1 and key2.

V is required to implement StorageDecodeLength.

If the value does not exists or it fails to decode the length, None is returned. Otherwise Some(len) is returned.

Warning

None does not mean that get() does not return a value. The default value is completly ignored by this function.

Loading content...

Implementors

impl<K1, K2, V, G> StorageDoubleMap<K1, K2, V> for G where
    K1: FullEncode,
    K2: FullEncode,
    V: FullCodec,
    G: StorageDoubleMap<K1, K2, V>, 
[src]

type Query = G::Query

Loading content...