pub struct StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where
    Repository: StateRepository<C, S, Version, Error>,
    Decider: StateComputation<C, S, E>,{ /* private fields */ }
Expand description

State Stored Aggregate.

It is using a Decider / StateComputation to compute new state based on the current state and the command. It is using a StateRepository to fetch the current state and to save the new state.

Generic parameters:

  • C - Command
  • S - State
  • E - Event
  • Repository - State repository
  • Decider - State computation
  • Version - Version
  • Error - Error

Implementations§

source§

impl<C, S, E, Repository, Decider, Version, Error> StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where Repository: StateRepository<C, S, Version, Error>, Decider: StateComputation<C, S, E>,

source

pub fn new(repository: Repository, decider: Decider) -> Self

Creates a new instance of StateStoredAggregate.

source

pub async fn handle(&self, command: &C) -> Result<(S, Version), Error>

Handles the command by fetching the state from the repository, computing new state based on the current state and the command, and saving the new state to the repository.

Auto Trait Implementations§

§

impl<C, S, E, Repository, Decider, Version, Error> RefUnwindSafe for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where C: RefUnwindSafe, Decider: RefUnwindSafe, E: RefUnwindSafe, Error: RefUnwindSafe, Repository: RefUnwindSafe, S: RefUnwindSafe, Version: RefUnwindSafe,

§

impl<C, S, E, Repository, Decider, Version, Error> Send for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where C: Send, Decider: Send, E: Send, Error: Send, Repository: Send, S: Send, Version: Send,

§

impl<C, S, E, Repository, Decider, Version, Error> Sync for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where C: Sync, Decider: Sync, E: Sync, Error: Sync, Repository: Sync, S: Sync, Version: Sync,

§

impl<C, S, E, Repository, Decider, Version, Error> Unpin for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where C: Unpin, Decider: Unpin, E: Unpin, Error: Unpin, Repository: Unpin, S: Unpin, Version: Unpin,

§

impl<C, S, E, Repository, Decider, Version, Error> UnwindSafe for StateStoredAggregate<C, S, E, Repository, Decider, Version, Error>where C: UnwindSafe, Decider: UnwindSafe, E: UnwindSafe, Error: UnwindSafe, Repository: UnwindSafe, S: UnwindSafe, Version: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.