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

#88 in Asynchronous

Download history 288/week @ 2023-12-15 307/week @ 2023-12-22 451/week @ 2023-12-29 217/week @ 2024-01-05 178/week @ 2024-01-12 241/week @ 2024-01-19 382/week @ 2024-01-26 394/week @ 2024-02-02 229/week @ 2024-02-09 413/week @ 2024-02-16 810/week @ 2024-02-23 497/week @ 2024-03-01 409/week @ 2024-03-08 378/week @ 2024-03-15 480/week @ 2024-03-22 426/week @ 2024-03-29

1,746 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–16MB
~199K SLoC