Skip to main content

ReadableKeyValueStore

Trait ReadableKeyValueStore 

Source
pub trait ReadableKeyValueStore:
    WithError
    + Send
    + Sync {
    const MAX_KEY_SIZE: usize;

    // Required methods
    fn max_stream_queries(&self) -> usize;
    fn root_key(&self) -> Result<Vec<u8>, Self::Error>;
    fn read_value_bytes(
        &self,
        key: &[u8],
    ) -> impl Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + Sync;
    fn contains_key(
        &self,
        key: &[u8],
    ) -> impl Future<Output = Result<bool, Self::Error>> + Send + Sync;
    fn contains_keys(
        &self,
        keys: &[Vec<u8>],
    ) -> impl Future<Output = Result<Vec<bool>, Self::Error>> + Send + Sync;
    fn read_multi_values_bytes(
        &self,
        keys: &[Vec<u8>],
    ) -> impl Future<Output = Result<Vec<Option<Vec<u8>>>, Self::Error>> + Send + Sync;
    fn find_keys_by_prefix(
        &self,
        key_prefix: &[u8],
    ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + Send + Sync;
    fn find_key_values_by_prefix(
        &self,
        key_prefix: &[u8],
    ) -> impl Future<Output = Result<Vec<(Vec<u8>, Vec<u8>)>, Self::Error>> + Send + Sync;

    // Provided methods
    fn read_value<V: DeserializeOwned>(
        &self,
        key: &[u8],
    ) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + Sync { ... }
    fn read_multi_values<V: DeserializeOwned + Send + Sync>(
        &self,
        keys: &[Vec<u8>],
    ) -> impl Future<Output = Result<Vec<Option<V>>, Self::Error>> + Send + Sync { ... }
}
Expand description

Asynchronous read key-value operations.

Required Associated Constants§

Source

const MAX_KEY_SIZE: usize

The maximal size of keys that can be stored.

Required Methods§

Source

fn max_stream_queries(&self) -> usize

Retrieve the number of stream queries.

Source

fn root_key(&self) -> Result<Vec<u8>, Self::Error>

Gets the root key of the store.

Source

fn read_value_bytes( &self, key: &[u8], ) -> impl Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + Sync

Retrieves a Vec<u8> from the database using the provided key.

Source

fn contains_key( &self, key: &[u8], ) -> impl Future<Output = Result<bool, Self::Error>> + Send + Sync

Tests whether a key exists in the database

Source

fn contains_keys( &self, keys: &[Vec<u8>], ) -> impl Future<Output = Result<Vec<bool>, Self::Error>> + Send + Sync

Tests whether a list of keys exist in the database

Source

fn read_multi_values_bytes( &self, keys: &[Vec<u8>], ) -> impl Future<Output = Result<Vec<Option<Vec<u8>>>, Self::Error>> + Send + Sync

Retrieves multiple Vec<u8> from the database using the provided keys.

Source

fn find_keys_by_prefix( &self, key_prefix: &[u8], ) -> impl Future<Output = Result<Vec<Vec<u8>>, Self::Error>> + Send + Sync

Finds the key matching the prefix. The prefix is not included in the returned keys.

Source

fn find_key_values_by_prefix( &self, key_prefix: &[u8], ) -> impl Future<Output = Result<Vec<(Vec<u8>, Vec<u8>)>, Self::Error>> + Send + Sync

Finds the (key,value) pairs matching the prefix. The prefix is not included in the returned keys.

Provided Methods§

Source

fn read_value<V: DeserializeOwned>( &self, key: &[u8], ) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + Sync

Reads a single key and deserializes the result if present.

Source

fn read_multi_values<V: DeserializeOwned + Send + Sync>( &self, keys: &[Vec<u8>], ) -> impl Future<Output = Result<Vec<Option<V>>, Self::Error>> + Send + Sync

Reads multiple keys and deserializes the results if present.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§