Struct domain::resolv::Resolver
[−]
[src]
pub struct Resolver(_);
Access to a DNS resolver.
This type collects all information making it possible to start DNS
queries. You can create a new resoler using the system’s configuration
using the new()
associate function or using your own configuration
with from_conf()
. Either function will spawn everything necessary
into a tokio_core
reactor core represented by a handle.
Resolver values can be cloned relatively cheaply as they keep all
information behind an arc. This is may already be useful when starting
a query using the query()
method. Since queries need their own copy
of resolver, the method consumes the resolver leaving it to clone it if
you need it later on or saving a clone if you don’t.
If you want to run a single query or lookup on a resolver synchronously,
you can safe yourself all the boiler plate of creating a reactor core
(even if this is nowhere near as dangerous as it sounds) and resolver by
using the run()
or run_with_conf()
associated functions.
Methods
impl Resolver
[src]
pub fn new(reactor: &Handle) -> Self
[src]
Creates a new resolver using the system’s default configuration.
All the networking components of the resolver will be spawned into
the reactor core referenced by reactor
.
pub fn from_conf(reactor: &Handle, conf: ResolvConf) -> Self
[src]
Creates a new resolver using the given configuration.
All the components of the resolver will be spawned into the reactor
referenced by reactor
.
pub fn query<N, Q>(self, question: Q) -> Query where
N: DName,
Q: Into<Question<N>>,
[src]
N: DName,
Q: Into<Question<N>>,
Trades the resolver for a DNS query.
This starts a query for something that can be turned into a question. In particular, both a tripel of a domain name, record type, and class as well as a pair of domain name and record type can be turned into a question, the latter assuming the class IN.
If you need to keep the resolver, clone it before calling query()
.
pub fn conf(&self) -> &ResolvConf
[src]
Returns a reference to the configuration of this resolver.
pub fn options(&self) -> &ResolvOptions
[src]
Returns a reference to the configuration options of this resolver.
impl Resolver
[src]
pub fn run<R, F>(op: F) -> Result<R::Item, R::Error> where
R: Future,
R::Error: From<Error>,
F: FnOnce(Resolver) -> R,
[src]
R: Future,
R::Error: From<Error>,
F: FnOnce(Resolver) -> R,
Synchronously perform a DNS operation atop a standard resolver.
This associated functions removes almost all boiler plate for the case that you want to perform some DNS operation, either a query or lookup, on a resolver using the system’s configuration and wait for the result.
The only argument is a closure taking a Resolver
and returning a
future. Whatever that future resolves to will be returned.
pub fn run_with_conf<R, F>(conf: ResolvConf, op: F) -> Result<R::Item, R::Error> where
R: Future,
R::Error: From<Error>,
F: FnOnce(Resolver) -> R,
[src]
R: Future,
R::Error: From<Error>,
F: FnOnce(Resolver) -> R,
Synchronously perform a DNS operation atop a configuredresolver.
This is like run()
but also takes a resolver configuration for
tailor-making your own resolver.
Trait Implementations
impl Clone for Resolver
[src]
fn clone(&self) -> Resolver
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more