pub struct History<T> { /* private fields */ }Implementations§
Source§impl<T> History<T>
impl<T> History<T>
pub fn new(capacity: usize) -> History<T>
pub fn push(&mut self, tick: u64, state: T) -> bool
Sourcepub fn bracket(&self, tick: f64) -> Option<(&T, &T, f32)>
pub fn bracket(&self, tick: f64) -> Option<(&T, &T, f32)>
No extrapolation outside retained history: old/untrusted shot times are rejected.
Sourcepub fn bracket_precise(
&self,
tick: u64,
fraction: f64,
endpoints: HistoryEndpointPolicy,
minimum_newest_tick: Option<u64>,
) -> Result<HistoryBracket<'_, T>, HistoryQueryError>
pub fn bracket_precise( &self, tick: u64, fraction: f64, endpoints: HistoryEndpointPolicy, minimum_newest_tick: Option<u64>, ) -> Result<HistoryBracket<'_, T>, HistoryQueryError>
Locate tick + fraction while comparing integer tick components exactly.
fraction must be finite and in [0, 1]. Exactly 1 carries to the next
integer tick; negative zero is zero. (u64::MAX, 1) is an overflow error,
while (u64::MAX, fraction < 1) is valid: a positive fraction there is
after every possible sample. Invalid inputs are never silently clamped.
minimum_newest_tick is an optional inclusive freshness cutoff in the
same nonwrapping authority/session tick domain as the stored samples. A
host with supplied authority now_tick and an integer maximum age can
pass Some(now_tick.saturating_sub(max_age_ticks)). None disables this
check. The target tick is not assumed to be current server time. A
cutoff cannot detect mismatched sessions or clock domains.
Precedence is input errors, empty, stale, then exact/interpolated/range placement. Freshness equality passes. The endpoint policy only affects out-of-range placement; it cannot override stale or invalid input.
Lookup takes O(log(len)) time across wrapped ring storage, allocates
nothing and leaves history unchanged. Strict insertion order makes each
interpolation gap positive. Subtraction occurs in ordered u64 values
before conversion to f64, so short gaps at large ticks remain precise.
Weights are approximate over wide gaps; use the outcome for identity,
never alpha == 0 or alpha == 1. See the runnable module recipe.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drop all retained states and forget insertion order, keeping allocated capacity.
On return, a lower tick may start a new session. Clear this history at the
same reconnect boundary as crate::clock::ClientClock::reset and
crate::clock::TickUnwrapper::reset, after excluding old-session traffic.
Neither clearing nor tick unwrapping authenticates a session. Old samples
cannot be recovered. A panic or side effect in T::drop is not rolled back;
allocation-free reuse assumes the states’ destructors do not allocate.
The module recipe demonstrates lower-tick reuse after reconnect.