[][src]Trait frame_support::traits::StoredMap

pub trait StoredMap<K, T> {
    pub fn get(k: &K) -> T;
pub fn is_explicit(k: &K) -> bool;
pub fn mutate<R>(k: &K, f: impl FnOnce(&mut T) -> R) -> R;
pub fn mutate_exists<R>(k: &K, f: impl FnOnce(&mut Option<T>) -> R) -> R;
pub fn try_mutate_exists<R, E>(
        k: &K,
        f: impl FnOnce(&mut Option<T>) -> Result<R, E>
    ) -> Result<R, E>;
pub fn remove(k: &K); pub fn insert(k: &K, t: T) { ... } }

An abstraction of a value stored within storage, but possibly as part of a larger composite item.

Required methods

pub fn get(k: &K) -> T[src]

Get the item, or its default if it doesn't yet exist; we make no distinction between the two.

pub fn is_explicit(k: &K) -> bool[src]

Get whether the item takes up any storage. If this is false, then get will certainly return the T::default(). If true, then there is no implication for get (i.e. it may return any value, including the default).

NOTE: This may still be true, even after remove is called. This is the case where a single storage entry is shared between multiple StoredMap items single, without additional logic to enforce it, deletion of any one them doesn't automatically imply deletion of them all.

pub fn mutate<R>(k: &K, f: impl FnOnce(&mut T) -> R) -> R[src]

Mutate the item.

pub fn mutate_exists<R>(k: &K, f: impl FnOnce(&mut Option<T>) -> R) -> R[src]

Mutate the item, removing or resetting to default value if it has been mutated to None.

pub fn try_mutate_exists<R, E>(
    k: &K,
    f: impl FnOnce(&mut Option<T>) -> Result<R, E>
) -> Result<R, E>
[src]

Maybe mutate the item only if an Ok value is returned from f. Do nothing if an Err is returned. It is removed or reset to default value if it has been mutated to None

pub fn remove(k: &K)[src]

Remove the item or otherwise replace it with its default value; we don't care which.

Loading content...

Provided methods

pub fn insert(k: &K, t: T)[src]

Set the item to something new.

Loading content...

Implementors

impl<S: StorageMap<K, T, Query = T>, Created: Happened<K>, Removed: Happened<K>, K: FullCodec, T: FullCodec> StoredMap<K, T> for StorageMapShim<S, Created, Removed, K, T>[src]

Loading content...