Skip to main content

StateRead

Trait StateRead 

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

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

Access to state required by the state read 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<i64>>, 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: Vec<i64>, num_values: usize, ) -> Self::Future

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

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<S> StateRead for TransactionView<S>
where S: StateStorage + Clone + Send + Sync + 'static,

Source§

type Error = TransactionViewError

Source§

type Future = Pin<Box<dyn Future<Output = Result<Vec<Vec<i64>>, <TransactionView<S> as StateRead>::Error>> + Send>>

Source§

fn key_range( &self, contract_addr: ContentAddress, key: Vec<i64>, num_words: usize, ) -> <TransactionView<S> as StateRead>::Future

Implementors§