Skip to main content

AccumulateOps

Trait AccumulateOps 

Source
pub trait AccumulateOps {
    type Error: Debug;

    // Required methods
    fn get(&self, id: ServiceId, key: &StorageKey) -> Option<Cow<'_, [u8]>>;
    fn set(
        &mut self,
        key: StorageKey,
        value: Cow<'_, [u8]>,
    ) -> Result<(), Self::Error>;
    fn remove(&mut self, key: &StorageKey) -> bool;
    fn min_memo_gas(&self, service_id: ServiceId) -> Option<UnsignedGas>;
    fn transfer(
        &self,
        destination: ServiceId,
        amount: Balance,
        gas_limit: UnsignedGas,
        memo: &Memo,
    ) -> Result<(), Self::Error>;
    fn bless<'a>(
        &mut self,
        manager: ServiceId,
        assigner: ServiceId,
        designator: ServiceId,
        registrar: ServiceId,
        always_acc: impl IntoIterator<Item = &'a (ServiceId, UnsignedGas)>,
    );
    fn zombify(&mut self, ejector: ServiceId);

    // Provided methods
    fn set_typed(
        &mut self,
        key: StorageKey,
        value: &impl Encode,
    ) -> Result<(), Self::Error> { ... }
    fn get_typed<T: Decode>(
        &self,
        id: ServiceId,
        key: &StorageKey,
    ) -> Result<Option<T>, Error> { ... }
    fn transfer_typed(
        &self,
        destination: ServiceId,
        amount: Balance,
        gas_limit: UnsignedGas,
        memo: &impl Encode,
    ) -> Result<(), Self::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, id: ServiceId, key: &StorageKey) -> Option<Cow<'_, [u8]>>

Read value under the specified key from the storage of the specified service.

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) -> bool

Remove value under the specified key from the storage of the service being accumulated.

Returns true if the value was present in the storage before the removal.

Source

fn min_memo_gas(&self, service_id: ServiceId) -> Option<UnsignedGas>

Get min. memo gas of the specified service.

Source

fn transfer( &self, destination: ServiceId, amount: Balance, gas_limit: UnsignedGas, memo: &Memo, ) -> Result<(), Self::Error>

Transfer data and/or funds to another service.

Source

fn bless<'a>( &mut self, manager: ServiceId, assigner: ServiceId, designator: ServiceId, registrar: ServiceId, always_acc: impl IntoIterator<Item = &'a (ServiceId, UnsignedGas)>, )

Reset the privileged services.

Source

fn zombify(&mut self, ejector: ServiceId)

Zombify the service.

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, id: ServiceId, key: &StorageKey, ) -> Result<Option<T>, Error>

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

Source

fn transfer_typed( &self, destination: ServiceId, amount: Balance, gas_limit: UnsignedGas, memo: &impl Encode, ) -> Result<(), Self::Error>

Same as transfer but encodes the provided memo using JAM codec.

Panics if the encoded value doesn’t fit into Memo.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<A: AccumulateOps + ?Sized> AccumulateOps for &mut A

Source§

type Error = <A as AccumulateOps>::Error

Source§

fn get(&self, service_id: ServiceId, 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) -> bool

Source§

fn min_memo_gas(&self, service_id: ServiceId) -> Option<UnsignedGas>

Source§

fn transfer( &self, destination: ServiceId, amount: Balance, gas_limit: UnsignedGas, memo: &Memo, ) -> Result<(), Self::Error>

Source§

fn bless<'a>( &mut self, manager: ServiceId, assigner: ServiceId, designator: ServiceId, registrar: ServiceId, always_acc: impl IntoIterator<Item = &'a (ServiceId, UnsignedGas)>, )

Source§

fn zombify(&mut self, ejector: ServiceId)

Implementors§