Skip to main content

ProjectionReducer

Trait ProjectionReducer 

Source
pub trait ProjectionReducer<Event> {
    type Projection;
    type Error;

    // Required methods
    fn seed(&self, event: &Event) -> Result<Self::Projection, Self::Error>;
    fn apply(
        &self,
        projection: &mut Self::Projection,
        event: &Event,
    ) -> Result<(), Self::Error>;
}
Expand description

Fold events into a projection that can later be rehydrated with #[validators].

Required Associated Types§

Source

type Projection

The output projection type.

Source

type Error

The reducer-specific error type.

Required Methods§

Source

fn seed(&self, event: &Event) -> Result<Self::Projection, Self::Error>

Create the first projection value from the first event in a stream.

Source

fn apply( &self, projection: &mut Self::Projection, event: &Event, ) -> Result<(), Self::Error>

Apply a later event to an existing projection value.

Implementors§