pub struct Backoff { /* private fields */ }Expand description
Computes backoff as
backoff = base^attempt * unit + jitterThe defaults are base=2, unit=50ms, jitter=50ms, min=0ms, max=5s. This gives a backoff of 50ms, 100ms, 200ms, 400ms, 800ms, 1.6s, 3.2s, 5s, (not including jitter).
You can have non-exponential backoff by setting base=1.
Implementations§
Source§impl Backoff
impl Backoff
pub fn with_base(self, base: u32) -> Self
pub fn with_unit(self, unit: u32) -> Self
pub fn with_jitter(self, jitter: i32) -> Self
pub fn with_min(self, min: u32) -> Self
pub fn with_max(self, max: u32) -> Self
pub fn next_backoff(&mut self) -> Duration
pub fn attempt(&self) -> u32
pub fn reset(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Backoff
impl RefUnwindSafe for Backoff
impl Send for Backoff
impl Sync for Backoff
impl Unpin for Backoff
impl UnsafeUnpin for Backoff
impl UnwindSafe for Backoff
Blanket Implementations§
impl<T> Allocation for T
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