simpler_timer 0.2.0

A very simple timer library with limited, but straight-forward functionality
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented1 out of 9 items with examples
  • Size
  • Source code size: 5.65 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.34 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • gregokent/simpler_timer
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gregokent

Simpler Timer

Crates.io Docs.rs

This library provides a very simple, poll based timer.

To use, include the following in Cargo.toml

[dependencies]
simpler_timer = "0.2.0"
use simpler_timer::Timer;
use std::time::Duration;

fn main() {
    let periodic = Timer::with_duration(Duration::from_millis(100));
    let timeout = Timer::with_duration(Duration::from_secs(2));
    

    loop {
        if periodic.expired() {
            println!("tick");
            periodic.reset();
        }

        if timeout.expired() {
            break;
        }
    }

    println!("total elapsed time: {}ms", timeout.elapsed().as_millis());
}