Module vec

Module vec 

Source
Expand description

Dynamic array (Vec<T>) implementation for the storage traits.

ยงStorage Layout

Vec uses Solidity-compatible dynamic array storage:

  • Base slot: Stores the array length (number of elements)
  • Data slots: Start at keccak256(len_slot), elements packed efficiently

ยงMulti-Slot Support

  • Supports both single-slot primitives and multi-slot types (structs, arrays)
  • Element at index i starts at slot data_start + i * T::SLOTS

Structsยง

VecHandler
Type-safe handler for accessing Vec<T> in storage.

Functionsยง

build_packed_slot ๐Ÿ”’
Build a packed storage slot from multiple elements.
calc_data_slot ๐Ÿ”’
Calculate the starting slot for dynamic array data.
load_packed_elements ๐Ÿ”’
Load packed elements from storage.
load_unpacked_elements ๐Ÿ”’
Load unpacked elements from storage.
store_packed_elements ๐Ÿ”’
Store packed elements to storage.
store_unpacked_elements ๐Ÿ”’
Store unpacked elements to storage.