Expand description
§Async Timing Util
Convenient utilities for doing repeated tasks at precise intervals.
use async_timing_util::{Timelength, wait_until_timelength};
loop {
let ts = wait_until_timelength(Timelength::OneHour).await;
/// Do something async every hour, on the hour
/// Runs at 00:00, 01:00, 02:00, etc.
}
Enums§
- Timelength
- Represents various standard lengths of time.
Constants§
- EIGHT_
HOURS_ MS - FIFTEEN_
MIN_ MS - FIFTEEN_
SECONDS_ MS - FIVE_
MIN_ MS - FIVE_
SECONDS_ MS - ONE_
DAY_ MS - ONE_
HOUR_ MS - ONE_
MIN_ MS - ONE_
SECOND_ MS - ONE_
WEEK_ MS - SIX_
HOURS_ MS - TEN_
MIN_ MS - TEN_
SECONDS_ MS - THIRTY_
DAYS_ MS - THIRTY_
MIN_ MS - THIRTY_
SECONDS_ MS - THREE_
DAY_ MS - TWELVE_
HOURS_ MS - TWO_
HOUR_ MS - TWO_
MIN_ MS - TWO_
WEEKS_ MS
Functions§
- get_
timelength_ in_ ms - Converts a timelength into milliseconds.
- last_
timelength_ interval - Gets the most recent complete interval of a given timelength.
- unix_
timestamp_ ms - Gets the system time in unix milliseconds. Panics if SystemTime::duration_since returns an error.
- wait_
until - Sleeps until the target unix time. Panics if the target time is before the current time.
- wait_
until_ timelength - Waits until the next even instance of the timelength. For example, Timelength::OneHour will wait until the next hour, eg 01:00, 02:00, plus the “additional_ms”.