Trait fuel_core_storage::StorageRead

source ·
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§

source

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.

source

fn read_alloc( &self, key: &<Type as Mappable>::Key, ) -> Result<Option<Vec<u8>>, Self::Error>

Same as read but allocates a new buffer and returns it.

Checks the size of the value and allocates a buffer of that size.

Implementations on Foreign Types§

source§

impl StorageRead<ContractsRawCode> for MemoryStorage

source§

impl StorageRead<ContractsRawCode> for PredicateStorage

source§

fn read( &self, _key: &<ContractsRawCode as Mappable>::Key, _buf: &mut [u8], ) -> Result<Option<usize>, StorageUnavailable>

source§

fn read_alloc( &self, _key: &<ContractsRawCode as Mappable>::Key, ) -> Result<Option<Vec<u8>>, StorageUnavailable>

source§

impl StorageRead<ContractsState> for MemoryStorage

source§

impl StorageRead<ContractsState> for PredicateStorage

source§

fn read( &self, _key: &<ContractsState as Mappable>::Key, _buf: &mut [u8], ) -> Result<Option<usize>, StorageUnavailable>

source§

fn read_alloc( &self, _key: &<ContractsState as Mappable>::Key, ) -> Result<Option<Vec<u8>>, StorageUnavailable>

source§

impl<'a, T, Type> StorageRead<Type> for &'a T
where T: StorageRead<Type> + StorageSize<Type> + ?Sized, Type: Mappable,

source§

fn read( &self, key: &<Type as Mappable>::Key, buf: &mut [u8], ) -> Result<Option<usize>, <&'a T as StorageInspect<Type>>::Error>

source§

fn read_alloc( &self, key: &<Type as Mappable>::Key, ) -> Result<Option<Vec<u8>>, <&'a T as StorageInspect<Type>>::Error>

source§

impl<'a, T, Type> StorageRead<Type> for &'a mut T
where T: StorageRead<Type> + StorageSize<Type> + ?Sized, Type: Mappable,

source§

fn read( &self, key: &<Type as Mappable>::Key, buf: &mut [u8], ) -> Result<Option<usize>, <&'a mut T as StorageInspect<Type>>::Error>

source§

fn read_alloc( &self, key: &<Type as Mappable>::Key, ) -> Result<Option<Vec<u8>>, <&'a mut T as StorageInspect<Type>>::Error>

Implementors§

source§

impl<Column, S, M> StorageRead<M> for StructuredStorage<S>
where S: KeyValueInspect<Column = Column>, M: Mappable + TableWithBlueprint<Column = Column, Value = [u8]>, M::Blueprint: BlueprintInspect<M, StructuredStorage<S>, ValueCodec = Raw>,

source§

impl<D, M: Mappable> StorageRead<M> for VmStorage<D>
where D: StorageRead<M, Error = Error>,