suspend-time
Suspend-time is a cross-platform monotonic clock that is suspend-unaware, written in Rust!
It allows system suspension (e.g. when a user closes their laptop on windows) to not affect Instant durations and timeouts!
Example
Example of using SuspendUnawareInstant:
use ;
use ;
Example of using suspend_time::timeout:
use Duration;
async
Instant vs SuspendUnawareInstant
This library is a drop-in replacement for std::time::Instant, so you don't need to worry about updating your code.
Similar to the standard library's implementation of Instant, except it is consistently unaware of system suspends across all platforms supported by this library.
Historically, this has been inconsistent in the standard library, with windows allowing time to pass when the system is suspended/hibernating, however unix systems do not "pass time" during system suspension. In this library, time never passes when the system is suspended on any platform.
This instant implementation is:
- Cross platform (windows, unix)
- Monotonic (time never goes backwards)
- Suspend-unaware (when you put your computer to sleep, "time" does not pass.)