32 stable releases (8 major)

8.3.0 Feb 23, 2024
8.2.0 Nov 30, 2023
7.6.0 Oct 14, 2023
7.5.0 Jan 29, 2023
0.2.0 Nov 20, 2016

#94 in Asynchronous

Download history 321/week @ 2024-01-24 424/week @ 2024-01-31 259/week @ 2024-02-07 430/week @ 2024-02-14 682/week @ 2024-02-21 542/week @ 2024-02-28 439/week @ 2024-03-06 250/week @ 2024-03-13 482/week @ 2024-03-20 433/week @ 2024-03-27 398/week @ 2024-04-03 397/week @ 2024-04-10 312/week @ 2024-04-17 282/week @ 2024-04-24 318/week @ 2024-05-01 495/week @ 2024-05-08

1,537 downloads per month
Used in 10 crates (4 directly)

MIT license

63KB
1K SLoC

c-ares-resolver

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 underlying c-ares library. It returns answers via callbacks. The other resolvers are built on top of this.
  • The FutureResolver returns answers as std::future::Futures.
  • The BlockingResolver isn't asynchronous at all - as the name suggests, it blocks until the lookup completes.

Crates.io Build Status

Documentation

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.

Examples

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.

Contributing

Contributions are welcome. Please send pull requests!

Dependencies

~5–15MB
~193K SLoC