@@ -9,6 +9,8 @@ use std::time::Duration;
99use bufstream:: BufStream ;
1010#[ cfg( feature = "unix_socket" ) ]
1111use unix_socket:: UnixStream ;
12+ #[ cfg( all( not( feature = "unix_socket" ) , feature = "nightly" ) ) ]
13+ use std:: os:: unix:: net:: UnixStream ;
1214#[ cfg( unix) ]
1315use std:: os:: unix:: io:: { AsRawFd , RawFd } ;
1416#[ cfg( windows) ]
@@ -32,15 +34,15 @@ impl StreamOptions for BufStream<Box<StreamWrapper>> {
3234 fn set_read_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
3335 match self . get_ref ( ) . get_ref ( ) . 0 {
3436 InternalStream :: Tcp ( ref s) => s. set_read_timeout ( timeout) ,
35- #[ cfg( feature = "unix_socket" ) ]
37+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
3638 InternalStream :: Unix ( ref s) => s. set_read_timeout ( timeout) ,
3739 }
3840 }
3941
4042 fn set_nonblocking ( & self , nonblock : bool ) -> io:: Result < ( ) > {
4143 match self . get_ref ( ) . get_ref ( ) . 0 {
4244 InternalStream :: Tcp ( ref s) => s. set_nonblocking ( nonblock) ,
43- #[ cfg( feature = "unix_socket" ) ]
45+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
4446 InternalStream :: Unix ( ref s) => s. set_nonblocking ( nonblock) ,
4547 }
4648 }
@@ -56,7 +58,7 @@ impl fmt::Debug for Stream {
5658 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
5759 match self . 0 {
5860 InternalStream :: Tcp ( ref s) => fmt:: Debug :: fmt ( s, fmt) ,
59- #[ cfg( feature = "unix_socket" ) ]
61+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
6062 InternalStream :: Unix ( ref s) => fmt:: Debug :: fmt ( s, fmt) ,
6163 }
6264 }
@@ -93,7 +95,7 @@ impl AsRawFd for Stream {
9395 fn as_raw_fd ( & self ) -> RawFd {
9496 match self . 0 {
9597 InternalStream :: Tcp ( ref s) => s. as_raw_fd ( ) ,
96- #[ cfg( feature = "unix_socket" ) ]
98+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
9799 InternalStream :: Unix ( ref s) => s. as_raw_fd ( ) ,
98100 }
99101 }
@@ -111,15 +113,15 @@ impl AsRawSocket for Stream {
111113
112114enum InternalStream {
113115 Tcp ( TcpStream ) ,
114- #[ cfg( feature = "unix_socket" ) ]
116+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
115117 Unix ( UnixStream ) ,
116118}
117119
118120impl Read for InternalStream {
119121 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
120122 match * self {
121123 InternalStream :: Tcp ( ref mut s) => s. read ( buf) ,
122- #[ cfg( feature = "unix_socket" ) ]
124+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
123125 InternalStream :: Unix ( ref mut s) => s. read ( buf) ,
124126 }
125127 }
@@ -129,15 +131,15 @@ impl Write for InternalStream {
129131 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
130132 match * self {
131133 InternalStream :: Tcp ( ref mut s) => s. write ( buf) ,
132- #[ cfg( feature = "unix_socket" ) ]
134+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
133135 InternalStream :: Unix ( ref mut s) => s. write ( buf) ,
134136 }
135137 }
136138
137139 fn flush ( & mut self ) -> io:: Result < ( ) > {
138140 match * self {
139141 InternalStream :: Tcp ( ref mut s) => s. flush ( ) ,
140- #[ cfg( feature = "unix_socket" ) ]
142+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
141143 InternalStream :: Unix ( ref mut s) => s. flush ( ) ,
142144 }
143145 }
@@ -149,7 +151,7 @@ fn open_socket(params: &ConnectParams) -> Result<InternalStream, ConnectError> {
149151 ConnectTarget :: Tcp ( ref host) => {
150152 Ok ( try!( TcpStream :: connect ( & ( & * * host, port) ) . map ( InternalStream :: Tcp ) ) )
151153 }
152- #[ cfg( feature = "unix_socket" ) ]
154+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
153155 ConnectTarget :: Unix ( ref path) => {
154156 let path = path. join ( & format ! ( ".s.PGSQL.{}" , port) ) ;
155157 Ok ( try!( UnixStream :: connect ( & path) . map ( InternalStream :: Unix ) ) )
@@ -183,7 +185,7 @@ pub fn initialize_stream(params: &ConnectParams,
183185 // Postgres doesn't support SSL over unix sockets
184186 let host = match params. target {
185187 ConnectTarget :: Tcp ( ref host) => host,
186- #[ cfg( feature = "unix_socket" ) ]
188+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
187189 ConnectTarget :: Unix ( _) => return Err ( ConnectError :: Io ( :: bad_response ( ) ) ) ,
188190 } ;
189191
0 commit comments