Skip to main content

SyncResolver

Struct SyncResolver 

Source
pub struct SyncResolver { /* private fields */ }
Expand description

A simple, synchronous, non-recursive (m)DNS stub resolver.

Implementations§

Source§

impl SyncResolver

Source

pub fn new(sock: SocketAddr) -> Result<Self>

Creates a new DNS resolver that will contact the given server.

Source

pub fn new_multicast_v4() -> Result<Self>

Creates a new mDNS resolver that will use IPv4.

Source

pub fn new_multicast_v6() -> Result<Self>

Creates a new mDNS resolver that will use IPv6.

Source

pub fn add_server(&mut self, server: SocketAddr)

Adds another server to be contacted by this resolver.

Calling SyncResolver::resolve or SyncResolver::resolve_domain will send a query to every server in this list. The first response containing at least one resolved IP address will be returned.

§Panics

All servers added to the same SyncResolver must match the family of the first server passed to SyncResolver::new, otherwise this method will panic.

This method will also panic when called on a multicast resolver.

Source

pub fn set_timeout(&mut self, timeout: Duration) -> Result<()>

Sets the timeout after which to abort a resolution attempt.

This is the timeout for individual receive operations, not for the whole query. Packets that don’t match the query that was sent will be ignored, but still reset the timeout.

Source

pub fn resolve( &mut self, hostname: &str, ) -> Result<impl Iterator<Item = IpAddr> + '_>

Attempts to resolve hostname using the configured DNS servers.

If the query times out, an error of type io::ErrorKind::WouldBlock or io::ErrorKind::TimedOut will be returned.

The resolver does not perform recursive resolution (it is a “stub resolver”). It does set the RD bit in the query, which instructs the server to perform recursion.

Source

pub fn resolve_domain( &mut self, name: &DomainName, ) -> Result<impl Iterator<Item = IpAddr> + '_>

Attempts to resolve a DomainName using the configured DNS servers.

If the query times out, an error of type io::ErrorKind::WouldBlock or io::ErrorKind::TimedOut will be returned.

The resolver does not perform recursive resolution (it is a “stub resolver”). It does set the RD bit in the query, which instructs the server to perform recursion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.