pub struct PredictionBuffer<A, S>{ /* private fields */ }Expand description
Rolling buffer of unacknowledged inputs + matching predicted snapshots, sized so the oldest entry is dropped when the ring is full.
Implementations§
Source§impl<A, S> PredictionBuffer<A, S>
impl<A, S> PredictionBuffer<A, S>
Sourcepub fn push(&mut self, input: PredictedInput<A>, snapshot: Snapshot<S>)
pub fn push(&mut self, input: PredictedInput<A>, snapshot: Snapshot<S>)
Push a (input, snapshot) pair. Drops the oldest entry when
the ring is full. The snapshot MUST be the result of applying
input to the previous state — the buffer does not verify
this.
Sourcepub fn head_snapshot(&self) -> Option<Snapshot<S>>
pub fn head_snapshot(&self) -> Option<Snapshot<S>>
Head (newest) snapshot, if any.
Sourcepub fn inputs(&self) -> &[PredictedInput<A>]
pub fn inputs(&self) -> &[PredictedInput<A>]
All buffered inputs.
Sourcepub fn drop_acknowledged(&mut self, authoritative_tick: u64)
pub fn drop_acknowledged(&mut self, authoritative_tick: u64)
Drop every entry with tick <= authoritative_tick. Used after
reconcile to discard now-obsolete predictions.
Trait Implementations§
Source§impl<A, S> Clone for PredictionBuffer<A, S>
impl<A, S> Clone for PredictionBuffer<A, S>
Auto Trait Implementations§
impl<A, S> Freeze for PredictionBuffer<A, S>
impl<A, S> RefUnwindSafe for PredictionBuffer<A, S>
impl<A, S> Send for PredictionBuffer<A, S>
impl<A, S> Sync for PredictionBuffer<A, S>
impl<A, S> Unpin for PredictionBuffer<A, S>
impl<A, S> UnsafeUnpin for PredictionBuffer<A, S>
impl<A, S> UnwindSafe for PredictionBuffer<A, S>
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> 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