pub struct DnsCache { /* private fields */ }Expand description
DNS cache for resolving hostnames
Implementations§
Source§impl DnsCache
impl DnsCache
Sourcepub async fn new() -> Result<Self, Box<dyn Error>>
pub async fn new() -> Result<Self, Box<dyn Error>>
Create a new DNS cache with system configuration
Sourcepub async fn with_ttl(ttl: Duration) -> Result<Self, Box<dyn Error>>
pub async fn with_ttl(ttl: Duration) -> Result<Self, Box<dyn Error>>
Create a DNS cache with custom TTL
Sourcepub async fn resolve(
&self,
hostname: &str,
) -> Result<Vec<IpAddr>, Box<dyn Error>>
pub async fn resolve( &self, hostname: &str, ) -> Result<Vec<IpAddr>, Box<dyn Error>>
Resolve a hostname, using cache if available
Sourcepub async fn prewarm(&self, hostname: &str) -> Result<(), Box<dyn Error>>
pub async fn prewarm(&self, hostname: &str) -> Result<(), Box<dyn Error>>
Pre-warm the cache by resolving a hostname
Sourcepub async fn cache_size(&self) -> usize
pub async fn cache_size(&self) -> usize
Get cache size
Auto Trait Implementations§
impl Freeze for DnsCache
impl !RefUnwindSafe for DnsCache
impl Send for DnsCache
impl Sync for DnsCache
impl Unpin for DnsCache
impl !UnwindSafe for DnsCache
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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