StorageWrite

Trait StorageWrite 

Source
pub trait StorageWrite {
    // Required methods
    fn write_bytes(
        &mut self,
        key: &Key,
        val: impl AsRef<[u8]>,
    ) -> Result<(), Error>;
    fn delete(&mut self, key: &Key) -> Result<(), Error>;

    // Provided methods
    fn write<T>(&mut self, key: &Key, val: T) -> Result<(), Error>
       where T: BorshSerialize { ... }
    fn delete_prefix(&mut self, prefix: &Key) -> Result<(), Error>
       where Self: Sized + StorageRead { ... }
}
Expand description

Common storage write interface

Required Methods§

Source

fn write_bytes(&mut self, key: &Key, val: impl AsRef<[u8]>) -> Result<(), Error>

Write a value as bytes at the given key to storage.

Source

fn delete(&mut self, key: &Key) -> Result<(), Error>

Delete a value at the given key from storage.

Provided Methods§

Source

fn write<T>(&mut self, key: &Key, val: T) -> Result<(), Error>
where T: BorshSerialize,

Write a value to be encoded with Borsh at the given key to storage.

Source

fn delete_prefix(&mut self, prefix: &Key) -> Result<(), Error>
where Self: Sized + StorageRead,

Delete all key-vals with a matching prefix.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D, H> StorageWrite for TxHostEnvState<'_, D, H>
where D: 'static + DB + for<'iter> DBIter<'iter>, H: 'static + StorageHasher,

Source§

fn write_bytes(&mut self, key: &Key, val: impl AsRef<[u8]>) -> Result<(), Error>

Source§

fn delete(&mut self, key: &Key) -> Result<(), Error>

Implementors§

Source§

impl StorageWrite for TestStorage

Source§

impl StorageWrite for Ctx

Source§

impl<'a, S, CA, EVAL> StorageWrite for PseudoExecutionStorage<'_, 'a, S, CA, EVAL>
where S: 'static + StateRead, CA: 'static + Clone, EVAL: 'static + VpEvaluator<'a, S, CA, EVAL>,

Source§

impl<'a, S, CA, EVAL> StorageWrite for VpValidationContext<'_, 'a, S, CA, EVAL>
where S: 'static + StateRead, CA: 'static + Clone, EVAL: VpEvaluator<'a, S, CA, EVAL>,

Source§

impl<D, H> StorageWrite for FullAccessState<D, H>
where D: 'static + DB + for<'iter> DBIter<'iter>, H: 'static + StorageHasher,

Source§

impl<D, H> StorageWrite for TempWlState<'_, D, H>
where D: 'static + DB + for<'iter> DBIter<'iter>, H: 'static + StorageHasher,

Source§

impl<D, H> StorageWrite for WlState<D, H>
where D: 'static + DB + for<'iter> DBIter<'iter>, H: 'static + StorageHasher,