Skip to main content

ApplyProjection

Trait ApplyProjection 

Source
pub trait ApplyProjection<E>: ProjectionFilters {
    // Required method
    fn apply_projection(
        &mut self,
        aggregate_id: &Self::Id,
        event: &E,
        metadata: &Self::Metadata,
    );
}
Expand description

Apply an event to a projection with access to envelope context.

Implementations receive the aggregate identifier, the pure domain event, and metadata supplied by the backing store.

impl ApplyProjection<InventoryAdjusted> for InventoryReport {
    fn apply_projection(&mut self, aggregate_id: &Self::Id, event: &InventoryAdjusted, _metadata: &Self::Metadata) {
        let stats = self.products.entry(aggregate_id.clone()).or_default();
        stats.quantity += event.delta;
    }
}

Required Methods§

Source

fn apply_projection( &mut self, aggregate_id: &Self::Id, event: &E, metadata: &Self::Metadata, )

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§