Repository

Struct Repository 

Source
pub struct Repository<T, Store>
where T: Aggregate + Clone + 'static, Store: EventStore<SourceId = <T as Aggregate>::Id, Event = <T as Aggregate>::Event>,
{ /* private fields */ }
Expand description

Implementation of the Repository pattern for storing, retrieving and deleting Aggregates.

A Repository instruments an EventStore to:

Implementations§

Source§

impl<T, Store> Repository<T, Store>
where T: Aggregate + Clone, Store: EventStore<SourceId = <T as Aggregate>::Id, Event = <T as Aggregate>::Event>,

Source

pub fn new( builder: AggregateRootBuilder<T>, store: Store, ) -> Repository<T, Store>

Creates a new Repository instance, using the Aggregate and EventStore provided.

Source§

impl<T, Store> Repository<T, Store>
where T: Aggregate + Clone, <T as Aggregate>::Id: Debug + Clone, <T as Aggregate>::Event: Clone, <T as Aggregate>::Error: Error + 'static, Store: EventStore<SourceId = <T as Aggregate>::Id, Event = <T as Aggregate>::Event>, <Store as EventStore>::Error: Error + 'static,

Source

pub async fn get( &self, id: <T as Aggregate>::Id, ) -> Result<AggregateRoot<T>, Error<<T as Aggregate>::Error, <Store as EventStore>::Error>>

Returns the Aggregate from the Repository with the specified id, if any.

In case the Aggregate with the specified id exists, returns a new AggregateRoot instance with its latest State.

Otherwise, None is returned.

Source

pub async fn add( &mut self, root: AggregateRoot<T>, ) -> Result<AggregateRoot<T>, Error<<T as Aggregate>::Error, <Store as EventStore>::Error>>

Adds a new State of the Aggregate into the Repository, through an AggregateRoot instance.

Returns Error::NoEvents if there are no Events to commit in the AggregateRoot.

Source

pub async fn remove( &mut self, id: <T as Aggregate>::Id, ) -> Result<(), Error<<T as Aggregate>::Error, <Store as EventStore>::Error>>

Removes the specified Aggregate from the Repository, using the provided AggregateId.

Trait Implementations§

Source§

impl<T, Store> Clone for Repository<T, Store>
where T: Clone + Aggregate + 'static, Store: Clone + EventStore<SourceId = <T as Aggregate>::Id, Event = <T as Aggregate>::Event>,

Source§

fn clone(&self) -> Repository<T, Store>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T, Store> Freeze for Repository<T, Store>
where Store: Freeze, T: Freeze,

§

impl<T, Store> RefUnwindSafe for Repository<T, Store>
where Store: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, Store> Send for Repository<T, Store>
where Store: Send, T: Send,

§

impl<T, Store> Sync for Repository<T, Store>
where Store: Sync, T: Sync,

§

impl<T, Store> Unpin for Repository<T, Store>
where Store: Unpin, T: Unpin,

§

impl<T, Store> UnwindSafe for Repository<T, Store>
where Store: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.