Skip to main content

Projector

Trait Projector 

Source
pub trait Projector<E, Evt>: Send + Sync {
    // Required methods
    fn project<'life0, 'async_trait>(
        &'life0 self,
        event: Evt,
        sequence: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn rebuild<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

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

Type parameters:

  • E — entity type the projection is built from
  • Evt — domain event type (e.g. OrderEvent / CrudEvent<Order>)

The entity-specific fields of the projection struct, the event handler methods, and the repository trait remain in the generated module.

Required Methods§

Source

fn project<'life0, 'async_trait>( &'life0 self, event: Evt, sequence: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Apply a single domain event to update the read model.

sequence is the monotonically-increasing position of the event in the event store, used for ordering and idempotency tracking.

Source

fn rebuild<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rebuild all projections from the full event history.

Returns the number of projections rebuilt.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§