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
- CommandE
- EventVersion
- Version/Offset/Sequence numberError
- Error
Required Methods§
Sourcefn fetch_events(
&self,
command: &C,
) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send
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.
Sourcefn save(
&self,
events: &[E],
latest_version: &Option<Version>,
) -> 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
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.