Function std::storage::storable_slice::read_slice
pub fn read_slice(key: b256) -> Option<raw_slice>
Expand description
Load a raw_slice from storage.
Arguments
key
: [b256] - The storage slot to load the value from.
Returns
- [Option<raw_slice>] - If no value was previously stored at
key
,None
is returned. Otherwise,
Some(value)
is returned, wherevalue
is the value stored atkey
.
Number of Storage Accesses
- Reads:
2
Examples
use std::{alloc::alloc_bytes, storage::{write_slice, read_slice}};
fn foo {
let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
assert(read_slice(b256::zero()).is_none());
write_slice(b256::zero(), slice);
let stored_slice = read_slice(b256::zero()).unwrap();
assert(slice == stored_slice);
}