pub trait ValueStorage {
type Value;
// Required methods
fn exists() -> bool;
fn get() -> Option<Self::Value>;
fn kill();
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(f: F) -> R;
fn put(value: Self::Value);
fn set(value: Self::Value) -> Option<Self::Value>;
fn take() -> Option<Self::Value>;
// Provided method
fn mutate_exists<R, F: FnOnce(&mut Self::Value) -> R>(f: F) -> Option<R> { ... }
}Expand description
Represents logic of managing globally stored value for more complicated logic.
In fact, represents custom implementation/wrapper
around of Substrate’s ValueStorage with OptionQuery.
Required Associated Types§
Required Methods§
Sourcefn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(f: F) -> R
fn mutate<R, F: FnOnce(&mut Option<Self::Value>) -> R>(f: F) -> R
Mutates stored value by Option reference, which stored
(or not in None case) with given function.
May return generic type value.
Provided Methods§
Sourcefn mutate_exists<R, F: FnOnce(&mut Self::Value) -> R>(f: F) -> Option<R>
fn mutate_exists<R, F: FnOnce(&mut Self::Value) -> R>(f: F) -> Option<R>
Works the same as Self::mutate, but triggers if value present.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl<TIStorage, TIProvider> ValueStorage for TotalIssuanceWrap<TIStorage, TIProvider>where
TIStorage: TotalIssuanceStorage<TIProvider> + 'static,
TIProvider: TotalIssuanceProvider + 'static,
Available on crate feature std only.
impl<TIStorage, TIProvider> ValueStorage for TotalIssuanceWrap<TIStorage, TIProvider>where
TIStorage: TotalIssuanceStorage<TIProvider> + 'static,
TIProvider: TotalIssuanceProvider + 'static,
Available on crate feature
std only.