async_timer_rs/lib.rs
1use std::{future::Future, time::Duration};
2
3/// Timer service provider trait.
4pub trait Timer: Future {
5 /// Create new timer.
6 ///
7 /// # Parameters
8 /// * `duration` - Timer expiration interval
9 fn new(duration: Duration) -> Self;
10}
11
12/// Timer service provider trait with more configiration.
13pub trait TimerWithContext: Timer {
14 /// timer extra context parameter.
15 type Context;
16 /// Create new timer with context parameter
17 ///
18 /// # Parameters
19 /// * `duration` - Timer expiration interval
20 /// * `context` - See [`TimerWithContext::Context`]
21 fn new_with_context<C>(duration: Duration, context: C) -> Self
22 where
23 C: AsMut<Self::Context>;
24}
25
26/// Timer implementation using hashed timewheel algorithm
27pub mod hashed;