|
1 | | -use crate::io::{self, PipeReader, PipeWriter}; |
2 | | -use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; |
3 | | -use crate::process::Stdio; |
| 1 | +use crate::io; |
4 | 2 | use crate::sys::fd::FileDesc; |
5 | 3 | use crate::sys::pipe::anon_pipe; |
6 | | -use crate::sys_common::{FromInner, IntoInner}; |
| 4 | +use crate::sys_common::IntoInner; |
7 | 5 |
|
8 | 6 | pub type AnonPipe = FileDesc; |
9 | 7 |
|
10 | 8 | #[inline] |
11 | 9 | pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> { |
12 | 10 | anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner())) |
13 | 11 | } |
14 | | - |
15 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
16 | | -impl AsFd for PipeReader { |
17 | | - fn as_fd(&self) -> BorrowedFd<'_> { |
18 | | - self.0.as_fd() |
19 | | - } |
20 | | -} |
21 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
22 | | -impl AsRawFd for PipeReader { |
23 | | - fn as_raw_fd(&self) -> RawFd { |
24 | | - self.0.as_raw_fd() |
25 | | - } |
26 | | -} |
27 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
28 | | -impl From<PipeReader> for OwnedFd { |
29 | | - fn from(pipe: PipeReader) -> Self { |
30 | | - FileDesc::into_inner(pipe.0) |
31 | | - } |
32 | | -} |
33 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
34 | | -impl FromRawFd for PipeReader { |
35 | | - unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { |
36 | | - unsafe { Self(FileDesc::from_raw_fd(raw_fd)) } |
37 | | - } |
38 | | -} |
39 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
40 | | -impl IntoRawFd for PipeReader { |
41 | | - fn into_raw_fd(self) -> RawFd { |
42 | | - self.0.into_raw_fd() |
43 | | - } |
44 | | -} |
45 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
46 | | -impl From<PipeReader> for Stdio { |
47 | | - fn from(pipe: PipeReader) -> Self { |
48 | | - Self::from(OwnedFd::from(pipe)) |
49 | | - } |
50 | | -} |
51 | | - |
52 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
53 | | -impl AsFd for PipeWriter { |
54 | | - fn as_fd(&self) -> BorrowedFd<'_> { |
55 | | - self.0.as_fd() |
56 | | - } |
57 | | -} |
58 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
59 | | -impl AsRawFd for PipeWriter { |
60 | | - fn as_raw_fd(&self) -> RawFd { |
61 | | - self.0.as_raw_fd() |
62 | | - } |
63 | | -} |
64 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
65 | | -impl From<PipeWriter> for OwnedFd { |
66 | | - fn from(pipe: PipeWriter) -> Self { |
67 | | - FileDesc::into_inner(pipe.0) |
68 | | - } |
69 | | -} |
70 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
71 | | -impl FromRawFd for PipeWriter { |
72 | | - unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { |
73 | | - unsafe { Self(FileDesc::from_raw_fd(raw_fd)) } |
74 | | - } |
75 | | -} |
76 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
77 | | -impl IntoRawFd for PipeWriter { |
78 | | - fn into_raw_fd(self) -> RawFd { |
79 | | - self.0.into_raw_fd() |
80 | | - } |
81 | | -} |
82 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
83 | | -impl From<PipeWriter> for Stdio { |
84 | | - fn from(pipe: PipeWriter) -> Self { |
85 | | - Self::from(OwnedFd::from(pipe)) |
86 | | - } |
87 | | -} |
88 | | - |
89 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
90 | | -impl From<OwnedFd> for PipeReader { |
91 | | - fn from(owned_fd: OwnedFd) -> Self { |
92 | | - Self(FileDesc::from_inner(owned_fd)) |
93 | | - } |
94 | | -} |
95 | | - |
96 | | -#[stable(feature = "anonymous_pipe", since = "CURRENT_RUSTC_VERSION")] |
97 | | -impl From<OwnedFd> for PipeWriter { |
98 | | - fn from(owned_fd: OwnedFd) -> Self { |
99 | | - Self(FileDesc::from_inner(owned_fd)) |
100 | | - } |
101 | | -} |
0 commit comments