pub struct Resolver<P: ConnectionProvider> { /* private fields */ }Expand description
An asynchronous resolver for DNS generic over async Runtimes.
The lookup methods on Resolver spawn background tasks to perform
queries. The futures returned by a Resolver and the corresponding
background tasks need not be spawned on the same executor, or be in the
same thread.
NOTE If lookup futures returned by a Resolver and the background
tasks 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.
Implementations§
Source§impl Resolver<GenericConnector<TokioRuntimeProvider>>
impl Resolver<GenericConnector<TokioRuntimeProvider>>
Sourcepub fn builder_tokio() -> Result<ResolverBuilder<TokioConnectionProvider>, ResolveError>
Available on (Unix or Windows) and crate feature system-config and crate feature tokio only.
pub fn builder_tokio() -> Result<ResolverBuilder<TokioConnectionProvider>, ResolveError>
system-config and crate feature tokio 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.
Source§impl<R: ConnectionProvider> Resolver<R>
impl<R: ConnectionProvider> Resolver<R>
Sourcepub fn builder(provider: R) -> Result<ResolverBuilder<R>, ResolveError>
Available on (Unix or Windows) and crate feature system-config only.
pub fn builder(provider: R) -> Result<ResolverBuilder<R>, ResolveError>
system-config only.Constructs a new Resolver via ResolverBuilder with the operating system’s
configuration.
To use this with Tokio, see TokioResolver::builder_tokio instead.
This will use /etc/resolv.conf on Unix OSes and the registry on Windows.
Sourcepub fn builder_with_config(
config: ResolverConfig,
provider: R,
) -> ResolverBuilder<R>
pub fn builder_with_config( config: ResolverConfig, provider: R, ) -> ResolverBuilder<R>
Construct a new Resolver via ResolverBuilder with the provided configuration.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Flushes/Removes all entries from the cache
Sourcepub fn config(&self) -> &ResolverConfig
pub fn config(&self) -> &ResolverConfig
Read the config for this resolver.
Sourcepub fn options(&self) -> &ResolverOpts
pub fn options(&self) -> &ResolverOpts
Read the options for this resolver.
Source§impl<P: ConnectionProvider> Resolver<P>
impl<P: ConnectionProvider> Resolver<P>
Sourcepub async fn lookup<N: IntoName>(
&self,
name: N,
record_type: RecordType,
) -> Result<Lookup, ResolveError>
pub async fn lookup<N: IntoName>( &self, name: N, record_type: RecordType, ) -> Result<Lookup, ResolveError>
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 returnedrecord_type- type of record to lookup, all RecordData responses will be filtered to this type
§Returns
Sourcepub async fn lookup_ip(
&self,
host: impl IntoName,
) -> Result<LookupIp, ResolveError>
pub async fn lookup_ip( &self, host: impl IntoName, ) -> Result<LookupIp, ResolveError>
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.
Sourcepub fn set_hosts(&mut self, hosts: Arc<Hosts>)
pub fn set_hosts(&mut self, hosts: Arc<Hosts>)
Customizes the static hosts used in this resolver.
Sourcepub async fn reverse_lookup(
&self,
query: IpAddr,
) -> Result<ReverseLookup, ResolveError>
pub async fn reverse_lookup( &self, query: IpAddr, ) -> Result<ReverseLookup, ResolveError>
Performs a lookup for the associated type.
§Arguments
query- a type which can be converted toNameviaFrom.
Sourcepub async fn ipv4_lookup<N: IntoName>(
&self,
query: N,
) -> Result<Ipv4Lookup, ResolveError>
pub async fn ipv4_lookup<N: IntoName>( &self, query: N, ) -> Result<Ipv4Lookup, ResolveError>
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
Sourcepub async fn ipv6_lookup<N: IntoName>(
&self,
query: N,
) -> Result<Ipv6Lookup, ResolveError>
pub async fn ipv6_lookup<N: IntoName>( &self, query: N, ) -> Result<Ipv6Lookup, ResolveError>
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
Sourcepub async fn mx_lookup<N: IntoName>(
&self,
query: N,
) -> Result<MxLookup, ResolveError>
pub async fn mx_lookup<N: IntoName>( &self, query: N, ) -> Result<MxLookup, ResolveError>
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
Sourcepub async fn ns_lookup<N: IntoName>(
&self,
query: N,
) -> Result<NsLookup, ResolveError>
pub async fn ns_lookup<N: IntoName>( &self, query: N, ) -> Result<NsLookup, ResolveError>
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
Sourcepub async fn soa_lookup<N: IntoName>(
&self,
query: N,
) -> Result<SoaLookup, ResolveError>
pub async fn soa_lookup<N: IntoName>( &self, query: N, ) -> Result<SoaLookup, ResolveError>
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
Sourcepub async fn srv_lookup<N: IntoName>(
&self,
query: N,
) -> Result<SrvLookup, ResolveError>
pub async fn srv_lookup<N: IntoName>( &self, query: N, ) -> Result<SrvLookup, ResolveError>
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
Sourcepub async fn tlsa_lookup<N: IntoName>(
&self,
query: N,
) -> Result<TlsaLookup, ResolveError>
pub async fn tlsa_lookup<N: IntoName>( &self, query: N, ) -> Result<TlsaLookup, ResolveError>
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
Sourcepub async fn txt_lookup<N: IntoName>(
&self,
query: N,
) -> Result<TxtLookup, ResolveError>
pub async fn txt_lookup<N: IntoName>( &self, query: N, ) -> Result<TxtLookup, ResolveError>
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
Sourcepub async fn cert_lookup<N: IntoName>(
&self,
query: N,
) -> Result<CertLookup, ResolveError>
pub async fn cert_lookup<N: IntoName>( &self, query: N, ) -> Result<CertLookup, ResolveError>
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