summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArvid Norlander <VorpalBlade@users.noreply.github.com>2023-02-19 16:13:58 +0100
committerArvid Norlander <VorpalBlade@users.noreply.github.com>2023-02-19 16:14:39 +0100
commit7830042a6572bc1bb86429299ca1bc202c1a0710 (patch)
tree0bf9ad6165d27840ffedd7792ef011abc4bd61af /src
parent1a838c7e54e6b908cc96db1c4a89dc87e8958f72 (diff)
downloadnix-7830042a6572bc1bb86429299ca1bc202c1a0710.zip
inotify: Add AsFd to allow using with epoll (issue #1998)
Diffstat (limited to 'src')
-rw-r--r--src/sys/inotify.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/sys/inotify.rs b/src/sys/inotify.rs
index 2398c16e..e5fe930f 100644
--- a/src/sys/inotify.rs
+++ b/src/sys/inotify.rs
@@ -32,7 +32,7 @@ use libc::{c_char, c_int};
use std::ffi::{CStr, OsStr, OsString};
use std::mem::{size_of, MaybeUninit};
use std::os::unix::ffi::OsStrExt;
-use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd, RawFd};
+use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd};
use std::ptr;
libc_bitflags! {
@@ -240,3 +240,9 @@ impl FromRawFd for Inotify {
Inotify { fd: OwnedFd::from_raw_fd(fd) }
}
}
+
+impl AsFd for Inotify {
+ fn as_fd(&'_ self) -> BorrowedFd<'_> {
+ self.fd.as_fd()
+ }
+}