pub trait Aggregate: Default {
// Required method
fn aggregate_type() -> &'static str;
// Provided methods
fn apply<E>(&mut self, event: E)
where E: AggregateEvent<Self> { ... }
fn execute<C>(
&self,
command: C,
) -> Result<<C as AggregateCommand<Self>>::Events, <C as AggregateCommand<Self>>::Error>
where C: AggregateCommand<Self> { ... }
}
Expand description
A projected state built from a series of events.
Required Methods§
Sourcefn aggregate_type() -> &'static str
fn aggregate_type() -> &'static str
A static string representing the type of the aggregate.
Note: This should effectively be a constant value, and should never change.
Provided Methods§
Sourcefn apply<E>(&mut self, event: E)where
E: AggregateEvent<Self>,
fn apply<E>(&mut self, event: E)where
E: AggregateEvent<Self>,
Consumes the event, applying its effects to the aggregate.
Sourcefn execute<C>(
&self,
command: C,
) -> Result<<C as AggregateCommand<Self>>::Events, <C as AggregateCommand<Self>>::Error>where
C: AggregateCommand<Self>,
fn execute<C>(
&self,
command: C,
) -> Result<<C as AggregateCommand<Self>>::Events, <C as AggregateCommand<Self>>::Error>where
C: AggregateCommand<Self>,
Consumes a command, attempting to execute it against the aggregate. If the execution is successful, a sequence of events is generated, which can be applied to the aggregate.
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.