pub struct VirtualTimer<'a, A: Alarm<'a>> { /* private fields */ }
Expand description

An object to multiplex multiple “virtual” timers over a single underlying alarm. A VirtualTimer is a node in a linked list of timers that share the same underlying alarm.

Implementations§

source§

impl<'a, A: Alarm<'a>> VirtualTimer<'a, A>

source

pub fn new(mux_timer: &'a MuxTimer<'a, A>) -> VirtualTimer<'a, A>

After calling new, always call setup()

source

pub fn setup(&'a self)

Call this method immediately after new() to link this to the mux, otherwise timers won’t fire

Trait Implementations§

source§

impl<'a, A: Alarm<'a>> AlarmClient for VirtualTimer<'a, A>

source§

fn alarm(&self)

Callback indicating the alarm time has been reached. The alarm MUST be disabled when this is called. If a new alarm is needed, the client can call Alarm::set_alarm.
source§

impl<'a, A: Alarm<'a>> ListNode<'a, VirtualTimer<'a, A>> for VirtualTimer<'a, A>

source§

fn next(&self) -> &'a ListLink<'_, VirtualTimer<'a, A>>

source§

impl<'a, A: Alarm<'a>> Time for VirtualTimer<'a, A>

§

type Frequency = <A as Time>::Frequency

The number of ticks per second
§

type Ticks = <A as Time>::Ticks

The width of a time value
source§

fn now(&self) -> A::Ticks

Returns a timestamp. Depending on the implementation of Time, this could represent either a static timestamp or a sample of a counter; if an implementation relies on it being constant or changing it should use Timestamp or Counter.
source§

impl<'a, A: Alarm<'a>> Timer<'a> for VirtualTimer<'a, A>

source§

fn set_timer_client(&self, client: &'a dyn TimerClient)

Specify the callback to invoke when the timer interval expires. If there was a previously installed callback this call replaces it.
source§

fn cancel(&self) -> Result<(), ErrorCode>

Cancel the current timer, if any. Value Result<(), ErrorCode> values are: Read more
source§

fn interval(&self) -> Option<Self::Ticks>

Return the interval of the last requested timer.
source§

fn is_oneshot(&self) -> bool

Return if the last requested timer is a one-shot timer.
source§

fn is_repeating(&self) -> bool

Return if the last requested timer is a repeating timer.
source§

fn is_enabled(&self) -> bool

Returns whether there is currently a timer enabled and so a callback will be expected in the future. If is_enabled returns false then the implementation MUST NOT invoke a callback until a call to oneshot or repeating restarts the timer.
source§

fn oneshot(&self, interval: Self::Ticks) -> Self::Ticks

Start a one-shot timer that will invoke the callback at least interval ticks in the future. If there is a timer currently pending, calling this cancels that previous timer. After a callback is invoked for a one shot timer, the timer MUST NOT invoke the callback again unless a new timer is started (either with repeating or one shot). Returns the actual interval for the timer that was registered. This MUST NOT be smaller than interval but MAY be larger.
source§

fn repeating(&self, interval: Self::Ticks) -> Self::Ticks

Start a repeating timer that will invoke the callback every interval ticks in the future. If there is a timer currently pending, calling this cancels that previous timer. Returns the actual interval for the timer that was registered. This MUST NOT be smaller than interval but MAY be larger.
source§

fn time_remaining(&self) -> Option<Self::Ticks>

Return how many ticks are remaining until the next callback, or None if the timer is disabled. This call is useful because there may be non-negligible delays between when a timer was requested and it was actually scheduled. Therefore, since a timer’s start might be delayed slightly, the time remaining might be slightly higher than one would expect if one calculated it right before the call to start the timer.

Auto Trait Implementations§

§

impl<'a, A> !Freeze for VirtualTimer<'a, A>

§

impl<'a, A> !RefUnwindSafe for VirtualTimer<'a, A>

§

impl<'a, A> !Send for VirtualTimer<'a, A>

§

impl<'a, A> !Sync for VirtualTimer<'a, A>

§

impl<'a, A> Unpin for VirtualTimer<'a, A>
where <A as Time>::Ticks: Unpin,

§

impl<'a, A> !UnwindSafe for VirtualTimer<'a, A>

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<T> ConvertTicks<<T as Time>::Ticks> for T
where T: Time + ?Sized,

source§

fn ticks_from_seconds(&self, s: u32) -> <T as Time>::Ticks

Returns the number of ticks in the provided number of seconds, rounding down any fractions. If the value overflows Ticks it returns Ticks::max_value().
source§

fn ticks_from_ms(&self, ms: u32) -> <T as Time>::Ticks

Returns the number of ticks in the provided number of milliseconds, rounding down any fractions. If the value overflows Ticks it returns Ticks::max_value().
source§

fn ticks_from_us(&self, us: u32) -> <T as Time>::Ticks

Returns the number of ticks in the provided number of microseconds, rounding down any fractions. If the value overflows Ticks it returns Ticks::max_value().
source§

fn ticks_to_seconds(&self, tick: <T as Time>::Ticks) -> u32

Returns the number of seconds in the provided number of ticks, rounding down any fractions. If the value overflows u32, u32::MAX is returned,
source§

fn ticks_to_ms(&self, tick: <T as Time>::Ticks) -> u32

Returns the number of milliseconds in the provided number of ticks, rounding down any fractions. If the value overflows u32, u32::MAX is returned,
source§

fn ticks_to_us(&self, tick: <T as Time>::Ticks) -> u32

Returns the number of microseconds in the provided number of ticks, rounding down any fractions. If the value overflows u32, u32::MAX is returned,
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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.