pub trait StorageRead<Type>: StorageInspect<Type> + StorageSize<Type>where
Type: Mappable,{
// Required methods
fn read(
&self,
key: &<Type as Mappable>::Key,
buf: &mut [u8],
) -> Result<Option<usize>, Self::Error>;
fn read_alloc(
&self,
key: &<Type as Mappable>::Key,
) -> Result<Option<Vec<u8>>, Self::Error>;
}
Expand description
Base storage trait for Fuel infrastructure.
Allows reading the raw bytes of the value stored at a given key into a provided buffer.
This trait should skip any deserialization and simply copy the raw bytes.
Required Methods§
Sourcefn read(
&self,
key: &<Type as Mappable>::Key,
buf: &mut [u8],
) -> Result<Option<usize>, Self::Error>
fn read( &self, key: &<Type as Mappable>::Key, buf: &mut [u8], ) -> Result<Option<usize>, Self::Error>
Read the value stored at the given key into the provided buffer if the value exists.
Does not perform any deserialization.
Returns None if the value does not exist. Otherwise, returns the number of bytes read.