Struct domain::resolv::conf::ResolvConf [−][src]
pub struct ResolvConf { pub servers: Vec<ServerConf>, pub search: Vec<DNameBuf>, pub ndots: usize, pub timeout: Duration, pub attempts: usize, pub options: ResolvOptions, pub idle_timeout: Duration, }
Resolver configuration.
This type collects all information necessary to configure how a stub resolver talks to its upstream resolvers.
The type follows the builder pattern. After creating a value with
ResolvConf::new()
you can manipulate the members. Once you are happy
with them, you call finalize()
to make sure the configuration is valid.
It mostly just fixes the servers
.
Additionally, the type can parse a glibc-style configuration file,
commonly known as /etc/resolv.conf
through the parse()
and
parse_file()
methods. You still need to call finalize()
after
parsing.
The easiest way, however, to get the system resolver configuration is
through ResolvConf::default()
. This will parse the configuration file
or return a default configuration if that fails.
Fields
servers: Vec<ServerConf>
Addresses of servers to query.
search: Vec<DNameBuf>
Search list for host-name lookup.
ndots: usize
TODO Sortlist sortlist: ?? Number of dots before an initial absolute query is made.
timeout: Duration
Timeout to wait for a response.
attempts: usize
Number of retries before giving up.
options: ResolvOptions
Default options.
idle_timeout: Duration
Default idle timeout for stream oriented transports.
Methods
impl ResolvConf
[src]
impl ResolvConf
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates a new, empty configuration.
Using an empty configuration will fail since it does not contain
any name servers. Call self.finalize()
to make it usable.
pub fn finalize(&mut self)
[src]
pub fn finalize(&mut self)
Finalizes the configuration for actual use.
The function does two things. If servers
is empty, it adds
127.0.0.1:53
. This is exactly what glibc does. If search
is
empty, it adds the root domain "."
. This differs from what
glibc does which considers the machine’s host name.
pub fn default() -> Self
[src]
pub fn default() -> Self
Creates a default configuration for this system.
XXX This currently only works for Unix-y systems.
impl ResolvConf
[src]
impl ResolvConf
pub fn parse_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
[src]
pub fn parse_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Parses the configuration from a file.
pub fn parse<R: Read>(&mut self, reader: &mut R) -> Result<()>
[src]
pub fn parse<R: Read>(&mut self, reader: &mut R) -> Result<()>
Parses the configuration from a reader.
The format is that of the /etc/resolv.conf file.
Trait Implementations
impl Clone for ResolvConf
[src]
impl Clone for ResolvConf
fn clone(&self) -> ResolvConf
[src]
fn clone(&self) -> ResolvConf
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for ResolvConf
[src]
impl Debug for ResolvConf
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for ResolvConf
[src]
impl Default for ResolvConf
impl Display for ResolvConf
[src]
impl Display for ResolvConf
Auto Trait Implementations
impl Send for ResolvConf
impl Send for ResolvConf
impl Sync for ResolvConf
impl Sync for ResolvConf