@@ -9,6 +9,8 @@ use std::time::Duration;
9
9
use bufstream:: BufStream ;
10
10
#[ cfg( feature = "unix_socket" ) ]
11
11
use unix_socket:: UnixStream ;
12
+ #[ cfg( all( not( feature = "unix_socket" ) , feature = "nightly" ) ) ]
13
+ use std:: os:: unix:: net:: UnixStream ;
12
14
#[ cfg( unix) ]
13
15
use std:: os:: unix:: io:: { AsRawFd , RawFd } ;
14
16
#[ cfg( windows) ]
@@ -32,15 +34,15 @@ impl StreamOptions for BufStream<Box<StreamWrapper>> {
32
34
fn set_read_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
33
35
match self . get_ref ( ) . get_ref ( ) . 0 {
34
36
InternalStream :: Tcp ( ref s) => s. set_read_timeout ( timeout) ,
35
- #[ cfg( feature = "unix_socket" ) ]
37
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
36
38
InternalStream :: Unix ( ref s) => s. set_read_timeout ( timeout) ,
37
39
}
38
40
}
39
41
40
42
fn set_nonblocking ( & self , nonblock : bool ) -> io:: Result < ( ) > {
41
43
match self . get_ref ( ) . get_ref ( ) . 0 {
42
44
InternalStream :: Tcp ( ref s) => s. set_nonblocking ( nonblock) ,
43
- #[ cfg( feature = "unix_socket" ) ]
45
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
44
46
InternalStream :: Unix ( ref s) => s. set_nonblocking ( nonblock) ,
45
47
}
46
48
}
@@ -56,7 +58,7 @@ impl fmt::Debug for Stream {
56
58
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
57
59
match self . 0 {
58
60
InternalStream :: Tcp ( ref s) => fmt:: Debug :: fmt ( s, fmt) ,
59
- #[ cfg( feature = "unix_socket" ) ]
61
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
60
62
InternalStream :: Unix ( ref s) => fmt:: Debug :: fmt ( s, fmt) ,
61
63
}
62
64
}
@@ -93,7 +95,7 @@ impl AsRawFd for Stream {
93
95
fn as_raw_fd ( & self ) -> RawFd {
94
96
match self . 0 {
95
97
InternalStream :: Tcp ( ref s) => s. as_raw_fd ( ) ,
96
- #[ cfg( feature = "unix_socket" ) ]
98
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
97
99
InternalStream :: Unix ( ref s) => s. as_raw_fd ( ) ,
98
100
}
99
101
}
@@ -111,15 +113,15 @@ impl AsRawSocket for Stream {
111
113
112
114
enum InternalStream {
113
115
Tcp ( TcpStream ) ,
114
- #[ cfg( feature = "unix_socket" ) ]
116
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
115
117
Unix ( UnixStream ) ,
116
118
}
117
119
118
120
impl Read for InternalStream {
119
121
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
120
122
match * self {
121
123
InternalStream :: Tcp ( ref mut s) => s. read ( buf) ,
122
- #[ cfg( feature = "unix_socket" ) ]
124
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
123
125
InternalStream :: Unix ( ref mut s) => s. read ( buf) ,
124
126
}
125
127
}
@@ -129,15 +131,15 @@ impl Write for InternalStream {
129
131
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
130
132
match * self {
131
133
InternalStream :: Tcp ( ref mut s) => s. write ( buf) ,
132
- #[ cfg( feature = "unix_socket" ) ]
134
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
133
135
InternalStream :: Unix ( ref mut s) => s. write ( buf) ,
134
136
}
135
137
}
136
138
137
139
fn flush ( & mut self ) -> io:: Result < ( ) > {
138
140
match * self {
139
141
InternalStream :: Tcp ( ref mut s) => s. flush ( ) ,
140
- #[ cfg( feature = "unix_socket" ) ]
142
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
141
143
InternalStream :: Unix ( ref mut s) => s. flush ( ) ,
142
144
}
143
145
}
@@ -149,7 +151,7 @@ fn open_socket(params: &ConnectParams) -> Result<InternalStream, ConnectError> {
149
151
ConnectTarget :: Tcp ( ref host) => {
150
152
Ok ( try!( TcpStream :: connect ( & ( & * * host, port) ) . map ( InternalStream :: Tcp ) ) )
151
153
}
152
- #[ cfg( feature = "unix_socket" ) ]
154
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
153
155
ConnectTarget :: Unix ( ref path) => {
154
156
let path = path. join ( & format ! ( ".s.PGSQL.{}" , port) ) ;
155
157
Ok ( try!( UnixStream :: connect ( & path) . map ( InternalStream :: Unix ) ) )
@@ -183,7 +185,7 @@ pub fn initialize_stream(params: &ConnectParams,
183
185
// Postgres doesn't support SSL over unix sockets
184
186
let host = match params. target {
185
187
ConnectTarget :: Tcp ( ref host) => host,
186
- #[ cfg( feature = "unix_socket" ) ]
188
+ #[ cfg( any ( feature = "unix_socket" , feature = "nightly" ) ) ]
187
189
ConnectTarget :: Unix ( _) => return Err ( ConnectError :: Io ( :: bad_response ( ) ) ) ,
188
190
} ;
189
191
0 commit comments