Struct sp_runtime::offchain::storage::StorageValueRef [−][src]
pub struct StorageValueRef<'a> { /* fields omitted */ }Expand description
An abstraction over local storage value.
Implementations
Create a new reference to a value in the persistent local storage.
Create a new reference to a value in the fork-aware local storage.
Set the value of the storage to encoding of given parameter.
Note that the storage may be accessed by workers running concurrently,
if you happen to write a get-check-set pattern you should most likely
be using mutate instead.
Retrieve & decode the value from storage.
Note that if you want to do some checks based on the value
and write changes after that, you should rather be using mutate.
Returns the value if stored. Returns an error if the value could not be decoded.
pub fn mutate<T, E, F>(
&self,
mutate_val: F
) -> Result<T, MutateStorageError<T, E>> where
T: Codec,
F: FnOnce(Result<Option<T>, StorageRetrievalError>) -> Result<T, E>,
pub fn mutate<T, E, F>(
&self,
mutate_val: F
) -> Result<T, MutateStorageError<T, E>> where
T: Codec,
F: FnOnce(Result<Option<T>, StorageRetrievalError>) -> Result<T, E>, Retrieve & decode the current value and set it to a new value atomically.
Function mutate_val takes as input the current value and should
return a new value that is attempted to be written to storage.
This function returns:
Ok(T)in case the value has been successfully set.Err(MutateStorageError::ConcurrentModification(T))in case the value was calculated by the passed closuremutate_val, but it could not be stored.Err(MutateStorageError::ValueFunctionFailed(_))in casemutate_valreturns an error.
Auto Trait Implementations
impl<'a> RefUnwindSafe for StorageValueRef<'a>impl<'a> Send for StorageValueRef<'a>impl<'a> Sync for StorageValueRef<'a>impl<'a> Unpin for StorageValueRef<'a>impl<'a> UnwindSafe for StorageValueRef<'a>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, pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;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