pub struct LazyCell<T> where
    T: SpreadLayout
{ /* private fields */ }
Expand description

A lazy storage entity.

This loads its value from storage upon first use.

Note

Use this if the storage field does not need to be loaded in some or most cases.

Implementations

Creates an already populated lazy storage cell.

Note

Since this already has a value it will never actually load from the contract storage.

Creates a lazy storage cell for the given key.

Note

This will actually lazily load from the associated storage cell upon access.

Returns a shared reference to the value.

Note

This eventually lazily loads the value from the contract storage.

Panics

If decoding the loaded value to T failed.

Returns an exclusive reference to the value.

Note

This eventually lazily loads the value from the contract storage.

Panics

If decoding the loaded value to T failed.

Sets the value in this cell 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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Default initializes the implementing type using spread layout. Read more

The footprint of the type. Read more

Pulls an instance of Self from the contract storage. Read more

Pushes an instance of Self to the contract storage. Read more

Clears an instance of Self from the contract storage. Read more

Indicates whether a type requires deep clean-up of its state meaning that a clean-up routine has to decode an entity into an instance in order to eventually recurse upon its tear-down. This is not required for the majority of primitive data types such as i32, however types such as storage::Box that might want to forward the clean-up procedure to their inner T require a deep clean-up. Read more

Returns the static storage layout of Self. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.