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§
Required Methods§
sourcefn 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 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
.
sourcefn 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 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
.
sourcefn 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 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
.
sourcefn 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 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
sourcefn 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 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