Trait linera_views::store::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 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 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

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.

Object Safety§

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

§

type Keys = <TraitVariantBlanketType as ReadableKeyValueStore>::Keys

§

type KeyValues = <TraitVariantBlanketType as ReadableKeyValueStore>::KeyValues