pub struct ProjectionHandle<P> { /* private fields */ }Expand description
Read-only access to a projection’s current state and offset.
P is the user’s projection type (the read model). Cloning a handle
is cheap — the underlying state is shared.
Implementations§
Source§impl<P: Send + Sync + 'static> ProjectionHandle<P>
impl<P: Send + Sync + 'static> ProjectionHandle<P>
Sourcepub fn offset(&self) -> u64
pub fn offset(&self) -> u64
Highest journal sequence number the runner has applied. Useful for tests that wait until the projection has caught up.
Sourcepub async fn snapshot(&self) -> RwLockReadGuard<'_, P>
pub async fn snapshot(&self) -> RwLockReadGuard<'_, P>
Take a read lock on the projection state.
Sourcepub async fn read<R>(&self, f: impl FnOnce(&P) -> R) -> R
pub async fn read<R>(&self, f: impl FnOnce(&P) -> R) -> R
Apply a closure to the projection state under a read lock and
return the result. Convenience wrapper around Self::snapshot.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for ProjectionHandle<P>
impl<P> !RefUnwindSafe for ProjectionHandle<P>
impl<P> Send for ProjectionHandle<P>
impl<P> Sync for ProjectionHandle<P>
impl<P> Unpin for ProjectionHandle<P>
impl<P> UnsafeUnpin for ProjectionHandle<P>
impl<P> !UnwindSafe for ProjectionHandle<P>
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