libsw_core/instant_impls/
tokio.rs

1// libsw: stopwatch library
2// copyright (C) 2022-2023 Ula Shipman <ula.hello@mailbox.org>
3// licensed under MIT OR Apache-2.0
4
5extern crate tokio;
6
7use ::core::time::Duration;
8
9use crate::Instant;
10
11impl Instant for tokio::time::Instant {
12    fn now() -> Self {
13        // NOTE: tokio::time::pause can freeze time
14        Self::now()
15    }
16
17    fn checked_add(&self, duration: Duration) -> Option<Self> {
18        self.checked_add(duration)
19    }
20
21    fn checked_sub(&self, duration: Duration) -> Option<Self> {
22        self.checked_sub(duration)
23    }
24
25    fn saturating_duration_since(&self, earlier: Self) -> Duration {
26        self.saturating_duration_since(earlier)
27    }
28}