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.