Skip to main content

AggregateRoot

Trait AggregateRoot 

Source
pub trait AggregateRoot: Entity {
    type Event: DomainEvent;

    // Required methods
    fn record(&mut self, event: Self::Event);
    fn take_events(&mut self) -> Vec<Self::Event>;
}
Expand description

An Entity that is a consistency boundary and the unit of persistence: changes to it (and whatever it contains) are saved and loaded together, and it records the domain events those changes produce.

Required Associated Types§

Source

type Event: DomainEvent

The domain event type this aggregate records.

Required Methods§

Source

fn record(&mut self, event: Self::Event)

Records that event happened, to be drained later via AggregateRoot::take_events.

Source

fn take_events(&mut self) -> Vec<Self::Event>

Returns and clears every event recorded since the last call.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§