[][src]Struct ink_storage::Lazy

pub struct Lazy<T> where
    T: SpreadLayout
{ /* fields omitted */ }

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]

#[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]

#[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]

Sets the value to value, without executing any reads.

Note

No reads from contract storage will be executed.

This method should be preferred over dereferencing or get_mut in case the returned value is of no interest to the caller.

Panics

If accessing the inner value fails.

Trait Implementations

impl<T> AsMut<T> for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> AsRef<T> for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> Borrow<T> for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> BorrowMut<T> for Lazy<T> where
    T: SpreadLayout
[src]

impl<T: Debug> Debug for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> Default for Lazy<T> where
    T: Default + SpreadLayout
[src]

impl<T> Deref for Lazy<T> where
    T: SpreadLayout
[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> Display for Lazy<T> where
    T: Display + SpreadLayout
[src]

impl<T> Eq for Lazy<T> where
    T: Eq + SpreadLayout
[src]

impl<T> From<T> for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> Hash for Lazy<T> where
    T: Hash + SpreadLayout
[src]

impl<T> Ord for Lazy<T> where
    T: Ord + SpreadLayout
[src]

impl<T> PartialEq<Lazy<T>> for Lazy<T> where
    T: PartialEq + SpreadLayout
[src]

impl<T> PartialOrd<Lazy<T>> for Lazy<T> where
    T: PartialOrd + SpreadLayout
[src]

impl<T> SpreadLayout for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> StorageLayout for Lazy<T> where
    T: StorageLayout + SpreadLayout
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Lazy<T>

impl<T> Send for Lazy<T> where
    T: Send

impl<T> !Sync for Lazy<T>

impl<T> Unpin for Lazy<T> where
    T: Unpin

impl<T> UnwindSafe for Lazy<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> AsByteSlice<T> for U where
    T: ToByteSlice,
    U: AsRef<[T]> + ?Sized

impl<T, U> AsMutByteSlice<T> for U where
    T: ToMutByteSlice,
    U: AsMut<[T]> + ?Sized

impl<U> AsMutSliceOf for U where
    U: AsMut<[u8]> + ?Sized

impl<U> AsSliceOf for U where
    U: AsRef<[u8]> + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,