osom_lib_wait_timer/traits.rs
1//! Defines the [`WaitTimer`] trait and holds [`MAX_WAIT_DURATION`] const.
2
3use core::time::Duration;
4
5/// The maximum duration allowed on [`WaitTimer`], which is one week.
6pub const MAX_WAIT_DURATION: Duration = Duration::from_hours(24 * 7);
7
8/// Represents structs that can be waited of for a given duration. Functionaly
9/// equivalent to `std::thread::sleep`.
10pub trait WaitTimer: Send + Sync + Default + 'static {
11 /// Sleeps for the given duration, blocking the thread. This function aims
12 /// to have 1ms resolution, assuming the underlying platform allows it.
13 fn wait(&mut self, dur: Duration);
14}