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:
		| @@ -14,6 +14,7 @@ autotests = true | |||||||
|  |  | ||||||
| [package.metadata.docs.rs] | [package.metadata.docs.rs] | ||||||
| all-features = true | all-features = true | ||||||
|  | rustdoc-args = ["--cfg", "docsrs"] | ||||||
| targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] | targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] | ||||||
|  |  | ||||||
| [package.metadata.playground] | [package.metadata.playground] | ||||||
|   | |||||||
| @@ -461,6 +461,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `cookies` feature to be enabled. |     /// This requires the optional `cookies` feature to be enabled. | ||||||
|     #[cfg(feature = "cookies")] |     #[cfg(feature = "cookies")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "cookies")))] | ||||||
|     pub fn cookie_store(mut self, enable: bool) -> ClientBuilder { |     pub fn cookie_store(mut self, enable: bool) -> ClientBuilder { | ||||||
|         self.config.cookie_store = if enable { |         self.config.cookie_store = if enable { | ||||||
|             Some(cookie::CookieStore::default()) |             Some(cookie::CookieStore::default()) | ||||||
| @@ -487,6 +488,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `gzip` feature to be enabled |     /// This requires the optional `gzip` feature to be enabled | ||||||
|     #[cfg(feature = "gzip")] |     #[cfg(feature = "gzip")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "gzip")))] | ||||||
|     pub fn gzip(mut self, enable: bool) -> ClientBuilder { |     pub fn gzip(mut self, enable: bool) -> ClientBuilder { | ||||||
|         self.config.accepts.gzip = enable; |         self.config.accepts.gzip = enable; | ||||||
|         self |         self | ||||||
| @@ -509,6 +511,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `brotli` feature to be enabled |     /// This requires the optional `brotli` feature to be enabled | ||||||
|     #[cfg(feature = "brotli")] |     #[cfg(feature = "brotli")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "brotli")))] | ||||||
|     pub fn brotli(mut self, enable: bool) -> ClientBuilder { |     pub fn brotli(mut self, enable: bool) -> ClientBuilder { | ||||||
|         self.config.accepts.brotli = enable; |         self.config.accepts.brotli = enable; | ||||||
|         self |         self | ||||||
| @@ -729,6 +732,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` |     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||||
|     /// feature to be enabled. |     /// feature to be enabled. | ||||||
|     #[cfg(feature = "__tls")] |     #[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 { |     pub fn add_root_certificate(mut self, cert: Certificate) -> ClientBuilder { | ||||||
|         self.config.root_certs.push(cert); |         self.config.root_certs.push(cert); | ||||||
|         self |         self | ||||||
| @@ -743,6 +747,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` |     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||||
|     /// feature to be enabled. |     /// feature to be enabled. | ||||||
|     #[cfg(feature = "__tls")] |     #[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( |     pub fn tls_built_in_root_certs( | ||||||
|         mut self, |         mut self, | ||||||
|         tls_built_in_root_certs: bool, |         tls_built_in_root_certs: bool, | ||||||
| @@ -758,6 +763,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be |     /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be | ||||||
|     /// enabled. |     /// enabled. | ||||||
|     #[cfg(any(feature = "native-tls", feature = "__rustls"))] |     #[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 { |     pub fn identity(mut self, identity: Identity) -> ClientBuilder { | ||||||
|         self.config.identity = Some(identity); |         self.config.identity = Some(identity); | ||||||
|         self |         self | ||||||
| @@ -778,6 +784,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `native-tls` feature to be enabled. |     /// This requires the optional `native-tls` feature to be enabled. | ||||||
|     #[cfg(feature = "native-tls")] |     #[cfg(feature = "native-tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||||
|     pub fn danger_accept_invalid_hostnames( |     pub fn danger_accept_invalid_hostnames( | ||||||
|         mut self, |         mut self, | ||||||
|         accept_invalid_hostname: bool, |         accept_invalid_hostname: bool, | ||||||
| @@ -803,6 +810,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` |     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||||
|     /// feature to be enabled. |     /// feature to be enabled. | ||||||
|     #[cfg(feature = "__tls")] |     #[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 { |     pub fn danger_accept_invalid_certs(mut self, accept_invalid_certs: bool) -> ClientBuilder { | ||||||
|         self.config.certs_verification = !accept_invalid_certs; |         self.config.certs_verification = !accept_invalid_certs; | ||||||
|         self |         self | ||||||
| @@ -817,6 +825,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `native-tls` feature to be enabled. |     /// This requires the optional `native-tls` feature to be enabled. | ||||||
|     #[cfg(feature = "native-tls")] |     #[cfg(feature = "native-tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||||
|     pub fn use_native_tls(mut self) -> ClientBuilder { |     pub fn use_native_tls(mut self) -> ClientBuilder { | ||||||
|         self.config.tls = TlsBackend::Default; |         self.config.tls = TlsBackend::Default; | ||||||
|         self |         self | ||||||
| @@ -831,6 +840,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `rustls-tls(-...)` feature to be enabled. |     /// This requires the optional `rustls-tls(-...)` feature to be enabled. | ||||||
|     #[cfg(feature = "__rustls")] |     #[cfg(feature = "__rustls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))] | ||||||
|     pub fn use_rustls_tls(mut self) -> ClientBuilder { |     pub fn use_rustls_tls(mut self) -> ClientBuilder { | ||||||
|         self.config.tls = TlsBackend::Rustls; |         self.config.tls = TlsBackend::Rustls; | ||||||
|         self |         self | ||||||
| @@ -858,6 +868,7 @@ impl ClientBuilder { | |||||||
|         feature = "native-tls", |         feature = "native-tls", | ||||||
|         feature = "__rustls", |         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 { |     pub fn use_preconfigured_tls(mut self, tls: impl Any) -> ClientBuilder { | ||||||
|         let mut tls = Some(tls); |         let mut tls = Some(tls); | ||||||
|         #[cfg(feature = "native-tls")] |         #[cfg(feature = "native-tls")] | ||||||
| @@ -893,6 +904,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `trust-dns` feature to be enabled |     /// This requires the optional `trust-dns` feature to be enabled | ||||||
|     #[cfg(feature = "trust-dns")] |     #[cfg(feature = "trust-dns")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "trust-dns")))] | ||||||
|     pub fn trust_dns(mut self, enable: bool) -> ClientBuilder { |     pub fn trust_dns(mut self, enable: bool) -> ClientBuilder { | ||||||
|         self.config.trust_dns = enable; |         self.config.trust_dns = enable; | ||||||
|         self |         self | ||||||
|   | |||||||
| @@ -264,6 +264,7 @@ impl RequestBuilder { | |||||||
|     /// # } |     /// # } | ||||||
|     /// ``` |     /// ``` | ||||||
|     #[cfg(feature = "multipart")] |     #[cfg(feature = "multipart")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "multipart")))] | ||||||
|     pub fn multipart(self, mut multipart: multipart::Form) -> RequestBuilder { |     pub fn multipart(self, mut multipart: multipart::Form) -> RequestBuilder { | ||||||
|         let mut builder = self.header( |         let mut builder = self.header( | ||||||
|             CONTENT_TYPE, |             CONTENT_TYPE, | ||||||
| @@ -353,6 +354,7 @@ impl RequestBuilder { | |||||||
|     /// Serialization can fail if `T`'s implementation of `Serialize` decides to |     /// Serialization can fail if `T`'s implementation of `Serialize` decides to | ||||||
|     /// fail, or if `T` contains a map with non-string keys. |     /// fail, or if `T` contains a map with non-string keys. | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { |     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { | ||||||
|         let mut error = None; |         let mut error = None; | ||||||
|         if let Ok(ref mut req) = self.request { |         if let Ok(ref mut req) = self.request { | ||||||
|   | |||||||
| @@ -103,6 +103,7 @@ impl Response { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `cookies` feature to be enabled. |     /// This requires the optional `cookies` feature to be enabled. | ||||||
|     #[cfg(feature = "cookies")] |     #[cfg(feature = "cookies")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "cookies")))] | ||||||
|     pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a { |     pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a { | ||||||
|         cookie::extract_response_cookies(&self.headers).filter_map(Result::ok) |         cookie::extract_response_cookies(&self.headers).filter_map(Result::ok) | ||||||
|     } |     } | ||||||
| @@ -236,6 +237,7 @@ impl Response { | |||||||
|     /// |     /// | ||||||
|     /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html |     /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     pub async fn json<T: DeserializeOwned>(self) -> crate::Result<T> { |     pub async fn json<T: DeserializeOwned>(self) -> crate::Result<T> { | ||||||
|         let full = self.bytes().await?; |         let full = self.bytes().await?; | ||||||
|  |  | ||||||
| @@ -308,6 +310,7 @@ impl Response { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `stream` feature to be enabled. |     /// This requires the optional `stream` feature to be enabled. | ||||||
|     #[cfg(feature = "stream")] |     #[cfg(feature = "stream")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "stream")))] | ||||||
|     pub fn bytes_stream(self) -> impl futures_core::Stream<Item = crate::Result<Bytes>> { |     pub fn bytes_stream(self) -> impl futures_core::Stream<Item = crate::Result<Bytes>> { | ||||||
|         self.body |         self.body | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -194,6 +194,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `cookies` feature to be enabled. |     /// This requires the optional `cookies` feature to be enabled. | ||||||
|     #[cfg(feature = "cookies")] |     #[cfg(feature = "cookies")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "cookies")))] | ||||||
|     pub fn cookie_store(self, enable: bool) -> ClientBuilder { |     pub fn cookie_store(self, enable: bool) -> ClientBuilder { | ||||||
|         self.with_inner(|inner| inner.cookie_store(enable)) |         self.with_inner(|inner| inner.cookie_store(enable)) | ||||||
|     } |     } | ||||||
| @@ -215,6 +216,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `gzip` feature to be enabled |     /// This requires the optional `gzip` feature to be enabled | ||||||
|     #[cfg(feature = "gzip")] |     #[cfg(feature = "gzip")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "gzip")))] | ||||||
|     pub fn gzip(self, enable: bool) -> ClientBuilder { |     pub fn gzip(self, enable: bool) -> ClientBuilder { | ||||||
|         self.with_inner(|inner| inner.gzip(enable)) |         self.with_inner(|inner| inner.gzip(enable)) | ||||||
|     } |     } | ||||||
| @@ -236,6 +238,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `brotli` feature to be enabled |     /// This requires the optional `brotli` feature to be enabled | ||||||
|     #[cfg(feature = "brotli")] |     #[cfg(feature = "brotli")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "brotli")))] | ||||||
|     pub fn brotli(self, enable: bool) -> ClientBuilder { self.with_inner(|inner| inner.brotli(enable)) } |     pub fn brotli(self, enable: bool) -> ClientBuilder { self.with_inner(|inner| inner.brotli(enable)) } | ||||||
|  |  | ||||||
|     /// Disable auto response body gzip decompression. |     /// Disable auto response body gzip decompression. | ||||||
| @@ -442,6 +445,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` |     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||||
|     /// feature to be enabled. |     /// feature to be enabled. | ||||||
|     #[cfg(feature = "__tls")] |     #[cfg(feature = "__tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(any(feature = "default-tls", feature = "native-tls", feature = "rustls-tls"))))] | ||||||
|     pub fn add_root_certificate(self, cert: Certificate) -> ClientBuilder { |     pub fn add_root_certificate(self, cert: Certificate) -> ClientBuilder { | ||||||
|         self.with_inner(move |inner| inner.add_root_certificate(cert)) |         self.with_inner(move |inner| inner.add_root_certificate(cert)) | ||||||
|     } |     } | ||||||
| @@ -455,6 +459,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` |     /// This requires the optional `default-tls`, `native-tls`, or `rustls-tls(-...)` | ||||||
|     /// feature to be enabled. |     /// feature to be enabled. | ||||||
|     #[cfg(feature = "__tls")] |     #[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( |     pub fn tls_built_in_root_certs( | ||||||
|         self, |         self, | ||||||
|         tls_built_in_root_certs: bool, |         tls_built_in_root_certs: bool, | ||||||
| @@ -469,6 +474,7 @@ impl ClientBuilder { | |||||||
|     /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be |     /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be | ||||||
|     /// enabled. |     /// enabled. | ||||||
|     #[cfg(any(feature = "native-tls", feature = "__rustls"))] |     #[cfg(any(feature = "native-tls", feature = "__rustls"))] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(any(feature = "native-tls", feature = "rustls-tls"))))] | ||||||
|     pub fn identity(self, identity: Identity) -> ClientBuilder { |     pub fn identity(self, identity: Identity) -> ClientBuilder { | ||||||
|         self.with_inner(move |inner| inner.identity(identity)) |         self.with_inner(move |inner| inner.identity(identity)) | ||||||
|     } |     } | ||||||
| @@ -488,6 +494,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `native-tls` feature to be enabled. |     /// This requires the optional `native-tls` feature to be enabled. | ||||||
|     #[cfg(feature = "native-tls")] |     #[cfg(feature = "native-tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||||
|     pub fn danger_accept_invalid_hostnames(self, accept_invalid_hostname: bool) -> ClientBuilder { |     pub fn danger_accept_invalid_hostnames(self, accept_invalid_hostname: bool) -> ClientBuilder { | ||||||
|         self.with_inner(|inner| inner.danger_accept_invalid_hostnames(accept_invalid_hostname)) |         self.with_inner(|inner| inner.danger_accept_invalid_hostnames(accept_invalid_hostname)) | ||||||
|     } |     } | ||||||
| @@ -504,6 +511,7 @@ impl ClientBuilder { | |||||||
|     /// introduces significant vulnerabilities, and should only be used |     /// introduces significant vulnerabilities, and should only be used | ||||||
|     /// as a last resort. |     /// as a last resort. | ||||||
|     #[cfg(feature = "__tls")] |     #[cfg(feature = "__tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(any(feature = "default-tls", feature = "native-tls", feature = "rustls-tls"))))] | ||||||
|     pub fn danger_accept_invalid_certs(self, accept_invalid_certs: bool) -> ClientBuilder { |     pub fn danger_accept_invalid_certs(self, accept_invalid_certs: bool) -> ClientBuilder { | ||||||
|         self.with_inner(|inner| inner.danger_accept_invalid_certs(accept_invalid_certs)) |         self.with_inner(|inner| inner.danger_accept_invalid_certs(accept_invalid_certs)) | ||||||
|     } |     } | ||||||
| @@ -517,6 +525,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `native-tls` feature to be enabled. |     /// This requires the optional `native-tls` feature to be enabled. | ||||||
|     #[cfg(feature = "native-tls")] |     #[cfg(feature = "native-tls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))] | ||||||
|     pub fn use_native_tls(self) -> ClientBuilder { |     pub fn use_native_tls(self) -> ClientBuilder { | ||||||
|         self.with_inner(move |inner| inner.use_native_tls()) |         self.with_inner(move |inner| inner.use_native_tls()) | ||||||
|     } |     } | ||||||
| @@ -530,6 +539,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `rustls-tls(-...)` feature to be enabled. |     /// This requires the optional `rustls-tls(-...)` feature to be enabled. | ||||||
|     #[cfg(feature = "__rustls")] |     #[cfg(feature = "__rustls")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))] | ||||||
|     pub fn use_rustls_tls(self) -> ClientBuilder { |     pub fn use_rustls_tls(self) -> ClientBuilder { | ||||||
|         self.with_inner(move |inner| inner.use_rustls_tls()) |         self.with_inner(move |inner| inner.use_rustls_tls()) | ||||||
|     } |     } | ||||||
| @@ -556,6 +566,7 @@ impl ClientBuilder { | |||||||
|         feature = "native-tls", |         feature = "native-tls", | ||||||
|         feature = "__rustls", |         feature = "__rustls", | ||||||
|     ))] |     ))] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(any(feature = "native-tls", feature = "rustls-tls"))))] | ||||||
|     pub fn use_preconfigured_tls(self, tls: impl Any) -> ClientBuilder { |     pub fn use_preconfigured_tls(self, tls: impl Any) -> ClientBuilder { | ||||||
|         self.with_inner(move |inner| inner.use_preconfigured_tls(tls)) |         self.with_inner(move |inner| inner.use_preconfigured_tls(tls)) | ||||||
|     } |     } | ||||||
| @@ -568,6 +579,7 @@ impl ClientBuilder { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `trust-dns` feature to be enabled |     /// This requires the optional `trust-dns` feature to be enabled | ||||||
|     #[cfg(feature = "trust-dns")] |     #[cfg(feature = "trust-dns")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "trust-dns")))] | ||||||
|     pub fn trust_dns(self, enable: bool) -> ClientBuilder { |     pub fn trust_dns(self, enable: bool) -> ClientBuilder { | ||||||
|         self.with_inner(|inner| inner.trust_dns(enable)) |         self.with_inner(|inner| inner.trust_dns(enable)) | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -472,6 +472,7 @@ impl RequestBuilder { | |||||||
|     /// Serialization can fail if `T`'s implementation of `Serialize` decides to |     /// Serialization can fail if `T`'s implementation of `Serialize` decides to | ||||||
|     /// fail, or if `T` contains a map with non-string keys. |     /// fail, or if `T` contains a map with non-string keys. | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { |     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { | ||||||
|         let mut error = None; |         let mut error = None; | ||||||
|         if let Ok(ref mut req) = self.request { |         if let Ok(ref mut req) = self.request { | ||||||
| @@ -510,6 +511,7 @@ impl RequestBuilder { | |||||||
|     /// |     /// | ||||||
|     /// See [`multipart`](multipart/) for more examples. |     /// See [`multipart`](multipart/) for more examples. | ||||||
|     #[cfg(feature = "multipart")] |     #[cfg(feature = "multipart")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "multipart")))] | ||||||
|     pub fn multipart(self, mut multipart: multipart::Form) -> RequestBuilder { |     pub fn multipart(self, mut multipart: multipart::Form) -> RequestBuilder { | ||||||
|         let mut builder = self.header( |         let mut builder = self.header( | ||||||
|             CONTENT_TYPE, |             CONTENT_TYPE, | ||||||
|   | |||||||
| @@ -136,6 +136,7 @@ impl Response { | |||||||
|     /// |     /// | ||||||
|     /// This requires the optional `cookies` feature to be enabled. |     /// This requires the optional `cookies` feature to be enabled. | ||||||
|     #[cfg(feature = "cookies")] |     #[cfg(feature = "cookies")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "cookies")))] | ||||||
|     pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a { |     pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a { | ||||||
|         cookie::extract_response_cookies(self.headers()).filter_map(Result::ok) |         cookie::extract_response_cookies(self.headers()).filter_map(Result::ok) | ||||||
|     } |     } | ||||||
| @@ -225,6 +226,7 @@ impl Response { | |||||||
|     /// |     /// | ||||||
|     /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html |     /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     pub fn json<T: DeserializeOwned>(self) -> crate::Result<T> { |     pub fn json<T: DeserializeOwned>(self) -> crate::Result<T> { | ||||||
|         wait::timeout(self.inner.json(), self.timeout).map_err(|e| match e { |         wait::timeout(self.inner.json(), self.timeout).map_err(|e| match e { | ||||||
|             wait::Waited::TimedOut(e) => crate::error::decode(e), |             wait::Waited::TimedOut(e) => crate::error::decode(e), | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| #![deny(missing_docs)] | #![deny(missing_docs)] | ||||||
| #![deny(missing_debug_implementations)] | #![deny(missing_debug_implementations)] | ||||||
|  | #![cfg_attr(docsrs, feature(doc_cfg))] | ||||||
| #![cfg_attr(test, deny(warnings))] | #![cfg_attr(test, deny(warnings))] | ||||||
| #![doc(html_root_url = "https://docs.rs/reqwest/0.11.0")] | #![doc(html_root_url = "https://docs.rs/reqwest/0.11.0")] | ||||||
|  |  | ||||||
|   | |||||||
| @@ -155,6 +155,7 @@ impl RequestBuilder { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     /// Set the request json |     /// Set the request json | ||||||
|     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { |     pub fn json<T: Serialize + ?Sized>(mut self, json: &T) -> RequestBuilder { | ||||||
|         let mut error = None; |         let mut error = None; | ||||||
| @@ -194,6 +195,7 @@ impl RequestBuilder { | |||||||
|  |  | ||||||
|     /// TODO |     /// TODO | ||||||
|     #[cfg(feature = "multipart")] |     #[cfg(feature = "multipart")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "multipart")))] | ||||||
|     pub fn multipart(mut self, multipart: super::multipart::Form) -> RequestBuilder { |     pub fn multipart(mut self, multipart: super::multipart::Form) -> RequestBuilder { | ||||||
|         if let Ok(ref mut req) = self.request { |         if let Ok(ref mut req) = self.request { | ||||||
|             *req.body_mut() = Some(Body::from_form(multipart)) |             *req.body_mut() = Some(Body::from_form(multipart)) | ||||||
|   | |||||||
| @@ -77,6 +77,7 @@ impl Response { | |||||||
|  |  | ||||||
|     /// Try to deserialize the response body as JSON. |     /// Try to deserialize the response body as JSON. | ||||||
|     #[cfg(feature = "json")] |     #[cfg(feature = "json")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "json")))] | ||||||
|     pub async fn json<T: DeserializeOwned>(self) -> crate::Result<T> { |     pub async fn json<T: DeserializeOwned>(self) -> crate::Result<T> { | ||||||
|         let full = self.bytes().await?; |         let full = self.bytes().await?; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user