Struct frame_support::traits::StorageMapShim
source · pub struct StorageMapShim<S, 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§
source§impl<S: StorageMap<K, T, Query = T>, K: FullCodec, T: FullCodec + Default> StoredMap<K, T> for StorageMapShim<S, K, T>
impl<S: StorageMap<K, T, Query = T>, K: FullCodec, T: FullCodec + Default> StoredMap<K, T> for StorageMapShim<S, K, T>
source§fn get(k: &K) -> T
fn get(k: &K) -> T
source§fn remove(k: &K) -> Result<(), DispatchError>
fn remove(k: &K) -> Result<(), DispatchError>
source§fn mutate_exists<R>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> R
) -> Result<R, DispatchError>
fn mutate_exists<R>( k: &K, f: impl FnOnce(&mut Option<T>) -> R ) -> Result<R, DispatchError>
None
. Read moresource§fn try_mutate_exists<R, E: From<DispatchError>>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> Result<R, E>
) -> Result<R, E>
fn try_mutate_exists<R, E: From<DispatchError>>( k: &K, f: impl FnOnce(&mut Option<T>) -> Result<R, E> ) -> Result<R, E>
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
.
f
will always be called with an option representing if the storage item exists (Some<V>
)
or if the storage item does not exist (None
), independent of the QueryType
.Auto Trait Implementations§
impl<S, K, T> RefUnwindSafe for StorageMapShim<S, K, T>where K: RefUnwindSafe, S: RefUnwindSafe, T: RefUnwindSafe,
impl<S, K, T> Send for StorageMapShim<S, K, T>where K: Send, S: Send, T: Send,
impl<S, K, T> Sync for StorageMapShim<S, K, T>where K: Sync, S: Sync, T: Sync,
impl<S, K, T> Unpin for StorageMapShim<S, K, T>where K: Unpin, S: Unpin, T: Unpin,
impl<S, K, T> UnwindSafe for StorageMapShim<S, K, T>where K: UnwindSafe, S: UnwindSafe, T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.