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
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)]