pub trait StateRepository<C, S, Version, Error> {
// Required methods
fn fetch_state(
&self,
command: &C,
) -> impl Future<Output = Result<Option<(S, Version)>, Error>> + Send;
fn save(
&self,
state: &S,
version: &Option<Version>,
) -> impl Future<Output = Result<(S, Version), Error>> + Send;
}
Expand description
State Repository trait
Generic parameters:
C
- CommandS
- StateVersion
- VersionError
- Error
Required Methods§
Sourcefn fetch_state(
&self,
command: &C,
) -> impl Future<Output = Result<Option<(S, Version)>, Error>> + Send
fn fetch_state( &self, command: &C, ) -> impl Future<Output = Result<Option<(S, Version)>, Error>> + Send
Fetches current state, based on the command.
Desugared async fn fetch_state(&self, command: &C) -> Result<Option<(S, 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,
state: &S,
version: &Option<Version>,
) -> impl Future<Output = Result<(S, Version), Error>> + Send
fn save( &self, state: &S, version: &Option<Version>, ) -> impl Future<Output = Result<(S, Version), Error>> + Send
Saves state.
Desugared async fn save(&self, state: &S, version: &Option<Version>) -> Result<(S, 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.