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

pub trait StoredMap<K, T> {
    fn get(k: &K) -> T;
fn is_explicit(k: &K) -> bool;
fn mutate<R>(k: &K, f: impl FnOnce(&mut T) -> R) -> R;
fn mutate_exists<R>(k: &K, f: impl FnOnce(&mut Option<T>) -> R) -> R;
fn try_mutate_exists<R, E>(
        k: &K,
        f: impl FnOnce(&mut Option<T>) -> Result<R, E>
    ) -> Result<R, E>;
fn remove(k: &K); 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

fn get(k: &K) -> T

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

fn is_explicit(k: &K) -> bool

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.

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

Mutate the item.

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

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

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

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

fn remove(k: &K)

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

Loading content...

Provided methods

fn insert(k: &K, t: T)

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