From cfa77e0e88a5a91da211ab0a8457fa5495d06166 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 19 Oct 2022 14:36:45 +0200 Subject: [PATCH] sys: impl AsFd for PTY Signed-off-by: Wolfgang Bumiller --- proxmox-sys/src/linux/pty.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxmox-sys/src/linux/pty.rs b/proxmox-sys/src/linux/pty.rs index a8e8008f..35f19bce 100644 --- a/proxmox-sys/src/linux/pty.rs +++ b/proxmox-sys/src/linux/pty.rs @@ -2,7 +2,7 @@ //! //! see [PTY](struct.PTY.html) for an example on how to use it -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; use nix::fcntl::OFlag; use nix::pty::{grantpt, posix_openpt, ptsname_r, unlockpt, PtyMaster}; @@ -125,3 +125,9 @@ impl AsRawFd for PTY { self.primary.as_raw_fd() } } + +impl AsFd for PTY { + fn as_fd(&self) -> BorrowedFd<'_> { + unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) } + } +}