TimerHandle

Struct TimerHandle 

Source
pub struct TimerHandle(/* private fields */);
Expand description

A timer handle.

This handle is used to interact with timers created by the driver implementation.

Implementations§

Source§

impl TimerHandle

Source

pub unsafe fn new( function: unsafe extern "C" fn(*mut c_void), data: *mut c_void, ) -> Self

Creates a new timer instance from the given callback.

§Safety
  • The callback and its data must be valid for the lifetime of the timer.
  • The callback and its data need to be able to be sent across threads.
Source

pub fn leak(self) -> TimerPtr

Converts this object into a pointer without dropping it.

Source

pub unsafe fn from_ptr(ptr: TimerPtr) -> Self

Recovers the object from a leaked pointer.

§Safety
  • The caller must only use pointers created using Self::leak.
  • The caller must ensure the pointer is not shared.
Source

pub unsafe fn ref_from_ptr(ptr: &TimerPtr) -> &Self

Creates a reference to this object from a leaked pointer.

This function is used in the esp-radio code to interact with the timer.

§Safety
  • The caller must only use pointers created using Self::leak.
Source

pub fn arm(&self, timeout: u64, periodic: bool)

Configures the timer to be triggered after the given timeout.

The timeout is specified in microsecond. If the timer is set to be periodic, the timer will be triggered with a constant frequency.

Source

pub fn is_active(&self) -> bool

Checks if the timer is currently active.

Source

pub fn disarm(&self)

Stops the timer.

Trait Implementations§

Source§

impl Drop for TimerHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for TimerHandle

§

impl RefUnwindSafe for TimerHandle

§

impl !Send for TimerHandle

§

impl !Sync for TimerHandle

§

impl Unpin for TimerHandle

§

impl UnwindSafe for TimerHandle

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

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.
§

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

Performs the conversion.