Trait std::storage::storable_slice::StorableSlice
pub trait StorableSlice<T> {
#[storage(read, write)]
fn write_slice(self, argument: T);
#[storage(read)]
fn read_slice(self) -> Option<T>;
#[storage(read, write)]
fn clear(self) -> bool;
/// The length of the slice in storage, in bytes,
/// or `0` if `read_slice` would return `None`.
#[storage(read)]
fn len(self) -> u64;
}Expand description
A trait for storing types in storage, whose content can be represented as a slice of bytes.
Note that although a type T can have a semantic of being “empty” (e.g., an empty String),
its StorableSlice implementation (e.g., StorageString) cannot be empty.
In other words, if the write_slice method of a StorableSlice<T> implementation is called
with an argument of type T that is semantically empty, the read_slice method of the
StorableSlice<T> implementation will return None and not a Some(empty_value),
where empty_value is the semantically empty T.
Required Methods
fn write_slice(
self,
argument: T,
)
fn write_slice(
self,
argument: T,
)
fn read_slice(self) -> Option<T>
fn read_slice(self) -> Option<T>
fn clear(self) -> bool
fn clear(self) -> bool
fn len(self) -> u64
fn len(self) -> u64
The length of the slice in storage, in bytes,
or 0 if read_slice would return None.