[−][src]Struct ink_storage::Lazy
A lazy storage entity.
This loads its value from storage upon first use.
Note
Use this if the storage field doesn't need to be loaded in some or most cases.
Implementations
impl<T> Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
#[must_use]pub fn new(value: T) -> Self
[src]
Creates an eagerly populated lazy storage value.
#[must_use]pub fn lazy(key: Key) -> Self
[src]
Creates a true lazy storage value for the given key.
impl<T> Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
#[must_use]pub fn get(lazy: &Self) -> &T
[src]
Returns a shared reference to the lazily loaded value.
Note
This loads the value from the contract storage if this did not happen before.
Panics
If loading from contract storage failed.
#[must_use]pub fn get_mut(lazy: &mut Self) -> &mut T
[src]
Returns an exclusive reference to the lazily loaded value.
Note
This loads the value from the contract storage if this did not happen before.
Panics
If loading from contract storage failed.
pub fn set(lazy: &mut Self, new_value: T)
[src]
Trait Implementations
impl<T> AsMut<T> for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> AsRef<T> for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Borrow<T> for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> BorrowMut<T> for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T: Debug> Debug for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Default for Lazy<T> where
T: Default + SpreadLayout,
[src]
T: Default + SpreadLayout,
impl<T> Deref for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> DerefMut for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Display for Lazy<T> where
T: Display + SpreadLayout,
[src]
T: Display + SpreadLayout,
impl<T> Eq for Lazy<T> where
T: Eq + SpreadLayout,
[src]
T: Eq + SpreadLayout,
impl<T> From<T> for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Hash for Lazy<T> where
T: Hash + SpreadLayout,
[src]
T: Hash + SpreadLayout,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Ord for Lazy<T> where
T: Ord + SpreadLayout,
[src]
T: Ord + SpreadLayout,
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T> PartialEq<Lazy<T>> for Lazy<T> where
T: PartialEq + SpreadLayout,
[src]
T: PartialEq + SpreadLayout,
impl<T> PartialOrd<Lazy<T>> for Lazy<T> where
T: PartialOrd + SpreadLayout,
[src]
T: PartialOrd + SpreadLayout,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
impl<T> SpreadLayout for Lazy<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
const FOOTPRINT: u64
[src]
fn pull_spread(ptr: &mut KeyPtr) -> Self
[src]
fn push_spread(&self, ptr: &mut KeyPtr)
[src]
fn clear_spread(&self, ptr: &mut KeyPtr)
[src]
const REQUIRES_DEEP_CLEAN_UP: bool
[src]
impl<T> StorageLayout for Lazy<T> where
T: StorageLayout + SpreadLayout,
[src]
T: StorageLayout + SpreadLayout,
Auto Trait Implementations
impl<T> !RefUnwindSafe for Lazy<T>
impl<T> Send for Lazy<T> where
T: Send,
T: Send,
impl<T> !Sync for Lazy<T>
impl<T> Unpin for Lazy<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Lazy<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, U> AsByteSlice<T> for U where
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
fn as_byte_slice(&self) -> &[u8]
impl<T, U> AsMutByteSlice<T> for U where
T: ToMutByteSlice,
U: AsMut<[T]> + ?Sized,
T: ToMutByteSlice,
U: AsMut<[T]> + ?Sized,
fn as_mut_byte_slice(&mut self) -> &mut [u8]
impl<U> AsMutSliceOf for U where
U: AsMut<[u8]> + ?Sized,
U: AsMut<[u8]> + ?Sized,
fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error> where
T: FromByteSlice,
T: FromByteSlice,
impl<U> AsSliceOf for U where
U: AsRef<[u8]> + ?Sized,
U: AsRef<[u8]> + ?Sized,
fn as_slice_of<T>(&self) -> Result<&[T], Error> where
T: FromByteSlice,
T: FromByteSlice,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,