pub trait StateReader<K, V> {
type Error;
// Required methods
fn read(
&self,
correlation_id: CorrelationId,
key: &K
) -> Result<Option<V>, Self::Error>;
fn read_with_proof(
&self,
correlation_id: CorrelationId,
key: &K
) -> Result<Option<TrieMerkleProof<K, V>>, Self::Error>;
fn keys_with_prefix(
&self,
correlation_id: CorrelationId,
prefix: &[u8]
) -> Result<Vec<K>, Self::Error>;
}
Expand description
A trait expressing the reading of state. This trait is used to abstract the underlying store.
Required Associated Types§
Required Methods§
sourcefn read(
&self,
correlation_id: CorrelationId,
key: &K
) -> Result<Option<V>, Self::Error>
fn read( &self, correlation_id: CorrelationId, key: &K ) -> Result<Option<V>, Self::Error>
Returns the state value from the corresponding key
sourcefn read_with_proof(
&self,
correlation_id: CorrelationId,
key: &K
) -> Result<Option<TrieMerkleProof<K, V>>, Self::Error>
fn read_with_proof( &self, correlation_id: CorrelationId, key: &K ) -> Result<Option<TrieMerkleProof<K, V>>, Self::Error>
Returns the merkle proof of the state value from the corresponding key
sourcefn keys_with_prefix(
&self,
correlation_id: CorrelationId,
prefix: &[u8]
) -> Result<Vec<K>, Self::Error>
fn keys_with_prefix( &self, correlation_id: CorrelationId, prefix: &[u8] ) -> Result<Vec<K>, Self::Error>
Returns the keys in the trie matching prefix
.
Implementors§
source§impl StateReader<Key, StoredValue> for InMemoryGlobalStateView
impl StateReader<Key, StoredValue> for InMemoryGlobalStateView
source§impl StateReader<Key, StoredValue> for LmdbGlobalStateView
impl StateReader<Key, StoredValue> for LmdbGlobalStateView
source§impl StateReader<Key, StoredValue> for ScratchGlobalStateView
impl StateReader<Key, StoredValue> for ScratchGlobalStateView
source§impl<R: StateReader<Key, StoredValue>> StateReader<Key, StoredValue> for &TrackingCopy<R>
impl<R: StateReader<Key, StoredValue>> StateReader<Key, StoredValue> for &TrackingCopy<R>
The purpose of this implementation is to allow a “snapshot” mechanism for
TrackingCopy. The state of a TrackingCopy (including the effects of
any transforms it has accumulated) can be read using an immutable
reference to that TrackingCopy via this trait implementation. See
TrackingCopy::fork
for more information.