Struct embedded_timers::Timer
source · pub struct Timer<'a, CLOCK>where
CLOCK: Clock,{ /* private fields */ }Expand description
An instance of a timer tied to a specific Clock and Timing Duration type.
Implementations§
source§impl<'a, CLOCK> Timer<'a, CLOCK>where
CLOCK: Clock,
impl<'a, CLOCK> Timer<'a, CLOCK>where
CLOCK: Clock,
sourcepub fn duration(&self) -> Result<Duration, TimerError>
pub fn duration(&self) -> Result<Duration, TimerError>
Get the Duration of the current timer, or Err if it is not running
sourcepub fn is_running(&self) -> Result<bool, TimerError>
pub fn is_running(&self) -> Result<bool, TimerError>
If the timer is running, this is true. If not, it is false. It can also return an error from the Clock.
sourcepub fn is_expired(&self) -> Result<bool, TimerError>
pub fn is_expired(&self) -> Result<bool, TimerError>
If the timer is expired, this is true. If not, it is false. It can also return an error from the Clock.
sourcepub fn duration_left(&self) -> Result<Duration, TimerError>
pub fn duration_left(&self) -> Result<Duration, TimerError>
Get the Duration until expire of the current timer, or Err if it is not running or if “now” could not be calculated
sourcepub fn try_start(&mut self, duration: Duration) -> Result<(), TimerError>
pub fn try_start(&mut self, duration: Duration) -> Result<(), TimerError>
Try to start the timer. Can fail due to errors from the clock.
sourcepub fn try_wait(&mut self) -> Result<(), TimerError>
pub fn try_wait(&mut self) -> Result<(), TimerError>
Try to wait for the timer, return an error if it is not running.
Trait Implementations§
Auto Trait Implementations§
impl<'a, CLOCK> RefUnwindSafe for Timer<'a, CLOCK>where
CLOCK: RefUnwindSafe,
impl<'a, CLOCK> Send for Timer<'a, CLOCK>where
CLOCK: Sync,
impl<'a, CLOCK> Sync for Timer<'a, CLOCK>where
CLOCK: Sync,
impl<'a, CLOCK> Unpin for Timer<'a, CLOCK>
impl<'a, CLOCK> UnwindSafe for Timer<'a, CLOCK>where
CLOCK: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more