Use doc_cfg to show feature requirements (#1134)
				
					
				
			* Use `doc_cfg` to show feature requirements * Apply suggestions from code review
This commit is contained in:
		| @@ -461,6 +461,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `cookies` feature to be enabled. | ||||
|     #[cfg(feature = "cookies")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "cookies")))] | ||||
|     pub fn cookie_store(mut self, enable: bool) -> ClientBuilder { | ||||
|         self.config.cookie_store = if enable { | ||||
|             Some(cookie::CookieStore::default()) | ||||
| @@ -487,6 +488,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `gzip` feature to be enabled | ||||
|     #[cfg(feature = "gzip")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "gzip")))] | ||||
|     pub fn gzip(mut self, enable: bool) -> ClientBuilder { | ||||
|         self.config.accepts.gzip = enable; | ||||
|         self | ||||
| @@ -509,6 +511,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `brotli` feature to be enabled | ||||
|     #[cfg(feature = "brotli")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "brotli")))] | ||||
|     pub fn brotli(mut self, enable: bool) -> ClientBuilder { | ||||
|         self.config.accepts.brotli = enable; | ||||
|         self | ||||
| @@ -729,6 +732,7 @@ impl ClientBuilder { | ||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||
|     /// feature to be enabled. | ||||
|     #[cfg(feature = "__tls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(any(feature = "default-tls", feature = "native-tls", feature = "rustls-tls"))))] | ||||
|     pub fn add_root_certificate(mut self, cert: Certificate) -> ClientBuilder { | ||||
|         self.config.root_certs.push(cert); | ||||
|         self | ||||
| @@ -743,6 +747,7 @@ impl ClientBuilder { | ||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||
|     /// feature to be enabled. | ||||
|     #[cfg(feature = "__tls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(any(feature = "default-tls", feature = "native-tls", feature = "rustls-tls"))))] | ||||
|     pub fn tls_built_in_root_certs( | ||||
|         mut self, | ||||
|         tls_built_in_root_certs: bool, | ||||
| @@ -758,6 +763,7 @@ impl ClientBuilder { | ||||
|     /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be | ||||
|     /// enabled. | ||||
|     #[cfg(any(feature = "native-tls", feature = "__rustls"))] | ||||
|     #[cfg_attr(docsrs, doc(cfg(any(feature = "native-tls", feature = "rustls-tls"))))] | ||||
|     pub fn identity(mut self, identity: Identity) -> ClientBuilder { | ||||
|         self.config.identity = Some(identity); | ||||
|         self | ||||
| @@ -778,6 +784,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `native-tls` feature to be enabled. | ||||
|     #[cfg(feature = "native-tls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||
|     pub fn danger_accept_invalid_hostnames( | ||||
|         mut self, | ||||
|         accept_invalid_hostname: bool, | ||||
| @@ -803,6 +810,7 @@ impl ClientBuilder { | ||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||
|     /// feature to be enabled. | ||||
|     #[cfg(feature = "__tls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(any(feature = "default-tls", feature = "native-tls", feature = "rustls-tls"))))] | ||||
|     pub fn danger_accept_invalid_certs(mut self, accept_invalid_certs: bool) -> ClientBuilder { | ||||
|         self.config.certs_verification = !accept_invalid_certs; | ||||
|         self | ||||
| @@ -817,6 +825,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `native-tls` feature to be enabled. | ||||
|     #[cfg(feature = "native-tls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||
|     pub fn use_native_tls(mut self) -> ClientBuilder { | ||||
|         self.config.tls = TlsBackend::Default; | ||||
|         self | ||||
| @@ -831,6 +840,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `rustls-tls(-...)` feature to be enabled. | ||||
|     #[cfg(feature = "__rustls")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))] | ||||
|     pub fn use_rustls_tls(mut self) -> ClientBuilder { | ||||
|         self.config.tls = TlsBackend::Rustls; | ||||
|         self | ||||
| @@ -858,6 +868,7 @@ impl ClientBuilder { | ||||
|         feature = "native-tls", | ||||
|         feature = "__rustls", | ||||
|     ))] | ||||
|     #[cfg_attr(docsrs, doc(cfg(any(feature = "native-tls", feature = "rustls-tls"))))] | ||||
|     pub fn use_preconfigured_tls(mut self, tls: impl Any) -> ClientBuilder { | ||||
|         let mut tls = Some(tls); | ||||
|         #[cfg(feature = "native-tls")] | ||||
| @@ -893,6 +904,7 @@ impl ClientBuilder { | ||||
|     /// | ||||
|     /// This requires the optional `trust-dns` feature to be enabled | ||||
|     #[cfg(feature = "trust-dns")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "trust-dns")))] | ||||
|     pub fn trust_dns(mut self, enable: bool) -> ClientBuilder { | ||||
|         self.config.trust_dns = enable; | ||||
|         self | ||||
|   | ||||
		Reference in New Issue
	
	Block a user