pub trait StateRead: Send + Sync {
type GetRawFut: Future<Output = Result<Option<Vec<u8>>>> + Send + 'static;
type PrefixRawStream: Stream<Item = Result<(String, Vec<u8>)>> + Send + 'static;
type PrefixKeysStream: Stream<Item = Result<String>> + Send + 'static;
type NonconsensusPrefixRawStream: Stream<Item = Result<(Vec<u8>, Vec<u8>)>> + Send + 'static;
type NonconsensusRangeRawStream: Stream<Item = Result<(Vec<u8>, Vec<u8>)>> + Send + 'static;
// Required methods
fn get_raw(&self, key: &str) -> Self::GetRawFut;
fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut;
fn object_get<T: Any + Send + Sync + Clone>(
&self,
key: &'static str,
) -> Option<T>;
fn object_type(&self, key: &'static str) -> Option<TypeId>;
fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream;
fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream;
fn nonverifiable_prefix_raw(
&self,
prefix: &[u8],
) -> Self::NonconsensusPrefixRawStream;
fn nonverifiable_range_raw(
&self,
prefix: Option<&[u8]>,
range: impl RangeBounds<Vec<u8>>,
) -> Result<Self::NonconsensusRangeRawStream>;
}
Expand description
Read access to chain state.
Required Associated Types§
type GetRawFut: Future<Output = Result<Option<Vec<u8>>>> + Send + 'static
type PrefixRawStream: Stream<Item = Result<(String, Vec<u8>)>> + Send + 'static
type PrefixKeysStream: Stream<Item = Result<String>> + Send + 'static
type NonconsensusPrefixRawStream: Stream<Item = Result<(Vec<u8>, Vec<u8>)>> + Send + 'static
type NonconsensusRangeRawStream: Stream<Item = Result<(Vec<u8>, Vec<u8>)>> + Send + 'static
Required Methods§
Sourcefn get_raw(&self, key: &str) -> Self::GetRawFut
fn get_raw(&self, key: &str) -> Self::GetRawFut
Gets a value from the verifiable key-value store as raw bytes.
Users should generally prefer to use get
or get_proto
from an extension trait.
Sourcefn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
Gets a byte value from the non-verifiable key-value store.
This is intended for application-specific indexes of the verifiable consensus state, rather than for use as a primary data storage method.
Sourcefn object_get<T: Any + Send + Sync + Clone>(
&self,
key: &'static str,
) -> Option<T>
fn object_get<T: Any + Send + Sync + Clone>( &self, key: &'static str, ) -> Option<T>
Gets an object from the ephemeral key-object store.
This is intended to allow application components to build up batched
data transactionally, ensuring that a transaction’s contributions to
some batched data are only included if the entire transaction executed
successfully. This data is not persisted to the Storage
during
commit
.
§Returns
Some(&T)
if a value of typeT
was present atkey
.None
ifkey
was not present.
§Panics
If there is a value at key
but it is not of the type requested.
Sourcefn object_type(&self, key: &'static str) -> Option<TypeId>
fn object_type(&self, key: &'static str) -> Option<TypeId>
Gets the [TypeId
] of the object stored at key
in the ephemeral key-object store, if any
is present.
Sourcefn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream
fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream
Retrieve all values for keys matching a prefix from the verifiable key-value store, as raw bytes.
Users should generally prefer to use prefix
or prefix_proto
from an extension trait.
Sourcefn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream
fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream
Retrieve all keys (but not values) matching a prefix from the verifiable key-value store.
Sourcefn nonverifiable_prefix_raw(
&self,
prefix: &[u8],
) -> Self::NonconsensusPrefixRawStream
fn nonverifiable_prefix_raw( &self, prefix: &[u8], ) -> Self::NonconsensusPrefixRawStream
Retrieve all values for keys matching a prefix from the non-verifiable key-value store, as raw bytes.
Users should generally prefer to use wrapper methods in an extension trait.
Sourcefn nonverifiable_range_raw(
&self,
prefix: Option<&[u8]>,
range: impl RangeBounds<Vec<u8>>,
) -> Result<Self::NonconsensusRangeRawStream>
fn nonverifiable_range_raw( &self, prefix: Option<&[u8]>, range: impl RangeBounds<Vec<u8>>, ) -> Result<Self::NonconsensusRangeRawStream>
Retrieve all values for keys in a range from the non-verifiable key-value store, as raw bytes. This method does not support inclusive ranges, and will return an error if passed one.
Users should generally prefer to use wrapper methods in an extension trait.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.