11use std:: borrow:: Cow ;
22use std:: error;
3- #[ cfg( all ( feature = "runtime" , unix) ) ]
3+ #[ cfg( unix) ]
44use std:: ffi:: OsStr ;
55use std:: fmt;
66use std:: iter;
77use std:: mem;
8- #[ cfg( all ( feature = "runtime" , unix) ) ]
8+ #[ cfg( unix) ]
99use std:: os:: unix:: ffi:: OsStrExt ;
10- #[ cfg( all ( feature = "runtime" , unix) ) ]
10+ #[ cfg( unix) ]
1111use std:: path:: { Path , PathBuf } ;
1212use std:: str:: { self , FromStr } ;
1313use std:: sync:: Arc ;
14- #[ cfg( feature = "runtime" ) ]
1514use std:: time:: Duration ;
1615use tokio_io:: { AsyncRead , AsyncWrite } ;
1716
@@ -26,7 +25,6 @@ use crate::{Error, TlsConnect};
2625use crate :: { MakeTlsConnect , Socket } ;
2726
2827/// Properties required of a session.
29- #[ cfg( feature = "runtime" ) ]
3028#[ derive( Debug , Copy , Clone , PartialEq ) ]
3129pub enum TargetSessionAttrs {
3230 /// No special properties are required.
@@ -48,7 +46,6 @@ pub enum SslMode {
4846 Require ,
4947}
5048
51- #[ cfg( feature = "runtime" ) ]
5249#[ derive( Debug , Clone , PartialEq ) ]
5350pub ( crate ) enum Host {
5451 Tcp ( String ) ,
@@ -64,17 +61,11 @@ pub(crate) struct Inner {
6461 pub ( crate ) options : Option < String > ,
6562 pub ( crate ) application_name : Option < String > ,
6663 pub ( crate ) ssl_mode : SslMode ,
67- #[ cfg( feature = "runtime" ) ]
6864 pub ( crate ) host : Vec < Host > ,
69- #[ cfg( feature = "runtime" ) ]
7065 pub ( crate ) port : Vec < u16 > ,
71- #[ cfg( feature = "runtime" ) ]
7266 pub ( crate ) connect_timeout : Option < Duration > ,
73- #[ cfg( feature = "runtime" ) ]
7467 pub ( crate ) keepalives : bool ,
75- #[ cfg( feature = "runtime" ) ]
7668 pub ( crate ) keepalives_idle : Duration ,
77- #[ cfg( feature = "runtime" ) ]
7869 pub ( crate ) target_session_attrs : TargetSessionAttrs ,
7970}
8071
@@ -170,17 +161,11 @@ impl Config {
170161 options : None ,
171162 application_name : None ,
172163 ssl_mode : SslMode :: Prefer ,
173- #[ cfg( feature = "runtime" ) ]
174164 host : vec ! [ ] ,
175- #[ cfg( feature = "runtime" ) ]
176165 port : vec ! [ ] ,
177- #[ cfg( feature = "runtime" ) ]
178166 connect_timeout : None ,
179- #[ cfg( feature = "runtime" ) ]
180167 keepalives : true ,
181- #[ cfg( feature = "runtime" ) ]
182168 keepalives_idle : Duration :: from_secs ( 2 * 60 * 60 ) ,
183- #[ cfg( feature = "runtime" ) ]
184169 target_session_attrs : TargetSessionAttrs :: Any ,
185170 } ) )
186171 }
@@ -234,9 +219,6 @@ impl Config {
234219 ///
235220 /// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
236221 /// 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" ) ]
240222 pub fn host ( & mut self , host : & str ) -> & mut Config {
241223 #[ cfg( unix) ]
242224 {
@@ -254,9 +236,6 @@ impl Config {
254236 /// Adds a Unix socket host to the configuration.
255237 ///
256238 /// 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) ) ]
260239 pub fn host_path < T > ( & mut self , host : T ) -> & mut Config
261240 where
262241 T : AsRef < Path > ,
@@ -272,9 +251,6 @@ impl Config {
272251 /// Multiple ports can be specified by calling this method multiple times. There must either be no ports, in which
273252 /// case the default of 5432 is used, a single port, in which it is used for all hosts, or the same number of ports
274253 /// as hosts.
275- ///
276- /// Requires the `runtime` Cargo feature (enabled by default).
277- #[ cfg( feature = "runtime" ) ]
278254 pub fn port ( & mut self , port : u16 ) -> & mut Config {
279255 Arc :: make_mut ( & mut self . 0 ) . port . push ( port) ;
280256 self
@@ -284,9 +260,6 @@ impl Config {
284260 ///
285261 /// Note that hostnames can resolve to multiple IP addresses, and this timeout will apply to each address of each
286262 /// host separately. Defaults to no limit.
287- ///
288- /// Requires the `runtime` Cargo feature (enabled by default).
289- #[ cfg( feature = "runtime" ) ]
290263 pub fn connect_timeout ( & mut self , connect_timeout : Duration ) -> & mut Config {
291264 Arc :: make_mut ( & mut self . 0 ) . connect_timeout = Some ( connect_timeout) ;
292265 self
@@ -295,9 +268,6 @@ impl Config {
295268 /// Controls the use of TCP keepalive.
296269 ///
297270 /// 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" ) ]
301271 pub fn keepalives ( & mut self , keepalives : bool ) -> & mut Config {
302272 Arc :: make_mut ( & mut self . 0 ) . keepalives = keepalives;
303273 self
@@ -306,9 +276,6 @@ impl Config {
306276 /// Sets the amount of idle time before a keepalive packet is sent on the connection.
307277 ///
308278 /// 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" ) ]
312279 pub fn keepalives_idle ( & mut self , keepalives_idle : Duration ) -> & mut Config {
313280 Arc :: make_mut ( & mut self . 0 ) . keepalives_idle = keepalives_idle;
314281 self
@@ -318,9 +285,6 @@ impl Config {
318285 ///
319286 /// This can be used to connect to the primary server in a clustered database rather than one of the read-only
320287 /// secondary servers. Defaults to `Any`.
321- ///
322- /// Requires the `runtime` Cargo feature (enabled by default).
323- #[ cfg( feature = "runtime" ) ]
324288 pub fn target_session_attrs (
325289 & mut self ,
326290 target_session_attrs : TargetSessionAttrs ,
@@ -355,13 +319,11 @@ impl Config {
355319 } ;
356320 self . ssl_mode ( mode) ;
357321 }
358- #[ cfg( feature = "runtime" ) ]
359322 "host" => {
360323 for host in value. split ( ',' ) {
361324 self . host ( host) ;
362325 }
363326 }
364- #[ cfg( feature = "runtime" ) ]
365327 "port" => {
366328 for port in value. split ( ',' ) {
367329 let port = if port. is_empty ( ) {
@@ -373,7 +335,6 @@ impl Config {
373335 self . port ( port) ;
374336 }
375337 }
376- #[ cfg( feature = "runtime" ) ]
377338 "connect_timeout" => {
378339 let timeout = value
379340 . parse :: < i64 > ( )
@@ -382,14 +343,12 @@ impl Config {
382343 self . connect_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
383344 }
384345 }
385- #[ cfg( feature = "runtime" ) ]
386346 "keepalives" => {
387347 let keepalives = value
388348 . parse :: < u64 > ( )
389349 . map_err ( |_| Error :: config_parse ( Box :: new ( InvalidValue ( "keepalives" ) ) ) ) ?;
390350 self . keepalives ( keepalives != 0 ) ;
391351 }
392- #[ cfg( feature = "runtime" ) ]
393352 "keepalives_idle" => {
394353 let keepalives_idle = value
395354 . parse :: < i64 > ( )
@@ -398,7 +357,6 @@ impl Config {
398357 self . keepalives_idle ( Duration :: from_secs ( keepalives_idle as u64 ) ) ;
399358 }
400359 }
401- #[ cfg( feature = "runtime" ) ]
402360 "target_session_attrs" => {
403361 let target_session_attrs = match & * value {
404362 "any" => TargetSessionAttrs :: Any ,
@@ -800,7 +758,7 @@ impl<'a> UrlParser<'a> {
800758 Ok ( ( ) )
801759 }
802760
803- #[ cfg( all ( feature = "runtime" , unix) ) ]
761+ #[ cfg( unix) ]
804762 fn host_param ( & mut self , s : & str ) -> Result < ( ) , Error > {
805763 let decoded = Cow :: from ( percent_encoding:: percent_decode ( s. as_bytes ( ) ) ) ;
806764 if decoded. get ( 0 ) == Some ( & b'/' ) {
@@ -813,7 +771,7 @@ impl<'a> UrlParser<'a> {
813771 Ok ( ( ) )
814772 }
815773
816- #[ cfg( not( all ( feature = "runtime" , unix) ) ) ]
774+ #[ cfg( not( unix) ) ]
817775 fn host_param ( & mut self , s : & str ) -> Result < ( ) , Error > {
818776 let s = self . decode ( s) ?;
819777 self . config . param ( "host" , & s)
0 commit comments