1 unstable release

0.1.0 Oct 30, 2020

#22 in #notifier

Custom license

6KB
76 lines

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

Dependencies

~5MB
~85K SLoC