pub trait LocalReadableKeyValueStore: WithError {
type Keys: KeyIterable<Self::Error>;
type KeyValues: KeyValueIterable<Self::Error>;
const MAX_KEY_SIZE: usize;
// Required methods
fn max_stream_queries(&self) -> usize;
async fn read_value_bytes(
&self,
key: &[u8],
) -> Result<Option<Vec<u8>>, Self::Error>;
async fn contains_key(&self, key: &[u8]) -> Result<bool, Self::Error>;
async fn contains_keys(
&self,
keys: Vec<Vec<u8>>,
) -> Result<Vec<bool>, Self::Error>;
async fn read_multi_values_bytes(
&self,
keys: Vec<Vec<u8>>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>;
async fn find_keys_by_prefix(
&self,
key_prefix: &[u8],
) -> Result<Self::Keys, Self::Error>;
async fn find_key_values_by_prefix(
&self,
key_prefix: &[u8],
) -> Result<Self::KeyValues, Self::Error>;
// Provided methods
fn read_value<V: DeserializeOwned>(
&self,
key: &[u8],
) -> impl Future<Output = Result<Option<V>, Self::Error>>
where Self: Sync { ... }
fn read_multi_values<V: DeserializeOwned + Send>(
&self,
keys: Vec<Vec<u8>>,
) -> impl Future<Output = Result<Vec<Option<V>>, Self::Error>>
where Self: Sync { ... }
}
Expand description
Low-level, asynchronous read key-value operations. Useful for storage APIs not based on views.
Required Associated Types§
sourcetype Keys: KeyIterable<Self::Error>
type Keys: KeyIterable<Self::Error>
Returns type for key search operations.
sourcetype KeyValues: KeyValueIterable<Self::Error>
type KeyValues: KeyValueIterable<Self::Error>
Returns type for key-value search operations.
Required Associated Constants§
sourceconst MAX_KEY_SIZE: usize
const MAX_KEY_SIZE: usize
The maximal size of keys that can be stored.
Required Methods§
sourcefn max_stream_queries(&self) -> usize
fn max_stream_queries(&self) -> usize
Retrieve the number of stream queries.
sourceasync fn read_value_bytes(
&self,
key: &[u8],
) -> Result<Option<Vec<u8>>, Self::Error>
async fn read_value_bytes( &self, key: &[u8], ) -> Result<Option<Vec<u8>>, Self::Error>
Retrieves a Vec<u8>
from the database using the provided key
.
sourceasync fn contains_key(&self, key: &[u8]) -> Result<bool, Self::Error>
async fn contains_key(&self, key: &[u8]) -> Result<bool, Self::Error>
Tests whether a key exists in the database
sourceasync fn contains_keys(
&self,
keys: Vec<Vec<u8>>,
) -> Result<Vec<bool>, Self::Error>
async fn contains_keys( &self, keys: Vec<Vec<u8>>, ) -> Result<Vec<bool>, Self::Error>
Tests whether a list of keys exist in the database
sourceasync fn read_multi_values_bytes(
&self,
keys: Vec<Vec<u8>>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
async fn read_multi_values_bytes( &self, keys: Vec<Vec<u8>>, ) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
Retrieves multiple Vec<u8>
from the database using the provided keys
.
Provided Methods§
sourcefn read_value<V: DeserializeOwned>(
&self,
key: &[u8],
) -> impl Future<Output = Result<Option<V>, Self::Error>>where
Self: Sync,
fn read_value<V: DeserializeOwned>(
&self,
key: &[u8],
) -> impl Future<Output = Result<Option<V>, Self::Error>>where
Self: Sync,
Reads a single key
and deserializes the result if present.
Object Safety§
This trait is not object safe.