AggregateRoot

Struct AggregateRoot 

Source
pub struct AggregateRoot<T>
where T: Aggregate + 'static,
{ /* private fields */ }
Expand description

An AggregateRoot represents an handler to the Aggregate it’s managing, such as:

§Initialize

An AggregateRoot can only be initialized using the AggregateRootBuilder.

Check AggregateRootBuilder::build for more information.

Implementations§

Source§

impl<T> AggregateRoot<T>
where T: Aggregate,

Source

pub fn id(&self) -> &T::Id

Returns a reference to the Aggregate Id that represents the entity wrapped by this AggregateRoot instance.

Source

pub fn state(&self) -> &T::State

Returns a reference to the current Aggregate State.

Source§

impl<T> AggregateRoot<T>
where T: Aggregate, T::Event: Clone, T::State: Clone, T::Command: Debug,

Source

pub async fn handle( &mut self, command: T::Command, ) -> Result<&mut Self, T::Error>

Handles the submitted Command using the Aggregate::handle method and updates the Aggregate State.

Returns a &mut self reference to allow for method chaining.

Trait Implementations§

Source§

impl<T> Debug for AggregateRoot<T>
where T: Aggregate + 'static + Debug, T::Id: Debug, T::State: Debug, T::Event: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for AggregateRoot<T>
where T: Aggregate,

Source§

type Target = <T as Aggregate>::State

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> PartialEq for AggregateRoot<T>
where T: Aggregate,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Versioned for AggregateRoot<T>
where T: Aggregate,

Source§

fn version(&self) -> u32

Current version of the data.

Auto Trait Implementations§

§

impl<T> Freeze for AggregateRoot<T>
where <T as Aggregate>::Id: Freeze, <T as Aggregate>::State: Freeze, T: Freeze,

§

impl<T> RefUnwindSafe for AggregateRoot<T>

§

impl<T> Send for AggregateRoot<T>
where <T as Aggregate>::Id: Send, <T as Aggregate>::State: Send, T: Send, <T as Aggregate>::Event: Send,

§

impl<T> Sync for AggregateRoot<T>
where <T as Aggregate>::Id: Sync, <T as Aggregate>::State: Sync, T: Sync, <T as Aggregate>::Event: Sync,

§

impl<T> Unpin for AggregateRoot<T>
where <T as Aggregate>::Id: Unpin, <T as Aggregate>::State: Unpin, T: Unpin, <T as Aggregate>::Event: Unpin,

§

impl<T> UnwindSafe for AggregateRoot<T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.