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

pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
    type Query;
    fn hashed_key_for<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
fn contains_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> bool
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
fn get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
fn take<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Self::Query
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
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>
;
fn insert<KArg1, KArg2, VArg>(k1: KArg1, k2: KArg2, val: VArg)
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        VArg: EncodeLike<V>
;
fn remove<KArg1, KArg2>(k1: KArg1, k2: KArg2)
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
;
fn remove_prefix<KArg1: ?Sized>(k1: KArg1)
    where
        KArg1: EncodeLike<K1>
;
fn iter_prefix<KArg1: ?Sized>(k1: KArg1) -> PrefixIterator<V>
    where
        KArg1: EncodeLike<K1>
;
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
;
fn append<Items, Item, EncodeLikeItem, KArg1, KArg2>(
        k1: KArg1,
        k2: KArg2,
        items: Items
    ) -> Result<(), &'static str>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        Item: Encode,
        EncodeLikeItem: EncodeLike<Item>,
        V: EncodeAppend<Item = Item>,
        Items: IntoIterator<Item = EncodeLikeItem>,
        Items::IntoIter: ExactSizeIterator
;
fn append_or_insert<Items, Item, EncodeLikeItem, KArg1, KArg2>(
        k1: KArg1,
        k2: KArg2,
        items: Items
    )
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        Item: Encode,
        EncodeLikeItem: EncodeLike<Item>,
        V: EncodeAppend<Item = Item>,
        Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
        Items::IntoIter: ExactSizeIterator
;
fn decode_len<KArg1, KArg2>(
        key1: KArg1,
        key2: KArg2
    ) -> Result<usize, &'static str>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>,
        V: DecodeLength + Len
;
fn migrate_keys<OldHasher1: StorageHasher, OldHasher2: StorageHasher, KeyArg1: EncodeLike<K1>, KeyArg2: EncodeLike<K2>>(
        key1: KeyArg1,
        key2: KeyArg2
    ) -> Option<V>; }

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

The type that get/take returns.

Loading content...

Required methods

fn hashed_key_for<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 

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

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

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

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>, 

Swap the values of two key-pairs.

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

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

fn remove_prefix<KArg1: ?Sized>(k1: KArg1) where
    KArg1: EncodeLike<K1>, 

fn iter_prefix<KArg1: ?Sized>(k1: KArg1) -> PrefixIterator<V> where
    KArg1: EncodeLike<K1>, 

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, 

fn append<Items, Item, EncodeLikeItem, KArg1, KArg2>(
    k1: KArg1,
    k2: KArg2,
    items: Items
) -> Result<(), &'static str> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    Item: Encode,
    EncodeLikeItem: EncodeLike<Item>,
    V: EncodeAppend<Item = Item>,
    Items: IntoIterator<Item = EncodeLikeItem>,
    Items::IntoIter: ExactSizeIterator

fn append_or_insert<Items, Item, EncodeLikeItem, KArg1, KArg2>(
    k1: KArg1,
    k2: KArg2,
    items: Items
) where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    Item: Encode,
    EncodeLikeItem: EncodeLike<Item>,
    V: EncodeAppend<Item = Item>,
    Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
    Items::IntoIter: ExactSizeIterator

fn decode_len<KArg1, KArg2>(
    key1: KArg1,
    key2: KArg2
) -> Result<usize, &'static str> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>,
    V: DecodeLength + Len

Read the length of the value in a fast way, without decoding the entire value.

V is required to implement Codec::DecodeLength.

Note that 0 is returned as the default value if no encoded value exists at the given key. Therefore, this function cannot be used as a sign of existence. use the ::contains_key() function for this purpose.

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

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...

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...