[][src]Trait feattle_core::persist::Persist

pub trait Persist: Send + Sync + 'static {
    type Error: Error + Send + Sync + 'static;
#[must_use]    fn save_current<'life0, 'life1, 'async_trait>(
        &'life0 self,
        value: &'life1 CurrentValues
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn load_current<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Option<CurrentValues>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[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>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn load_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<Option<ValueHistory>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

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

type Error: Error + Send + Sync + 'static

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>> + Send + 'async_trait>> 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>> + Send + 'async_trait>> 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>> + Send + 'async_trait>> 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>> + Send + 'async_trait>> 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.

Loading content...

Implementors

impl Persist for NoPersistence[src]

type Error = Error

Loading content...