pub struct RetryFutureConfig<BackoffT, OnRetryT> { /* private fields */ }
Expand description

Configuration describing how to retry a future.

This is useful if you have many futures you want to retry in the same way.

Implementations§

source§

impl RetryFutureConfig<NoBackoff, NoOnRetry>

source

pub fn new(max_retries: u32) -> Self

Create a new configuration with a max number of retries and no backoff strategy.

source§

impl<BackoffT, OnRetryT> RetryFutureConfig<BackoffT, OnRetryT>

source

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

Set the max duration to sleep between each attempt.

source

pub fn no_backoff(self) -> RetryFutureConfig<NoBackoff, OnRetryT>

Remove the backoff strategy.

This will make the future be retried immediately without any delay in between attempts.

source

pub fn exponential_backoff( self, initial_delay: Duration ) -> RetryFutureConfig<ExponentialBackoff, OnRetryT>

Use exponential backoff for retrying the future.

The first delay will be initial_delay and afterwards the delay will double every time.

source

pub fn fixed_backoff( self, delay: Duration ) -> RetryFutureConfig<FixedBackoff, OnRetryT>

Use a fixed backoff for retrying the future.

The delay between attempts will always be delay.

source

pub fn linear_backoff( self, delay: Duration ) -> RetryFutureConfig<LinearBackoff, OnRetryT>

Use a linear backoff for retrying the future.

The delay will be delay * attempt so it’ll scale linear with the attempt.

source

pub fn custom_backoff<B>( self, backoff_strategy: B ) -> RetryFutureConfig<B, OnRetryT>

Use a custom backoff specified by some function.

See RetryFuture::custom_backoff for more details.

source

pub fn on_retry<F>(self, f: F) -> RetryFutureConfig<BackoffT, F>

Some async computation that will be spawned before each retry.

See RetryFuture::on_retry for more details.

Trait Implementations§

source§

impl<BackoffT: Clone, OnRetryT: Clone> Clone for RetryFutureConfig<BackoffT, OnRetryT>

source§

fn clone(&self) -> RetryFutureConfig<BackoffT, OnRetryT>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<BackoffT, OnRetryT> Debug for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: Debug,

source§

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

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

impl<BackoffT: PartialEq, OnRetryT: PartialEq> PartialEq<RetryFutureConfig<BackoffT, OnRetryT>> for RetryFutureConfig<BackoffT, OnRetryT>

source§

fn eq(&self, other: &RetryFutureConfig<BackoffT, OnRetryT>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<BackoffT: Copy, OnRetryT: Copy> Copy for RetryFutureConfig<BackoffT, OnRetryT>

source§

impl<BackoffT: Eq, OnRetryT: Eq> Eq for RetryFutureConfig<BackoffT, OnRetryT>

source§

impl<BackoffT, OnRetryT> StructuralEq for RetryFutureConfig<BackoffT, OnRetryT>

source§

impl<BackoffT, OnRetryT> StructuralPartialEq for RetryFutureConfig<BackoffT, OnRetryT>

Auto Trait Implementations§

§

impl<BackoffT, OnRetryT> RefUnwindSafe for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: RefUnwindSafe, OnRetryT: RefUnwindSafe,

§

impl<BackoffT, OnRetryT> Send for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: Send, OnRetryT: Send,

§

impl<BackoffT, OnRetryT> Sync for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: Sync, OnRetryT: Sync,

§

impl<BackoffT, OnRetryT> Unpin for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: Unpin, OnRetryT: Unpin,

§

impl<BackoffT, OnRetryT> UnwindSafe for RetryFutureConfig<BackoffT, OnRetryT>where BackoffT: UnwindSafe, OnRetryT: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.