pub struct BookSync<E, P = ()> { /* private fields */ }Expand description
Synchronization state of one subscribed book.
Implementations§
Source§impl<E: Clone, P> BookSync<E, P>
impl<E: Clone, P> BookSync<E, P>
Sourcepub fn position(&self) -> Option<&P>
pub fn position(&self) -> Option<&P>
Returns the venue position of the last accepted frame while synced.
Sourcepub fn is_current(&self, recovery: &Arc<BookRecovery<E>>) -> bool
pub fn is_current(&self, recovery: &Arc<BookRecovery<E>>) -> bool
Returns whether recovery is the book’s current episode.
Sourcepub fn has_pending_snapshot(&self) -> bool
pub fn has_pending_snapshot(&self) -> bool
Returns whether a snapshot wait or deadline is pending.
Sourcepub fn is_send_pending(&self) -> bool
pub fn is_send_pending(&self) -> bool
Returns whether a guarded subscription write is still in flight.
Sourcepub fn expect_snapshot(&mut self, gate: SnapshotGate) -> CancellationToken
pub fn expect_snapshot(&mut self, gate: SnapshotGate) -> CancellationToken
Records the initial snapshot wait for a subscription whose write gate guards.
Accepting a snapshot, claiming a recovery, or removing the book cancels the returned token.
Sourcepub fn accept_snapshot(&mut self, position: P, now: Instant) -> bool
pub fn accept_snapshot(&mut self, position: P, now: Instant) -> bool
Accepts a snapshot at position unless a subscription write or recovery gate blocks it.
Sourcepub fn advance(&mut self, position: P, now: Instant) -> bool
pub fn advance(&mut self, position: P, now: Instant) -> bool
Advances a synced book to position, returning false when the book is not synced.
Sourcepub fn gap(&mut self) -> BookSequenceOutcome
pub fn gap(&mut self) -> BookSequenceOutcome
Marks the book out of sync after a gap, an incremental while unsynced, or an invalid snapshot.
Returns BookSequenceOutcome::Recover when neither a running recovery nor an armed
snapshot deadline owns the book; the adapter then claims a recovery. The result grants no
ownership, so later calls return Recover again until the adapter claims one.
Sourcepub fn claim(&mut self) -> Option<Arc<BookRecovery<E>>>
pub fn claim(&mut self) -> Option<Arc<BookRecovery<E>>>
Claims a recovery episode, refusing while another is running.
The claimed episode owns the book and retires any pending snapshot wait. Cancel it if its task cannot start, or it keeps the book owned with nothing running.
Sourcepub fn reject(&self, error: E) -> bool
pub fn reject(&self, error: E) -> bool
Delivers error to the running recovery, returning false when none is running.
Sourcepub fn reset_on_reconnect(&mut self)
pub fn reset_on_reconnect(&mut self)
Restarts synchronization after the book’s connection reconnects.
An initial subscription write still in flight keeps its snapshot wait, since reconnect
replay may not include it yet. A running recovery keeps running with its budget;
BookRecoveryState::reset_on_reconnect describes when the reconnect wakes it.
Sourcepub fn arm_deadline(&mut self, deadline: Instant) -> bool
pub fn arm_deadline(&mut self, deadline: Instant) -> bool
Arms a snapshot deadline, returning false while an initial snapshot wait is in flight.
Sourcepub fn take_expired(&mut self, now: Instant) -> bool
pub fn take_expired(&mut self, now: Instant) -> bool
Removes an expired snapshot deadline, returning whether one expired.
Sourcepub fn stale(&mut self, threshold: Duration, now: Instant) -> Option<Duration>
pub fn stale(&mut self, threshold: Duration, now: Instant) -> Option<Duration>
Returns how long the book has gone without an accepted frame once that exceeds
threshold, re-arming the window so a dead feed is reported once per threshold.
A book owned by a running recovery is not reported; the recovery logs its own attempts.
Trait Implementations§
Auto Trait Implementations§
impl<E, P = ()> !RefUnwindSafe for BookSync<E, P>
impl<E, P = ()> !UnwindSafe for BookSync<E, P>
impl<E, P> Freeze for BookSync<E, P>
impl<E, P> Send for BookSync<E, P>
impl<E, P> Sync for BookSync<E, P>
impl<E, P> Unpin for BookSync<E, P>
impl<E, P> UnsafeUnpin for BookSync<E, 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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