88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- #![ stable ( feature = "unix_socket_redox" , since = "1.27.0 " ) ]
11+ #![ unstable ( feature = "unix_socket_redox" , reason = "new feature" , issue= "51553 ") ]
1212
1313//! Unix-specific networking functionality
1414
@@ -36,7 +36,6 @@ use sys::{cvt, fd::FileDesc, syscall};
3636/// };
3737/// let addr = socket.local_addr().expect("Couldn't get local address");
3838/// ```
39- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
4039#[ derive( Clone ) ]
4140pub struct SocketAddr ;
4241
@@ -65,12 +64,10 @@ impl SocketAddr {
6564 /// let addr = socket.local_addr().expect("Couldn't get local address");
6665 /// assert_eq!(addr.as_pathname(), None);
6766 /// ```
68- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
6967 pub fn as_pathname ( & self ) -> Option < & Path > {
7068 None
7169 }
7270}
73- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
7471impl fmt:: Debug for SocketAddr {
7572 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
7673 write ! ( fmt, "SocketAddr" )
@@ -91,10 +88,8 @@ impl fmt::Debug for SocketAddr {
9188/// stream.read_to_string(&mut response).unwrap();
9289/// println!("{}", response);
9390/// ```
94- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
9591pub struct UnixStream ( FileDesc ) ;
9692
97- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
9893impl fmt:: Debug for UnixStream {
9994 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
10095 let mut builder = fmt. debug_struct ( "UnixStream" ) ;
@@ -125,7 +120,6 @@ impl UnixStream {
125120 /// }
126121 /// };
127122 /// ```
128- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
129123 pub fn connect < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixStream > {
130124 if let Some ( s) = path. as_ref ( ) . to_str ( ) {
131125 cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CLOEXEC ) )
@@ -156,7 +150,6 @@ impl UnixStream {
156150 /// }
157151 /// };
158152 /// ```
159- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
160153 pub fn pair ( ) -> io:: Result < ( UnixStream , UnixStream ) > {
161154 let server = cvt ( syscall:: open ( "chan:" , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
162155 . map ( FileDesc :: new) ?;
@@ -180,7 +173,6 @@ impl UnixStream {
180173 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
181174 /// let sock_copy = socket.try_clone().expect("Couldn't clone socket");
182175 /// ```
183- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
184176 pub fn try_clone ( & self ) -> io:: Result < UnixStream > {
185177 self . 0 . duplicate ( ) . map ( UnixStream )
186178 }
@@ -195,7 +187,6 @@ impl UnixStream {
195187 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
196188 /// let addr = socket.local_addr().expect("Couldn't get local address");
197189 /// ```
198- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
199190 pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
200191 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::local_addr unimplemented on redox" ) )
201192 }
@@ -210,7 +201,6 @@ impl UnixStream {
210201 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
211202 /// let addr = socket.peer_addr().expect("Couldn't get peer address");
212203 /// ```
213- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
214204 pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
215205 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::peer_addr unimplemented on redox" ) )
216206 }
@@ -249,7 +239,6 @@ impl UnixStream {
249239 /// let err = result.unwrap_err();
250240 /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
251241 /// ```
252- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
253242 pub fn set_read_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
254243 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_read_timeout unimplemented on redox" ) )
255244 }
@@ -288,7 +277,6 @@ impl UnixStream {
288277 /// let err = result.unwrap_err();
289278 /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
290279 /// ```
291- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
292280 pub fn set_write_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
293281 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_write_timeout unimplemented on redox" ) )
294282 }
@@ -305,7 +293,6 @@ impl UnixStream {
305293 /// socket.set_read_timeout(Some(Duration::new(1, 0))).expect("Couldn't set read timeout");
306294 /// assert_eq!(socket.read_timeout().unwrap(), Some(Duration::new(1, 0)));
307295 /// ```
308- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
309296 pub fn read_timeout ( & self ) -> io:: Result < Option < Duration > > {
310297 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::read_timeout unimplemented on redox" ) )
311298 }
@@ -322,7 +309,6 @@ impl UnixStream {
322309 /// socket.set_write_timeout(Some(Duration::new(1, 0))).expect("Couldn't set write timeout");
323310 /// assert_eq!(socket.write_timeout().unwrap(), Some(Duration::new(1, 0)));
324311 /// ```
325- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
326312 pub fn write_timeout ( & self ) -> io:: Result < Option < Duration > > {
327313 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::write_timeout unimplemented on redox" ) )
328314 }
@@ -337,7 +323,6 @@ impl UnixStream {
337323 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
338324 /// socket.set_nonblocking(true).expect("Couldn't set nonblocking");
339325 /// ```
340- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
341326 pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
342327 self . 0 . set_nonblocking ( nonblocking)
343328 }
@@ -354,7 +339,6 @@ impl UnixStream {
354339 /// println!("Got error: {:?}", err);
355340 /// }
356341 /// ```
357- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
358342 pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
359343 Ok ( None )
360344 }
@@ -376,13 +360,11 @@ impl UnixStream {
376360 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
377361 /// socket.shutdown(Shutdown::Both).expect("shutdown function failed");
378362 /// ```
379- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
380363 pub fn shutdown ( & self , _how : Shutdown ) -> io:: Result < ( ) > {
381364 Err ( Error :: new ( ErrorKind :: Other , "UnixStream::shutdown unimplemented on redox" ) )
382365 }
383366}
384367
385- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
386368impl io:: Read for UnixStream {
387369 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
388370 io:: Read :: read ( & mut & * self , buf)
@@ -394,7 +376,6 @@ impl io::Read for UnixStream {
394376 }
395377}
396378
397- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
398379impl < ' a > io:: Read for & ' a UnixStream {
399380 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
400381 self . 0 . read ( buf)
@@ -406,7 +387,6 @@ impl<'a> io::Read for &'a UnixStream {
406387 }
407388}
408389
409- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
410390impl io:: Write for UnixStream {
411391 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
412392 io:: Write :: write ( & mut & * self , buf)
@@ -417,7 +397,6 @@ impl io::Write for UnixStream {
417397 }
418398}
419399
420- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
421400impl < ' a > io:: Write for & ' a UnixStream {
422401 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
423402 self . 0 . write ( buf)
@@ -428,21 +407,18 @@ impl<'a> io::Write for &'a UnixStream {
428407 }
429408}
430409
431- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
432410impl AsRawFd for UnixStream {
433411 fn as_raw_fd ( & self ) -> RawFd {
434412 self . 0 . raw ( )
435413 }
436414}
437415
438- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
439416impl FromRawFd for UnixStream {
440417 unsafe fn from_raw_fd ( fd : RawFd ) -> UnixStream {
441418 UnixStream ( FileDesc :: new ( fd) )
442419 }
443420}
444421
445- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
446422impl IntoRawFd for UnixStream {
447423 fn into_raw_fd ( self ) -> RawFd {
448424 self . 0 . into_raw ( )
@@ -477,10 +453,8 @@ impl IntoRawFd for UnixStream {
477453/// }
478454/// }
479455/// ```
480- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
481456pub struct UnixListener ( FileDesc ) ;
482457
483- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
484458impl fmt:: Debug for UnixListener {
485459 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
486460 let mut builder = fmt. debug_struct ( "UnixListener" ) ;
@@ -508,7 +482,6 @@ impl UnixListener {
508482 /// }
509483 /// };
510484 /// ```
511- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
512485 pub fn bind < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixListener > {
513486 if let Some ( s) = path. as_ref ( ) . to_str ( ) {
514487 cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
@@ -542,7 +515,6 @@ impl UnixListener {
542515 /// Err(e) => println!("accept function failed: {:?}", e),
543516 /// }
544517 /// ```
545- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
546518 pub fn accept ( & self ) -> io:: Result < ( UnixStream , SocketAddr ) > {
547519 self . 0 . duplicate_path ( b"listen" ) . map ( |fd| ( UnixStream ( fd) , SocketAddr ) )
548520 }
@@ -562,7 +534,6 @@ impl UnixListener {
562534 ///
563535 /// let listener_copy = listener.try_clone().expect("try_clone failed");
564536 /// ```
565- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
566537 pub fn try_clone ( & self ) -> io:: Result < UnixListener > {
567538 self . 0 . duplicate ( ) . map ( UnixListener )
568539 }
@@ -578,7 +549,6 @@ impl UnixListener {
578549 ///
579550 /// let addr = listener.local_addr().expect("Couldn't get local address");
580551 /// ```
581- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
582552 pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
583553 Err ( Error :: new ( ErrorKind :: Other , "UnixListener::local_addr unimplemented on redox" ) )
584554 }
@@ -594,7 +564,6 @@ impl UnixListener {
594564 ///
595565 /// listener.set_nonblocking(true).expect("Couldn't set non blocking");
596566 /// ```
597- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
598567 pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
599568 self . 0 . set_nonblocking ( nonblocking)
600569 }
@@ -612,7 +581,6 @@ impl UnixListener {
612581 /// println!("Got error: {:?}", err);
613582 /// }
614583 /// ```
615- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
616584 pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
617585 Ok ( None )
618586 }
@@ -648,34 +616,29 @@ impl UnixListener {
648616 /// }
649617 /// }
650618 /// ```
651- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
652619 pub fn incoming < ' a > ( & ' a self ) -> Incoming < ' a > {
653620 Incoming { listener : self }
654621 }
655622}
656623
657- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
658624impl AsRawFd for UnixListener {
659625 fn as_raw_fd ( & self ) -> RawFd {
660626 self . 0 . raw ( )
661627 }
662628}
663629
664- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
665630impl FromRawFd for UnixListener {
666631 unsafe fn from_raw_fd ( fd : RawFd ) -> UnixListener {
667632 UnixListener ( FileDesc :: new ( fd) )
668633 }
669634}
670635
671- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
672636impl IntoRawFd for UnixListener {
673637 fn into_raw_fd ( self ) -> RawFd {
674638 self . 0 . into_raw ( )
675639 }
676640}
677641
678- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
679642impl < ' a > IntoIterator for & ' a UnixListener {
680643 type Item = io:: Result < UnixStream > ;
681644 type IntoIter = Incoming < ' a > ;
@@ -716,12 +679,10 @@ impl<'a> IntoIterator for &'a UnixListener {
716679/// }
717680/// ```
718681#[ derive( Debug ) ]
719- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
720682pub struct Incoming < ' a > {
721683 listener : & ' a UnixListener ,
722684}
723685
724- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
725686impl < ' a > Iterator for Incoming < ' a > {
726687 type Item = io:: Result < UnixStream > ;
727688
0 commit comments