pub struct PollFd<'fd> { /* private fields */ }
Expand description
Implementations§
source§impl<'fd> PollFd<'fd>
impl<'fd> PollFd<'fd>
sourcepub fn new(fd: BorrowedFd<'fd>, events: PollFlags) -> PollFd<'fd>
pub fn new(fd: BorrowedFd<'fd>, events: PollFlags) -> PollFd<'fd>
Creates a new PollFd
specifying the events of interest
for a given file descriptor.
§Examples
let (r, w) = pipe().unwrap();
let pfd = PollFd::new(r.as_fd(), PollFlags::POLLIN);
let mut fds = [pfd];
poll(&mut fds, PollTimeout::NONE).unwrap();
let mut buf = [0u8; 80];
read(&r, &mut buf[..]);
sourcepub fn revents(self) -> Option<PollFlags>
pub fn revents(self) -> Option<PollFlags>
Returns the events that occurred in the last call to poll
or ppoll
. Will only return
None
if the kernel provides status flags that Nix does not know about.
sourcepub fn any(self) -> Option<bool>
pub fn any(self) -> Option<bool>
Returns if any of the events of interest occured in the last call to poll
or ppoll
. Will
only return None
if 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
.
sourcepub fn all(self) -> Option<bool>
pub fn all(self) -> Option<bool>
Returns if all the events of interest occured in the last call to poll
or ppoll
. Will
only return None
if 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
.
sourcepub fn set_events(&mut self, events: PollFlags)
pub fn set_events(&mut self, events: PollFlags)
Modify the events of interest for this PollFd
.
Trait Implementations§
source§impl<'fd> AsFd for PollFd<'fd>
impl<'fd> AsFd for PollFd<'fd>
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
impl<'fd> Copy for PollFd<'fd>
impl<'fd> Eq for PollFd<'fd>
impl<'fd> StructuralPartialEq for PollFd<'fd>
Auto Trait Implementations§
impl<'fd> Freeze for PollFd<'fd>
impl<'fd> RefUnwindSafe for PollFd<'fd>
impl<'fd> Send for PollFd<'fd>
impl<'fd> Sync for PollFd<'fd>
impl<'fd> Unpin for PollFd<'fd>
impl<'fd> UnwindSafe for PollFd<'fd>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)