[−][src]Struct embedded_time::Timer
A Timer
counts toward an expiration, can be polled for elapsed and remaining time, and can be
one-shot or continuous/periodic.
Implementations
impl<'a, Clock: Clock, Dur: Duration, '_> Timer<'_, None, None, Clock, Dur>
[src]
pub fn new(clock: &Clock, duration: Dur) -> Timer<OneShot, Armed, Clock, Dur>
[src]
Construct a new, OneShot
Timer
impl<'a, Type, State, Clock: Clock, Dur: Duration> Timer<'a, Type, State, Clock, Dur>
[src]
pub fn into_oneshot(self) -> Timer<'a, OneShot, State, Clock, Dur>
[src]
Change timer type to one-shot
pub fn into_periodic(self) -> Timer<'a, Periodic, State, Clock, Dur>
[src]
Change timer type into periodic
impl<'a, Type, Clock: Clock, Dur: Duration> Timer<'a, Type, Armed, Clock, Dur>
[src]
pub fn start(self) -> Result<Timer<'a, Type, Running, Clock, Dur>, TimeError> where
Clock::T: TryFrom<Dur::T>,
Dur: FixedPoint,
[src]
Clock::T: TryFrom<Dur::T>,
Dur: FixedPoint,
Start the timer from this instant
impl<Type, Clock: Clock, Dur: Duration, '_> Timer<'_, Type, Running, Clock, Dur>
[src]
pub fn elapsed(&self) -> Result<Dur, TimeError> where
Dur: FixedPoint + TryFrom<Generic<Clock::T>, Error = ConversionError>,
Dur::T: TryFrom<Clock::T>,
Clock::T: TryFrom<Dur::T>,
[src]
Dur: FixedPoint + TryFrom<Generic<Clock::T>, Error = ConversionError>,
Dur::T: TryFrom<Clock::T>,
Clock::T: TryFrom<Dur::T>,
Returns the Duration
of time elapsed since it was started
The duration is truncated, not rounded.
The units of the Duration
are the same as that used to construct the Timer
.
pub fn remaining(&self) -> Result<Dur, TimeError> where
Dur: FixedPoint + TryFrom<Generic<Clock::T>, Error = ConversionError>,
Dur::T: TryFrom<u32> + TryFrom<Clock::T>,
Clock::T: TryFrom<Dur::T>,
[src]
Dur: FixedPoint + TryFrom<Generic<Clock::T>, Error = ConversionError>,
Dur::T: TryFrom<u32> + TryFrom<Clock::T>,
Clock::T: TryFrom<Dur::T>,
impl<'a, Clock: Clock, Dur: Duration> Timer<'a, OneShot, Running, Clock, Dur>
[src]
pub fn wait(self) -> Result<Timer<'a, OneShot, Armed, Clock, Dur>, TimeError>
[src]
Block until the timer has expired
pub fn is_expired(&self) -> Result<bool, TimeError>
[src]
Check whether the timer has expired
The timer is not restarted
impl<Clock: Clock, Dur: Duration, '_> Timer<'_, Periodic, Running, Clock, Dur>
[src]
pub fn wait(self) -> Result<Self, TimeError> where
Instant<Clock>: Add<Dur, Output = Instant<Clock>>,
[src]
Instant<Clock>: Add<Dur, Output = Instant<Clock>>,
Block until the timer has expired
The timer is restarted
pub fn period_complete(&mut self) -> Result<bool, TimeError> where
Instant<Clock>: Add<Dur, Output = Instant<Clock>>,
[src]
Instant<Clock>: Add<Dur, Output = Instant<Clock>>,
Check whether a periodic timer has elapsed
The timer is restarted if it has elapsed.
Trait Implementations
impl<'a, Type: Debug, State: Debug, Clock: Debug + Clock, Dur: Debug + Duration> Debug for Timer<'a, Type, State, Clock, Dur>
[src]
impl<'a, Type: Hash, State: Hash, Clock: Hash + Clock, Dur: Hash + Duration> Hash for Timer<'a, Type, State, Clock, Dur>
[src]
Auto Trait Implementations
impl<'a, Type, State, Clock, Dur> Send for Timer<'a, Type, State, Clock, Dur> where
Clock: Sync,
Dur: Send,
State: Send,
Type: Send,
<Clock as Clock>::T: Send,
Clock: Sync,
Dur: Send,
State: Send,
Type: Send,
<Clock as Clock>::T: Send,
impl<'a, Type, State, Clock, Dur> Sync for Timer<'a, Type, State, Clock, Dur> where
Clock: Sync,
Dur: Sync,
State: Sync,
Type: Sync,
<Clock as Clock>::T: Sync,
Clock: Sync,
Dur: Sync,
State: Sync,
Type: Sync,
<Clock as Clock>::T: Sync,
impl<'a, Type, State, Clock, Dur> Unpin for Timer<'a, Type, State, Clock, Dur> where
Dur: Unpin,
State: Unpin,
Type: Unpin,
<Clock as Clock>::T: Unpin,
Dur: Unpin,
State: Unpin,
Type: Unpin,
<Clock as Clock>::T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,