Struct Events

Source
pub struct Events { /* private fields */ }
Expand description

Wrapper over an epoll::EpollEvent object.

When working directly with epoll related methods, the user associates an u64 wide epoll_data_t object with every event. We want to use fds as identifiers, but at the same time keep the ability to associate opaque data with an event. An Events object always contains an fd and an u32 data member that can be supplied by the user. When registering events with the inner epoll event set, the fd and data members of Events are used together to generate the underlying u64 member of the epoll_data union.

Implementations§

Source§

impl Events

Source

pub fn empty<T>(source: &T) -> Events
where T: AsRawFd,

Create an empty event set associated with source.

No explicit events are monitored for the associated file descriptor. Nevertheless, EventSet::ERROR and EventSet::HANG_UP are implicitly monitored.

§Arguments
  • source: object that wraps a file descriptor to be associated with events
§Example
let eventfd = EventFd::new(0).unwrap();
let ev_set = Events::empty(&eventfd);
Source

pub fn empty_raw(fd: i32) -> Events

Create an empty event set associated with the supplied RawFd value.

No explicit events are monitored for the associated file descriptor. Nevertheless, EventSet::ERROR and EventSet::HANG_UP are implicitly monitored.

§Example
let eventfd = EventFd::new(0).unwrap();
let ev_set = Events::empty_raw(eventfd.as_raw_fd());
Source

pub fn new<T>(source: &T, events: EventSet) -> Events
where T: AsRawFd,

Create an event with source and the associated events for monitoring.

§Arguments
  • source: object that wraps a file descriptor to be associated with events
  • events: events to monitor on the provided source; EventSet::ERROR and EventSet::HANG_UP are always monitored and don’t need to be explicitly added to the list.
§Example
let eventfd = EventFd::new(0).unwrap();
let event_set = EventSet::IN;
let ev_set = Events::new(&eventfd, event_set);
Source

pub fn new_raw(source: i32, events: EventSet) -> Events

Create an event with the supplied RawFd value and events for monitoring.

§Arguments
  • source: file descriptor on which to monitor the events
  • events: events to monitor on the provided source; EventSet::ERROR and EventSet::HANG_UP are always monitored and don’t need to be explicitly added to the list.
§Example
let eventfd = EventFd::new(0).unwrap();
let event_set = EventSet::IN;
let ev_set = Events::new_raw(eventfd.as_raw_fd(), event_set);
Source

pub fn with_data<T>(source: &T, data: u32, events: EventSet) -> Events
where T: AsRawFd,

Create an event set associated with the underlying file descriptor of the source, active events, and data.

§Arguments
  • source: object that wraps a file descriptor to be associated with events
  • data: custom user data associated with the file descriptor; the data can be used for uniquely identify monitored events instead of using the file descriptor.
  • events: events to monitor on the provided source; EventSet::ERROR and EventSet::HANG_UP are always monitored and don’t need to be explicitly added to the list.
§Examples
let eventfd = EventFd::new(0).unwrap();
let event_set = EventSet::IN;
let custom_data = 42;
let ev_set = Events::with_data(&eventfd, custom_data, event_set);
Source

pub fn with_data_raw(source: i32, data: u32, events: EventSet) -> Events

Create an event set associated with the supplied RawFd value, active events, and data.

§Arguments
  • source: file descriptor to be associated with events
  • data: custom user data associated with the file descriptor; the data can be used for uniquely identify monitored events instead of using the file descriptor.
  • events: events to monitor on the provided source; EventSet::ERROR and EventSet::HANG_UP are always monitored and don’t need to be explicitly added to the list.
§Examples
let eventfd = EventFd::new(0).unwrap();
let event_set = EventSet::IN;
let custom_data = 42;
let ev_set = Events::with_data_raw(eventfd.as_raw_fd(), custom_data, event_set);
Source

pub fn fd(&self) -> i32

Return the inner fd value.

Source

pub fn data(&self) -> u32

Return the inner data value.

Source

pub fn event_set(&self) -> EventSet

Return the active event set.

Source

pub fn epoll_event(&self) -> EpollEvent

Return the inner EpollEvent.

Trait Implementations§

Source§

impl Clone for Events

Source§

fn clone(&self) -> Events

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Events

Source§

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

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

impl PartialEq for Events

Source§

fn eq(&self, other: &Events) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Events

Auto Trait Implementations§

§

impl Freeze for Events

§

impl RefUnwindSafe for Events

§

impl Send for Events

§

impl Sync for Events

§

impl Unpin for Events

§

impl UnwindSafe for Events

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.