pub trait Timer:
Send
+ Sync
+ 'static {
// Required methods
fn sleep(&self, dur: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>;
fn next_tick(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}Expand description
Async scheduling primitive. Single port for “wait N ms” / “yield event-loop tick”.
The futures are written out as Pin<Box<dyn Future + Send>> — every name
in them is core’s. An alias from futures would put a foreign crate on
this vocabulary’s surface (RFC_202610142318 R4); futures::future::BoxFuture
is the same type, so an implementor may still spell it that way.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".