mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-04 03:45:15 +00:00
proxmox: tools: add RawFdNum helper
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
48f8e6070d
commit
4e2e37b7d3
@ -62,3 +62,26 @@ impl Fd {
|
||||
nix::fcntl::openat(dirfd.as_raw_fd(), path, oflag, mode).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw file descriptor by number. Thin wrapper to provide `AsRawFd` which a simple `RawFd` does
|
||||
/// not since it's just an `i32`.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct RawFdNum(RawFd);
|
||||
|
||||
impl AsRawFd for RawFdNum {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl FromRawFd for RawFdNum {
|
||||
fn from_raw_fd(fd: RawFd) -> Self {
|
||||
Self(fd)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoRawFd for RawFdNum {
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user