Skip to main content

Strategy

Trait Strategy 

Source
pub trait Strategy: MaybeSend + MaybeSync {
    // Required method
    fn backoff(&self, attempts: usize, time_spent: Instant) -> Option<Duration>;

    // Provided method
    fn backoff_at_least(
        &self,
        attempts: usize,
        time_spent: Instant,
        floor: Duration,
    ) -> Option<Duration> { ... }
}
Expand description

The strategy interface

Required Methods§

Source

fn backoff(&self, attempts: usize, time_spent: Instant) -> Option<Duration>

A time that this retry should backoff Returns None when we should no longer backoff, despite possibly being below attempts

Provided Methods§

Source

fn backoff_at_least( &self, attempts: usize, time_spent: Instant, floor: Duration, ) -> Option<Duration>

The wait before the next attempt when the error asks for at least floor. Returns None when the strategy gives up instead of waiting.

Implementations on Foreign Types§

Source§

impl Strategy for ()

Source§

fn backoff(&self, _attempts: usize, _time_spent: Instant) -> Option<Duration>

Source§

impl<S: ?Sized + Strategy> Strategy for Box<S>

Source§

fn backoff(&self, attempts: usize, time_spent: Instant) -> Option<Duration>

Source§

fn backoff_at_least( &self, attempts: usize, time_spent: Instant, floor: Duration, ) -> Option<Duration>

Implementors§