]> git.proxmox.com Git - proxmox.git/commitdiff
sys: add From<OwnedFd/Fd> for Fd/OwnedFd temporarily
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 19 Oct 2022 11:49:16 +0000 (13:49 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 19 Oct 2022 11:50:17 +0000 (13:50 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-sys/src/fd/fd_impl.rs

index 31f15e4f974ce193e444fcb90836db9194069423..d4732c80cd41f48e211121321bec76af6a528eec 100644 (file)
@@ -1,5 +1,5 @@
 use std::borrow::Borrow;
-use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
+use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
 
 use nix::fcntl::OFlag;
 use nix::sys::stat::Mode;
@@ -100,6 +100,20 @@ impl std::ops::Deref for Fd {
     }
 }
 
+#[allow(deprecated)]
+impl From<OwnedFd> for Fd {
+    fn from(fd: OwnedFd) -> Fd {
+        Fd(fd.into_raw_fd())
+    }
+}
+
+#[allow(deprecated)]
+impl From<Fd> for OwnedFd {
+    fn from(fd: Fd) -> OwnedFd {
+        unsafe { OwnedFd::from_raw_fd(fd.into_raw_fd()) }
+    }
+}
+
 /// A reference to a raw file descriptor. (Strongly typed `&RawFd` which is not equivalent to an
 /// `&i32`.
 ///