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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more