Builder

Struct Builder 

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

Builder for DnsResolver.

Implementations§

Source§

impl Builder

Source

pub fn with_system_defaults(self) -> Self

Makes the builder respect the host system’s DNS configuration.

The configuration is read in a platform-specific way. If that fails, or if it lists no nameservers, the fallback tier answers instead, subject to the FallbackMode.

Source

pub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Self

👎Deprecated since 1.2.0: use add_nameserver_config()

Adds a single nameserver config.

For DNS-over-TLS and DNS-over-HTTPS, the server name is inferred from the IP address. To set a different one, build a NameserverConfig with NameserverConfig::with_tls_server_name and pass it to Self::add_nameserver_config.

Source

pub fn with_nameservers( self, nameservers: impl IntoIterator<Item = (SocketAddr, DnsProtocol)>, ) -> Self

👎Deprecated since 1.2.0: use add_nameserver_configs()

Adds a list of nameserver configs.

For DNS-over-TLS and DNS-over-HTTPS, the server name is inferred from the IP address. To set a different one, build a NameserverConfig with NameserverConfig::with_tls_server_name and pass it to Self::add_nameserver_configs.

Source

pub fn add_nameserver_config(self, nameserver: NameserverConfig) -> Self

Adds a single nameserver config.

Source

pub fn add_nameserver_configs( self, nameservers: impl IntoIterator<Item = NameserverConfig>, ) -> Self

Adds a list of nameserver configs.

Source

pub fn tls_client_config(self, client_config: ClientConfig) -> Self

Sets a custom TLS client configuration.

This overrides the default configuration used for DNS-over-TLS and DNS-over-HTTPS.

When neither the tls-ring nor tls-aws-lc-rs feature is enabled, DNS-over-TLS and DNS-over-HTTPS require a custom configuration containing a crypto provider, supplied with Self::tls_client_config.

Source

pub fn with_fallback_mode(self, mode: FallbackMode) -> Self

Sets how the fallback nameservers are used relative to the primary ones.

The default is FallbackMode::Deferred: the fallback nameservers are a lower-priority tier, queried only when the primary nameservers fail or time out. See FallbackMode for the other modes.

Source

pub fn disable_fallback(self) -> Self

Disables the fallback nameservers, so only the primary ones are queried.

Shorthand for Self::with_fallback_mode with FallbackMode::Never.

Source

pub fn fallback_nameserver_configs( self, nameservers: impl IntoIterator<Item = NameserverConfig>, ) -> Self

Adds nameservers to the fallback tier, in place of the default ones.

Appends, so it can be called repeatedly. Adding any nameserver here replaces the default public resolvers, which are only used when this list is left empty. Has no effect when the fallback mode is FallbackMode::Never.

Source

pub fn build(self) -> DnsResolver

Builds the DNS resolver.

Trait Implementations§

Source§

impl Clone for Builder

Source§

fn clone(&self) -> Builder

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

impl Debug for Builder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

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

§

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