Add try_clone for AsFd types

This commit is contained in:
Aode (lion) 2022-03-05 14:53:38 -06:00
parent 4e11c032de
commit 1afe134741

View file

@ -9,10 +9,18 @@ use std::{
pub mod io;
pub mod net;
pub use rustix::{
fd::{AsFd, AsRawFd, BorrowedFd},
io::OwnedFd,
};
pub mod fd {
pub use rustix::{
fd::{AsFd, AsRawFd, BorrowedFd},
io::OwnedFd,
};
pub fn try_clone<A: AsFd>(fd: A) -> super::io::Result<OwnedFd> {
rustix::fs::fcntl_dupfd_cloexec(fd, 0).map_err(From::from)
}
}
use fd::{AsFd, OwnedFd};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct KeyRef(*const ());