[][src]Struct eventually_core::repository::Repository

pub struct Repository<T, Store> where
    T: Aggregate + 'static, 
{ /* fields omitted */ }

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

A Repository instruments an EventStore to:

Implementations

impl<T, Store> Repository<T, Store> where
    T: Aggregate,
    Store: EventStore<SourceId = AggregateId<T>, Event = T::Event>, 
[src]

pub fn new(aggregate: T, store: Store) -> Self[src]

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

impl<T, Store> Repository<T, Store> where
    T: Aggregate + Debug + Clone,
    T::Event: Clone,
    T::State: Default + Identifiable,
    T::Error: StdError + 'static,
    AggregateId<T>: Default,
    Store: EventStore<SourceId = AggregateId<T>, Event = T::Event> + Debug,
    Store::Offset: Default,
    Store::Error: StdError + 'static, 
[src]

pub async fn get<'_>(
    &'_ self,
    id: AggregateId<T>
) -> Result<Option<AggregateRoot<T>>, T, Store>
[src]

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.

pub async fn add<'_>(
    &'_ mut self,
    __arg1: AggregateRoot<T>
) -> Result<AggregateRoot<T>, T, Store>
[src]

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.

pub async fn remove<'_>(
    &'_ mut self,
    id: AggregateId<T>
) -> Result<(), T, Store>
[src]

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

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.