Trait feattle_core::persist::Persist
source · pub trait Persist: Send + Sync {
// Required methods
fn save_current<'life0, 'life1, 'async_trait>(
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn load_current<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn save_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn load_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
Responsible for storing and loading data from a permanent storage.
Async
The methods on this trait are async and can be implemented with the help of the async_trait
crate:
use async_trait::async_trait;
use feattle_core::BoxError;
use feattle_core::persist::*;
struct MyPersistenceLogic;
#[async_trait]
impl Persist for MyPersistenceLogic {
async fn save_current(&self, value: &CurrentValues) -> Result<(), BoxError> {
unimplemented!()
}
async fn load_current(&self) -> Result<Option<CurrentValues>, BoxError> {
unimplemented!()
}
async fn save_history(&self, key: &str, value: &ValueHistory) -> Result<(), BoxError> {
unimplemented!()
}
async fn load_history(&self, key: &str) -> Result<Option<ValueHistory>, BoxError> {
unimplemented!()
}
}
Errors
The persistence layer can return an error, that will be bubbled up by other error
types, like super::UpdateError
and super::HistoryError
.
Required Methods§
sourcefn save_current<'life0, 'life1, 'async_trait>(
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_current<'life0, 'life1, 'async_trait>( &'life0 self, value: &'life1 CurrentValues ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Save current state of all feattles.
sourcefn load_current<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_current<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, BoxError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Load the current state of all feattles. With no previous state existed, Ok(None)
should be
returned.
sourcefn save_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 ValueHistory ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Save the full history of a single feattle.
sourcefn load_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_history<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, BoxError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Load the full history of a single feattle. With the feattle has no history, Ok(None)
should be returned.