pub struct DnsResolver { /* private fields */ }Expand description
Background DNS resolver with caching
Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn with_defaults_deferred() -> Self
pub fn with_defaults_deferred() -> Self
Create a DNS resolver that will not spawn background threads until
DnsResolver::start is called.
This is intended for runtimes that must finish privileged setup and apply a process sandbox before starting general worker threads.
Sourcepub fn start(&self) -> Result<()>
pub fn start(&self) -> Result<()>
Start the background resolver and cache-cleanup threads.
Starting is idempotent. A resolver that has already been stopped cannot be restarted.
Returns an error if a worker cannot be spawned. Workers staged before that failure are stopped and joined before the error is returned.
Sourcepub fn request_resolution(&self, ip: IpAddr)
pub fn request_resolution(&self, ip: IpAddr)
Request resolution for an IP address (non-blocking)
Sourcepub fn get_hostname(&self, ip: &IpAddr) -> Option<String>
pub fn get_hostname(&self, ip: &IpAddr) -> Option<String>
Get hostname for IP if resolved, otherwise return None
Sourcepub fn stop(&self) -> DnsStopReport
pub fn stop(&self) -> DnsStopReport
Stop the resolver and join background workers within a shared deadline.
Stopping is idempotent and prevents a deferred resolver from starting. All workers share one deadline, so several blocked resolver calls cannot extend shutdown one timeout at a time. Workers that remain blocked after the deadline are detached and reported as timed out.