diff options
Diffstat (limited to 'vendor/reqwest/src/dns/gai.rs')
-rw-r--r-- | vendor/reqwest/src/dns/gai.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/reqwest/src/dns/gai.rs b/vendor/reqwest/src/dns/gai.rs new file mode 100644 index 000000000..f32f3b0e0 --- /dev/null +++ b/vendor/reqwest/src/dns/gai.rs @@ -0,0 +1,32 @@ +use futures_util::future::FutureExt; +use hyper::client::connect::dns::{GaiResolver as HyperGaiResolver, Name}; +use hyper::service::Service; + +use crate::dns::{Addrs, Resolve, Resolving}; +use crate::error::BoxError; + +#[derive(Debug)] +pub struct GaiResolver(HyperGaiResolver); + +impl GaiResolver { + pub fn new() -> Self { + Self(HyperGaiResolver::new()) + } +} + +impl Default for GaiResolver { + fn default() -> Self { + GaiResolver::new() + } +} + +impl Resolve for GaiResolver { + fn resolve(&self, name: Name) -> Resolving { + let this = &mut self.0.clone(); + Box::pin(Service::<Name>::call(this, name).map(|result| { + result + .map(|addrs| -> Addrs { Box::new(addrs) }) + .map_err(|err| -> BoxError { Box::new(err) }) + })) + } +} |