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