Struct trust_dns_resolver::Resolver
source · [−]pub struct Resolver { /* private fields */ }
Expand description
The Resolver is used for performing DNS queries.
For forward (A) lookups, hostname -> IP address, see: Resolver::lookup_ip
Special note about resource consumption. The Resolver and all Trust-DNS software is built around the Tokio async-io library. This synchronous Resolver is intended to be a simpler wrapper for of the AsyncResolver
. To allow the Resolver
to be Send
+ Sync
, the construction of the AsyncResolver
is lazy, this means some of the features of the AsyncResolver
, like performance based resolution via the most efficient NameServer
will be lost (the lookup cache is shared across invocations of the Resolver
). If these other features of the Trust-DNS Resolver are desired, please use the tokio based AsyncResolver
.
Note: Threaded/Sync usage: In multithreaded scenarios, the internal Tokio Runtime will block on an internal Mutex for the tokio Runtime in use. For higher performance, it’s recommended to use the AsyncResolver
.
Implementations
sourceimpl Resolver
impl Resolver
sourcepub fn new(config: ResolverConfig, options: ResolverOpts) -> Result<Self>
pub fn new(config: ResolverConfig, options: ResolverOpts) -> Result<Self>
sourcepub fn default() -> Result<Self>
pub fn default() -> Result<Self>
Constructs a new Resolver with default config and default options.
See ResolverConfig::default
and ResolverOpts::default
for more information.
Returns
A new Resolver
or an error if there was an error with the configuration.
sourcepub fn from_system_conf() -> Result<Self>
This is supported on crate feature system-config
and (Unix or Windows) only.
pub fn from_system_conf() -> Result<Self>
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.
sourcepub fn clear_cache(&mut self) -> ResolveResult<()>
pub fn clear_cache(&mut self) -> ResolveResult<()>
Flushes/Removes all entries from the cache
sourcepub fn lookup<N: IntoName>(
&self,
name: N,
record_type: RecordType
) -> ResolveResult<Lookup>
pub fn lookup<N: IntoName>(
&self,
name: N,
record_type: RecordType
) -> ResolveResult<Lookup>
Generic lookup for any RecordType
WARNING This interface may change in the future, please use Self::lookup_ip
or another variant for more stable interfaces.
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
sourcepub fn lookup_ip<N: IntoName + TryParseIp>(
&self,
host: N
) -> ResolveResult<LookupIp>
pub fn lookup_ip<N: IntoName + TryParseIp>(
&self,
host: N
) -> ResolveResult<LookupIp>
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 reverse_lookup(&self, query: IpAddr) -> ResolveResult<ReverseLookup>
pub fn reverse_lookup(&self, query: IpAddr) -> ResolveResult<ReverseLookup>
Performs a lookup for the associated type.
Arguments
query
- a type which can be converted toName
viaFrom
.
sourcepub fn ipv4_lookup<N: IntoName>(&self, query: N) -> ResolveResult<Ipv4Lookup>
pub fn ipv4_lookup<N: IntoName>(&self, query: N) -> ResolveResult<Ipv4Lookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn ipv6_lookup<N: IntoName>(&self, query: N) -> ResolveResult<Ipv6Lookup>
pub fn ipv6_lookup<N: IntoName>(&self, query: N) -> ResolveResult<Ipv6Lookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn mx_lookup<N: IntoName>(&self, query: N) -> ResolveResult<MxLookup>
pub fn mx_lookup<N: IntoName>(&self, query: N) -> ResolveResult<MxLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn ns_lookup<N: IntoName>(&self, query: N) -> ResolveResult<NsLookup>
pub fn ns_lookup<N: IntoName>(&self, query: N) -> ResolveResult<NsLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn soa_lookup<N: IntoName>(&self, query: N) -> ResolveResult<SoaLookup>
pub fn soa_lookup<N: IntoName>(&self, query: N) -> ResolveResult<SoaLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn srv_lookup<N: IntoName>(&self, query: N) -> ResolveResult<SrvLookup>
pub fn srv_lookup<N: IntoName>(&self, query: N) -> ResolveResult<SrvLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn tlsa_lookup<N: IntoName>(&self, query: N) -> ResolveResult<TlsaLookup>
pub fn tlsa_lookup<N: IntoName>(&self, query: N) -> ResolveResult<TlsaLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
sourcepub fn txt_lookup<N: IntoName>(&self, query: N) -> ResolveResult<TxtLookup>
pub fn txt_lookup<N: IntoName>(&self, query: N) -> ResolveResult<TxtLookup>
Performs a lookup for the associated type.
hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups
Arguments
query
- a&str
which parses to a domain name, failure to parse will return an error
Auto Trait Implementations
impl !RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl !UnwindSafe for Resolver
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more