[−][src]Struct eventually_core::repository::Repository
Implementation of the Repository pattern for storing, retrieving
and deleting Aggregates.
A Repository instruments an EventStore to:
- Insert
Events in theEventStorefor an Aggregate, using theAggregateRoot, - Get all the
Events in theEventStoreand rebuild theStateof an Aggregate, into a newAggregateRootinstance, - Remove all the
Events for an Aggregate in theEventStore.
Implementations
impl<T, Store> Repository<T, Store> where
T: Aggregate,
Store: EventStore<SourceId = AggregateId<T>, Event = T::Event>, [src]
T: Aggregate,
Store: EventStore<SourceId = AggregateId<T>, Event = T::Event>,
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]
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,
pub async fn get<'_>(
&'_ self,
id: AggregateId<T>
) -> Result<Option<AggregateRoot<T>>, T, Store>[src]
&'_ self,
id: AggregateId<T>
) -> Result<Option<AggregateRoot<T>>, T, Store>
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]
&'_ mut self,
__arg1: AggregateRoot<T>
) -> Result<AggregateRoot<T>, T, Store>
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]
&'_ mut self,
id: AggregateId<T>
) -> Result<(), T, Store>
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,
Store: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, Store> Send for Repository<T, Store> where
Store: Send,
T: Send,
Store: Send,
T: Send,
impl<T, Store> Sync for Repository<T, Store> where
Store: Sync,
T: Sync,
Store: Sync,
T: Sync,
impl<T, Store> Unpin for Repository<T, Store> where
Store: Unpin,
T: Unpin,
Store: Unpin,
T: Unpin,
impl<T, Store> UnwindSafe for Repository<T, Store> where
Store: UnwindSafe,
T: UnwindSafe,
Store: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,