fuel_core_storage

Trait StorageWrite

Source
pub trait StorageWrite<Type>: StorageMutate<Type>
where Type: Mappable,
{ // Required methods fn write_bytes( &mut self, key: &<Type as Mappable>::Key, buf: &[u8], ) -> Result<usize, Self::Error>; fn replace_bytes( &mut self, key: &<Type as Mappable>::Key, buf: &[u8], ) -> Result<(usize, Option<Vec<u8>>), Self::Error>; fn take_bytes( &mut self, key: &<Type as Mappable>::Key, ) -> Result<Option<Vec<u8>>, Self::Error>; }
Expand description

Base storage trait for Fuel infrastructure.

Allows writing the raw bytes of the value stored to a given key from a provided buffer.

This trait should skip any serialization and simply copy the raw bytes to the storage.

Required Methods§

Source

fn write_bytes( &mut self, key: &<Type as Mappable>::Key, buf: &[u8], ) -> Result<usize, Self::Error>

Write the bytes to the given key from the provided buffer.

Does not perform any serialization.

Returns the number of bytes written.

Source

fn replace_bytes( &mut self, key: &<Type as Mappable>::Key, buf: &[u8], ) -> Result<(usize, Option<Vec<u8>>), Self::Error>

Write the bytes to the given key from the provided buffer and return the previous bytes if it existed.

Does not perform any serialization.

Returns the number of bytes written and the previous value if it existed.

Source

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

Removes a bytes from the storage and returning it without deserializing it.

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<D> StorageWrite<BlobData> for PredicateStorage<D>

Source§

fn write_bytes( &mut self, _key: &<BlobData as Mappable>::Key, _buf: &[u8], ) -> Result<usize, <PredicateStorage<D> as StorageInspect<BlobData>>::Error>

Source§

fn replace_bytes( &mut self, _key: &<BlobData as Mappable>::Key, _buf: &[u8], ) -> Result<(usize, Option<Vec<u8>>), <PredicateStorage<D> as StorageInspect<BlobData>>::Error>

Source§

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

Source§

impl<D> StorageWrite<ContractsRawCode> for PredicateStorage<D>

Source§

impl<D> StorageWrite<ContractsState> for PredicateStorage<D>

Implementors§

Source§

impl<Column, S, M> StorageWrite<M> for StructuredStorage<S>
where S: KeyValueMutate<Column = Column>, M: TableWithBlueprint<Column = Column, Value = [u8]>, M::Blueprint: BlueprintMutate<M, StructuredStorage<S>, ValueCodec = Raw>, M::OwnedValue: Into<Vec<u8>>,

Source§

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