pub async fn sleep_until<Tz: TimeZone>(time: DateTime<Tz>) -> Result<(), Error>
Expand description

Waits until the specified time.

tokio::time::sleep uses monotonic clock, so if the system is suspended while the timer is active, the timer is delayed by a period equal to the amount of time the system was suspended.

This timer operates using wall clock as a reference instead. If the system is suspended at the time that the timer would expire, the timer expires immediately after the system resumes from sleep.

Errors

Returns an error if:

  • Setting a underlying signal handler fails for any reason (see signal).
  • Getting the current time (via clock_gettime(2)) fails.
  • Creating the timer (via timer_create(2)) fails.
  • Setting the timer (via timer_settime(2)) fails.
  • Cleaning up the timer after it has triggered (via timer_delete(2)) fails.