Struct frame_support::traits::StorageMapShim [−][src]
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 StorageValues should blanket implement StoredValues, 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
impl<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>Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more
Remove the item or otherwise replace it with its default value; we don’t care which.
Mutate the item, removing or resetting to default value if it has been mutated to None. Read more
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>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> UnwindSafe for StorageMapShim<S, L, K, T> where
K: UnwindSafe,
L: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any, Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = TShould always be Self
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
pub fn vzip(self) -> V