mini_c_ares/lib.rs
1//! A safe wrapper for the [`c-ares`](https://c-ares.org) library.
2//!
3//! This crate is a fairly faithful wrapper of `c-ares`; which is to say that it preserves some of
4//! the complexity of using the underlying library. If you just want to make a DNS query, you
5//! should probably prefer the [`c-ares-resolver`](https://crates.io/crates/c-ares-resolver) crate,
6//! which does the hard work for you.
7//!
8//! Direct usage of this crate requires you to pay attention to `c-ares` as it tells you which
9//! file descriptors it cares about, and to poll for activity on those file descriptors.
10//! This likely requires you to have an event loop or similar with which to integrate.
11//!
12//! Still here? Usage of this crate is as follows:
13//!
14//! - Create a `Channel`.
15//!
16//! - Make queries on the `Channel`. Queries all take callbacks, which will be called when the
17//! query completes.
18//!
19//! - Have `c-ares` tell you what file descriptors to listen on for read and / or write events.
20//! You can do this either by providing a callback, which is called whenever the set of interesting
21//! file descriptors changes, or by querying the `Channel` directly either with `get_sock()` or
22//! with `fds()`.
23//!
24//! - Do as `c-ares` asks. That is, listen for the events that it requests, on the file
25//! descriptors that it cares about.
26//!
27//! - When a file descriptor becomes readable or writable, call either `process_fd()` or
28//! `process()` on the `Channel` to tell `c-ares` what has happened.
29//!
30//! - If you have queries pending and don't see events happening, you still need to call either
31//! `process_fd()` or `process()` at some point anyway - to give `c-ares` an opportunity to process
32//! any requests that have timed out.
33//!
34//! Complete examples showing how to use the library can be found
35//! [here](https://github.com/dimbleby/rust-c-ares/tree/main/examples).
36#![deny(missing_docs)]
37
38#[macro_use]
39mod macros;
40mod a;
41mod aaaa;
42mod caa;
43mod channel;
44mod cname;
45mod error;
46mod flags;
47mod host;
48mod hostent;
49mod mx;
50mod nameinfo;
51mod naptr;
52mod ni_flags;
53mod ns;
54mod panic;
55mod ptr;
56mod query;
57mod soa;
58mod srv;
59mod txt;
60mod types;
61mod uri;
62mod utils;
63
64#[cfg(test)]
65mod tests;
66
67// Re-export public interfaces.
68pub use crate::a::{AResult, AResults, AResultsIter};
69pub use crate::aaaa::{AAAAResult, AAAAResults, AAAAResultsIter};
70pub use crate::caa::{CAAResult, CAAResults, CAAResultsIter};
71pub use crate::channel::{Channel, GetSock, GetSockIter, Options};
72pub use crate::cname::CNameResults;
73pub use crate::error::{Error, Result};
74pub use crate::flags::Flags;
75pub use crate::host::HostResults;
76pub use crate::hostent::{HostAddressResultsIter, HostAliasResultsIter};
77pub use crate::mx::{MXResult, MXResults, MXResultsIter};
78pub use crate::nameinfo::NameInfoResult;
79pub use crate::naptr::{NAPTRResult, NAPTRResults, NAPTRResultsIter};
80pub use crate::ni_flags::NIFlags;
81pub use crate::ns::NSResults;
82pub use crate::ptr::PTRResults;
83pub use crate::soa::SOAResult;
84pub use crate::srv::{SRVResult, SRVResults, SRVResultsIter};
85pub use crate::txt::{TXTResult, TXTResults, TXTResultsIter};
86pub use crate::types::{AddressFamily, Socket, SOCKET_BAD};
87pub use crate::uri::{URIResult, URIResults, URIResultsIter};
88pub use crate::utils::version;