Skip to main content

ResolverCache

Trait ResolverCache 

Source
pub trait ResolverCache<K, V>: Sized {
    // Required methods
    fn get<Q>(&self, name: &Q) -> Option<V>
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn remove<Q>(&self, name: &Q) -> Option<V>
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn insert(&self, key: K, value: V, valid_until: Instant);
}
Expand description

A cache for one DNS record type, keyed by K and holding values of type V.

Methods take &self, so implementations that mutate must use interior mutability (a lock or a concurrent map). The lookup helpers call get before querying and insert after a query that returned records or a cacheable negative answer; they do not check expiry themselves. See the module documentation for an example.

Required Methods§

Source

fn get<Q>(&self, name: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a copy of the cached value for name, or None if there is none. Implementations should return None for expired entries.

Source

fn remove<Q>(&self, name: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Removes the entry for name and returns its value. Not called by this crate; available to applications that invalidate entries.

Source

fn insert(&self, key: K, value: V, valid_until: Instant)

Stores value under key. valid_until is the expiry time derived from the TTLs of the DNS answer, or from its negative TTL for a negative answer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, V> ResolverCache<K, V> for NoCache