moniclock

Crates.iomoniclock
lib.rsmoniclock
version0.1.0
sourcesrc
created_at2020-09-07 06:18:08.115714
updated_at2020-09-07 06:18:08.115714
descriptionMonotonic clock
homepagehttps://github.com/stephaneyfx/moniclock
repositoryhttps://github.com/stephaneyfx/moniclock.git
max_upload_size
id285617
size8,290
crate-publishers (github:osmosis-labs:crate-publishers)

documentation

README

Crate Docs MIT license

Defines a monotonic clock whose values are instances of Duration.

Why not std::time::Instant?

Instant is opaque and cannot be serialized.

Example

let mut clock = moniclock::Clock::new();
let t0 = clock.elapsed();
let sleep_duration = std::time::Duration::from_millis(100);
std::thread::sleep(sleep_duration);
let t1 = clock.elapsed();
assert!(t1 - t0 >= sleep_duration);
Commit count: 1

cargo fmt