Skip to main content

Counter

Struct Counter 

Source
pub struct Counter<C: CounterInterface> { /* private fields */ }
Expand description

An up-counter keeping track of elapsed time.

Implementations§

Source§

impl<C: CounterInterface> Counter<C>

Source

pub fn new(counter: C) -> Self

Creates a new instance.

Source

pub fn elapsed_time(&self) -> Duration

Returns the counter value.

Trait Implementations§

Source§

impl<T: CounterInterface> Timer for Counter<T>

Available on crate feature embedded-hal-timer only.
Source§

fn start(&mut self)

Start or restart the timer at 0. Read more
Source§

fn tickrate(&self) -> u64

Get the amount of ticks per second. Read more
Source§

fn elapsed_ticks(&self) -> Result<u64, OverflowError>

Return the number of elapsed ticks.
Source§

fn elapsed_nanos(&self) -> Result<u64, OverflowError>

Return the number of elapsed nanoseconds, rounded down.
Source§

fn elapsed_micros(&self) -> Result<u64, OverflowError>

Return the number of elapsed microseconds, rounded down.
Source§

fn elapsed_millis(&self) -> Result<u64, OverflowError>

Return the number of elapsed milliseconds, rounded down.
Source§

fn elapsed_secs(&self) -> Result<u64, OverflowError>

Return the number of elapsed seconds, rounded down.
Source§

fn max_ticks(&self) -> u64

The (inclusive) maximum number of ticks that can elapse after start before the timer overflows. Read more
Source§

fn max_nanos(&self) -> u64

The (inclusive) maximum number of nanoseconds that can elapse after start before the timer overflows. Read more
Source§

fn max_micros(&self) -> u64

The (inclusive) maximum number of microseconds that can elapse after start before the timer overflows. Read more
Source§

fn max_millis(&self) -> u64

The (inclusive) maximum number of milliseconds that can elapse after start before the timer overflows. Read more
Source§

fn max_secs(&self) -> u64

The (inclusive) maximum number of seconds that can elapse after start before the timer overflows. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Counter<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Counter<C>
where C: RefUnwindSafe,

§

impl<C> Send for Counter<C>
where C: Send,

§

impl<C> Sync for Counter<C>
where C: Sync,

§

impl<C> Unpin for Counter<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Counter<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for Counter<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.