[−][src]Trait eventually::Aggregate
An Aggregate manages a domain entity State
, acting as a transaction boundary.
It allows state mutations through the use of Command
s, which the
Aggregate instance handles and emits a number of Domain Event
s.
Associated Types
type Id: Eq
Aggregate identifier: this should represent an unique identifier to refer to a unique Aggregate instance.
type State: Default
State of the Aggregate: this should represent the Domain Entity data structure.
type Event
Represents a specific, domain-related change to the Aggregate State
.
type Command
Commands are all the possible operations available on an Aggregate.
Use Commands to model business use-cases or State
mutations.
type Error
Required methods
fn apply(
state: Self::State,
event: Self::Event
) -> Result<Self::State, Self::Error>
state: Self::State,
event: Self::Event
) -> Result<Self::State, Self::Error>
Applies an Event
to the current Aggregate State
.
To enforce immutability, this method takes ownership of the previous State
and the current Event
to apply, and returns the new version of the State
or an error.
fn handle<'a, 's>(
&'a self,
id: &'s Self::Id,
state: &'s Self::State,
command: Self::Command
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Self::Event>>, Self::Error>> + 'a + Send>> where
's: 'a,
&'a self,
id: &'s Self::Id,
state: &'s Self::State,
command: Self::Command
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Self::Event>>, Self::Error>> + 'a + Send>> where
's: 'a,
Implementors
impl<A> Aggregate for AsAggregate<A> where
A: Aggregate + Send + Sync,
<A as Aggregate>::Id: Send,
<A as Aggregate>::Id: Sync,
<A as Aggregate>::Command: Send,
<A as Aggregate>::Command: Sync,
<A as Aggregate>::State: Send,
<A as Aggregate>::State: Sync,
[src]
A: Aggregate + Send + Sync,
<A as Aggregate>::Id: Send,
<A as Aggregate>::Id: Sync,
<A as Aggregate>::Command: Send,
<A as Aggregate>::Command: Sync,
<A as Aggregate>::State: Send,
<A as Aggregate>::State: Sync,
type Id = <A as Aggregate>::Id
type State = Option<<A as Aggregate>::State>
type Event = <A as Aggregate>::Event
type Command = <A as Aggregate>::Command
type Error = <A as Aggregate>::Error
fn apply(
state: <AsAggregate<A> as Aggregate>::State,
event: <AsAggregate<A> as Aggregate>::Event
) -> Result<<AsAggregate<A> as Aggregate>::State, <AsAggregate<A> as Aggregate>::Error>
[src]
state: <AsAggregate<A> as Aggregate>::State,
event: <AsAggregate<A> as Aggregate>::Event
) -> Result<<AsAggregate<A> as Aggregate>::State, <AsAggregate<A> as Aggregate>::Error>
fn handle<'a, 's>(
&'a self,
id: &'s <AsAggregate<A> as Aggregate>::Id,
state: &'s <AsAggregate<A> as Aggregate>::State,
command: <AsAggregate<A> as Aggregate>::Command
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<<AsAggregate<A> as Aggregate>::Event>>, <AsAggregate<A> as Aggregate>::Error>> + 'a + Send>> where
's: 'a,
AsAggregate<A>: Sized,
[src]
&'a self,
id: &'s <AsAggregate<A> as Aggregate>::Id,
state: &'s <AsAggregate<A> as Aggregate>::State,
command: <AsAggregate<A> as Aggregate>::Command
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<<AsAggregate<A> as Aggregate>::Event>>, <AsAggregate<A> as Aggregate>::Error>> + 'a + Send>> where
's: 'a,
AsAggregate<A>: Sized,