pub struct CacheExpiration { /* private fields */ }
Expand description

Small structure to represent expiration in a cache.

Expirations are constructed using the From and Into traits from the standard library; there are no other functions.

There are currently several supported conversions:

  • u64 -> a number of milliseconds to pass before an entry should expire.
  • Instant -> an exact time that an entry should expire.
  • Duration -> a duration to pass before an entry should expire.
  • Range<u64> -> a random range of milliseconds to sample from to determine when an entry should expire.

Other conversions may be added in future, but this should suffice for most cases. Any of these types may be passed to the insertion methods on a cache type when adding entries to a cache.

Implementations

Create an expiration at a given instant.

Create an empty expiration (i.e. no expiration).

Retrieve the instant associated with this expiration.

Retrieve whether a cache entry has passed expiration.

Retrieve the time remaining before expiration.

Trait Implementations

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.