pub struct MaterializedView<S, E, Repository, View, Error>where
    Repository: ViewStateRepository<E, S, Error>,
    View: ViewStateComputation<E, S>,{ /* private fields */ }
Expand description

Materialized View.

It is using a View / ViewStateComputation to compute new state based on the current state and the event. It is using a ViewStateRepository to fetch the current state and to save the new state.

Generic parameters:

  • S - State
  • E - Event
  • Repository - View State repository
  • View - View
  • Error - Error

Implementations§

source§

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

source

pub fn new(repository: Repository, view: View) -> Self

Creates a new instance of MaterializedView.

source

pub async fn handle(&self, event: &E) -> Result<S, Error>

Handles the event by fetching the state from the repository, computing new state based on the current state and the event, and saving the new state to the repository.

Auto Trait Implementations§

§

impl<S, E, Repository, View, Error> RefUnwindSafe for MaterializedView<S, E, Repository, View, Error>where E: RefUnwindSafe, Error: RefUnwindSafe, Repository: RefUnwindSafe, S: RefUnwindSafe, View: RefUnwindSafe,

§

impl<S, E, Repository, View, Error> Send for MaterializedView<S, E, Repository, View, Error>where E: Send, Error: Send, Repository: Send, S: Send, View: Send,

§

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

§

impl<S, E, Repository, View, Error> Unpin for MaterializedView<S, E, Repository, View, Error>where E: Unpin, Error: Unpin, Repository: Unpin, S: Unpin, View: Unpin,

§

impl<S, E, Repository, View, Error> UnwindSafe for MaterializedView<S, E, Repository, View, Error>where E: UnwindSafe, Error: UnwindSafe, Repository: UnwindSafe, S: UnwindSafe, View: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.