pub struct LazyArray<T, const N: usize> { /* private fields */ }
Expand description

A lazy storage array that spans over N storage cells.

Storage data structure to emulate storage arrays: [T; N].

Note

Computes operations on the underlying N storage cells in a lazy fashion. Due to the size constraints the LazyArray is generally more efficient than the LazyMap for most use cases with limited elements.

This is mainly used as low-level storage primitives by other high-level storage primitives in order to manage the contract storage for a whole chunk of storage cells.

Implementations

Clears the underlying storage of the entry at the given index.

Safety

For performance reasons this does not synchronize the lazy array’s memory-side cache which invalidates future accesses the cleared entry. Care should be taken when using this API.

The general use of this API is to streamline Drop implementations of high-level abstractions that build upon this low-level data structure.

Creates a new empty lazy array.

Note

A lazy array created this way cannot be used to load from the contract storage. All operations that directly or indirectly load from storage will panic.

Returns the constant capacity of the lazy array.

Returns the offset key of the lazy array if any.

Puts a new value into the given indexed slot.

Note

Use LazyArray::put_get(None) to remove an element.

Returns the offset key for the given index if not out of bounds.

Returns a shared reference to the element at the given index if any.

Note

This operation eventually loads from contract storage.

Panics

If the given index is out of bounds.

Returns an exclusive reference to the element at the given index if any.

Note

This operation eventually loads from contract storage.

Panics

If the given index is out of bounds.

Puts the new value into the indexed slot and returns the old value if any.

Note
  • This operation eventually loads from contract storage.
  • Prefer LazyArray::put if you are not interested in the old value.
  • Use LazyArray::put_get(None) to remove an element.
Panics

If the given index is out of bounds.

Swaps the values at indices x and y.

Note

This operation eventually loads from contract storage.

Panics

If any of the given indices is out of bounds.

Trait Implementations

Formats the value using the given formatter. Read more

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

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.

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.