Skip to main content

EventMapper

Trait EventMapper 

Source
pub trait EventMapper {
    type Output;
    type Error;

    // Required method
    fn map_event(
        &mut self,
        event: &ButtonEvent,
        output: &mut Vec<Self::Output>,
    ) -> Result<(), Self::Error>;

    // Provided method
    fn map_batch(
        &mut self,
        events: &[ButtonEvent],
        output: &mut Vec<Self::Output>,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Maps one domain event into zero or more owned downstream events.

Implementations append to output; they must not clear or reorder values already present in it. Returning no values is the explicit policy for an ignored domain event.

Required Associated Types§

Required Methods§

Source

fn map_event( &mut self, event: &ButtonEvent, output: &mut Vec<Self::Output>, ) -> Result<(), Self::Error>

Provided Methods§

Source

fn map_batch( &mut self, events: &[ButtonEvent], output: &mut Vec<Self::Output>, ) -> Result<(), Self::Error>

Map a complete ordered domain batch.

The default implementation calls Self::map_event in slice order. It may have mutated mapper state before a later event fails. Stateful mappers which require transactional batches should override this method, preflight the batch, and mutate only after validation succeeds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§