Trait SyncEventHandler

pub trait SyncEventHandler<E, S>
where E: Event, S: State,
{ type Context: SyncEventHandlerContext; // Required methods fn handles_event(&self, event: &E) -> bool; fn create_context_for_batch( &self, state: &S, ) -> impl Future<Output = Result<Self::Context, Error>> + Send; fn handle_event( &self, ctx: &Self::Context, event: &E, meta: SyncEventMeta, state: S, ) -> impl Future<Output = Result<EventHandleResult<E, S>, Error>> + Send; fn handle_side_effect_event( &self, ctx: &Self::Context, event: &E, output_events: &[E], new_state: &S, ) -> impl Future<Output = Result<(), Error>> + Send; fn finalize_state( &self, ctx: &Self::Context, state: &mut S, ) -> impl Future<Output = Result<(), Error>> + Send; fn persist_in_memory_state( &self, ctx: &Self::Context, state: &S, ) -> impl Future<Output = Result<(), Error>> + Send; }

Required Associated Types§

Required Methods§

fn handles_event(&self, event: &E) -> bool

Returns true if this event should be handled by the sync handler (requires DB context).

fn create_context_for_batch( &self, state: &S, ) -> impl Future<Output = Result<Self::Context, Error>> + Send

fn handle_event( &self, ctx: &Self::Context, event: &E, meta: SyncEventMeta, state: S, ) -> impl Future<Output = Result<EventHandleResult<E, S>, Error>> + Send

fn handle_side_effect_event( &self, ctx: &Self::Context, event: &E, output_events: &[E], new_state: &S, ) -> impl Future<Output = Result<(), Error>> + Send

fn finalize_state( &self, ctx: &Self::Context, state: &mut S, ) -> impl Future<Output = Result<(), Error>> + Send

fn persist_in_memory_state( &self, ctx: &Self::Context, state: &S, ) -> impl Future<Output = Result<(), Error>> + Send

Persist in-memory state to DB context before commit. Called by flush_state to save changes accumulated without DB context (e.g. fight ticks).

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§