use chrono::Duration; use chrono::Utc; /// Takes a number as input and waits that many seconds before exiting. /// /// Runnable with `cargo run --example=wait_for -- 2`. #[tokio::main] async fn main() { let mut arguments = std::env::args(); arguments.next().expect("process executable has a name"); let arg1 = arguments.next().expect("first argument is specified"); let duration: i64 = arg1.parse().expect("first argument is a valid integer"); let duration = Duration::seconds(duration); let timeout = Utc::now() + duration; tokio_walltime::sleep_until(timeout) .await .expect("timer completes okay"); }