[][src]Struct embedded_time::Timer

pub struct Timer<'a, Type, State, Clock: Clock, Dur: Duration> { /* fields omitted */ }

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]

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]

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]

Returns the Duration until the expiration of the timer

The duration is truncated, not rounded.

The units of the Duration are the same as that used to construct the Timer.

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]

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]

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.