Skip to main content

PersistentActor

Trait PersistentActor 

Source
pub trait PersistentActor: Send + 'static {
    type Command: Send + 'static;
    type Event: Send + Clone + 'static;
    type State: Default + Send + 'static;

    // Required methods
    fn persistence_id(&self) -> String;
    fn command_to_events(
        &self,
        state: &Self::State,
        cmd: Self::Command,
    ) -> Vec<Self::Event>;
    fn apply_event(state: &mut Self::State, event: &Self::Event);
    fn encode_event(event: &Self::Event) -> Vec<u8> ;
    fn decode_event(bytes: &[u8]) -> Self::Event;

    // Provided methods
    fn recover<'life0, 'life1, 'life2, 'async_trait, J>(
        &'life0 self,
        journal: Arc<J>,
        state: &'life1 mut Self::State,
        writer_uuid: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + 'async_trait>>
       where J: 'async_trait + Journal,
             Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn handle_command<'life0, 'life1, 'life2, 'life3, 'async_trait, J>(
        &'life0 self,
        journal: Arc<J>,
        state: &'life1 mut Self::State,
        next_seq: &'life2 mut u64,
        writer_uuid: &'life3 str,
        cmd: Self::Command,
    ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'async_trait>>
       where J: 'async_trait + Journal,
             Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn save_snapshot<'life0, 'async_trait, S>(
        &'life0 self,
        store: Arc<S>,
        sequence_nr: u64,
        payload: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where S: 'async_trait + SnapshotStore,
             Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}

Required Associated Types§

Source

type Command: Send + 'static

Source

type Event: Send + Clone + 'static

Source

type State: Default + Send + 'static

Required Methods§

Source

fn persistence_id(&self) -> String

Source

fn command_to_events( &self, state: &Self::State, cmd: Self::Command, ) -> Vec<Self::Event>

Source

fn apply_event(state: &mut Self::State, event: &Self::Event)

Source

fn encode_event(event: &Self::Event) -> Vec<u8>

Source

fn decode_event(bytes: &[u8]) -> Self::Event

Provided Methods§

Source

fn recover<'life0, 'life1, 'life2, 'async_trait, J>( &'life0 self, journal: Arc<J>, state: &'life1 mut Self::State, writer_uuid: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<u64, JournalError>> + Send + 'async_trait>>
where J: 'async_trait + Journal, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn handle_command<'life0, 'life1, 'life2, 'life3, 'async_trait, J>( &'life0 self, journal: Arc<J>, state: &'life1 mut Self::State, next_seq: &'life2 mut u64, writer_uuid: &'life3 str, cmd: Self::Command, ) -> Pin<Box<dyn Future<Output = Result<(), JournalError>> + Send + 'async_trait>>
where J: 'async_trait + Journal, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source

fn save_snapshot<'life0, 'async_trait, S>( &'life0 self, store: Arc<S>, sequence_nr: u64, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where S: 'async_trait + SnapshotStore, Self: Sync + 'async_trait, 'life0: 'async_trait,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§