Trait fuel_storage::StorageWrite

source ·
pub trait StorageWrite<Type: Mappable>: StorageMutate<Type> {
    // Required methods
    fn write(
        &mut self,
        key: &Type::Key,
        buf: &[u8],
    ) -> Result<usize, Self::Error>;
    fn replace(
        &mut self,
        key: &Type::Key,
        buf: &[u8],
    ) -> Result<(usize, Option<Vec<u8>>), Self::Error>;
    fn take(&mut self, key: &Type::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(&mut self, key: &Type::Key, buf: &[u8]) -> Result<usize, Self::Error>

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

Does not perform any serialization.

Returns the number of bytes written.

source

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

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

Does not perform any serialization.

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

source

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

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

Implementations on Foreign Types§

source§

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

source§

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

source§

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

source§

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

Implementors§