pub struct BackoffState { /* private fields */ }Expand description
Per-instance mutable backoff state.
Carries the current interval and a lightweight pseudo-random seed so that no external RNG dependency is needed.
Implementations§
Source§impl BackoffState
impl BackoffState
Sourcepub fn new(seed: u32) -> Self
pub fn new(seed: u32) -> Self
Create fresh state, seeded from the given value.
Use a per-peer value (e.g. truncated FaceId or timestamp) as the seed to decorrelate hellos across nodes.
Sourcepub fn next_failure(&mut self, cfg: &BackoffConfig) -> Duration
pub fn next_failure(&mut self, cfg: &BackoffConfig) -> Duration
Compute the next wait duration and update internal state.
Call this after a failed probe to get the retry delay.
Sourcepub fn reset(&mut self, _cfg: &BackoffConfig)
pub fn reset(&mut self, _cfg: &BackoffConfig)
Reset to the initial interval after a successful exchange.
Clears the current interval so the next [next_failure] call
starts fresh from cfg.initial_interval.
Trait Implementations§
Source§impl Clone for BackoffState
impl Clone for BackoffState
Source§fn clone(&self) -> BackoffState
fn clone(&self) -> BackoffState
Returns a duplicate of the value. Read more
1.0.0 · 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 BackoffState
impl RefUnwindSafe for BackoffState
impl Send for BackoffState
impl Sync for BackoffState
impl Unpin for BackoffState
impl UnwindSafe for BackoffState
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