From 7830042a6572bc1bb86429299ca1bc202c1a0710 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Sun, 19 Feb 2023 16:13:58 +0100 Subject: inotify: Add AsFd to allow using with epoll (issue #1998) --- src/sys/inotify.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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() + } +} -- cgit v1.2.3