From 88677d895509a815ec976f570638f503634aee20 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 19 Oct 2022 13:49:16 +0200 Subject: [PATCH] sys: add From for Fd/OwnedFd temporarily Signed-off-by: Wolfgang Bumiller --- proxmox-sys/src/fd/fd_impl.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/proxmox-sys/src/fd/fd_impl.rs b/proxmox-sys/src/fd/fd_impl.rs index 31f15e4f..d4732c80 100644 --- a/proxmox-sys/src/fd/fd_impl.rs +++ b/proxmox-sys/src/fd/fd_impl.rs @@ -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 for Fd { + fn from(fd: OwnedFd) -> Fd { + Fd(fd.into_raw_fd()) + } +} + +#[allow(deprecated)] +impl From 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`. ///