Skip to main content

KeyValueStore

Trait KeyValueStore 

Source
pub trait KeyValueStore<K: Send + Sync, V: Send>: StateStore {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 K,
    ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put<'life0, 'async_trait>(
        &'life0 mut self,
        key: K,
        value: V,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 K,
    ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn range<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        lo: &'life1 K,
        hi: &'life2 K,
    ) -> Pin<Box<dyn Future<Output = Vec<(K, V)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

A keyed store. The in-memory store implements it, and a processor gets this typed view from ProcessorContext::get_state_store.

K needs Send + Sync because get and delete take &K, and the boxed store future must be Send. The whole execution chain runs inside tokio::spawn: Graph::pipe, then the processors, then the store ops. A &K is only Send when K: Sync.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 K, ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn put<'life0, 'async_trait>( &'life0 mut self, key: K, value: V, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 K, ) -> Pin<Box<dyn Future<Output = Option<V>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn range<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, lo: &'life1 K, hi: &'life2 K, ) -> Pin<Box<dyn Future<Output = Vec<(K, V)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Half-open range scan [lo, hi) in memcmp (lexicographic) key order.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<K: Send + Sync + 'static, V: Send + 'static> KeyValueStore<K, V> for KeyValueBytesStore<K, V>