Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add more trait bound for backoff trait #26

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/backoff.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::fmt::Debug;
use std::time::Duration;

/// Backoff is an [`Iterator`] that returns [`Duration`].
///
/// - `Some(Duration)` means caller need to `sleep(Duration)` and retry the same request
/// - `None` means we have reaching the limits, caller needs to return current error instead.
pub trait Backoff: Iterator<Item = Duration> + Clone {}
impl<T> Backoff for T where T: Iterator<Item = Duration> + Clone {}
pub trait Backoff: Iterator<Item = Duration> + Default + Debug + Send + Sync + Unpin {}
impl<T> Backoff for T where T: Iterator<Item = Duration> + Default + Debug + Send + Sync + Unpin {}
2 changes: 1 addition & 1 deletion src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::time::Duration;
/// Ok(())
/// }
/// ```
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct ConstantBackoff {
delay: Duration,
max_times: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion src/exponential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::time::Duration;
/// Ok(())
/// }
/// ```
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct ExponentialBackoff {
jitter: bool,
factor: f32,
Expand Down