pub trait Aggregate {
    type Id: Eq;
    type State;
    type Event;
    type Command;
    type Error;
    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>(
        &'s self,
        id: &'a Self::Id,
        command: Self::Command
    ) -> BoxFuture<'s, Result<Option<Vec<Self::Event>>, Self::Error>>
    where
        Self: Sized
;
fn handle_next<'a, 's: 'a>(
        &'a self,
        id: &'a Self::Id,
        state: &'s Self::State,
        command: Self::Command
    ) -> BoxFuture<'a, Result<Option<Vec<Self::Event>>, Self::Error>>
    where
        Self: Sized
; 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.

Associated Types

Identifier type of the Aggregate.

Check out Aggregate::Id for more information.

State of the Aggregate.

Check out Aggregate::State for more information.

Events produced and supported by the Aggregate.

Check out Aggregate::Event for more information.

Commands supported by the Aggregate.

Check out Aggregate::Command for more information.

Error produced by the the Aggregate while applying Events or handling Commands.

Required methods

Applies the specified Event when the State is empty.

Applies the specified Event on a pre-existing State value.

Handles the specified Command when the State is empty.

Handles the specified Command on a pre-existing State value.

Provided methods

Translates the current optional::Aggregate instance into a newtype instance compatible with the core Aggregate trait.

Implementors