pub trait StorageReadView: Send + Sync {
// Required methods
fn get(
&self,
table: &'static str,
key: &[u8],
) -> Result<Option<Vec<u8>>, StoreError>;
fn prefix_iterator(
&self,
table: &'static str,
prefix: &[u8],
) -> Result<Box<dyn Iterator<Item = PrefixResult> + '_>, StoreError>;
// Provided method
fn multi_get(
&self,
table: &'static str,
keys: &[&[u8]],
) -> Vec<Result<Option<Vec<u8>>, StoreError>> { ... }
}Expand description
Read-only transaction interface. Provides methods to read data from the database
Required Methods§
Sourcefn get(
&self,
table: &'static str,
key: &[u8],
) -> Result<Option<Vec<u8>>, StoreError>
fn get( &self, table: &'static str, key: &[u8], ) -> Result<Option<Vec<u8>>, StoreError>
Retrieves a value by key from the specified table.
Sourcefn prefix_iterator(
&self,
table: &'static str,
prefix: &[u8],
) -> Result<Box<dyn Iterator<Item = PrefixResult> + '_>, StoreError>
fn prefix_iterator( &self, table: &'static str, prefix: &[u8], ) -> Result<Box<dyn Iterator<Item = PrefixResult> + '_>, StoreError>
Returns an iterator over all key-value pairs with the given prefix.
Provided Methods§
Sourcefn multi_get(
&self,
table: &'static str,
keys: &[&[u8]],
) -> Vec<Result<Option<Vec<u8>>, StoreError>>
fn multi_get( &self, table: &'static str, keys: &[&[u8]], ) -> Vec<Result<Option<Vec<u8>>, StoreError>>
Retrieves multiple values by key from the specified table.
Returns results in the same order as the input keys.
Backends that support batched reads (e.g. RocksDB multi_get_cf)
should override this for better throughput. Callers should not
assume multi_get is asymptotically faster than get; on backends
without a batched read primitive (e.g. the in-memory backend) the
default impl below is equivalent to N independent get calls.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".