Expand description
A safe wrapper for the c-ares library.
If your c-ares is sufficiently recent (version 1.26+) and built with thread safety, it should
be quite ergonomic to use this crate directly. See the
event_thread
example.
Otherwise, you will need to manage your own event loop. You may prefer the
c-ares-resolver crate, which does that for you.
That crate also offers a variety of resolvers: using callbacks, using futures, or blocking.
Direct usage without the event thread requires you to pay attention to c-ares as it tells you
which file descriptors it cares about, and to poll for activity on those file descriptors:
-
Create a
Channel. -
Make queries on the
Channel. Queries all take callbacks, which will be called when the query completes. -
Have
c-arestell you what file descriptors to listen on for read and / or write events. You can do this either by providing a callback, which is called whenever the set of interesting file descriptors changes, or by querying theChanneldirectly either withsockets()or withfds(). -
Do as
c-aresasks. That is, listen for the events that it requests, on the file descriptors that it cares about. -
When a file descriptor becomes readable or writable, call either
process_fd()orprocess()on theChannelto tellc-areswhat has happened. -
If you have queries pending and don’t see events happening, you still need to call either
process_fd()orprocess()at some point anyway - to givec-aresan opportunity to process any requests that have timed out.
Structs§
- AAAA
Result - The contents of a single AAAA record.
- AAAA
Results - The result of a successful AAAA lookup.
- AAAA
Results Iter - Iterator of
AAAAResults. - ARecord
- Typed view of an
Arecord. - AResult
- The contents of a single A record.
- AResults
- The result of a successful A lookup.
- AResults
Iter - Iterator of
AResults. - Aaaa
Record - Typed view of an
AAAArecord. - Addr
InfoC Name - A single CNAME record from an
AddrInfoResults. - Addr
InfoC Name Iter - Iterator over the CNAME chain in an
AddrInfoResults. - Addr
Info Flags - Flags that may be passed in
AddrInfoHints. - Addr
Info Hints - Hints for an
ares_getaddrinfo()call, controlling the returned results. - Addr
Info Node - A single address node from an
AddrInfoResults. - Addr
Info Node Iter - Iterator over the address nodes in an
AddrInfoResults. - Addr
Info Results - The result of a successful
get_addrinfo()call. - AresBuf
- A smart pointer wrapping a byte buffer as allocated by c-ares.
- Ares
String - A smart pointer wrapping a string as allocated by c-ares.
- CAAResult
- The contents of a single CAA record.
- CAAResults
- The result of a successful CAA lookup.
- CAAResults
Iter - Iterator of
CAAResults. - CName
Results - The result of a successful CNAME lookup.
- CaaRecord
- Typed view of a
CAArecord. - Channel
- A channel for name service lookups.
- Cname
Record - Typed view of a
CNAMErecord. - DnsFlags
- DNS message header flags.
- DnsParse
Flags - Flags controlling DNS message parsing behaviour.
- DnsRecord
- An owned DNS record (message), wrapping
ares_dns_record_t. - DnsRr
- A view of a DNS resource record, wrapping
ares_dns_rr_t. - FdEvent
Flags - Events used by FdEvents.
- FdEvents
- Type holding a file descriptor and mask of events, used by
crate::Channel::process_fds(). - Flags
- Flags that may be passed when initializing a
Channel. - Hinfo
Record - Typed view of an
HINFOrecord. - Host
Address Results Iter - Iterator of
IpAddrs. - Host
Alias Results Iter - Iterator of
&'a strs. - Host
Results - The result of a host lookup, wrapping a C
hostent. - Https
Record - Typed view of an
HTTPSrecord. - MXResult
- The contents of a single MX record.
- MXResults
- The result of a successful MX lookup.
- MXResults
Iter - Iterator of
MXResults. - MxRecord
- Typed view of an
MXrecord. - NAPTR
Result - The contents of a single NAPTR record.
- NAPTR
Results - The result of a successful NAPTR lookup.
- NAPTR
Results Iter - Iterator of
NAPTRResults. - NIFlags
- Flags that may be provided on a call to
get_name_info(). - NSResults
- The result of a successful NS lookup.
- Name
Info Result - The result of a successful name-info lookup.
- Naptr
Record - Typed view of a
NAPTRrecord. - NsRecord
- Typed view of an
NSrecord. - OptParse
Error - Error returned when an option value cannot be parsed.
- OptRecord
- Typed view of an
OPT(EDNS0) record. - Options
- Used to configure the behaviour of the name resolver.
- PTRResults
- The result of a successful PTR lookup.
- Process
Flags - Flags used by
crate::Channel::process_fds(). - PtrRecord
- Typed view of a
PTRrecord. - RawRr
Record - Typed view of a
RAW_RRrecord. - SOAResult
- The result of a successful SOA lookup.
- SRVResult
- The contents of a single SRV record.
- SRVResults
- The result of a successful SRV lookup.
- SRVResults
Iter - Iterator of
SRVResults. - Server
Failover Options - Server failover options.
- Server
State Flags - Flags that may be provided on server state callbacks.
- SigRecord
- Typed view of a
SIGrecord. - SoaRecord
- Typed view of an
SOArecord. - Sockets
- Information about the set of sockets that
c-aresis interested in, as returned bysockets(). - Sockets
Iter - Iterator for sockets of interest to
c-ares. - SrvRecord
- Typed view of an
SRVrecord. - Svcb
Record - Typed view of an
SVCBrecord. - TXTResult
- The contents of a single TXT record.
- TXTResults
- The result of a successful TXT lookup.
- TXTResults
Iter - Iterator of
TXTResults. - Tlsa
Record - Typed view of a
TLSArecord. - TxtRecord
- Typed view of a
TXTrecord. - URIResult
- The contents of a single URI record.
- URIResults
- The result of a successful URI lookup.
- URIResults
Iter - Iterator of
URIResults. - UriRecord
- Typed view of a
URIrecord.
Enums§
- Address
Family - Address families.
- DnsCls
- DNS classes for requests and responses.
- DnsData
Type - Data types for DNS resource record fields.
- DnsOpcode
- DNS header opcodes.
- DnsOpt
Data Type - Data type for option records for keys like
OPT_OPTIONSandHTTPS_PARAMS. - DnsRcode
- DNS response codes.
- DnsRecord
Type - DNS record types handled by c-ares.
- DnsRr
Key - DNS resource record field keys.
- DnsSection
- DNS message sections.
- Error
- Error codes that the library might return.
- Event
Sys - Event system to use for the c-ares built-in event thread.
- OptValue
- A parsed DNS option value.
- TypedRr
- Match-friendly enumeration of every typed record view.
Constants§
- SOCKET_
BAD - An invalid socket / file descriptor. Use this to represent ‘no action’ when calling
process_fd()on a channel.
Functions§
- expand_
name - Expand a DNS-encoded domain name from a DNS message.
- expand_
string - Expand a single DNS-encoded string from a DNS message.
- parse_
opt_ value - Parse a raw option value according to its datatype.
- thread_
safety - Whether the underlying
c-areslibrary was built with thread safety enabled or not. - version
- Get the version number of the underlying
c-areslibrary.