Crate c_ares_resolver[−][src]
Expand description
DNS resolvers built on c-ares
, for asynchronous DNS requests.
This crate provides three resolver types - the Resolver
, the FutureResolver
, and the
BlockingResolver
:
-
The
Resolver
is the thinnest wrapper around the underlyingc-ares
library. It returns answers via callbacks. The other resolvers are built on top of this. -
The
FutureResolver
returns answers asstd::future::Future
s. -
The
BlockingResolver
isn’t asynchronous at all - as the name suggests, it blocks until the lookup completes.
On all resolvers:
-
methods like
query_xxx
correspond to thec-ares
functionares_query
, which “initiates a single-question DNS query”. -
methods like
search_xxx
correspond to thec-ares
functionares_search
, which “initiates a series of single-question DNS queries … using the channel’s search domains as well as a host alias file given by the HOSTALIAS environment variable”.
See c-ares
documentation for more details.
Example
extern crate c_ares_resolver;
extern crate futures_executor;
use futures_executor::block_on;
fn main() {
let resolver = c_ares_resolver::FutureResolver::new().unwrap();
let query = resolver.query_a("google.com");
let response = block_on(query);
match response {
Ok(result) => println!("{}", result),
Err(e) => println!("Lookup failed with error '{}'", e)
}
}
Further examples showing how to use the library can be found here.
Structs
A blocking DNS resolver.
The type of future returned by methods on the FutureResolver
.
An asynchronous DNS resolver, which returns results as futures::Future
s.
An owned version of c_ares::HostResults
.
An owned version of c_ares::NameInfoResult
.
Used to configure the behaviour of the resolver.
An asynchronous DNS resolver, which returns results via callbacks.
Enums
Error codes that the library might return.