Trait esrs::aggregate::Aggregate[][src]

pub trait Aggregate: Identifier {
    type State: Default + Debug + Clone + Send + Sync;
    type Command: Send + Sync;
    type Event: Serialize + DeserializeOwned + Clone + Send + Sync;
    type Error: Send + Sync;
    fn event_store(
        &self
    ) -> &(dyn EventStore<Self::Event, Self::Error> + Send + Sync);
fn apply_event(
        id: &Uuid,
        state: Self::State,
        event: &StoreEvent<Self::Event>
    ) -> Self::State;
fn validate_command(
        aggregate_state: &AggregateState<Self::State>,
        cmd: &Self::Command
    ) -> Result<(), Self::Error>;
#[must_use] fn do_handle_command<'life0, 'async_trait>(
        &'life0 self,
        aggregate_state: AggregateState<Self::State>,
        cmd: Self::Command
    ) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; #[must_use] fn handle_command<'life0, 'async_trait>(
        &'life0 self,
        aggregate_state: AggregateState<Self::State>,
        cmd: Self::Command
    ) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
fn apply_events(
        aggregate_state: AggregateState<Self::State>,
        events: Vec<StoreEvent<Self::Event>>
    ) -> AggregateState<Self::State> { ... }
#[must_use] fn load<'life0, 'async_trait>(
        &'life0 self,
        aggregate_id: Uuid
    ) -> Pin<Box<dyn Future<Output = Option<AggregateState<Self::State>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
#[must_use] fn persist<'life0, 'async_trait>(
        &'life0 self,
        aggregate_state: AggregateState<Self::State>,
        event: Self::Event
    ) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

Aggregate trait. It is used to keep the state in-memory and to validate commands. It also persist events

Associated Types

Required methods

fn event_store(
    &self
) -> &(dyn EventStore<Self::Event, Self::Error> + Send + Sync)
[src]

Event store configured for aggregate

fn apply_event(
    id: &Uuid,
    state: Self::State,
    event: &StoreEvent<Self::Event>
) -> Self::State
[src]

This function applies the event onto the aggregate and returns a new one, updated with the event data

fn validate_command(
    aggregate_state: &AggregateState<Self::State>,
    cmd: &Self::Command
) -> Result<(), Self::Error>
[src]

#[must_use]
fn do_handle_command<'life0, 'async_trait>(
    &'life0 self,
    aggregate_state: AggregateState<Self::State>,
    cmd: Self::Command
) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Provided methods

#[must_use]
fn handle_command<'life0, 'async_trait>(
    &'life0 self,
    aggregate_state: AggregateState<Self::State>,
    cmd: Self::Command
) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

fn apply_events(
    aggregate_state: AggregateState<Self::State>,
    events: Vec<StoreEvent<Self::Event>>
) -> AggregateState<Self::State>
[src]

#[must_use]
fn load<'life0, 'async_trait>(
    &'life0 self,
    aggregate_id: Uuid
) -> Pin<Box<dyn Future<Output = Option<AggregateState<Self::State>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

#[must_use]
fn persist<'life0, 'async_trait>(
    &'life0 self,
    aggregate_state: AggregateState<Self::State>,
    event: Self::Event
) -> Pin<Box<dyn Future<Output = Result<AggregateState<Self::State>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

Implementors