[][src]Struct tryhard::RetryFutureConfig

pub struct RetryFutureConfig<BackoffT, OnRetryT> { /* fields omitted */ }

Configuration describing how to retry a future.

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

Implementations

impl RetryFutureConfig<NoBackoff, NoOnRetry>[src]

pub fn new(max_retries: u32) -> Self[src]

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

impl<BackoffT, OnRetryT> RetryFutureConfig<BackoffT, OnRetryT>[src]

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

Set the max duration to sleep between each attempt.

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

Remove the backoff strategy.

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

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

Use exponential backoff for retrying the future.

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

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

Use a fixed backoff for retrying the future.

The delay between attempts will always be delay.

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

Use a linear backoff for retrying the future.

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

pub fn custom_backoff<F, R, E>(
    self,
    f: F
) -> RetryFutureConfig<CustomBackoffStrategy<F>, OnRetryT> where
    F: FnMut(u32, &E) -> R,
    R: Into<RetryPolicy>, 
[src]

Use a custom backoff specified by some function.

See RetryFuture::custom_backoff for more details.

pub fn on_retry<F, OnRetryFuture, E>(
    self,
    f: F
) -> RetryFutureConfig<BackoffT, F> where
    F: FnMut(u32, Option<Duration>, &E) -> OnRetryFuture,
    OnRetryFuture: Future + Send + 'static,
    OnRetryFuture::Output: Send + 'static, 
[src]

Some async computation that will be spawned before each retry.

See RetryFuture::on_retry for more details.

Trait Implementations

impl<BackoffT: Clone, OnRetryT: Clone> Clone for RetryFutureConfig<BackoffT, OnRetryT>[src]

impl<BackoffT: Copy, OnRetryT: Copy> Copy for RetryFutureConfig<BackoffT, OnRetryT>[src]

impl<BackoffT, OnRetryT> Debug for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: Debug
[src]

impl<BackoffT: Eq, OnRetryT: Eq> Eq for RetryFutureConfig<BackoffT, OnRetryT>[src]

impl<BackoffT: PartialEq, OnRetryT: PartialEq> PartialEq<RetryFutureConfig<BackoffT, OnRetryT>> for RetryFutureConfig<BackoffT, OnRetryT>[src]

impl<BackoffT, OnRetryT> StructuralEq for RetryFutureConfig<BackoffT, OnRetryT>[src]

impl<BackoffT, OnRetryT> StructuralPartialEq for RetryFutureConfig<BackoffT, OnRetryT>[src]

Auto Trait Implementations

impl<BackoffT, OnRetryT> RefUnwindSafe for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: RefUnwindSafe,
    OnRetryT: RefUnwindSafe
[src]

impl<BackoffT, OnRetryT> Send for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: Send,
    OnRetryT: Send
[src]

impl<BackoffT, OnRetryT> Sync for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: Sync,
    OnRetryT: Sync
[src]

impl<BackoffT, OnRetryT> Unpin for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: Unpin,
    OnRetryT: Unpin
[src]

impl<BackoffT, OnRetryT> UnwindSafe for RetryFutureConfig<BackoffT, OnRetryT> where
    BackoffT: UnwindSafe,
    OnRetryT: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.