pub struct ProjectionUnit { /* private fields */ }Expand description
Standard composition of a Projector and a ReadModelStore.
This is the typical way to create a Projection: provide the event-handling
logic (projector) and the storage backend (store), and ProjectionUnit wires
them together.
§Example
ⓘ
let projector = Box::new(UserListProjector);
let store: Arc<dyn ReadModelStore> = Arc::new(SqliteReadModelStore::new(pool));
let projection = ProjectionUnit::new(projector, store, "users_view");
engine.register(Box::new(projection));Implementations§
Trait Implementations§
Source§impl Projection for ProjectionUnit
impl Projection for ProjectionUnit
Source§fn handles(&self) -> Vec<String>
fn handles(&self) -> Vec<String>
Event types this projection handles (delegates to the projector).
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ProjectionResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ProjectionResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a single event by applying it through the projector to the store.
Auto Trait Implementations§
impl !RefUnwindSafe for ProjectionUnit
impl !UnwindSafe for ProjectionUnit
impl Freeze for ProjectionUnit
impl Send for ProjectionUnit
impl Sync for ProjectionUnit
impl Unpin for ProjectionUnit
impl UnsafeUnpin for ProjectionUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more