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
Resolveris the thinnest wrapper around the underlyingc-areslibrary. It returns answers via callbacks. The other resolvers are built on top of this. -
The
FutureResolverreturns answers asstd::future::Futures. -
The
BlockingResolverisn’t asynchronous at all - as the name suggests, it blocks until the lookup completes.
On all resolvers:
-
methods like
query_xxxcorrespond to thec-aresfunctionares_query, which “initiates a single-question DNS query”. -
methods like
search_xxxcorrespond to thec-aresfunctionares_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§
- Blocking
Resolver - A blocking DNS resolver.
- CAres
Future - The type of future returned by methods on the
FutureResolver. - Future
Resolver - An asynchronous DNS resolver, which returns results as
futures::Futures. - Host
Results - An owned version of
c_ares::HostResults. - Name
Info Result - An owned version of
c_ares::NameInfoResult. - Options
- Used to configure the behaviour of the resolver.
- Resolver
- An asynchronous DNS resolver, which returns results via callbacks.
Enums§
- Error
- Error codes that the library might return.