1- #![ stable ( feature = "rust1 " , since = "1.0.0 " ) ]
1+ #![ unstable ( feature = "windows_unix_domain_sockets " , issue = "none " ) ]
22
33use core:: mem;
44use core:: time:: Duration ;
@@ -14,10 +14,8 @@ use crate::sys::c::{SO_RCVTIMEO, SO_SNDTIMEO, connect, getpeername, getsockname}
1414use crate :: sys:: cvt;
1515use crate :: sys:: net:: Socket ;
1616
17- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1817pub struct UnixStream ( pub Socket ) ;
1918impl UnixStream {
20- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2119 pub fn connect < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixStream > {
2220 unsafe {
2321 let inner = Socket :: new_unix ( ) ?;
@@ -26,64 +24,50 @@ impl UnixStream {
2624 Ok ( UnixStream ( inner) )
2725 }
2826 }
29- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
30-
3127 pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
3228 SocketAddr :: new ( |addr, len| unsafe { getsockname ( self . 0 . as_raw ( ) as _ , addr, len) } )
3329 }
34- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
3530 pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
3631 SocketAddr :: new ( |addr, len| unsafe { getpeername ( self . 0 . as_raw ( ) as _ , addr, len) } )
3732 }
38- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
3933 pub fn read_timeout ( & self ) -> io:: Result < Option < Duration > > {
4034 self . 0 . timeout ( SO_RCVTIMEO )
4135 }
42- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
4336 pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
4437 self . 0 . set_nonblocking ( nonblocking)
4538 }
46- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
4739 pub fn set_read_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > {
4840 self . 0 . set_timeout ( dur, SO_RCVTIMEO )
4941 }
50- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
5142 pub fn set_write_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > {
5243 self . 0 . set_timeout ( dur, SO_SNDTIMEO )
5344 }
54- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
5545 pub fn shutdown ( & self , how : Shutdown ) -> io:: Result < ( ) > {
5646 self . 0 . shutdown ( how)
5747 }
58- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
5948 pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
6049 self . 0 . take_error ( )
6150 }
62- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
6351 pub fn try_clone ( & self ) -> io:: Result < UnixStream > {
6452 self . 0 . duplicate ( ) . map ( UnixStream )
6553 }
66- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
6754 pub fn write_timeout ( & self ) -> io:: Result < Option < Duration > > {
6855 self . 0 . timeout ( SO_SNDTIMEO )
6956 }
7057}
7158
72- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
7359impl io:: Read for UnixStream {
7460 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
7561 io:: Read :: read ( & mut & * self , buf)
7662 }
7763}
7864
79- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
8065impl < ' a > io:: Read for & ' a UnixStream {
8166 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
8267 self . 0 . read ( buf)
8368 }
8469}
8570
86- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
8771impl io:: Write for UnixStream {
8872 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
8973 io:: Write :: write ( & mut & * self , buf)
@@ -93,7 +77,6 @@ impl io::Write for UnixStream {
9377 io:: Write :: flush ( & mut & * self )
9478 }
9579}
96- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
9780impl < ' a > io:: Write for & ' a UnixStream {
9881 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
9982 self . 0 . write_vectored ( & [ IoSlice :: new ( buf) ] )
@@ -104,28 +87,24 @@ impl<'a> io::Write for &'a UnixStream {
10487 }
10588}
10689
107- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
10890impl AsSocket for UnixStream {
10991 fn as_socket ( & self ) -> BorrowedSocket {
11092 self . 0 . as_socket ( )
11193 }
11294}
11395
114- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
11596impl AsRawSocket for UnixStream {
11697 fn as_raw_socket ( & self ) -> RawSocket {
11798 self . 0 . as_raw_socket ( )
11899 }
119100}
120101
121- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
122102impl FromRawSocket for UnixStream {
123103 unsafe fn from_raw_socket ( sock : RawSocket ) -> Self {
124104 unsafe { UnixStream ( Socket :: from_raw_socket ( sock) ) }
125105 }
126106}
127107
128- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
129108impl IntoRawSocket for UnixStream {
130109 fn into_raw_socket ( self ) -> RawSocket {
131110 let ret = self . 0 . as_raw_socket ( ) ;
0 commit comments