Skip to main content

Aggregate

Trait Aggregate 

Source
pub trait Aggregate: Sized + Default {
    type ReplayError: Display;

    // Required methods
    fn entity(&self) -> &Entity;
    fn entity_mut(&mut self) -> &mut Entity;
    fn replay_event(
        &mut self,
        event: &EventRecord,
    ) -> Result<(), Self::ReplayError>;

    // Provided methods
    fn aggregate_type() -> &'static str { ... }
    fn new_empty() -> Self { ... }
    fn upcasters() -> &'static [EventUpcaster] { ... }
}
Expand description

Trait for domain aggregates that can be event-sourced.

Required Associated Types§

Required Methods§

Source

fn entity(&self) -> &Entity

Source

fn entity_mut(&mut self) -> &mut Entity

Source

fn replay_event(&mut self, event: &EventRecord) -> Result<(), Self::ReplayError>

Provided Methods§

Source

fn aggregate_type() -> &'static str

Stable aggregate type used by stream-aware persistence.

The default is a development fallback based on Rust’s type name so existing examples keep working. Production persistence should override this with an explicit, durable application name.

Source

fn new_empty() -> Self

Source

fn upcasters() -> &'static [EventUpcaster]

Override to register upcasters for this aggregate’s events. Upcasters are configuration, not state — this is a static method.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§