Struct timerfd::TimerFd

source ·
pub struct TimerFd(_);
Expand description

Represents a timerfd.

See also timerfd_create(2).

Implementations§

source§

impl TimerFd

source

pub fn new_custom( clock: ClockId, nonblocking: bool, cloexec: bool ) -> IoResult<TimerFd>

Creates a new TimerFd.

By default, it uses the monotonic clock, is blocking and does not close on exec. The parameters allow you to change that.

Errors

On Linux 2.6.26 and earlier, nonblocking and cloexec are not supported and setting them will return an error of kind ErrorKind::InvalidInput.

This can also fail in various cases of resource exhaustion. Please check timerfd_create(2) for details.

source

pub fn new() -> IoResult<TimerFd>

Creates a new TimerFd with default settings.

Use new_custom to specify custom settings.

source

pub fn set_state( &mut self, state: TimerState, sflags: SetTimeFlags ) -> TimerState

Sets this timerfd to a given TimerState and returns the old state.

source

pub fn get_state(&self) -> TimerState

Returns the current TimerState.

source

pub fn read(&self) -> u64

Read from this timerfd.

Returns the number of timer expirations since the last read. If this timerfd is operating in blocking mode (the default), it will not return zero but instead block until the timer has expired at least once.

Trait Implementations§

source§

impl AsFd for TimerFd

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl AsRawFd for TimerFd

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for TimerFd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<TimerFd> for OwnedFd

source§

fn from(fd: TimerFd) -> OwnedFd

Converts to this type from the input type.
source§

impl FromRawFd for TimerFd

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsFilelike for Twhere T: AsFd,

§

fn as_filelike(&self) -> BorrowedFd<'_>

Borrows the reference. Read more
§

fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>where Target: FilelikeViewType,

Return a borrowing view of a resource which dereferences to a &Target. Read more
§

impl<T> AsRawFilelike for Twhere T: AsRawFd,

§

fn as_raw_filelike(&self) -> i32

Returns the raw value.
§

impl<T> AsRawSocketlike for Twhere T: AsRawFd,

§

fn as_raw_socketlike(&self) -> i32

Returns the raw value.
§

impl<T> AsSocketlike for Twhere T: AsFd,

§

fn as_socketlike(&self) -> BorrowedFd<'_>

Borrows the reference.
§

fn as_socketlike_view<Target>(&self) -> SocketlikeView<'_, Target>where Target: SocketlikeViewType,

Return a borrowing view of a resource which dereferences to a &Target. 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.

§

impl<T> FromRawFilelike for Twhere T: FromRawFd,

§

unsafe fn from_raw_filelike(raw: i32) -> T

Constructs Self from the raw value. Read more
§

impl<T> FromRawSocketlike for Twhere T: FromRawFd,

§

unsafe fn from_raw_socketlike(raw: i32) -> T

Constructs Self from the raw value. Read more
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.

§

impl<T> IntoFd for Twhere OwnedFd: From<T>,

§

fn into_fd(self) -> OwnedFd

👎Deprecated since 1.0.0: IntoFd is replaced by From<...> for OwnedFd or Into<OwnedFd>
Consumes this object, returning the underlying file descriptor. Read more
§

impl<T> IntoFilelike for Twhere T: Into<OwnedFd>,

§

fn into_filelike(self) -> OwnedFd

Consumes this object, returning the underlying filelike object. Read more
§

impl<T> IntoSocketlike for Twhere T: Into<OwnedFd>,

§

fn into_socketlike(self) -> OwnedFd

Consumes this object, returning the underlying socketlike object.
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.