Trait StateRead

Source
pub trait StateRead {
    type Error: Debug + Display;
    type Future: Future<Output = Result<Vec<Vec<Word>>, Self::Error>> + Unpin;

    // Required method
    fn key_range(
        &self,
        contract_addr: ContentAddress,
        key: Key,
        num_values: usize,
    ) -> Self::Future;
}
Expand description

Read-only access to state required by the VM.

Required Associated Types§

Source

type Error: Debug + Display

An error type describing any cases that might occur during state reading.

Source

type Future: Future<Output = Result<Vec<Vec<Word>>, Self::Error>> + Unpin

The future type returned from the key_range method.

§Unpin

This Future must be Unpin in order for the Vm’s ExecFuture to remain zero-allocation by default. Implementers may decide on whether they require dynamic allocation as a part of their StateRead implementation.

It is likely that in-memory implementations may be Unpin by default using std::future::Ready, however more involved implementations that require calling async functions with anonymised return types may require using a Box in order to name the anonymised type.

Required Methods§

Source

fn key_range( &self, contract_addr: ContentAddress, key: Key, num_values: usize, ) -> Self::Future

Read the given number of values from state at the given key associated with the given contract address.

Implementors§