99use std:: collections:: { hash_map, HashMap , VecDeque } ;
1010use std:: sync:: { Arc , Mutex } ;
1111
12- #[ cfg( feature = "tokio-rustls" ) ]
12+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
1313use crate :: connection:: tls_config:: { TlsConfig , TlsConfigBuilder } ;
1414use crate :: connection:: AsyncConnection ;
1515use crate :: request:: { OwnedConnectionParams as ConnectionKey , ParsedRequest } ;
1616use crate :: { Error , Request , Response } ;
1717
1818#[ derive( Clone ) ]
1919pub ( crate ) struct ClientConfig {
20- #[ cfg( feature = "tokio-rustls" ) ]
20+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
2121 pub ( crate ) tls : Option < TlsConfig > ,
2222}
2323
2424pub struct ClientBuilder {
2525 capacity : usize ,
26- #[ cfg( feature = "tokio-rustls" ) ]
26+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
2727 tls_config : Option < TlsConfigBuilder > ,
2828}
2929
@@ -48,7 +48,7 @@ impl ClientBuilder {
4848 pub fn new ( ) -> Self {
4949 Self {
5050 capacity : 10 ,
51- #[ cfg( feature = "tokio-rustls" ) ]
51+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
5252 tls_config : None ,
5353 }
5454 }
@@ -59,8 +59,8 @@ impl ClientBuilder {
5959 self
6060 }
6161
62- #[ cfg( feature = "tokio-rustls" ) ]
6362 /// Builds the `Client` with the configured settings.
63+ #[ cfg( any( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
6464 pub fn build ( self ) -> Result < Client , Error > {
6565 let build_config = if let Some ( builder) = self . tls_config {
6666 let tls_config = builder. build ( ) ?;
@@ -81,7 +81,7 @@ impl ClientBuilder {
8181 }
8282
8383 /// Builds the `Client` with the configured settings.
84- #[ cfg( not( feature = "tokio-rustls" ) ) ]
84+ #[ cfg( not( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ) ]
8585 pub fn build ( self ) -> Result < Client , Error > {
8686 Ok ( Client {
8787 r#async : Arc :: new ( Mutex :: new ( ClientImpl {
@@ -111,7 +111,7 @@ impl ClientBuilder {
111111 /// # Ok(())
112112 /// # }
113113 /// ```
114- #[ cfg( feature = "tokio-rustls" ) ]
114+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
115115 pub fn with_root_certificate < T : Into < Vec < u8 > > > ( mut self , cert_der : T ) -> Result < Self , Error > {
116116 let cert_der = cert_der. into ( ) ;
117117 if let Some ( ref mut tls_config) = self . tls_config {
@@ -126,7 +126,7 @@ impl ClientBuilder {
126126
127127 /// Disables default root certificates for TLS connections.
128128 /// Returns [`Error::InvalidTlsConfig`] if TLS has not been configured.
129- #[ cfg( feature = "tokio-rustls" ) ]
129+ #[ cfg( any ( feature = "tokio-rustls" , feature = "tokio-native-tls" ) ) ]
130130 pub fn disable_default_certificates ( mut self ) -> Result < Self , Error > {
131131 match self . tls_config {
132132 Some ( ref mut tls_config) => tls_config. disable_default_certificates ( ) ?,
0 commit comments