Trait ic_stable_structures::storable::Storable
source · Expand description
A trait with convenience methods for storing an element into a stable structure.
Required Methods
sourcefn to_bytes(&self) -> Cow<'_, [u8]>
fn to_bytes(&self) -> Cow<'_, [u8]>
Converts an element into bytes.
NOTE: Cow
is used here to avoid unnecessary cloning.
sourcefn from_bytes(bytes: Vec<u8>) -> Self
fn from_bytes(bytes: Vec<u8>) -> Self
Converts bytes into an element.
NOTE: The bytes are passed as a Vec<u8>
as opposed to &[u8]
because
in the vast majority of cases, the caller will no longer need the bytes,
and passing a Vec<u8>
prevents unnecessary cloning.