[−][src]Trait frame_support::storage::StorageMap
A strongly-typed map in storage.
Details on implementation can be found at
[generator::StorageMap
]
Associated Types
type Query
The type that get/take return.
Required methods
fn hashed_key_for<KeyArg: EncodeLike<K>>(key: KeyArg) -> Vec<u8>
Get the storage key used to fetch a value corresponding to a specific key.
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool
Does the value (explicitly) exist in storage?
fn get<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query
Load the value associated with the given key from the map.
fn swap<KeyArg1: EncodeLike<K>, KeyArg2: EncodeLike<K>>(
key1: KeyArg1,
key2: KeyArg2
)
key1: KeyArg1,
key2: KeyArg2
)
Swap the values of two keys.
fn insert<KeyArg: EncodeLike<K>, ValArg: EncodeLike<V>>(
key: KeyArg,
val: ValArg
)
key: KeyArg,
val: ValArg
)
Store a value to be associated with the given key from the map.
fn remove<KeyArg: EncodeLike<K>>(key: KeyArg)
Remove the value under a key.
fn mutate<KeyArg: EncodeLike<K>, R, F: FnOnce(&mut Self::Query) -> R>(
key: KeyArg,
f: F
) -> R
key: KeyArg,
f: F
) -> R
Mutate the value under a key.
fn try_mutate<KeyArg: EncodeLike<K>, R, E, F: FnOnce(&mut Self::Query) -> Result<R, E>>(
key: KeyArg,
f: F
) -> Result<R, E>
key: KeyArg,
f: F
) -> Result<R, E>
Mutate the item, only if an Ok
value is returned.
fn mutate_exists<KeyArg: EncodeLike<K>, R, F: FnOnce(&mut Option<V>) -> R>(
key: KeyArg,
f: F
) -> R
key: KeyArg,
f: F
) -> R
Mutate the value under a key. Deletes the item if mutated to a None
.
fn try_mutate_exists<KeyArg: EncodeLike<K>, R, E, F: FnOnce(&mut Option<V>) -> Result<R, E>>(
key: KeyArg,
f: F
) -> Result<R, E>
key: KeyArg,
f: F
) -> Result<R, E>
Mutate the item, only if an Ok
value is returned. Deletes the item if mutated to a None
.
fn take<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query
Take the value under a key.
fn append<Items, Item, EncodeLikeItem, KeyArg>(
key: KeyArg,
items: Items
) -> Result<(), &'static str> where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem>,
Items::IntoIter: ExactSizeIterator,
key: KeyArg,
items: Items
) -> Result<(), &'static str> where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem>,
Items::IntoIter: ExactSizeIterator,
Append the given items to the value in the storage.
V
is required to implement codec::EncodeAppend
.
fn append_or_insert<Items, Item, EncodeLikeItem, KeyArg>(
key: KeyArg,
items: Items
) where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
Items::IntoIter: ExactSizeIterator,
key: KeyArg,
items: Items
) where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
Items::IntoIter: ExactSizeIterator,
Safely append the given items to the value in the storage. If a codec error occurs, then the
old (presumably corrupt) value is replaced with the given items
.
V
is required to implement codec::EncodeAppend
.
fn decode_len<KeyArg: EncodeLike<K>>(key: KeyArg) -> Result<usize, &'static str> where
V: DecodeLength + Len,
V: DecodeLength + Len,
Read the length of the value in a fast way, without decoding the entire value.
T
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.
Implementors
impl<K: FullEncode, V: FullCodec, G: StorageMap<K, V>> StorageMap<K, V> for G
[src]
type Query = G::Query
fn hashed_key_for<KeyArg: EncodeLike<K>>(key: KeyArg) -> Vec<u8>
[src]
fn swap<KeyArg1: EncodeLike<K>, KeyArg2: EncodeLike<K>>(
key1: KeyArg1,
key2: KeyArg2
)
[src]
key1: KeyArg1,
key2: KeyArg2
)
fn contains_key<KeyArg: EncodeLike<K>>(key: KeyArg) -> bool
[src]
fn get<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query
[src]
fn insert<KeyArg: EncodeLike<K>, ValArg: EncodeLike<V>>(
key: KeyArg,
val: ValArg
)
[src]
key: KeyArg,
val: ValArg
)
fn remove<KeyArg: EncodeLike<K>>(key: KeyArg)
[src]
fn mutate<KeyArg: EncodeLike<K>, R, F: FnOnce(&mut Self::Query) -> R>(
key: KeyArg,
f: F
) -> R
[src]
key: KeyArg,
f: F
) -> R
fn mutate_exists<KeyArg: EncodeLike<K>, R, F: FnOnce(&mut Option<V>) -> R>(
key: KeyArg,
f: F
) -> R
[src]
key: KeyArg,
f: F
) -> R
fn try_mutate<KeyArg: EncodeLike<K>, R, E, F: FnOnce(&mut Self::Query) -> Result<R, E>>(
key: KeyArg,
f: F
) -> Result<R, E>
[src]
key: KeyArg,
f: F
) -> Result<R, E>
fn try_mutate_exists<KeyArg: EncodeLike<K>, R, E, F: FnOnce(&mut Option<V>) -> Result<R, E>>(
key: KeyArg,
f: F
) -> Result<R, E>
[src]
key: KeyArg,
f: F
) -> Result<R, E>
fn take<KeyArg: EncodeLike<K>>(key: KeyArg) -> Self::Query
[src]
fn append<Items, Item, EncodeLikeItem, KeyArg>(
key: KeyArg,
items: Items
) -> Result<(), &'static str> where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem>,
Items::IntoIter: ExactSizeIterator,
[src]
key: KeyArg,
items: Items
) -> Result<(), &'static str> where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem>,
Items::IntoIter: ExactSizeIterator,
fn append_or_insert<Items, Item, EncodeLikeItem, KeyArg>(
key: KeyArg,
items: Items
) where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
Items::IntoIter: ExactSizeIterator,
[src]
key: KeyArg,
items: Items
) where
KeyArg: EncodeLike<K>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
V: EncodeAppend<Item = Item>,
Items: IntoIterator<Item = EncodeLikeItem> + Clone + EncodeLike<V>,
Items::IntoIter: ExactSizeIterator,
fn decode_len<KeyArg: EncodeLike<K>>(key: KeyArg) -> Result<usize, &'static str> where
V: DecodeLength + Len,
[src]
V: DecodeLength + Len,