Skip to content

Commit bb08602

Browse files
committed
Add trait impls for std::process::Child and std::process::Stdio.
1 parent fe71cfc commit bb08602

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/traits.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,38 @@ impl IntoHandle for std::process::ChildStderr {
698698
}
699699
}
700700

701+
#[cfg(unix)]
702+
impl FromFd for std::process::Stdio {
703+
#[inline]
704+
fn from_fd(owned: OwnedFd) -> Self {
705+
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
706+
}
707+
}
708+
709+
#[cfg(windows)]
710+
impl FromHandle for std::process::Stdio {
711+
#[inline]
712+
fn from_handle(owned: OwnedHandle) -> Self {
713+
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
714+
}
715+
}
716+
717+
#[cfg(windows)]
718+
impl AsHandle for std::process::Child {
719+
#[inline]
720+
fn as_handle(&self) -> BorrowedHandle<'_> {
721+
unsafe { BorrowedHandle::borrow_raw_handle(self.as_raw_handle()) }
722+
}
723+
}
724+
725+
#[cfg(windows)]
726+
impl IntoHandle for std::process::Child {
727+
#[inline]
728+
fn into_handle(self) -> OwnedHandle {
729+
unsafe { OwnedHandle::from_raw_handle(self.into_raw_handle()) }
730+
}
731+
}
732+
701733
#[cfg(unix)]
702734
impl AsFd for std::os::unix::net::UnixStream {
703735
#[inline]

0 commit comments

Comments
 (0)