pub struct DnsResolver { /* private fields */ }Expand description
DNS resolver for querying various record types.
Uses Google DNS (8.8.8.8) by default, but supports custom nameservers. The default resolver is cached and reused across queries to avoid repeated initialization overhead.
Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets the timeout for DNS queries.
The default is 5 seconds, which is sufficient for most DNS queries.
Sourcepub async fn resolve(
&self,
domain: &str,
record_type: RecordType,
nameserver: Option<&str>,
) -> Result<Vec<DnsRecord>>
pub async fn resolve( &self, domain: &str, record_type: RecordType, nameserver: Option<&str>, ) -> Result<Vec<DnsRecord>>
Resolves DNS records for a domain.
§Arguments
domain- The domain name to queryrecord_type- The type of DNS record to look up (A, AAAA, MX, etc.)nameserver- Optional custom nameserver IP; uses Google DNS if None
Sourcepub async fn resolve_srv(
&self,
service: &str,
protocol: &str,
domain: &str,
nameserver: Option<&str>,
) -> Result<Vec<DnsRecord>>
pub async fn resolve_srv( &self, service: &str, protocol: &str, domain: &str, nameserver: Option<&str>, ) -> Result<Vec<DnsRecord>>
Resolves SRV records for a service.
§Arguments
service- The service name (e.g., “http”, “ldap”)protocol- The protocol (e.g., “tcp”, “udp”)domain- The domain namenameserver- Optional custom nameserver IP
Trait Implementations§
Source§impl Clone for DnsResolver
impl Clone for DnsResolver
Source§fn clone(&self) -> DnsResolver
fn clone(&self) -> DnsResolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DnsResolver
impl Debug for DnsResolver
Auto Trait Implementations§
impl Freeze for DnsResolver
impl !RefUnwindSafe for DnsResolver
impl Send for DnsResolver
impl Sync for DnsResolver
impl Unpin for DnsResolver
impl UnsafeUnpin for DnsResolver
impl !UnwindSafe for DnsResolver
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request