pub struct Cacher<T>where
T: Storable,{ /* private fields */ }
Expand description
Cacher
is data wrapper to support Lazy Read and Lazy Write to Contract Storage.
§Example
// Use new() to instantiate Cacher
let cacher: Cacher<u64> = Cacher::new();
// Defer-ed on behalf of the u64 data. Actual world state read happens once
let b = cacher.saturating_add(123);
// Value assignment after Defer-ed. No world state write. Actually write is handled afterwards by SDK.
*cacher = 123_u64;
Implementations§
Trait Implementations§
Source§impl<T> Storable for Cacher<T>where
T: Storable,
impl<T> Storable for Cacher<T>where
T: Storable,
Source§fn __load_storage(field: &StoragePath) -> Self
fn __load_storage(field: &StoragePath) -> Self
the implementation should eventually call get() to obtain data from world-state and assign the value to the fields of struct
Source§fn __save_storage(&mut self, field: &StoragePath)
fn __save_storage(&mut self, field: &StoragePath)
the implementation should eventually call set() to obtain fields’ value of struct and save it to world-state
Auto Trait Implementations§
impl<T> !Freeze for Cacher<T>
impl<T> !RefUnwindSafe for Cacher<T>
impl<T> Send for Cacher<T>where
T: Send,
impl<T> !Sync for Cacher<T>
impl<T> Unpin for Cacher<T>where
T: Unpin,
impl<T> UnwindSafe for Cacher<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more