Skip to main content

BackoffBuilder

Struct BackoffBuilder 

Source
pub struct BackoffBuilder { /* private fields */ }
Expand description

Builder for Backoff.

Implementations§

Source§

impl BackoffBuilder

Source

pub fn initial(self, d: Duration) -> Self

Initial delay. Default: 100ms.

Source

pub fn max_delay(self, d: Duration) -> Self

Maximum delay cap. Default: 30s.

Source

pub fn max_retries(self, n: u32) -> Self

Maximum number of retries. Default: unlimited.

Source

pub fn deadline(self, deadline: Instant) -> Self

Wall-clock deadline. After this instant, Backoff::wait returns Err(Exhausted). Sleep durations are capped to not exceed it.

Default: no deadline.

Source

pub fn jitter(self, factor: f64) -> Self

Jitter factor (0.0 to 1.0). Default: 0.0 (no jitter).

Each delay is randomly scaled by 1.0 ± jitter. For example, jitter(0.25) means a 100ms delay becomes 75ms–125ms.

Source

pub fn build(self) -> Backoff

Build the backoff.

§Panics

Panics if initial exceeds max_delay.

Trait Implementations§

Source§

impl Default for BackoffBuilder

Source§

fn default() -> Self

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

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> 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, 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.