AccumulateOps

Trait AccumulateOps 

Source
pub trait AccumulateOps {
    type Error: Debug;

    // Required methods
    fn get(&self, key: &StorageKey) -> Option<Cow<'_, [u8]>>;
    fn set(
        &mut self,
        key: StorageKey,
        value: Cow<'_, [u8]>,
    ) -> Result<(), Self::Error>;
    fn remove(&mut self, key: &StorageKey);

    // Provided methods
    fn set_typed(
        &mut self,
        key: StorageKey,
        value: &impl Encode,
    ) -> Result<(), Self::Error> { ... }
    fn get_typed<T: Decode>(&self, key: &StorageKey) -> Result<Option<T>, Error> { ... }
}
Expand description

Operations that AccumulateEngine uses during accumulation.

Each operation corresponds to a JAM host-call.

Required Associated Types§

Source

type Error: Debug

Implemenatation-specific error type.

Required Methods§

Source

fn get(&self, key: &StorageKey) -> Option<Cow<'_, [u8]>>

Read value under the specified key from the storage.

Source

fn set( &mut self, key: StorageKey, value: Cow<'_, [u8]>, ) -> Result<(), Self::Error>

Write value under the specified key to the storage.

Source

fn remove(&mut self, key: &StorageKey)

Read value under the specified key from the storage.

Provided Methods§

Source

fn set_typed( &mut self, key: StorageKey, value: &impl Encode, ) -> Result<(), Self::Error>

Same as set but encodes the provided value using JAM codec.

Source

fn get_typed<T: Decode>(&self, key: &StorageKey) -> Result<Option<T>, Error>

Same as get but decodes the retrieved value using JAM codec.

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<A: AccumulateOps + ?Sized> AccumulateOps for &mut A

Source§

type Error = <A as AccumulateOps>::Error

Source§

fn get(&self, key: &StorageKey) -> Option<Cow<'_, [u8]>>

Source§

fn set( &mut self, key: StorageKey, value: Cow<'_, [u8]>, ) -> Result<(), Self::Error>

Source§

fn remove(&mut self, key: &StorageKey)

Implementors§