pub struct PeerLatencyState {
pub peer_id: String,
pub ewma_ms: f64,
pub ewma_variance: f64,
pub sample_count: u64,
pub recent_ewmas: Vec<f64>,
pub last_updated_secs: u64,
}Expand description
Per-peer latency tracking state.
Fields§
§peer_id: StringIdentifier of the tracked peer.
ewma_ms: f64Current EWMA of RTT (milliseconds).
ewma_variance: f64EWMA of squared deviation from the EWMA (variance proxy for jitter).
sample_count: u64Number of samples recorded so far.
recent_ewmas: Vec<f64>Rolling window of the last 5 EWMA values (oldest → newest).
last_updated_secs: u64Unix timestamp (seconds) of the most recent sample.
Implementations§
Source§impl PeerLatencyState
impl PeerLatencyState
Sourcepub fn jitter_ms(&self) -> f64
pub fn jitter_ms(&self) -> f64
Returns the estimated jitter in milliseconds (sqrt of EWMA variance).
Sourcepub fn predicted_rtt_ms(&self) -> f64
pub fn predicted_rtt_ms(&self) -> f64
Returns a conservative predicted RTT: EWMA + 0.5 * jitter.
Sourcepub fn trend(&self) -> TrendDirection
pub fn trend(&self) -> TrendDirection
Infers the latency trend from the rolling EWMA window.
Requires at least 2 values. Splits recent_ewmas into first-half and
second-half, comparing their means:
- second > first × 1.05 →
Degrading - second < first × 0.95 →
Improving - otherwise →
Stable
Trait Implementations§
Source§impl Clone for PeerLatencyState
impl Clone for PeerLatencyState
Source§fn clone(&self) -> PeerLatencyState
fn clone(&self) -> PeerLatencyState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PeerLatencyState
impl RefUnwindSafe for PeerLatencyState
impl Send for PeerLatencyState
impl Sync for PeerLatencyState
impl Unpin for PeerLatencyState
impl UnsafeUnpin for PeerLatencyState
impl UnwindSafe for PeerLatencyState
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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