Struct base::Timer

source ·
pub struct Timer {
    pub(crate) handle: SafeDescriptor,
    pub(crate) interval: Option<Duration>,
}

Fields§

§handle: SafeDescriptor§interval: Option<Duration>

Implementations§

source§

impl Timer

source

pub fn try_clone(&self) -> Result<Timer, Error>

Creates a new Timer instance that shares the same underlying SafeDescriptor as the existing Timer instance.

source§

impl Timer

source

pub fn new() -> Result<Timer>

Creates a new timerfd. The timer is initally disarmed and must be armed by calling reset.

source

fn set_time( &mut self, dur: Option<Duration>, interval: Option<Duration> ) -> Result<()>

Trait Implementations§

source§

impl AsRawDescriptor for Timer

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more
source§

impl AsRawFd for Timer

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl FromRawDescriptor for Timer

source§

unsafe fn from_raw_descriptor(handle: RawDescriptor) -> Self

Safety Read more
source§

impl IntoRawDescriptor for Timer

source§

impl TimerTrait for Timer

source§

fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()>

Sets the timer to expire after dur. If interval is not None and non-zero it represents the period for repeated expirations after the initial expiration. Otherwise the timer will expire just once. Cancels any existing duration and repeating interval.
source§

fn clear(&mut self) -> Result<()>

Disarms the timer.
source§

fn wait(&mut self) -> Result<()>

Waits until the timer expires.
source§

fn mark_waited(&mut self) -> Result<bool>

After a timer is triggered from an EventContext, mark the timer as having been waited for. If a timer is not marked waited, it will immediately trigger the event context again. This does not need to be called after calling Timer::wait. Read more
source§

fn resolution(&self) -> Result<Duration>

Returns the resolution of timers on the host.

Auto Trait Implementations§

§

impl RefUnwindSafe for Timer

§

impl Send for Timer

§

impl Sync for Timer

§

impl Unpin for Timer

§

impl UnwindSafe for Timer

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsRawDescriptors for Twhere T: AsRawDescriptor,

source§

fn as_raw_descriptors(&self) -> Vec<i32, Global>

Returns the underlying raw descriptors. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.