pub trait ViewStateRepository<E, S, Error> {
// Required methods
fn fetch_state(
&self,
event: &E,
) -> impl Future<Output = Result<Option<S>, Error>> + Send;
fn save(&self, state: &S) -> impl Future<Output = Result<S, Error>> + Send;
}
Expand description
View State Repository trait
Generic parameters:
E
- EventS
- StateError
- Error
Required Methods§
Sourcefn fetch_state(
&self,
event: &E,
) -> impl Future<Output = Result<Option<S>, Error>> + Send
fn fetch_state( &self, event: &E, ) -> impl Future<Output = Result<Option<S>, Error>> + Send
Fetches current state, based on the event.
Desugared async fn fetch_state(&self, event: &E) -> Result<Option<S>, 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, state: &S) -> impl Future<Output = Result<S, Error>> + Send
fn save(&self, state: &S) -> impl Future<Output = Result<S, Error>> + Send
Saves the new state.
Desugared async fn save(&self, state: &S) -> Result<S, 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.