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],
) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send;
fn version_provider(
&self,
event: &E,
) -> impl Future<Output = Result<Option<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],
) -> impl Future<Output = Result<Vec<(E, Version)>, Error>> + Send
fn save( &self, events: &[E], ) -> 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.
Sourcefn version_provider(
&self,
event: &E,
) -> impl Future<Output = Result<Option<Version>, Error>> + Send
fn version_provider( &self, event: &E, ) -> impl Future<Output = Result<Option<Version>, Error>> + Send
Version provider. It is used to provide the version/sequence of the stream to wich this event belongs to. Optimistic locking is useing this version to check if the event is already saved.
Desugared async fn version_provider(&self, event: &E) -> Result<Option<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.