Struct domain::resolv::Resolver
[−]
[src]
pub struct Resolver { /* fields omitted */ }
Access to a resolver.
This types collects all information in order to be able to start a DNS
query on a resolver. You can create a new resolver by calling either
the new()
or from_conf()
functions passing in a handle to a Tokio
reactor core. Either function will spawn everything necessary for a
resolver into that core. Existing resolver values can be cloned. Clones
will refer to the same resolver.
In order to perform a query, you will have to call the start()
method
to create a future that will resolve into an intermediary value that
will than allow calling a query()
method on it and will also allow
more complex operations as a complex future.
Alternatively, you can use the run()
associated function to
synchronously perfrom a series of queries.
Methods
impl Resolver
[src]
fn new(reactor: &Handle) -> Result<Self>
Creates a new resolver using the system’s default configuration.
All the components of the resolver will be spawned into the reactor
referenced by reactor
.
fn from_conf(reactor: &Handle, conf: ResolvConf) -> Result<Self>
Creates a new resolver using the given configuration.
All the components of the resolver will be spawned into the reactor
referenced by reactor
.
fn conf(&self) -> &ResolvConf
Returns a reference to the configuration of this resolver.
fn options(&self) -> &ResolvOptions
Returns a reference to the configuration options of this resolver.
fn start<E>(&self) -> BoxFuture<ResolverTask, E> where E: Send + 'static
Starts a resolver future atop this resolver.
The method returns a future that will resolve into a ResolverTask value that can be used to start queries atop this resolver.
Since the future will never error, it is generic over the error type.
impl Resolver
[src]
fn run<R, F>(f: F) -> Result<R::Item, R::Error> where R: Future, R::Error: From<Error> + Send + 'static, F: FnOnce(ResolverTask) -> 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 on a resolver using the system’s configuration and wait for the result.
The only argument is a closure taking a [ResolverTask] for creating queries and returning a future. Whatever that future resolves to will be returned.
fn run_with_conf<R, F>(conf: ResolvConf, f: F) -> Result<R::Item, R::Error> where R: Future, R::Error: From<Error> + Send + 'static, F: FnOnce(ResolverTask) -> R
fn spawn<R, F>(&self, f: F) -> BoxFuture<R::Item, R::Error> where R: Future + Send + 'static, R::Error: From<Error> + Send + 'static, F: FnOnce(ResolverTask) -> R + Send + 'static
Spawn a query.
This method is a shortcut for self.start().and_then(f).boxed()
.
Because of the boxed()
bit, it requires lots of things to be
Send + 'static
and because of that isn’t necessarily better than
the longer way.
I am also not sure if spawn is the right name. Probably not since it actually returns the future.
Trait Implementations
impl Clone for Resolver
[src]
fn clone(&self) -> Resolver
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more