Trait mithril_persistence::store::adapter::StoreAdapter

source ·
pub trait StoreAdapter: Sync + Send {
    type Key;
    type Record;

    // Required methods
    fn store_record<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        key: &'life1 Self::Key,
        record: &'life2 Self::Record,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_record<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Record>, AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn record_exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_last_n_records<'life0, 'async_trait>(
        &'life0 self,
        how_many: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(Self::Key, Self::Record)>, AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 Self::Key,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Record>, AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_iter<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = Self::Record> + '_>, AdapterError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Represent a way to store Key/Value pair data.

Required Associated Types§

source

type Key

The key type

source

type Record

The record type

Required Methods§

source

fn store_record<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, key: &'life1 Self::Key, record: &'life2 Self::Record, ) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store the given record.

source

fn get_record<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 Self::Key, ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Record>, AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the record stored using the given key.

source

fn record_exists<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 Self::Key, ) -> Pin<Box<dyn Future<Output = Result<bool, AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a record exist for the given key.

source

fn get_last_n_records<'life0, 'async_trait>( &'life0 self, how_many: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(Self::Key, Self::Record)>, AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the last n records in the store

source

fn remove<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 Self::Key, ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Record>, AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

remove values from store

if the value exists it is returned by the adapter otherwise None is returned

source

fn get_iter<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = Self::Record> + '_>, AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get an iterator over the stored values, from the latest to the oldest.

Implementors§

source§

impl<K, R> StoreAdapter for DumbStoreAdapter<K, R>
where R: Clone + Send + Sync, K: PartialEq + Clone + Send + Sync,

source§

type Key = K

source§

type Record = R

source§

impl<K, R> StoreAdapter for FailStoreAdapter<K, R>
where R: Clone + Send + Sync, K: PartialEq + Clone + Send + Sync,

source§

type Key = K

source§

type Record = R

source§

impl<K, V> StoreAdapter for MemoryAdapter<K, V>
where K: Hash + Eq + Send + Sync + Clone, V: Send + Sync + Clone,

source§

type Key = K

source§

type Record = V

source§

impl<K, V> StoreAdapter for SQLiteAdapter<K, V>

source§

type Key = K

source§

type Record = V