pub trait EventSourced {
    type Id: Debug + Send + 'static;
    type Cmd: Debug + Send + Sync + 'static;
    type Evt: Debug + Send + Sync;
    type State: Debug + Default + Send + Sync + 'static;
    type Error: StdError + Send + Sync + 'static;

    const TYPE_NAME: &'static str;

    // Required methods
    fn handle_cmd(
        id: &Self::Id,
        state: &Self::State,
        cmd: Self::Cmd
    ) -> Result<Self::Evt, Self::Error>;
    fn handle_evt(state: Self::State, evt: Self::Evt) -> Self::State;
}
Expand description

Command and event handling for an event sourced entity.

Required Associated Types§

source

type Id: Debug + Send + 'static

Id type.

source

type Cmd: Debug + Send + Sync + 'static

Command type.

source

type Evt: Debug + Send + Sync

Event type.

source

type State: Debug + Default + Send + Sync + 'static

State type.

source

type Error: StdError + Send + Sync + 'static

Error type for rejected (a.k.a. invalid) commands.

Required Associated Constants§

source

const TYPE_NAME: &'static str

Required Methods§

source

fn handle_cmd( id: &Self::Id, state: &Self::State, cmd: Self::Cmd ) -> Result<Self::Evt, Self::Error>

Command handler, returning the to be persisted event or an error.

source

fn handle_evt(state: Self::State, evt: Self::Evt) -> Self::State

Event handler.

Object Safety§

This trait is not object safe.

Implementors§