| 1 |
use std::time::Duration; |
| 2 |
|
| 3 |
pub mod fence; |
| 4 |
|
| 5 |
mod fine_duration; |
| 6 |
mod timer; |
| 7 |
mod timestamp; |
| 8 |
|
| 9 |
pub(crate) use fine_duration::*; |
| 10 |
pub(crate) use timer::*; |
| 11 |
pub(crate) use timestamp::*; |
| 12 |
|
| 13 |
/// Private-public trait for being polymorphic over `Duration`. |
| 14 |
pub trait IntoDuration { |
| 15 |
/// Converts into a `Duration`. |
| 16 |
fn into_duration(self) -> Duration; |
| 17 |
} |
| 18 |
|
| 19 |
impl IntoDuration for Duration { |
| 20 |
#[inline] |
| 21 |
fn into_duration(self) -> Duration { |
| 22 |
self |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
impl IntoDuration for u64 { |
| 27 |
#[inline] |
| 28 |
fn into_duration(self) -> Duration { |
| 29 |
Duration::from_secs(self) |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
impl IntoDuration for f64 { |
| 34 |
#[inline] |
| 35 |
fn into_duration(self) -> Duration { |
| 36 |
Duration::from_secs_f64(self) |
| 37 |
} |
| 38 |
} |