forked from Proxmox/proxmox
sys: add From<OwnedFd/Fd> for Fd/OwnedFd temporarily
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
8bd961acdc
commit
88677d8955
@ -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`.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user