snooze 0.1.0

An timeout based event notifier for Rust
Documentation
  • Coverage
  • 12.5%
    1 out of 8 items documented0 out of 7 items with examples
  • Size
  • Source code size: 6.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.52 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MarinPostma

Snooze

Snooze is a crate that allows you to trigger the sending of a message with a specific delay or interval. This is usefull to handle TTL for example.

Usage

Basically, you just need to instanciate an instance of a Notifier, to which you register events to trigger at a certain time:

let mut notifier = Nofifier::new();
// do not drop the handle
notifier.notify_afer(Duration::from_secs(1), "world");
let _handle = notifier.notify_interval(Duration::from_secs(2), "hello");

assert_eq!(notifier.next().await, Some("hello"));
assert_eq!(notifier.next().await, Some("world"));
assert_eq!(notifier.next().await, Some("hello"));