Struct os_timer::Timer[][src]

pub struct Timer { /* fields omitted */ }
Expand description

Posix timer wrapper

Implementations

impl Timer[src]

pub const unsafe fn uninit() -> Self[src]

Creates new uninitialized instance.

In order to use it one must call init.

pub fn is_init(&self) -> bool[src]

Returns whether timer is initialized

#[must_use]
pub fn init(&self, cb: Callback) -> bool
[src]

Performs timer initialization

cb pointer to function to invoke when timer expires.

Returns whether timer has been initialized successfully or not.

If timer is already initialized does nothing, returning false.

pub fn new(cb: Callback) -> Option<Self>[src]

Creates new timer, invoking provided cb when timer expires.

On failure, returns None

pub fn schedule_interval(&self, timeout: Duration, interval: Duration) -> bool[src]

Schedules timer to alarm periodically with interval with initial alarm of timeout.

Note that if timer has been scheduled before, but hasn’t expire yet, it shall be cancelled. To prevent that user must cancel timer first.

Returns true if successfully set, otherwise on error returns false

pub fn is_scheduled(&self) -> bool[src]

Returns true if timer has been scheduled and still pending.

On Win/Mac it only returns whether timer has been scheduled, as there is no way to check whether timer is ongoing

pub fn cancel(&self)[src]

Cancels ongoing timer, if it was scheduled.

impl Timer[src]

pub const fn schedule(&self) -> Schedule<'_>[src]

Creates new schedule

pub fn schedule_once(&self, timeout: Duration) -> bool[src]

Schedules timer to alarm once after timeout passes.

Note that if timer has been scheduled before, but hasn’t expire yet, it shall be cancelled. To prevent that user must cancel timer first.

Returns true if successfully set, otherwise on error returns false

Trait Implementations

impl Drop for Timer[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl Send for Timer[src]

impl Sync for Timer[src]

Auto Trait Implementations

impl Unpin for Timer

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.