pub fn read_slice_slot(slot: b256) -> Option<raw_slice> 
Expand description

Loads a raw_slice from storage, stored in a single dynamic slot.

Additional Information

Loading does not distinguish between a slot that has never been written to
and a slot that contains a slice of length zero. In both cases, None is returned.

Arguments

  • slot: [b256] - The storage slot to load a slice from.

Returns

  • [Option<raw_slice>] - If no value was previously stored at slot, or the stored slice was empty, None is returned. Otherwise,
    Some(value) is returned, where value is the raw_slice stored at slot.

Number of Storage Accesses

  • Preloads: 1 (for the length of the slice)
  • Reads: 1 (for the slice content)

Examples

use std::{alloc::alloc_bytes, storage::{write_slice_slot, read_slice_slot}};

fn foo {
    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
    assert(read_slice_slot(b256::zero()).is_none());
    write_slice_slot(b256::zero(), slice);
    let stored_slice = read_slice_slot(b256::zero()).unwrap();
    assert_eq(slice, stored_slice);
}