Skip to main content

Module projection

Module projection 

Source
Expand description

Projector base trait for CQRS read models.

Phase 0 generic base for the projection.rs generator (Category C).

Each generated {Name}Projector struct applies domain events to its projection (read model). The structural contract — applying an event and rebuilding from scratch — is identical for all entities. This trait captures that contract so generated projectors can implement rather than independently describe it.

§Generated output (after Phase 1):

ⓘ
use backbone_core::projection::Projector;

#[async_trait]
impl<R: OrderProjectionRepository> Projector<Order, OrderEvent> for OrderProjector<R> {
    async fn project(&self, event: OrderEvent, sequence: i64) -> anyhow::Result<()> {
        // dispatch to on_created / on_updated / on_deleted
    }
    async fn rebuild(&self) -> anyhow::Result<u64> {
        self.repository.rebuild_all().await
    }
}

Traits§

Projector
Applies domain events to a CQRS read model (projection).