Struct PollFd
struct PollFd<'fd> { ... }
This is a wrapper around libc::pollfd.
It's meant to be used as an argument to the poll and
ppoll functions to specify the events of interest
for a specific file descriptor.
After a call to poll or ppoll, the events that occurred can be retrieved by calling
revents() on the PollFd object from the array passed to poll.
Implementations
impl<'fd> PollFd<'fd>
fn new(fd: BorrowedFd<'fd>, events: PollFlags) -> PollFd<'fd>Creates a new
PollFdspecifying the events of interest for a given file descriptor.Examples
# use std::os::unix::io::{AsFd, AsRawFd, FromRawFd}; # use nix::{ # poll::{PollTimeout, PollFd, PollFlags, poll}, # unistd::{pipe, read} # }; let (r, w) = pipe().unwrap(); let pfd = PollFd::new(r.as_fd(), PollFlags::POLLIN);fn revents(self: &Self) -> Option<PollFlags>Returns the events that occurred in the last call to
pollorppoll. Will only returnNoneif the kernel provides status flags that Nix does not know about.fn any(self: &Self) -> Option<bool>Returns if any of the events of interest occured in the last call to
pollorppoll. Will only returnNoneif the kernel provides status flags that Nix does not know about.Equivalent to
x.revents()? != PollFlags::empty().This is marginally more efficient than
PollFd::all.fn all(self: &Self) -> Option<bool>Returns if all the events of interest occured in the last call to
pollorppoll. Will only returnNoneif the kernel provides status flags that Nix does not know about.Equivalent to
x.revents()? & x.events() == x.events().This is marginally less efficient than
PollFd::any.fn events(self: &Self) -> PollFlagsThe events of interest for this
PollFd.fn set_events(self: &mut Self, events: PollFlags)Modify the events of interest for this
PollFd.
impl AsFd for PollFd<'_>
fn as_fd(self: &Self) -> BorrowedFd<'_>
impl<'fd> Clone for PollFd<'fd>
fn clone(self: &Self) -> PollFd<'fd>
impl<'fd> Debug for PollFd<'fd>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'fd> Eq for PollFd<'fd>
impl<'fd> Freeze for PollFd<'fd>
impl<'fd> Hash for PollFd<'fd>
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl<'fd> PartialEq for PollFd<'fd>
fn eq(self: &Self, other: &PollFd<'fd>) -> bool
impl<'fd> RefUnwindSafe for PollFd<'fd>
impl<'fd> Send for PollFd<'fd>
impl<'fd> StructuralPartialEq for PollFd<'fd>
impl<'fd> Sync for PollFd<'fd>
impl<'fd> Unpin for PollFd<'fd>
impl<'fd> UnsafeUnpin for PollFd<'fd>
impl<'fd> UnwindSafe for PollFd<'fd>
impl<T> Any for PollFd<'fd>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for PollFd<'fd>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for PollFd<'fd>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for PollFd<'fd>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for PollFd<'fd>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for PollFd<'fd>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for PollFd<'fd>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for PollFd<'fd>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for PollFd<'fd>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>