1
1
use crate :: { io, process:: Stdio , sys:: pipe:: AnonPipe } ;
2
2
3
3
/// Create annoymous pipe that is close-on-exec and blocking.
4
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
4
5
#[ inline]
5
6
pub fn pipe ( ) -> io:: Result < ( PipeReader , PipeWriter ) > {
6
7
cfg_if:: cfg_if! {
@@ -13,29 +14,34 @@ pub fn pipe() -> io::Result<(PipeReader, PipeWriter)> {
13
14
}
14
15
15
16
/// Read end of the annoymous pipe.
17
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
16
18
#[ derive( Debug ) ]
17
19
pub struct PipeReader ( AnonPipe ) ;
18
20
19
21
/// Write end of the annoymous pipe.
22
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
20
23
#[ derive( Debug ) ]
21
24
pub struct PipeWriter ( AnonPipe ) ;
22
25
23
26
impl PipeReader {
24
27
/// Create a new [`PipeReader`] instance that shares the same underlying file description.
28
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
25
29
pub fn try_clone ( & self ) -> io:: Result < Self > {
26
30
self . 0 . try_clone ( ) . map ( Self )
27
31
}
28
32
}
29
33
30
34
impl PipeWriter {
31
35
/// Create a new [`PipeWriter`] instance that shares the same underlying file description.
36
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
32
37
pub fn try_clone ( & self ) -> io:: Result < Self > {
33
38
self . 0 . try_clone ( ) . map ( Self )
34
39
}
35
40
}
36
41
37
42
macro_rules! forward_io_read_traits {
38
43
( $name: ty) => {
44
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
39
45
impl io:: Read for $name {
40
46
fn read( & mut self , buf: & mut [ u8 ] ) -> io:: Result <usize > {
41
47
self . 0 . read( buf)
@@ -60,6 +66,7 @@ forward_io_read_traits!(&PipeReader);
60
66
61
67
macro_rules! forward_io_write_traits {
62
68
( $name: ty) => {
69
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
63
70
impl io:: Write for $name {
64
71
fn write( & mut self , buf: & [ u8 ] ) -> io:: Result <usize > {
65
72
self . 0 . write( buf)
@@ -104,31 +111,37 @@ mod unix {
104
111
105
112
macro_rules! impl_traits {
106
113
( $name: ty) => {
114
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
107
115
impl AsFd for $name {
108
116
fn as_fd( & self ) -> BorrowedFd <' _> {
109
117
self . 0 . as_fd( )
110
118
}
111
119
}
120
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
112
121
impl AsRawFd for $name {
113
122
fn as_raw_fd( & self ) -> RawFd {
114
123
self . 0 . as_raw_fd( )
115
124
}
116
125
}
126
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
117
127
impl From <$name> for OwnedFd {
118
128
fn from( pipe: $name) -> Self {
119
129
FileDesc :: into_inner( AnonPipe :: into_inner( pipe. 0 ) )
120
130
}
121
131
}
132
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
122
133
impl FromRawFd for $name {
123
134
unsafe fn from_raw_fd( raw_fd: RawFd ) -> Self {
124
135
Self ( AnonPipe :: from_raw_fd( raw_fd) )
125
136
}
126
137
}
138
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
127
139
impl IntoRawFd for $name {
128
140
fn into_raw_fd( self ) -> RawFd {
129
141
self . 0 . into_raw_fd( )
130
142
}
131
143
}
144
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
132
145
impl From <$name> for Stdio {
133
146
fn from( pipe: $name) -> Self {
134
147
Self :: from( OwnedFd :: from( pipe) )
@@ -177,6 +190,7 @@ mod unix {
177
190
}
178
191
}
179
192
193
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
180
194
impl TryFrom < OwnedFd > for PipeReader {
181
195
type Error = io:: Error ;
182
196
@@ -187,6 +201,7 @@ mod unix {
187
201
}
188
202
}
189
203
204
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
190
205
impl TryFrom < OwnedFd > for PipeWriter {
191
206
type Error = io:: Error ;
192
207
@@ -221,33 +236,39 @@ mod windows {
221
236
222
237
macro_rules! impl_traits {
223
238
( $name: ty) => {
239
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
224
240
impl AsHandle for $name {
225
241
fn as_handle( & self ) -> BorrowedHandle <' _> {
226
242
self . 0 . handle( ) . as_handle( )
227
243
}
228
244
}
245
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
229
246
impl AsRawHandle for $name {
230
247
fn as_raw_handle( & self ) -> RawHandle {
231
248
self . 0 . handle( ) . as_raw_handle( )
232
249
}
233
250
}
234
251
252
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
235
253
impl FromRawHandle for $name {
236
254
unsafe fn from_raw_handle( raw_handle: RawHandle ) -> Self {
237
255
Self ( AnonPipe :: from_inner( Handle :: from_raw_handle( raw_handle) ) )
238
256
}
239
257
}
258
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
240
259
impl IntoRawHandle for $name {
241
260
fn into_raw_handle( self ) -> RawHandle {
242
261
self . 0 . into_handle( ) . into_raw_handle( )
243
262
}
244
263
}
245
264
265
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
246
266
impl From <$name> for OwnedHandle {
247
267
fn from( pipe: $name) -> Self {
248
268
Handle :: into_inner( AnonPipe :: into_inner( pipe. 0 ) )
249
269
}
250
270
}
271
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
251
272
impl From <$name> for Stdio {
252
273
fn from( pipe: $name) -> Self {
253
274
Self :: from( OwnedHandle :: from( pipe) )
@@ -262,6 +283,7 @@ mod windows {
262
283
AnonPipe :: from_inner ( Handle :: from_inner ( owned_handle) )
263
284
}
264
285
286
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
265
287
impl TryFrom < OwnedHandle > for PipeReader {
266
288
type Error = io:: Error ;
267
289
@@ -270,6 +292,7 @@ mod windows {
270
292
}
271
293
}
272
294
295
+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
273
296
impl TryFrom < OwnedHandle > for PipeWriter {
274
297
type Error = io:: Error ;
275
298
0 commit comments