From b0b7beb2a8772dd492272c4896425cde46b8dce9 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 7 Sep 2021 00:32:38 -0700 Subject: Implement AsRawFd for PollFd Implement the trait on PollFd, providing an `as_raw_fd()` accessor to get the RawFd associated with the PollFd. Subsumes #1147, #1286. Closes #1146. Test: `cargo test --test test test_pollfd_fd` --- src/poll.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/poll.rs b/src/poll.rs index e814337a..0eaf7e1d 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -3,7 +3,7 @@ use crate::sys::time::TimeSpec; #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] use crate::sys::signal::SigSet; -use std::os::unix::io::RawFd; +use std::os::unix::io::{AsRawFd, RawFd}; use crate::Result; use crate::errno::Errno; @@ -41,6 +41,12 @@ impl PollFd { } } +impl AsRawFd for PollFd { + fn as_raw_fd(&self) -> RawFd { + self.pollfd.fd + } +} + libc_bitflags! { /// These flags define the different events that can be monitored by `poll` and `ppoll` pub struct PollFlags: libc::c_short { -- cgit v1.2.3