jitter-backoff 11.2.0

Zero-dependency exponential backoff, full/equal/decorrelated jitter, deadline retry budgets, Retry-After header parsing, and synchronous retry execution.
Documentation
use super::*;

/// Immutable retry and exponential backoff configuration.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RetryPolicy {
    /// Maximum number of retries after the initial attempt (`0` disables retries).
    pub(crate) max_retries: u32,
    /// Initial base delay in milliseconds.
    pub(crate) initial_delay_ms: u64,
    /// Maximum delay cap in milliseconds.
    pub(crate) max_delay_ms: u64,
    /// Exponential multiplier expressed in tenths (`20` = `2.0x`).
    pub(crate) multiplier_tenths: u32,
    /// Jitter distribution strategy.
    pub(crate) jitter: JitterMode,
    /// Optional total deadline budget in milliseconds across all attempts (`0` = unbounded).
    pub(crate) total_timeout_ms: u64,
}

/// Stateful per-operation retry schedule tracker producing delays for successive attempts.
#[derive(Clone, Debug)]
pub struct RetrySchedule {
    /// Policy governing delays and limits.
    pub(crate) policy: RetryPolicy,
    /// Completed retry count so far.
    pub(crate) attempts_used: u32,
    /// Previous delay in milliseconds (used by [`JitterMode::Decorrelated`]).
    pub(crate) prev_delay_ms: u64,
    /// Local PRNG state for jitter sampling.
    pub(crate) rng_state: u64,
    /// Operation start instant for total timeout enforcement (only captured when bounded).
    pub(crate) started_at: Option<Instant>,
}