pub struct Resolver { /* private fields */ }Expand description
An asynchronous DNS resolver, which returns results via callbacks.
Note that dropping the resolver will cause all outstanding requests to fail with result
c_ares::Error::EDESTRUCTION.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn with_options(options: Options) -> Result<Self, Error>
pub fn with_options(options: Options) -> Result<Self, Error>
Create a new Resolver, with the given Options.
Sourcepub fn set_servers<I, S>(&self, servers: I) -> Result<&Self>
pub fn set_servers<I, S>(&self, servers: I) -> Result<&Self>
Set the list of servers to contact, instead of the servers specified in resolv.conf or the local named.
String format is host[:port]. IPv6 addresses with ports require square brackets eg
[2001:4860:4860::8888]:53.
Sourcepub fn servers(&self) -> Vec<String>
pub fn servers(&self) -> Vec<String>
Retrieves the list of configured servers.
Each entry is in host[:port] format, matching what set_servers
accepts.
Sourcepub fn set_local_ipv4(&self, ipv4: Ipv4Addr) -> &Self
pub fn set_local_ipv4(&self, ipv4: Ipv4Addr) -> &Self
Set the local IPv4 address from which to make queries.
Sourcepub fn set_local_ipv6(&self, ipv6: Ipv6Addr) -> &Self
pub fn set_local_ipv6(&self, ipv6: Ipv6Addr) -> &Self
Set the local IPv6 address from which to make queries.
Sourcepub fn set_local_device(&self, device: &str) -> Result<&Self>
pub fn set_local_device(&self, device: &str) -> Result<&Self>
Set the local device from which to make queries.
Sourcepub fn set_sortlist<I, S>(&self, sortlist: I) -> Result<&Self>
pub fn set_sortlist<I, S>(&self, sortlist: I) -> Result<&Self>
Initializes an address sortlist configuration, so that addresses returned by
get_host_by_name() are sorted according to the sortlist.
Each element of the sortlist holds an IP-address/netmask pair. The netmask is optional but follows the address after a slash if present. For example: “130.155.160.0/255.255.240.0”, or “130.155.0.0”.
Sourcepub fn set_server_state_callback<F>(&self, callback: F) -> &Self
pub fn set_server_state_callback<F>(&self, callback: F) -> &Self
Set a callback function to be invoked whenever a query on the channel completes.
callback(server, success, flags) will be called when a query completes.
serverindicates the DNS server that was used for the query.successindicates whether the query succeeded or not.flagsis a bitmask of flags describing various aspects of the query.
Sourcepub fn query_a<F>(&self, name: &str, handler: F)
pub fn query_a<F>(&self, name: &str, handler: F)
Look up the A records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_a<F>(&self, name: &str, handler: F)
pub fn search_a<F>(&self, name: &str, handler: F)
Search for the A records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_aaaa<F>(&self, name: &str, handler: F)
pub fn query_aaaa<F>(&self, name: &str, handler: F)
Look up the AAAA records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_aaaa<F>(&self, name: &str, handler: F)
pub fn search_aaaa<F>(&self, name: &str, handler: F)
Search for the AAAA records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_caa<F>(&self, name: &str, handler: F)
pub fn query_caa<F>(&self, name: &str, handler: F)
Look up the CAA records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_caa<F>(&self, name: &str, handler: F)
pub fn search_caa<F>(&self, name: &str, handler: F)
Search for the CAA records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_cname<F>(&self, name: &str, handler: F)
pub fn query_cname<F>(&self, name: &str, handler: F)
Look up the CNAME records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_cname<F>(&self, name: &str, handler: F)
pub fn search_cname<F>(&self, name: &str, handler: F)
Search for the CNAME records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_mx<F>(&self, name: &str, handler: F)
pub fn query_mx<F>(&self, name: &str, handler: F)
Look up the MX records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_mx<F>(&self, name: &str, handler: F)
pub fn search_mx<F>(&self, name: &str, handler: F)
Search for the MX records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_naptr<F>(&self, name: &str, handler: F)
pub fn query_naptr<F>(&self, name: &str, handler: F)
Look up the NAPTR records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_naptr<F>(&self, name: &str, handler: F)
pub fn search_naptr<F>(&self, name: &str, handler: F)
Search for the NAPTR records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_ns<F>(&self, name: &str, handler: F)
pub fn query_ns<F>(&self, name: &str, handler: F)
Look up the NS records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_ns<F>(&self, name: &str, handler: F)
pub fn search_ns<F>(&self, name: &str, handler: F)
Search for the NS records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_ptr<F>(&self, name: &str, handler: F)
pub fn query_ptr<F>(&self, name: &str, handler: F)
Look up the PTR records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_ptr<F>(&self, name: &str, handler: F)
pub fn search_ptr<F>(&self, name: &str, handler: F)
Search for the PTR records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_soa<F>(&self, name: &str, handler: F)
pub fn query_soa<F>(&self, name: &str, handler: F)
Look up the SOA record associated with name.
On completion, handler is called with the result.
Sourcepub fn search_soa<F>(&self, name: &str, handler: F)
pub fn search_soa<F>(&self, name: &str, handler: F)
Search for the SOA record associated with name.
On completion, handler is called with the result.
Sourcepub fn query_srv<F>(&self, name: &str, handler: F)
pub fn query_srv<F>(&self, name: &str, handler: F)
Look up the SRV records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_srv<F>(&self, name: &str, handler: F)
pub fn search_srv<F>(&self, name: &str, handler: F)
Search for the SRV records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_txt<F>(&self, name: &str, handler: F)
pub fn query_txt<F>(&self, name: &str, handler: F)
Look up the TXT records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_txt<F>(&self, name: &str, handler: F)
pub fn search_txt<F>(&self, name: &str, handler: F)
Search for the TXT records associated with name.
On completion, handler is called with the result.
Sourcepub fn query_uri<F>(&self, name: &str, handler: F)
pub fn query_uri<F>(&self, name: &str, handler: F)
Look up the URI records associated with name.
On completion, handler is called with the result.
Sourcepub fn search_uri<F>(&self, name: &str, handler: F)
pub fn search_uri<F>(&self, name: &str, handler: F)
Search for the URI records associated with name.
On completion, handler is called with the result.
Sourcepub fn get_host_by_address<F>(&self, address: &IpAddr, handler: F)
pub fn get_host_by_address<F>(&self, address: &IpAddr, handler: F)
Perform a host query by address.
On completion, handler is called with the result.
Sourcepub fn get_host_by_name<F>(&self, name: &str, family: AddressFamily, handler: F)
pub fn get_host_by_name<F>(&self, name: &str, family: AddressFamily, handler: F)
Perform a host query by name.
On completion, handler is called with the result.
Sourcepub fn get_name_info<F>(&self, address: &SocketAddr, flags: NIFlags, handler: F)
pub fn get_name_info<F>(&self, address: &SocketAddr, flags: NIFlags, handler: F)
Address-to-nodename translation in protocol-independent manner.
On completion, handler is called with the result.
Sourcepub fn get_addrinfo<F>(
&self,
name: &str,
service: Option<&str>,
hints: &AddrInfoHints,
handler: F,
)
pub fn get_addrinfo<F>( &self, name: &str, service: Option<&str>, hints: &AddrInfoHints, handler: F, )
Initiate a host query by name and service.
On completion, handler is called with the result.
Sourcepub fn query<F>(&self, name: &str, dns_class: u16, query_type: u16, handler: F)
pub fn query<F>(&self, name: &str, dns_class: u16, query_type: u16, handler: F)
Initiate a single-question DNS query for name. The class and type of the query are per
the provided parameters, taking values as defined in arpa/nameser.h.
On completion, handler is called with the result.
This method is provided so that users can query DNS types for which c-ares does not
provide a parser; or in case a third-party parser is preferred. Usually, if a suitable
query_xxx() is available, that should be used.
Sourcepub fn search<F>(&self, name: &str, dns_class: u16, query_type: u16, handler: F)
pub fn search<F>(&self, name: &str, dns_class: u16, query_type: u16, handler: F)
Initiate a series of single-question DNS queries for name. The class and type of the
query are per the provided parameters, taking values as defined in arpa/nameser.h.
On completion, handler is called with the result.
This method is provided so that users can search DNS types for which c-ares does not
provide a parser; or in case a third-party parser is preferred. Usually, if a suitable
search_xxx() is available, that should be used.
Sourcepub fn send_dnsrec<F>(&self, dnsrec: &DnsRecord, handler: F) -> Result<u16>
pub fn send_dnsrec<F>(&self, dnsrec: &DnsRecord, handler: F) -> Result<u16>
Send a DNS query using a pre-built c_ares::DnsRecord.
On completion, handler is called with the result.
Sourcepub fn query_dnsrec<F>(
&self,
name: &str,
dns_class: DnsCls,
query_type: DnsRecordType,
handler: F,
) -> Result<u16>
pub fn query_dnsrec<F>( &self, name: &str, dns_class: DnsCls, query_type: DnsRecordType, handler: F, ) -> Result<u16>
Initiate a DNS query for name with the given class and type, receiving a parsed
c_ares::DnsRecord in the callback.
Sourcepub fn search_dnsrec<F>(&self, dnsrec: &DnsRecord, handler: F) -> Result<()>
pub fn search_dnsrec<F>(&self, dnsrec: &DnsRecord, handler: F) -> Result<()>
Initiate a series of DNS queries using a pre-built c_ares::DnsRecord, receiving a
parsed c_ares::DnsRecord in the callback.
Sourcepub fn queue_wait_empty(&self, timeout: Option<Duration>) -> Result<()>
pub fn queue_wait_empty(&self, timeout: Option<Duration>) -> Result<()>
Block until notified that there are no longer any queries in queue, or the specified timeout has expired.
Pass None to wait indefinitely.
Sourcepub fn queue_active_queries(&self) -> usize
pub fn queue_active_queries(&self) -> usize
Retrieve the total number of active queries pending answers from servers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resolver
impl RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
impl UnwindSafe for Resolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more