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
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
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
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
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
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
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more