Trait sequential_storage::map::StorageItem
source · pub trait StorageItem {
type Key: Eq;
type Error;
// Required methods
fn serialize_into(&self, buffer: &mut [u8]) -> Result<usize, Self::Error>;
fn deserialize_from(buffer: &[u8]) -> Result<Self, Self::Error>
where Self: Sized;
fn key(&self) -> Self::Key;
// Provided method
fn deserialize_key_only(buffer: &[u8]) -> Result<Self::Key, Self::Error>
where Self: Sized { ... }
}
Expand description
A way of serializing and deserializing items in the storage.
Serialized items must not be 0 bytes and may not be longer than u16::MAX. Items must also fit within a page (together with the bits of overhead added in the storage process).
Required Associated Types§
Required Methods§
sourcefn serialize_into(&self, buffer: &mut [u8]) -> Result<usize, Self::Error>
fn serialize_into(&self, buffer: &mut [u8]) -> Result<usize, Self::Error>
Serialize the key-value item into the given buffer. Returns the number of bytes the buffer was filled with or an error.
The serialized data does not have to self-describe its length or do framing. This crate already stores the length of any item in flash.