Skip to main content

Projection

Trait Projection 

Source
pub trait Projection<E>: Default {
    // Required method
    fn apply(&mut self, event: &StoredEvent<E>) -> Result<()>;

    // Provided methods
    fn prepare_replay(&mut self, _events: &[StoredEvent<E>]) { ... }
    fn apply_owned(&mut self, event: StoredEvent<E>) -> Result<()> { ... }
}

Required Methods§

Source

fn apply(&mut self, event: &StoredEvent<E>) -> Result<()>

Applies one validated stored event.

§Errors

Returns domain-specific invariant violations.

Provided Methods§

Source

fn prepare_replay(&mut self, _events: &[StoredEvent<E>])

Reserves projection-specific capacity before a known replay batch.

The default is a no-op. Implementations must not mutate observable projection state or weaken validation.

Source

fn apply_owned(&mut self, event: StoredEvent<E>) -> Result<()>

Applies one owned event. The default preserves the borrowed contract; projections may override it to move large payloads without cloning.

§Errors

Returns the same invariant violations as Self::apply.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§