Implement ability to disable trust-dns in ClientBuilder.

This commit is contained in:
daxpedda
2020-02-28 15:47:29 +01:00
committed by Sean McArthur
parent d2fc485d11
commit c1c2b9dd7b
3 changed files with 147 additions and 22 deletions

View File

@@ -481,6 +481,27 @@ impl ClientBuilder {
self.with_inner(move |inner| inner.use_preconfigured_tls(tls))
}
/// Enables the [trust-dns](trust_dns_resolver) async resolver instead of a default threadpool using `getaddrinfo`.
///
/// If the `trust-dns` feature is turned on, the default option is enabled.
///
/// # Optional
///
/// This requires the optional `trust-dns` feature to be enabled
#[cfg(feature = "trust-dns")]
pub fn trust_dns(self, enable: bool) -> ClientBuilder {
self.with_inner(|inner| inner.trust_dns(enable))
}
/// Disables the trust-dns async resolver.
///
/// This method exists even if the optional `trust-dns` feature is not enabled.
/// This can be used to ensure a `Client` doesn't use the trust-dns async resolver
/// even if another dependency were to enable the optional `trust-dns` feature.
pub fn no_trust_dns(self) -> ClientBuilder {
self.with_inner(|inner| inner.no_trust_dns())
}
// private
fn with_inner<F>(mut self, func: F) -> ClientBuilder