Trait transact::state::Read

source ·
pub trait Read: Send + Send {
    type StateId;
    type Key;
    type Value;

    // Required methods
    fn get(
        &self,
        state_id: &Self::StateId,
        keys: &[Self::Key]
    ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>;
    fn clone_box(
        &self
    ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>;
}
Expand description

state::Read provides a way to retrieve state from a particular storage system.

It provides the ability to read values from an underlying storage

Implementations are expected to be thread-safe.

Required Associated Types§

source

type StateId

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.

source

type Key

The Key that is being stored in state.

source

type Value

The Value that is being stored in state.

Required Methods§

source

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>

At a given StateId, attempt to retrieve the given slice of keys.

The results of the get will be returned in a HashMap. Only keys that were found will be in this map. Keys missing from the map can be assumed to be missing from the underlying storage system as well.

Errors

StateReadError is returned if any issues occur while trying to fetch the values.

source

fn clone_box( &self ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>

Trait Implementations§

source§

impl<S, K, V> Clone for Box<dyn Read<StateId = S, Key = K, Value = V>>

source§

fn clone(&self) -> Box<dyn Read<StateId = S, Key = K, Value = V>>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§