snooze

Crates.iosnooze
lib.rssnooze
version0.1.0
sourcesrc
created_at2020-10-30 16:47:05.256596
updated_at2020-10-30 16:47:05.256596
descriptionAn timeout based event notifier for Rust
homepage
repositoryhttps://github.com/MarinPostma/snooze
max_upload_size
id307026
size6,738
ad hoc (MarinPostma)

documentation

README

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"));
Commit count: 0

cargo fmt