pub struct TtlConfig { /* private fields */ }Expand description
The time-to-live (TTL) configuration used by the cache.
Minimum and maximum TTLs can be set for both positive responses and negative responses. Separate limits may be set depending on the query type.
Note that TTLs in DNS are represented as a number of seconds stored in a 32-bit unsigned
integer. We use Duration here, instead of u32, which can express larger values than the DNS
standard. Generally, a Duration greater than u32::MAX_VALUE shouldn’t cause any issue, as
this will never be used in serialization, but note that this would be outside the standard
range.
Implementations§
Source§impl TtlConfig
impl TtlConfig
Sourcepub fn from_opts(opts: &ResolverOpts) -> Self
pub fn from_opts(opts: &ResolverOpts) -> Self
Construct the LRU’s TTL configuration based on the ResolverOpts configuration.
Sourcepub fn new(
positive_min_ttl: Option<Duration>,
negative_min_ttl: Option<Duration>,
positive_max_ttl: Option<Duration>,
negative_max_ttl: Option<Duration>,
) -> Self
pub fn new( positive_min_ttl: Option<Duration>, negative_min_ttl: Option<Duration>, positive_max_ttl: Option<Duration>, negative_max_ttl: Option<Duration>, ) -> Self
Creates a new cache TTL configuration.
The provided minimum and maximum TTLs will be applied to all queries unless otherwise
specified via Self::with_query_type_ttl_bounds.
If a minimum value is not provided, it will default to 0 seconds. If a maximum value is not provided, it will default to one day.
Sourcepub fn with_query_type_ttl_bounds(
&mut self,
query_type: RecordType,
positive_min_ttl: Option<Duration>,
negative_min_ttl: Option<Duration>,
positive_max_ttl: Option<Duration>,
negative_max_ttl: Option<Duration>,
) -> &mut Self
pub fn with_query_type_ttl_bounds( &mut self, query_type: RecordType, positive_min_ttl: Option<Duration>, negative_min_ttl: Option<Duration>, positive_max_ttl: Option<Duration>, negative_max_ttl: Option<Duration>, ) -> &mut Self
Override the minimum and maximum TTL values for a specific query type.
If a minimum value is not provided, it will default to 0 seconds. If a maximum value is not provided, it will default to one day.
Sourcepub fn positive_response_ttl_bounds(
&self,
query_type: RecordType,
) -> RangeInclusive<Duration>
pub fn positive_response_ttl_bounds( &self, query_type: RecordType, ) -> RangeInclusive<Duration>
Retrieves the minimum and maximum TTL values for positive responses.
Sourcepub fn negative_response_ttl_bounds(
&self,
query_type: RecordType,
) -> RangeInclusive<Duration>
pub fn negative_response_ttl_bounds( &self, query_type: RecordType, ) -> RangeInclusive<Duration>
Retrieves the minimum and maximum TTL values for negative responses.
Trait Implementations§
impl Eq for TtlConfig
impl StructuralPartialEq for TtlConfig
Auto Trait Implementations§
impl Freeze for TtlConfig
impl RefUnwindSafe for TtlConfig
impl Send for TtlConfig
impl Sync for TtlConfig
impl Unpin for TtlConfig
impl UnwindSafe for TtlConfig
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.