Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ impl<B: Backoff + ?Sized> Backoff for Box<B> {
}
}

/// Option of a Backoff retries the operation with backoff if the Option is Some(backoff)
/// and never retries the operation if the Option is None
impl<B: Backoff> Backoff for Option<B> {
fn next_backoff(&mut self) -> Option<Duration> {
self.as_mut().and_then(|b| b.next_backoff())
}

fn reset(&mut self) {
if let Some(b) = self {
b.reset()
}
}
}

/// Immediately retry the operation.
#[derive(Debug)]
pub struct Zero {}
Expand Down