pub struct AsyncResolver<C: DnsHandle<Error = ResolveError>, P: ConnectionProvider<Conn = C>> { /* private fields */ }
Expand description

An asynchronous resolver for DNS generic over async Runtimes.

Creating a AsyncResolver returns a new handle and a future that should be spawned on an executor to drive the background work. The lookup methods on AsyncResolver request lookups from the background task.

The futures returned by a AsyncResolver and the corresponding background task need not be spawned on the same executor, or be in the same thread. Additionally, one background task may have any number of handles; calling clone() on a handle will create a new handle linked to the same background task.

NOTE If lookup futures returned by a AsyncResolver and the background future are spawned on two separate CurrentThread executors, one thread cannot run both executors simultaneously, so the run or block_on functions will cause the thread to deadlock. If both the background work and the lookup futures are intended to be run on the same thread, they should be spawned on the same executor.

The background task manages the name server pool and other state used to drive lookups. When this future is spawned on an executor, it will first construct and configure the necessary client state, before checking for any incoming lookup requests, handling them, and yielding. It will continue to do so as long as there are still any AsyncResolver handle linked to it. When all of its AsyncResolvers have been dropped, the background future will finish.

Implementations

This is supported on crate feature tokio-runtime only.

Construct a new Tokio based AsyncResolver with the provided configuration.

Arguments
  • config - configuration, name_servers, etc. for the Resolver
  • options - basic lookup options for the resolver
Returns

A tuple containing the new AsyncResolver and a future that drives the background task that runs resolutions for the AsyncResolver. See the documentation for AsyncResolver for more information on how to use the background future.

This is supported on crate feature system-config and (Unix or Windows) and crate feature tokio-runtime only.

Constructs a new Tokio based Resolver with the system configuration.

This will use /etc/resolv.conf on Unix OSes and the registry on Windows.

Construct a new generic AsyncResolver with the provided configuration.

see [TokioAsyncResolver::tokio(..)] instead.

Arguments
  • config - configuration, name_servers, etc. for the Resolver
  • options - basic lookup options for the resolver
Returns

A tuple containing the new AsyncResolver and a future that drives the background task that runs resolutions for the AsyncResolver. See the documentation for AsyncResolver for more information on how to use the background future.

This is supported on crate feature system-config and (Unix or Windows) only.

Constructs a new Resolver with the system configuration.

see [TokioAsyncResolver::tokio_from_system_conf(..)] instead.

This will use /etc/resolv.conf on Unix OSes and the registry on Windows.

Flushes/Removes all entries from the cache

Construct a new AsyncResolver with the provided configuration.

Arguments
  • config - configuration, name_servers, etc. for the Resolver
  • options - basic lookup options for the resolver
Returns

A tuple containing the new AsyncResolver and a future that drives the background task that runs resolutions for the AsyncResolver. See the documentation for AsyncResolver for more information on how to use the background future.

This is supported on crate feature system-config and (Unix or Windows) only.

Constructs a new Resolver with the system configuration.

This will use /etc/resolv.conf on Unix OSes and the registry on Windows.

Generic lookup for any RecordType

WARNING this interface may change in the future, see if one of the specializations would be better.

Arguments
  • name - name of the record to lookup, if name is not a valid domain name, an error will be returned
  • record_type - type of record to lookup, all RecordData responses will be filtered to this type
Returns

Performs a dual-stack DNS lookup for the IP for the given hostname.

See the configuration and options parameters for controlling the way in which A(Ipv4) and AAAA(Ipv6) lookups will be performed. For the least expensive query a fully-qualified-domain-name, FQDN, which ends in a final ., e.g. www.example.com., will only issue one query. Anything else will always incur the cost of querying the ResolverConfig::domain and ResolverConfig::search.

Arguments
  • host - string hostname, if this is an invalid hostname, an error will be returned.

Performs a lookup for the associated type.

Arguments
  • query - a type which can be converted to Name via From.

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more