1
1
use std:: borrow:: Cow ;
2
2
use std:: error;
3
- #[ cfg( all ( feature = "runtime" , unix) ) ]
3
+ #[ cfg( unix) ]
4
4
use std:: ffi:: OsStr ;
5
5
use std:: fmt;
6
6
use std:: iter;
7
7
use std:: mem;
8
- #[ cfg( all ( feature = "runtime" , unix) ) ]
8
+ #[ cfg( unix) ]
9
9
use std:: os:: unix:: ffi:: OsStrExt ;
10
- #[ cfg( all ( feature = "runtime" , unix) ) ]
10
+ #[ cfg( unix) ]
11
11
use std:: path:: { Path , PathBuf } ;
12
12
use std:: str:: { self , FromStr } ;
13
13
use std:: sync:: Arc ;
14
- #[ cfg( feature = "runtime" ) ]
15
14
use std:: time:: Duration ;
16
15
use tokio_io:: { AsyncRead , AsyncWrite } ;
17
16
@@ -26,7 +25,6 @@ use crate::{Error, TlsConnect};
26
25
use crate :: { MakeTlsConnect , Socket } ;
27
26
28
27
/// Properties required of a session.
29
- #[ cfg( feature = "runtime" ) ]
30
28
#[ derive( Debug , Copy , Clone , PartialEq ) ]
31
29
pub enum TargetSessionAttrs {
32
30
/// No special properties are required.
@@ -48,7 +46,6 @@ pub enum SslMode {
48
46
Require ,
49
47
}
50
48
51
- #[ cfg( feature = "runtime" ) ]
52
49
#[ derive( Debug , Clone , PartialEq ) ]
53
50
pub ( crate ) enum Host {
54
51
Tcp ( String ) ,
@@ -64,17 +61,11 @@ pub(crate) struct Inner {
64
61
pub ( crate ) options : Option < String > ,
65
62
pub ( crate ) application_name : Option < String > ,
66
63
pub ( crate ) ssl_mode : SslMode ,
67
- #[ cfg( feature = "runtime" ) ]
68
64
pub ( crate ) host : Vec < Host > ,
69
- #[ cfg( feature = "runtime" ) ]
70
65
pub ( crate ) port : Vec < u16 > ,
71
- #[ cfg( feature = "runtime" ) ]
72
66
pub ( crate ) connect_timeout : Option < Duration > ,
73
- #[ cfg( feature = "runtime" ) ]
74
67
pub ( crate ) keepalives : bool ,
75
- #[ cfg( feature = "runtime" ) ]
76
68
pub ( crate ) keepalives_idle : Duration ,
77
- #[ cfg( feature = "runtime" ) ]
78
69
pub ( crate ) target_session_attrs : TargetSessionAttrs ,
79
70
}
80
71
@@ -170,17 +161,11 @@ impl Config {
170
161
options : None ,
171
162
application_name : None ,
172
163
ssl_mode : SslMode :: Prefer ,
173
- #[ cfg( feature = "runtime" ) ]
174
164
host : vec ! [ ] ,
175
- #[ cfg( feature = "runtime" ) ]
176
165
port : vec ! [ ] ,
177
- #[ cfg( feature = "runtime" ) ]
178
166
connect_timeout : None ,
179
- #[ cfg( feature = "runtime" ) ]
180
167
keepalives : true ,
181
- #[ cfg( feature = "runtime" ) ]
182
168
keepalives_idle : Duration :: from_secs ( 2 * 60 * 60 ) ,
183
- #[ cfg( feature = "runtime" ) ]
184
169
target_session_attrs : TargetSessionAttrs :: Any ,
185
170
} ) )
186
171
}
@@ -234,9 +219,6 @@ impl Config {
234
219
///
235
220
/// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
236
221
/// systems, a host starting with a `/` is interpreted as a path to a directory containing Unix domain sockets.
237
- ///
238
- /// Requires the `runtime` Cargo feature (enabled by default).
239
- #[ cfg( feature = "runtime" ) ]
240
222
pub fn host ( & mut self , host : & str ) -> & mut Config {
241
223
#[ cfg( unix) ]
242
224
{
@@ -254,9 +236,6 @@ impl Config {
254
236
/// Adds a Unix socket host to the configuration.
255
237
///
256
238
/// Unlike `host`, this method allows non-UTF8 paths.
257
- ///
258
- /// Requires the `runtime` Cargo feature (enabled by default) and a Unix target.
259
- #[ cfg( all( feature = "runtime" , unix) ) ]
260
239
pub fn host_path < T > ( & mut self , host : T ) -> & mut Config
261
240
where
262
241
T : AsRef < Path > ,
@@ -272,9 +251,6 @@ impl Config {
272
251
/// Multiple ports can be specified by calling this method multiple times. There must either be no ports, in which
273
252
/// case the default of 5432 is used, a single port, in which it is used for all hosts, or the same number of ports
274
253
/// as hosts.
275
- ///
276
- /// Requires the `runtime` Cargo feature (enabled by default).
277
- #[ cfg( feature = "runtime" ) ]
278
254
pub fn port ( & mut self , port : u16 ) -> & mut Config {
279
255
Arc :: make_mut ( & mut self . 0 ) . port . push ( port) ;
280
256
self
@@ -284,9 +260,6 @@ impl Config {
284
260
///
285
261
/// Note that hostnames can resolve to multiple IP addresses, and this timeout will apply to each address of each
286
262
/// host separately. Defaults to no limit.
287
- ///
288
- /// Requires the `runtime` Cargo feature (enabled by default).
289
- #[ cfg( feature = "runtime" ) ]
290
263
pub fn connect_timeout ( & mut self , connect_timeout : Duration ) -> & mut Config {
291
264
Arc :: make_mut ( & mut self . 0 ) . connect_timeout = Some ( connect_timeout) ;
292
265
self
@@ -295,9 +268,6 @@ impl Config {
295
268
/// Controls the use of TCP keepalive.
296
269
///
297
270
/// This is ignored for Unix domain socket connections. Defaults to `true`.
298
- ///
299
- /// Requires the `runtime` Cargo feature (enabled by default).
300
- #[ cfg( feature = "runtime" ) ]
301
271
pub fn keepalives ( & mut self , keepalives : bool ) -> & mut Config {
302
272
Arc :: make_mut ( & mut self . 0 ) . keepalives = keepalives;
303
273
self
@@ -306,9 +276,6 @@ impl Config {
306
276
/// Sets the amount of idle time before a keepalive packet is sent on the connection.
307
277
///
308
278
/// This is ignored for Unix domain sockets, or if the `keepalives` option is disabled. Defaults to 2 hours.
309
- ///
310
- /// Requires the `runtime` Cargo feature (enabled by default).
311
- #[ cfg( feature = "runtime" ) ]
312
279
pub fn keepalives_idle ( & mut self , keepalives_idle : Duration ) -> & mut Config {
313
280
Arc :: make_mut ( & mut self . 0 ) . keepalives_idle = keepalives_idle;
314
281
self
@@ -318,9 +285,6 @@ impl Config {
318
285
///
319
286
/// This can be used to connect to the primary server in a clustered database rather than one of the read-only
320
287
/// secondary servers. Defaults to `Any`.
321
- ///
322
- /// Requires the `runtime` Cargo feature (enabled by default).
323
- #[ cfg( feature = "runtime" ) ]
324
288
pub fn target_session_attrs (
325
289
& mut self ,
326
290
target_session_attrs : TargetSessionAttrs ,
@@ -355,13 +319,11 @@ impl Config {
355
319
} ;
356
320
self . ssl_mode ( mode) ;
357
321
}
358
- #[ cfg( feature = "runtime" ) ]
359
322
"host" => {
360
323
for host in value. split ( ',' ) {
361
324
self . host ( host) ;
362
325
}
363
326
}
364
- #[ cfg( feature = "runtime" ) ]
365
327
"port" => {
366
328
for port in value. split ( ',' ) {
367
329
let port = if port. is_empty ( ) {
@@ -373,7 +335,6 @@ impl Config {
373
335
self . port ( port) ;
374
336
}
375
337
}
376
- #[ cfg( feature = "runtime" ) ]
377
338
"connect_timeout" => {
378
339
let timeout = value
379
340
. parse :: < i64 > ( )
@@ -382,14 +343,12 @@ impl Config {
382
343
self . connect_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
383
344
}
384
345
}
385
- #[ cfg( feature = "runtime" ) ]
386
346
"keepalives" => {
387
347
let keepalives = value
388
348
. parse :: < u64 > ( )
389
349
. map_err ( |_| Error :: config_parse ( Box :: new ( InvalidValue ( "keepalives" ) ) ) ) ?;
390
350
self . keepalives ( keepalives != 0 ) ;
391
351
}
392
- #[ cfg( feature = "runtime" ) ]
393
352
"keepalives_idle" => {
394
353
let keepalives_idle = value
395
354
. parse :: < i64 > ( )
@@ -398,7 +357,6 @@ impl Config {
398
357
self . keepalives_idle ( Duration :: from_secs ( keepalives_idle as u64 ) ) ;
399
358
}
400
359
}
401
- #[ cfg( feature = "runtime" ) ]
402
360
"target_session_attrs" => {
403
361
let target_session_attrs = match & * value {
404
362
"any" => TargetSessionAttrs :: Any ,
@@ -800,7 +758,7 @@ impl<'a> UrlParser<'a> {
800
758
Ok ( ( ) )
801
759
}
802
760
803
- #[ cfg( all ( feature = "runtime" , unix) ) ]
761
+ #[ cfg( unix) ]
804
762
fn host_param ( & mut self , s : & str ) -> Result < ( ) , Error > {
805
763
let decoded = Cow :: from ( percent_encoding:: percent_decode ( s. as_bytes ( ) ) ) ;
806
764
if decoded. get ( 0 ) == Some ( & b'/' ) {
@@ -813,7 +771,7 @@ impl<'a> UrlParser<'a> {
813
771
Ok ( ( ) )
814
772
}
815
773
816
- #[ cfg( not( all ( feature = "runtime" , unix) ) ) ]
774
+ #[ cfg( not( unix) ) ]
817
775
fn host_param ( & mut self , s : & str ) -> Result < ( ) , Error > {
818
776
let s = self . decode ( s) ?;
819
777
self . config . param ( "host" , & s)
0 commit comments