History

feat: Make it easy to configure lock acquisition failure from Duration.

Now `Duration` can be turned into `acquire::Fail`.

Sebastian Thiel committed 3 years ago

Commit fda43371 parent a8b227e1 file · +10 −0Browse files

Unified · Split

gix-lock/src/acquire.rs+10−0
@@ -30,6 +30,16 @@ impl fmt::Display for Fail { · 29 unmodified lines
30 }30 }
31}31}
32 32
33impl 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/// The error returned when acquiring a [`File`] or [`Marker`].43/// The error returned when acquiring a [`File`] or [`Marker`].
34#[derive(Debug, thiserror::Error)]44#[derive(Debug, thiserror::Error)]
35#[allow(missing_docs)]45#[allow(missing_docs)]