diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2021-09-07 00:32:38 -0700 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2021-09-07 08:57:17 -0700 |
commit | b0b7beb2a8772dd492272c4896425cde46b8dce9 (patch) | |
tree | 37ebda260cf42ee897ddf602b90bcb370a498eb0 /src/poll.rs | |
parent | 2142ec3c27f1c6a275aecc502b7fd3ee3bdaf08a (diff) | |
download | nix-b0b7beb2a8772dd492272c4896425cde46b8dce9.zip |
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`
Diffstat (limited to 'src/poll.rs')
-rw-r--r-- | src/poll.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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 { |