Skip to main content

ViewStateRepository

Trait ViewStateRepository 

Source
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 - Event
  • S - State
  • Error - Error

Required Methods§

Source

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.

Source

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".

Implementors§

Source§

impl<S, E, Repository, View, Error> ViewStateRepository<E, S, Error> for MaterializedView<S, E, Repository, View, Error>
where Repository: ViewStateRepository<E, S, Error> + Sync, View: ViewStateComputation<E, S> + Sync, E: Sync, S: Sync, Error: Sync,

Available on non-crate feature not-send-futures only.