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