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§
Sourcetype Event: DomainEvent
type Event: DomainEvent
The domain event type this aggregate records.
Required Methods§
Sourcefn record(&mut self, event: Self::Event)
fn record(&mut self, event: Self::Event)
Records that event happened, to be drained later via
AggregateRoot::take_events.
Sourcefn take_events(&mut self) -> Vec<Self::Event>
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".