Crates.io | c-ares-resolver |
lib.rs | c-ares-resolver |
version | 10.1.0 |
source | src |
created_at | 2016-10-17 13:59:01.936665 |
updated_at | 2024-10-10 19:22:00.903166 |
description | An asynchronous DNS resolver, backed by c-ares. |
homepage | |
repository | https://github.com/dimbleby/c-ares-resolver |
max_upload_size | |
id | 6883 |
size | 88,796 |
DNS resolvers built on c-ares
, for
asynchronous DNS requests.
This crate provides three resolver types - the Resolver
, the FutureResolver
,
and the BlockingResolver
:
Resolver
is the thinnest wrapper around the underlying c-ares
library.
It returns answers via callbacks. The other resolvers are built on top of
this.FutureResolver
returns answers as std::future::Future
s.BlockingResolver
isn't asynchronous at all - as the name suggests, it
blocks until the lookup completes.API documentation is here.
Setting the feature build-cmake
will cause the c-ares
library to be built
using cmake
.
This is significantly faster than the default autotools
build on unix
platforms: so if it works for you, you should probably prefer it.
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 example programs can be found here.
Contributions are welcome. Please send pull requests!