linera_views::store

Trait LocalReadableKeyValueStore

Source
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 Constants§

Source

const MAX_KEY_SIZE: usize

The maximal size of keys that can be stored.

Required Associated Types§

Source

type Keys: KeyIterable<Self::Error>

Returns type for key search operations.

Source

type KeyValues: KeyValueIterable<Self::Error>

Returns type for key-value search operations.

Required Methods§

Source

fn max_stream_queries(&self) -> usize

Retrieve the number of stream queries.

Source

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.

Source

async fn contains_key(&self, key: &[u8]) -> Result<bool, Self::Error>

Tests whether a key exists in the database

Source

async fn contains_keys( &self, keys: Vec<Vec<u8>>, ) -> Result<Vec<bool>, Self::Error>

Tests whether a list of keys exist in the database

Source

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.

Source

async fn find_keys_by_prefix( &self, key_prefix: &[u8], ) -> Result<Self::Keys, Self::Error>

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

Source

async fn find_key_values_by_prefix( &self, key_prefix: &[u8], ) -> Result<Self::KeyValues, Self::Error>

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>>
where Self: Sync,

Reads a single key and deserializes the result if present.

Source

fn read_multi_values<V: DeserializeOwned + Send>( &self, keys: Vec<Vec<u8>>, ) -> impl Future<Output = Result<Vec<Option<V>>, Self::Error>>
where Self: 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", so this trait is not object safe.

Implementors§

Source§

impl<TraitVariantBlanketType: ReadableKeyValueStore> LocalReadableKeyValueStore for TraitVariantBlanketType

Source§

const MAX_KEY_SIZE: usize = <Self as ReadableKeyValueStore>::MAX_KEY_SIZE

Source§

type Keys = <TraitVariantBlanketType as ReadableKeyValueStore>::Keys

Source§

type KeyValues = <TraitVariantBlanketType as ReadableKeyValueStore>::KeyValues