@@ -30,14 +30,14 @@ use ffi::OsStr;
3030use fmt;
3131use io:: { self , Initializer } ;
3232use mem;
33- use net:: Shutdown ;
33+ use net:: { self , Shutdown } ;
3434use os:: unix:: ffi:: OsStrExt ;
3535use os:: unix:: io:: { RawFd , AsRawFd , FromRawFd , IntoRawFd } ;
3636use path:: Path ;
3737use time:: Duration ;
38- use sys:: cvt;
38+ use sys:: { self , cvt} ;
3939use sys:: net:: Socket ;
40- use sys_common:: { AsInner , FromInner , IntoInner } ;
40+ use sys_common:: { self , AsInner , FromInner , IntoInner } ;
4141
4242#[ cfg( any( target_os = "linux" , target_os = "android" ,
4343 target_os = "dragonfly" , target_os = "freebsd" ,
@@ -588,6 +588,64 @@ impl IntoRawFd for UnixStream {
588588 }
589589}
590590
591+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
592+ impl AsRawFd for net:: TcpStream {
593+ fn as_raw_fd ( & self ) -> RawFd { * self . as_inner ( ) . socket ( ) . as_inner ( ) }
594+ }
595+
596+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
597+ impl AsRawFd for net:: TcpListener {
598+ fn as_raw_fd ( & self ) -> RawFd { * self . as_inner ( ) . socket ( ) . as_inner ( ) }
599+ }
600+
601+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
602+ impl AsRawFd for net:: UdpSocket {
603+ fn as_raw_fd ( & self ) -> RawFd { * self . as_inner ( ) . socket ( ) . as_inner ( ) }
604+ }
605+
606+ #[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
607+ impl FromRawFd for net:: TcpStream {
608+ unsafe fn from_raw_fd ( fd : RawFd ) -> net:: TcpStream {
609+ let socket = sys:: net:: Socket :: from_inner ( fd) ;
610+ net:: TcpStream :: from_inner ( sys_common:: net:: TcpStream :: from_inner ( socket) )
611+ }
612+ }
613+
614+ #[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
615+ impl FromRawFd for net:: TcpListener {
616+ unsafe fn from_raw_fd ( fd : RawFd ) -> net:: TcpListener {
617+ let socket = sys:: net:: Socket :: from_inner ( fd) ;
618+ net:: TcpListener :: from_inner ( sys_common:: net:: TcpListener :: from_inner ( socket) )
619+ }
620+ }
621+
622+ #[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
623+ impl FromRawFd for net:: UdpSocket {
624+ unsafe fn from_raw_fd ( fd : RawFd ) -> net:: UdpSocket {
625+ let socket = sys:: net:: Socket :: from_inner ( fd) ;
626+ net:: UdpSocket :: from_inner ( sys_common:: net:: UdpSocket :: from_inner ( socket) )
627+ }
628+ }
629+
630+ #[ stable( feature = "into_raw_os" , since = "1.4.0" ) ]
631+ impl IntoRawFd for net:: TcpStream {
632+ fn into_raw_fd ( self ) -> RawFd {
633+ self . into_inner ( ) . into_socket ( ) . into_inner ( )
634+ }
635+ }
636+ #[ stable( feature = "into_raw_os" , since = "1.4.0" ) ]
637+ impl IntoRawFd for net:: TcpListener {
638+ fn into_raw_fd ( self ) -> RawFd {
639+ self . into_inner ( ) . into_socket ( ) . into_inner ( )
640+ }
641+ }
642+ #[ stable( feature = "into_raw_os" , since = "1.4.0" ) ]
643+ impl IntoRawFd for net:: UdpSocket {
644+ fn into_raw_fd ( self ) -> RawFd {
645+ self . into_inner ( ) . into_socket ( ) . into_inner ( )
646+ }
647+ }
648+
591649/// A structure representing a Unix domain socket server.
592650///
593651/// # Examples
0 commit comments