snooze 0.1.0

An timeout based event notifier for Rust
Documentation

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"));