StorageRead

Trait StorageRead 

Source
pub trait StorageRead<Type>: StorageInspect<Type> + StorageSize<Type>
where Type: Mappable,
{ // Required methods fn read( &self, key: &<Type as Mappable>::Key, offset: usize, buf: &mut [u8], ) -> Result<bool, 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, offset: usize, buf: &mut [u8], ) -> Result<bool, Self::Error>

Read the value stored at the given key into the provided buffer if the value exists. Errors if the buffer cannot be filled completely, or if attempting to read past the end of the value.

Does not perform any deserialization.

Returns Ok(true) if the value does exist, and Ok(false) otherwise.

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<BlobData> for EmptyStorage

Source§

impl<D> StorageRead<BlobData> for PredicateStorage<D>

Source§

fn read( &self, key: &<BlobData as Mappable>::Key, offset: usize, buf: &mut [u8], ) -> Result<bool, <PredicateStorage<D> as StorageInspect<BlobData>>::Error>

Source§

fn read_alloc( &self, key: &<BlobData as Mappable>::Key, ) -> Result<Option<Vec<u8>>, <PredicateStorage<D> as StorageInspect<BlobData>>::Error>

Source§

impl<D> StorageRead<ContractsRawCode> for PredicateStorage<D>

Source§

impl<D> StorageRead<ContractsState> for PredicateStorage<D>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn read_alloc( &self, key: &<Type as Mappable>::Key, ) -> Result<Option<Vec<u8>>, <&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>,