[−][src]Trait feattle::persist::Persist
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::persist::*; struct MyPersistenceLogic; #[async_trait] impl Persist for MyPersistenceLogic { type Error = std::io::Error; async fn save_current(&self, value: &CurrentValues) -> Result<(), Self::Error> { unimplemented!() } async fn load_current(&self) -> Result<Option<CurrentValues>, Self::Error> { unimplemented!() } async fn save_history(&self, key: &str, value: &ValueHistory) -> Result<(), Self::Error> { unimplemented!() } async fn load_history(&self, key: &str) -> Result<Option<ValueHistory>, Self::Error> { unimplemented!() } }
Errors
The persistence layer can define their own error type, that will be bubbled up by other error
types, like super::UpdateError
and super::HistoryError
.
Associated Types
Loading content...Required methods
#[must_use]fn save_current<'life0, 'life1, 'async_trait>(
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Save current state of all feattles.
#[must_use]fn load_current<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
Self: 'async_trait,
Load the current state of all feattles. With no previous state existed, Ok(None)
should be
returned.
#[must_use]fn save_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Save the full history of a single feattle.
#[must_use]fn load_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, Self::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load the full history of a single feattle. With the feattle has no history, Ok(None)
should be returned.
Implementors
impl Persist for NoPersistence
[src]
type Error = Error
fn save_current<'life0, 'life1, 'async_trait>(
&'life0 self,
_value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
NoPersistence: 'async_trait,
[src]
&'life0 self,
_value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
NoPersistence: 'async_trait,
fn load_current<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
NoPersistence: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
NoPersistence: 'async_trait,
fn save_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
NoPersistence: 'async_trait,
[src]
&'life0 self,
_key: &'life1 str,
_value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
NoPersistence: 'async_trait,
fn load_history<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
NoPersistence: 'async_trait,
[src]
&'life0 self,
_key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, <NoPersistence as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
NoPersistence: 'async_trait,
impl Persist for Disk
[src]
type Error = Error
fn save_current<'life0, 'life1, 'async_trait>(
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Disk: 'async_trait,
[src]
&'life0 self,
value: &'life1 CurrentValues
) -> Pin<Box<dyn Future<Output = Result<(), <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Disk: 'async_trait,
fn load_current<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
Disk: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
Disk: 'async_trait,
fn save_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Disk: 'async_trait,
[src]
&'life0 self,
key: &'life1 str,
value: &'life2 ValueHistory
) -> Pin<Box<dyn Future<Output = Result<(), <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Disk: 'async_trait,
fn load_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Disk: 'async_trait,
[src]
&'life0 self,
key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, <Disk as Persist>::Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Disk: 'async_trait,