[][src]Crate hyper_trust_dns_connector

hyper_trust_dns_connector

A crate to make trust-dns-resolver's asynchronous resolver compatible with hyper client, to use instead of the default dns threadpool.

Features

  • hyper-tls-connector This feature includes hyper-tls and native-tls to provide a helper function to create a tls connector.

Usage

trust-dns-resolver creates a background that needs to be spawned on top of an executor to run dns queries. It does not need to be spawned on the same executor as the client, but will deadlock if spawned on top of another executor that runs on the same thread.

Example

extern crate hyper_trust_dns_connector;
extern crate hyper;
extern crate tokio;
 
use hyper_trust_dns_connector::new_async_http_connector;
use hyper::{Client, Body};
use tokio::prelude::Future;
use tokio::runtime::Runtime;
 
let mut rt = Runtime::new().expect("couldn't create runtime");
let (async_http, background) = new_async_http_connector()
    .expect("couldn't create connector");
let client = Client::builder()
    .executor(rt.executor())
    .build::<_, Body>(async_http);
rt.spawn(background);
let status_code = rt
    .block_on(client.get(hyper::Uri::from_static("http://httpbin.org/ip"))
    .map(|res| res.status()))
    .expect("error during the request");
println!("status is {:?}", status_code);

Modules

https

Module to use hyper-tls, needs "hyper-tls-connector" feature enabled

Structs

AsyncHyperResolver

Wrapper around trust-dns-resolver's AsyncResolver

HyperLookupFuture

Wrapper future around trust-dns-resolver's BackgroundLookupIp

Functions

new_async_http_connector

A helper function to create an http connector and a dns task with the default configuration