Skip to main content

BackoffStrategy

Enum BackoffStrategy 

Source
pub enum BackoffStrategy {
    Immediate,
    Fixed {
        delay_ms: u32,
    },
    Exponential {
        base_delay_ms: u32,
        max_delay_ms: u32,
    },
    Linear {
        initial_delay_ms: u32,
        increment_ms: u32,
        max_delay_ms: u32,
    },
}
Expand description

Retry delay strategy used after a request times out.

The delay is computed per retry attempt in a poll-driven manner. No internal sleeping or blocking waits are performed by the library.

Variants§

§

Immediate

Retry immediately after timeout detection.

§

Fixed

Retry using a constant delay in milliseconds.

Fields

§delay_ms: u32

Delay applied before each retry.

§

Exponential

Retry with an exponential sequence: base_delay_ms * 2^(attempt-1).

Fields

§base_delay_ms: u32

Base delay for the first retry attempt.

§max_delay_ms: u32

Upper bound used to clamp growth.

§

Linear

Retry with a linear sequence: initial_delay_ms + (attempt-1) * increment_ms.

Fields

§initial_delay_ms: u32

Delay for the first retry attempt.

§increment_ms: u32

Increment added on every subsequent retry.

§max_delay_ms: u32

Upper bound used to clamp growth.

Implementations§

Source§

impl BackoffStrategy

Source

pub fn delay_ms_for_retry(&self, retry_attempt: u8) -> u32

Computes the base retry delay in milliseconds for a 1-based retry attempt index.

retry_attempt is expected to start at 1 for the first retry after the initial request timeout.

Trait Implementations§

Source§

impl Clone for BackoffStrategy

Source§

fn clone(&self) -> BackoffStrategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BackoffStrategy

Source§

impl Debug for BackoffStrategy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BackoffStrategy

Source§

fn default() -> BackoffStrategy

Returns the “default value” for a type. Read more
Source§

impl Eq for BackoffStrategy

Source§

impl PartialEq for BackoffStrategy

Source§

fn eq(&self, other: &BackoffStrategy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BackoffStrategy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.