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>;
fn first_key(
&self,
table: &'static str,
) -> Result<Option<Vec<u8>>, StoreError>;
fn last_key(
&self,
table: &'static str,
) -> Result<Option<Vec<u8>>, 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 the key-value pairs of table from the first key not less than prefix
onward, in key order. The iterator does not stop where keys stop starting with
prefix: the RocksDB backend configures no prefix extractor, so this is a plain
seek. Callers stop once keys leave the range they want, and may seek into the
middle of a 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".