pub struct Exponential { /* private fields */ }Expand description
Exponential backoff strategy.
Grows exponentially with each attempt. It is also possible, and advisable, to set the maximum
backoff using BackoffStrategy::with_max.
Note: This type cannot be constructed directly, instead BackoffStrategy::exponential
should be used.
§Example
let strategy =
BackoffStrategy::exponential(TimeDelta::seconds(2)).with_max(TimeDelta::seconds(30));
assert_eq!(strategy.backoff(1), TimeDelta::seconds(2));
assert_eq!(strategy.backoff(2), TimeDelta::seconds(4));
assert_eq!(strategy.backoff(3), TimeDelta::seconds(8));
assert_eq!(strategy.backoff(4), TimeDelta::seconds(16));
assert_eq!(strategy.backoff(5), TimeDelta::seconds(30));
assert_eq!(strategy.backoff(6), TimeDelta::seconds(30));Trait Implementations§
Auto Trait Implementations§
impl Freeze for Exponential
impl RefUnwindSafe for Exponential
impl Send for Exponential
impl Sync for Exponential
impl Unpin for Exponential
impl UnwindSafe for Exponential
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more