Trait eventsourced::EventSourced
source · pub trait EventSourced: Sized + Send + Sync + 'static {
type Cmd: Debug + Send + Sync + 'static;
type Evt: Debug + Send + Sync + 'static;
type State: Send + Sync;
type Error: StdError + Send + Sync + 'static;
fn handle_cmd(
&self,
cmd: Self::Cmd
) -> Result<impl IntoTaggedEvt<Self::Evt>, Self::Error>;
fn handle_evt(&mut self, evt: Self::Evt) -> Option<Self::State>;
fn set_state(&mut self, state: Self::State);
}Expand description
Command and event handling for an event sourced entity.
Required Associated Types§
Required Methods§
sourcefn handle_cmd(
&self,
cmd: Self::Cmd
) -> Result<impl IntoTaggedEvt<Self::Evt>, Self::Error>
fn handle_cmd(
&self,
cmd: Self::Cmd
) -> Result<impl IntoTaggedEvt<Self::Evt>, Self::Error>
Command handler, returning the to be persisted event or an error.
sourcefn handle_evt(&mut self, evt: Self::Evt) -> Option<Self::State>
fn handle_evt(&mut self, evt: Self::Evt) -> Option<Self::State>
Event handler, returning whether to take a snapshot or not.