retryable_result/
retryable.rs1use std::time::{Duration, Instant};
2
3#[allow(clippy::module_name_repetitions)]
4pub trait Retryable
5where
6 Self: Sized,
7{
8 type FatalError;
14 fn to_fatal(self) -> Self::FatalError;
15 fn wait_time(
16 &self,
17 my_time: Instant,
18 previous_retriable_failures: &[(Self, Instant)],
19 ) -> Option<Duration>;
20}
21
22#[allow(clippy::module_name_repetitions)]
23#[allow(dead_code)]
24pub enum RetryableResult<T, R, F>
25where
26 R: Retryable<FatalError = F> + Sized,
27 T: Sized,
28 F: Sized,
29{
30 GoodResult(T),
31 Retryable(R),
32 Fatal(F),
33}