Now `Duration` can be turned into `acquire::Fail`.
Unified · Split
| @@ -30,6 +30,16 @@ impl fmt::Display for Fail { · 29 unmodified lines | ||
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | +impl From<Duration> for Fail { | |
| 34 | + fn from(value: Duration) -> Self { | |
| 35 | + if value.is_zero() { | |
| 36 | + Fail::Immediately | |
| 37 | + } else { | |
| 38 | + Fail::AfterDurationWithBackoff(value) | |
| 39 | + } | |
| 40 | + } | |
| 41 | +} | |
| 42 | + | |
| 33 | 43 | /// The error returned when acquiring a [`File`] or [`Marker`]. |
| 34 | 44 | #[derive(Debug, thiserror::Error)] |
| 35 | 45 | #[allow(missing_docs)] |