Struct Resolver

pub struct Resolver<P>{ /* private fields */ }
Expand description

An asynchronous resolver for DNS generic over async Runtimes.

The lookup methods on Resolver spawn background tasks to perform queries. The futures returned by a Resolver and the corresponding background tasks need not be spawned on the same executor, or be in the same thread.

NOTE If lookup futures returned by a Resolver and the background tasks are spawned on two separate CurrentThread executors, one thread cannot run both executors simultaneously, so the run or block_on functions will cause the thread to deadlock. If both the background work and the lookup futures are intended to be run on the same thread, they should be spawned on the same executor.

Implementations§

§

impl Resolver<GenericConnector<TokioRuntimeProvider>>

pub fn builder_tokio() -> Result<ResolverBuilder<GenericConnector<TokioRuntimeProvider>>, ResolveError>

Constructs a new Tokio based Resolver with the system configuration.

This will use /etc/resolv.conf on Unix OSes and the registry on Windows.

§

impl<R> Resolver<R>

pub fn builder(provider: R) -> Result<ResolverBuilder<R>, ResolveError>

Constructs a new Resolver via ResolverBuilder with the operating system’s configuration.

To use this with Tokio, see TokioResolver::builder_tokio instead.

This will use /etc/resolv.conf on Unix OSes and the registry on Windows.

pub fn builder_with_config( config: ResolverConfig, provider: R, ) -> ResolverBuilder<R>

Construct a new Resolver via ResolverBuilder with the provided configuration.

pub fn clear_cache(&self)

Flushes/Removes all entries from the cache

pub fn config(&self) -> &ResolverConfig

Read the config for this resolver.

pub fn options(&self) -> &ResolverOpts

Read the options for this resolver.

§

impl<P> Resolver<P>

pub async fn lookup<N>( &self, name: N, record_type: RecordType, ) -> Result<Lookup, ResolveError>
where N: IntoName,

Generic lookup for any RecordType

WARNING this interface may change in the future, see if one of the specializations would be better.

§Arguments
  • name - name of the record to lookup, if name is not a valid domain name, an error will be returned
  • record_type - type of record to lookup, all RecordData responses will be filtered to this type
§Returns

pub async fn lookup_ip( &self, host: impl IntoName, ) -> Result<LookupIp, ResolveError>

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.

pub fn set_hosts(&mut self, hosts: Arc<Hosts>)

Customizes the static hosts used in this resolver.

pub async fn reverse_lookup( &self, query: IpAddr, ) -> Result<ReverseLookup, ResolveError>

Performs a lookup for the associated type.

§Arguments
  • query - a type which can be converted to Name via From.

pub async fn ipv4_lookup<N>(&self, query: N) -> Result<Ipv4Lookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn ipv6_lookup<N>(&self, query: N) -> Result<Ipv6Lookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn mx_lookup<N>(&self, query: N) -> Result<MxLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn ns_lookup<N>(&self, query: N) -> Result<NsLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn soa_lookup<N>(&self, query: N) -> Result<SoaLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn srv_lookup<N>(&self, query: N) -> Result<SrvLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn tlsa_lookup<N>(&self, query: N) -> Result<TlsaLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn txt_lookup<N>(&self, query: N) -> Result<TxtLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

pub async fn cert_lookup<N>(&self, query: N) -> Result<CertLookup, ResolveError>
where N: IntoName,

Performs a lookup for the associated type.

hint queries that end with a ‘.’ are fully qualified names and are cheaper lookups

§Arguments
  • query - a string which parses to a domain name, failure to parse will return an error

Trait Implementations§

§

impl<P> Clone for Resolver<P>

§

fn clone(&self) -> Resolver<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<P> Debug for Resolver<P>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<Resolver<GenericConnector<TokioRuntimeProvider>>> for HickoryDns

§

fn from(value: Resolver<GenericConnector<TokioRuntimeProvider>>) -> HickoryDns

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<P> Freeze for Resolver<P>

§

impl<P> !RefUnwindSafe for Resolver<P>

§

impl<P> Send for Resolver<P>

§

impl<P> Sync for Resolver<P>

§

impl<P> Unpin for Resolver<P>

§

impl<P> !UnwindSafe for Resolver<P>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

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

§

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

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,