#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct RetryOptions {
pub(crate) limit: usize,
pub(crate) delay: std::time::Duration,
}
impl Default for RetryOptions {
fn default() -> Self {
Self {
limit: 3,
delay: std::time::Duration::from_millis(500),
}
}
}
impl RetryOptions {
pub fn retry_limit(self, limit: usize) -> Self {
Self { limit, ..self }
}
pub fn retry_forever(self) -> Self {
self.retry_limit(usize::MAX)
}
pub fn retry_delay(self, delay: std::time::Duration) -> Self {
Self { delay, ..self }
}
}