Struct AsyncResolver

Source
pub struct AsyncResolver { /* private fields */ }
Expand description

A handle for resolving DNS records.

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§

Source§

impl AsyncResolver

Source

pub fn new( config: ResolverConfig, options: ResolverOpts, ) -> (AsyncResolver, impl Future<Output = ()> + Send)

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.

Source

pub fn from_system_conf() -> Result<(AsyncResolver, impl Future<Output = ()>), ResolveError>

Constructs a new Resolver with the system configuration.

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

Source

pub fn lookup<N>( &self, name: N, record_type: RecordType, ) -> Background<LookupFuture>
where N: IntoName,

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
Source

pub fn lookup_ip<N>(&self, host: N) -> Background<LookupIpFuture>
where N: IntoName + TryParseIp,

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.
Source

pub fn lookup_service( &self, service: &str, protocol: &str, name: &str, ) -> Background<LookupFuture, SrvLookupFuture>

👎Deprecated: use lookup_srv instead, this interface is not ideal

Performs a DNS lookup for an SRV record for the specified service type and protocol at the given name.

This is a convenience method over lookup_srv, it combines the service, protocol and name into a single name: _service._protocol.name.

§Arguments
  • service - service to lookup, e.g. ldap or http
  • protocol - wire protocol, e.g. udp or tcp
  • name - zone or other name at which the service is located.
Source

pub fn lookup_srv<N>( &self, name: N, ) -> Background<LookupFuture, SrvLookupFuture>
where N: IntoName,

Lookup an SRV record.

Source

pub fn reverse_lookup( &self, query: IpAddr, ) -> Background<LookupFuture, ReverseLookupFuture>

Performs a lookup for the associated type.

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

pub fn ipv4_lookup<N>( &self, query: N, ) -> Background<LookupFuture, Ipv4LookupFuture>
where N: IntoName,

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
Source

pub fn ipv6_lookup<N>( &self, query: N, ) -> Background<LookupFuture, Ipv6LookupFuture>
where N: IntoName,

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
Source

pub fn mx_lookup<N>(&self, query: N) -> Background<LookupFuture, MxLookupFuture>
where N: IntoName,

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
Source

pub fn ns_lookup<N>(&self, query: N) -> Background<LookupFuture, NsLookupFuture>
where N: IntoName,

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
Source

pub fn soa_lookup<N>( &self, query: N, ) -> Background<LookupFuture, SoaLookupFuture>
where N: IntoName,

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
Source

pub fn srv_lookup<N>( &self, query: N, ) -> Background<LookupFuture, SrvLookupFuture>
where N: IntoName,

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
Source

pub fn txt_lookup<N>( &self, query: N, ) -> Background<LookupFuture, TxtLookupFuture>
where N: IntoName,

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§

Source§

impl Clone for AsyncResolver

Source§

fn clone(&self) -> AsyncResolver

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsyncResolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,