Factor out a common RawFd/AsRawFd/etc for Unix and WASI.

This commit is contained in:
Dan Gohman
2021-08-19 12:24:25 -07:00
parent 0377a63352
commit e555003e6d
16 changed files with 355 additions and 525 deletions

View File

@@ -3,7 +3,9 @@
#![stable(feature = "process_extensions", since = "1.2.0")]
use crate::ffi::OsStr;
use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle};
use crate::os::windows::io::{
AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
};
use crate::process;
use crate::sealed::Sealed;
use crate::sys;
@@ -21,7 +23,7 @@ impl FromRawHandle for process::Stdio {
#[unstable(feature = "io_safety", issue = "87074")]
impl From<OwnedHandle> for process::Stdio {
fn from(handle: OwnedHandle) -> process::Stdio {
let handle = sys::handle::Handle::from_handle(handle);
let handle = sys::handle::Handle::from_inner(handle);
let io = sys::process::Stdio::Handle(handle);
process::Stdio::from_inner(io)
}
@@ -51,9 +53,9 @@ impl IntoRawHandle for process::Child {
}
#[unstable(feature = "io_safety", issue = "87074")]
impl IntoHandle for process::Child {
fn into_handle(self) -> BorrowedHandle<'_> {
self.into_inner().into_handle().into_handle()
impl From<process::Child> for OwnedHandle {
fn from(child: process::Child) -> OwnedHandle {
child.into_inner().into_handle().into_inner()
}
}