Skip to main content

ProjectionFilters

Trait ProjectionFilters 

Source
pub trait ProjectionFilters: Sized {
    type Id;
    type InstanceId;
    type Metadata;

    // Required methods
    fn init(instance_id: &Self::InstanceId) -> Self;
    fn filters<S>(instance_id: &Self::InstanceId) -> Filters<S, Self>
       where S: EventStore<Id = Self::Id, Metadata = Self::Metadata>;
}
Expand description

Base trait for types that subscribe to events.

The filters() method returns both the event filters AND the handlers needed to process those events. It is generic over the store type S, allowing the same projection to work with any store that shares the same Id and Metadata types.

filters() must be pure and deterministic: given the same instance_id, it must always return the same filter set.

init() constructs a fresh instance from the instance identifier. This replaces the Default constraint, allowing instance-aware projections to capture their identity at construction time.

Required Associated Types§

Source

type Id

Aggregate identifier type this subscriber is compatible with.

Source

type InstanceId

Instance identifier for this subscriber.

For singleton subscribers use ().

Source

type Metadata

Metadata type expected by this subscriber’s handlers.

Required Methods§

Source

fn init(instance_id: &Self::InstanceId) -> Self

Construct a fresh instance from the instance identifier.

For singleton projections (InstanceId = ()), this typically delegates to Self::default(). For instance projections, this captures the instance identifier at construction time.

Source

fn filters<S>(instance_id: &Self::InstanceId) -> Filters<S, Self>
where S: EventStore<Id = Self::Id, Metadata = Self::Metadata>,

Build the filter set and handler map for this subscriber.

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§