Struct frame_support::traits::StorageMapShim
source · [−]pub struct StorageMapShim<S, L, K, T>(_);
Expand description
A shim for placing around a storage item in order to use it as a StoredValue
. Ideally this
wouldn’t be needed as StorageValue
s should blanket implement StoredValue
s, however this
would break the ability to have custom impls of StoredValue
. The other workaround is to
implement it directly in the macro.
This form has the advantage that two additional types are provides, Created
and Removed
,
which are both generic events that can be tied to handlers to do something in the case of being
about to create an account where one didn’t previously exist (at all; not just where it used to
be the default value), or where the account is being removed or reset back to the default value
where previously it did exist (though may have been in a default state). This works well with
system module’s CallOnCreatedAccount
and CallKillAccount
.
Trait Implementations
sourceimpl<S: StorageMap<K, T, Query = T>, L: HandleLifetime<K>, K: FullCodec, T: FullCodec + Default> StoredMap<K, T> for StorageMapShim<S, L, K, T>
impl<S: StorageMap<K, T, Query = T>, L: HandleLifetime<K>, K: FullCodec, T: FullCodec + Default> StoredMap<K, T> for StorageMapShim<S, L, K, T>
sourcefn get(k: &K) -> T
fn get(k: &K) -> T
Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more
sourcefn remove(k: &K) -> Result<(), StoredMapError>
fn remove(k: &K) -> Result<(), StoredMapError>
Remove the item or otherwise replace it with its default value; we don’t care which.
sourcefn mutate_exists<R>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> R
) -> Result<R, StoredMapError>
fn mutate_exists<R>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> R
) -> Result<R, StoredMapError>
Mutate the item, removing or resetting to default value if it has been mutated to None
. Read more
sourcefn try_mutate_exists<R, E: From<StoredMapError>>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> Result<R, E>
) -> Result<R, E>
fn try_mutate_exists<R, E: From<StoredMapError>>(
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
Read more
Auto Trait Implementations
impl<S, L, K, T> RefUnwindSafe for StorageMapShim<S, L, K, T> where
K: RefUnwindSafe,
L: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<S, L, K, T> Send for StorageMapShim<S, L, K, T> where
K: Send,
L: Send,
S: Send,
T: Send,
impl<S, L, K, T> Sync for StorageMapShim<S, L, K, T> where
K: Sync,
L: Sync,
S: Sync,
T: Sync,
impl<S, L, K, T> Unpin for StorageMapShim<S, L, K, T> where
K: Unpin,
L: Unpin,
S: Unpin,
T: Unpin,
impl<S, L, K, T> UnwindSafe for StorageMapShim<S, L, K, T> where
K: UnwindSafe,
L: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.