1 2 3 4 5 6 7 8 9 10 11 12 13 14
pub trait NanoClock { fn nano_time(&self) -> i64; } pub struct SystemNanoClock; impl NanoClock for SystemNanoClock { fn nano_time(&self) -> i64 { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_nanos() as i64 } }