Trait EventRepository

Source
pub trait EventRepository<C, E, Version, Error> {
    // Required methods
    fn fetch_events(
        &self,
        command: &C,
    ) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send;
    fn save(
        &self,
        events: &[E],
        latest_version: &Option<Version>,
    ) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send;
}
Expand description

Event Repository trait

Generic parameters:

  • C - Command
  • E - Event
  • Version - Version/Offset/Sequence number
  • Error - Error

Required Methods§

Source

fn fetch_events( &self, command: &C, ) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send

Fetches current events, based on the command. Desugared async fn fetch_events(&self, command: &C) -> Result<Vec<(E, Version)>, Error>; to a normal fn that returns impl Future, and adds bound Send. You can freely move between the async fn and -> impl Future spelling in your traits and impls. This is true even when one form has a Send bound.

Source

fn save( &self, events: &[E], latest_version: &Option<Version>, ) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send

Saves events. Desugared async fn save(&self, events: &[E], latest_version: &Option<Version>) -> Result<Vec<(E, Version)>, Error>; to a normal fn that returns impl Future, and adds bound Send You can freely move between the async fn and -> impl Future spelling in your traits and impls. This is true even when one form has a Send bound.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<C, S, E, Repository, Decider, Version, Error> EventRepository<C, E, Version, Error> for EventSourcedAggregate<C, S, E, Repository, Decider, Version, Error>
where Repository: EventRepository<C, E, Version, Error> + Sync, Decider: EventComputation<C, S, E> + Sync, C: Sync, S: Sync, E: Sync, Version: Sync, Error: Sync,