1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Units used for time calculations
use std::time::Duration;

/// Represent a Duration where the maximum precision is in the second
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(
    any(test, feature = "property-test-api"),
    derive(test_strategy::Arbitrary)
)]
pub struct DurationSeconds(pub u64);

impl From<u64> for DurationSeconds {
    fn from(v: u64) -> Self {
        Self(v)
    }
}

impl From<DurationSeconds> for u64 {
    fn from(v: DurationSeconds) -> Self {
        v.0
    }
}

impl From<DurationSeconds> for Duration {
    fn from(v: DurationSeconds) -> Self {
        Duration::from_secs(v.0)
    }
}