1use std::time::Duration;
2
3#[derive(Clone, Copy, Debug)]
8pub struct Timeout(Duration);
9
10impl Timeout {
11 pub fn new(d: Duration) -> Self {
12 Self(d)
13 }
14
15 pub fn duration(self) -> Duration {
16 self.0
17 }
18}
19
20impl From<i32> for Timeout {
22 fn from(value: i32) -> Self {
23 assert!(value >= 0);
24 Self(Duration::from_millis(value as u64))
25 }
26}
27
28impl From<u32> for Timeout {
30 fn from(value: u32) -> Self {
31 Self(Duration::from_millis(value as u64))
32 }
33}
34
35impl From<u64> for Timeout {
37 fn from(value: u64) -> Self {
38 Self(Duration::from_millis(value))
39 }
40}
41
42impl From<Duration> for Timeout {
43 fn from(value: Duration) -> Self {
44 Self(value)
45 }
46}