pub trait Aggregate {
type Id: Eq;
type State;
type Event;
type Command;
type Error;
// Required methods
fn apply_first(event: Self::Event) -> Result<Self::State, Self::Error>;
fn apply_next(
state: Self::State,
event: Self::Event,
) -> Result<Self::State, Self::Error>;
fn handle_first<'s, 'a>(
&'s self,
id: &'a Self::Id,
command: Self::Command,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Self::Event>>, Self::Error>> + Send + 's>>
where 'a: 's,
Self: Sized;
fn handle_next<'a, 's>(
&'a self,
id: &'a Self::Id,
state: &'s Self::State,
command: Self::Command,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Self::Event>>, Self::Error>> + Send + 'a>>
where 's: 'a,
Self: Sized;
// Provided method
fn as_aggregate(self) -> AsAggregate<Self>
where Self: Sized { ... }
}Expand description
An Option-flavoured, Aggregate-compatible trait
to model Aggregates having an optional State.
Use as_aggregate to get an Aggregate-compatible instance
of this trait.
Required Associated Types§
Sourcetype Id: Eq
type Id: Eq
Identifier type of the Aggregate.
Check out Aggregate::Id for more information.
Sourcetype State
type State
State of the Aggregate.
Check out Aggregate::State for more information.
Sourcetype Event
type Event
Events produced and supported by the Aggregate.
Check out Aggregate::Event for more information.
Sourcetype Command
type Command
Commands supported by the Aggregate.
Check out Aggregate::Command for more information.
Required Methods§
Provided Methods§
Sourcefn as_aggregate(self) -> AsAggregate<Self>where
Self: Sized,
fn as_aggregate(self) -> AsAggregate<Self>where
Self: Sized,
Translates the current optional::Aggregate instance into
a newtype instance compatible with the core Aggregate trait.
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.