11use crate :: { io, process:: Stdio , sys:: pipe:: AnonPipe } ;
22
33/// Create annoymous pipe that is close-on-exec and blocking.
4+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
45#[ inline]
56pub fn pipe ( ) -> io:: Result < ( PipeReader , PipeWriter ) > {
67 cfg_if:: cfg_if! {
@@ -13,29 +14,34 @@ pub fn pipe() -> io::Result<(PipeReader, PipeWriter)> {
1314}
1415
1516/// Read end of the annoymous pipe.
17+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
1618#[ derive( Debug ) ]
1719pub struct PipeReader ( AnonPipe ) ;
1820
1921/// Write end of the annoymous pipe.
22+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
2023#[ derive( Debug ) ]
2124pub struct PipeWriter ( AnonPipe ) ;
2225
2326impl PipeReader {
2427 /// Create a new [`PipeReader`] instance that shares the same underlying file description.
28+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
2529 pub fn try_clone ( & self ) -> io:: Result < Self > {
2630 self . 0 . try_clone ( ) . map ( Self )
2731 }
2832}
2933
3034impl PipeWriter {
3135 /// Create a new [`PipeWriter`] instance that shares the same underlying file description.
36+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
3237 pub fn try_clone ( & self ) -> io:: Result < Self > {
3338 self . 0 . try_clone ( ) . map ( Self )
3439 }
3540}
3641
3742macro_rules! forward_io_read_traits {
3843 ( $name: ty) => {
44+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
3945 impl io:: Read for $name {
4046 fn read( & mut self , buf: & mut [ u8 ] ) -> io:: Result <usize > {
4147 self . 0 . read( buf)
@@ -60,6 +66,7 @@ forward_io_read_traits!(&PipeReader);
6066
6167macro_rules! forward_io_write_traits {
6268 ( $name: ty) => {
69+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
6370 impl io:: Write for $name {
6471 fn write( & mut self , buf: & [ u8 ] ) -> io:: Result <usize > {
6572 self . 0 . write( buf)
@@ -104,31 +111,37 @@ mod unix {
104111
105112 macro_rules! impl_traits {
106113 ( $name: ty) => {
114+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
107115 impl AsFd for $name {
108116 fn as_fd( & self ) -> BorrowedFd <' _> {
109117 self . 0 . as_fd( )
110118 }
111119 }
120+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
112121 impl AsRawFd for $name {
113122 fn as_raw_fd( & self ) -> RawFd {
114123 self . 0 . as_raw_fd( )
115124 }
116125 }
126+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
117127 impl From <$name> for OwnedFd {
118128 fn from( pipe: $name) -> Self {
119129 FileDesc :: into_inner( AnonPipe :: into_inner( pipe. 0 ) )
120130 }
121131 }
132+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
122133 impl FromRawFd for $name {
123134 unsafe fn from_raw_fd( raw_fd: RawFd ) -> Self {
124135 Self ( AnonPipe :: from_raw_fd( raw_fd) )
125136 }
126137 }
138+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
127139 impl IntoRawFd for $name {
128140 fn into_raw_fd( self ) -> RawFd {
129141 self . 0 . into_raw_fd( )
130142 }
131143 }
144+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
132145 impl From <$name> for Stdio {
133146 fn from( pipe: $name) -> Self {
134147 Self :: from( OwnedFd :: from( pipe) )
@@ -177,6 +190,7 @@ mod unix {
177190 }
178191 }
179192
193+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
180194 impl TryFrom < OwnedFd > for PipeReader {
181195 type Error = io:: Error ;
182196
@@ -187,6 +201,7 @@ mod unix {
187201 }
188202 }
189203
204+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
190205 impl TryFrom < OwnedFd > for PipeWriter {
191206 type Error = io:: Error ;
192207
@@ -221,33 +236,39 @@ mod windows {
221236
222237 macro_rules! impl_traits {
223238 ( $name: ty) => {
239+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
224240 impl AsHandle for $name {
225241 fn as_handle( & self ) -> BorrowedHandle <' _> {
226242 self . 0 . handle( ) . as_handle( )
227243 }
228244 }
245+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
229246 impl AsRawHandle for $name {
230247 fn as_raw_handle( & self ) -> RawHandle {
231248 self . 0 . handle( ) . as_raw_handle( )
232249 }
233250 }
234251
252+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
235253 impl FromRawHandle for $name {
236254 unsafe fn from_raw_handle( raw_handle: RawHandle ) -> Self {
237255 Self ( AnonPipe :: from_inner( Handle :: from_raw_handle( raw_handle) ) )
238256 }
239257 }
258+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
240259 impl IntoRawHandle for $name {
241260 fn into_raw_handle( self ) -> RawHandle {
242261 self . 0 . into_handle( ) . into_raw_handle( )
243262 }
244263 }
245264
265+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
246266 impl From <$name> for OwnedHandle {
247267 fn from( pipe: $name) -> Self {
248268 Handle :: into_inner( AnonPipe :: into_inner( pipe. 0 ) )
249269 }
250270 }
271+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
251272 impl From <$name> for Stdio {
252273 fn from( pipe: $name) -> Self {
253274 Self :: from( OwnedHandle :: from( pipe) )
@@ -262,6 +283,7 @@ mod windows {
262283 AnonPipe :: from_inner ( Handle :: from_inner ( owned_handle) )
263284 }
264285
286+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
265287 impl TryFrom < OwnedHandle > for PipeReader {
266288 type Error = io:: Error ;
267289
@@ -270,6 +292,7 @@ mod windows {
270292 }
271293 }
272294
295+ #[ unstable( feature = "anonymous_pipe" , issue = "127154" ) ]
273296 impl TryFrom < OwnedHandle > for PipeWriter {
274297 type Error = io:: Error ;
275298
0 commit comments