Skip to content

Commit fda4337

Browse files
committed
feat: Make it easy to configure lock acquisition failure from Duration.
Now `Duration` can be turned into `acquire::Fail`.
1 parent a8b227e commit fda4337

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gix-lock/src/acquire.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ impl fmt::Display for Fail {
3030
}
3131
}
3232

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+
3343
/// The error returned when acquiring a [`File`] or [`Marker`].
3444
#[derive(Debug, thiserror::Error)]
3545
#[allow(missing_docs)]

0 commit comments

Comments
 (0)