Skip to main content

BookSync

Struct BookSync 

Source
pub struct BookSync<E, P = ()> { /* private fields */ }
Expand description

Synchronization state of one subscribed book.

Implementations§

Source§

impl<E: Clone, P> BookSync<E, P>

Source

pub fn new(now: Instant) -> Self

Creates a book waiting for its first snapshot.

Source

pub fn phase(&self) -> &BookPhase<P>

Returns the synchronization phase.

Source

pub fn position(&self) -> Option<&P>

Returns the venue position of the last accepted frame while synced.

Source

pub fn is_current(&self, recovery: &Arc<BookRecovery<E>>) -> bool

Returns whether recovery is the book’s current episode.

Source

pub fn has_pending_snapshot(&self) -> bool

Returns whether a snapshot wait or deadline is pending.

Source

pub fn is_send_pending(&self) -> bool

Returns whether a guarded subscription write is still in flight.

Source

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.

Source

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.

Source

pub fn advance(&mut self, position: P, now: Instant) -> bool

Advances a synced book to position, returning false when the book is not synced.

Source

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.

Source

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.

Source

pub fn reject(&self, error: E) -> bool

Delivers error to the running recovery, returning false when none is running.

Source

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.

Source

pub fn arm_deadline(&mut self, deadline: Instant) -> bool

Arms a snapshot deadline, returning false while an initial snapshot wait is in flight.

Source

pub fn take_expired(&mut self, now: Instant) -> bool

Removes an expired snapshot deadline, returning whether one expired.

Source

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§

Source§

impl<E: Debug, P: Debug> Debug for BookSync<E, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
§

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more