pub struct DnsEntry {
pub hostname: String,
pub addresses: Vec<SocketAddr>,
pub resolved_at: Instant,
pub ttl: Duration,
pub ipv4_preferred: bool,
}Expand description
A single cached DNS entry containing resolved addresses and metadata.
Each entry stores the resolved socket addresses for a hostname, along with when it was resolved and its time-to-live duration.
Fields§
§hostname: StringThe hostname this entry was resolved for
addresses: Vec<SocketAddr>Resolved socket addresses (sorted by preference)
resolved_at: InstantTimestamp when this entry was created/resolved
ttl: DurationTime-to-live for this entry before it’s considered stale
ipv4_preferred: boolWhether IPv4 addresses should be preferred in ordering
Implementations§
Source§impl DnsEntry
impl DnsEntry
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this DNS entry has expired based on its TTL.
Returns true if the elapsed time since resolution exceeds the TTL,
meaning the entry should be re-resolved.
Sourcepub fn best_address(&self) -> Option<SocketAddr>
pub fn best_address(&self) -> Option<SocketAddr>
Get the best address from this entry.
If IPv4 is preferred, returns the first IPv4 address if available,
otherwise falls back to the first address in the list.
Returns None if there are no addresses.
Sourcepub fn all_addresses(&self) -> Vec<SocketAddr>
pub fn all_addresses(&self) -> Vec<SocketAddr>
Return a clone of all cached addresses for this entry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DnsEntry
impl RefUnwindSafe for DnsEntry
impl Send for DnsEntry
impl Sync for DnsEntry
impl Unpin for DnsEntry
impl UnsafeUnpin for DnsEntry
impl UnwindSafe for DnsEntry
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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