Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
110c3ae
commit bae9f42
Showing
8 changed files
with
200 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use futures_util::future::FutureExt; | ||
use hyper::client::connect::dns::{GaiResolver as HyperGaiResolver, Name}; | ||
use hyper::service::Service; | ||
|
||
use crate::BoxError; | ||
use crate::dns::{Addrs, Resolve, Resolving}; | ||
|
||
#[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) }))) | ||
} | ||
} |
Oops, something went wrong.