Skip to main content

CacheMeta

Struct CacheMeta 

Source
pub struct CacheMeta(/* private fields */);
Expand description

The cacheable response header and cache metadata

Implementations§

Source§

impl CacheMeta

Source

pub fn new( fresh_until: SystemTime, created: SystemTime, stale_while_revalidate_sec: u32, stale_if_error_sec: u32, header: ResponseHeader, ) -> CacheMeta

Create a CacheMeta from the given metadata and the response header

Source

pub fn created(&self) -> SystemTime

When the asset was created/admitted to cache

Source

pub fn updated(&self) -> SystemTime

The last time the asset was revalidated

This value will be the same as Self::created() if no revalidation ever happens

Source

pub fn epoch(&self) -> SystemTime

The reference point for cache age. This represents the “starting point” for fresh_until.

This defaults to the updated timestamp but is overridden by the epoch_override field if set.

Source

pub fn epoch_override(&self) -> Option<SystemTime>

Get the epoch override for this asset

Source

pub fn set_epoch_override(&mut self, epoch: SystemTime)

Set the epoch override for this asset

When set, this will be used as the reference point for calculating age and freshness instead of the updated time.

Source

pub fn remove_epoch_override(&mut self)

Remove the epoch override for this asset

Source

pub fn is_fresh(&self, time: SystemTime) -> bool

Is the asset still valid

Source

pub fn fresh_sec(&self) -> u64

How long (in seconds) the asset should be fresh since its admission/revalidation

This is essentially the max-age value (or its equivalence). If an epoch override is set, it will be used as the reference point instead of the updated time.

Source

pub fn fresh_until(&self) -> SystemTime

Until when the asset is considered fresh

Source

pub fn age(&self) -> Duration

How old the asset is since its admission/revalidation

If an epoch override is set, it will be used as the reference point instead of the updated time.

Source

pub fn stale_while_revalidate_sec(&self) -> u32

The stale-while-revalidate limit in seconds

Source

pub fn stale_if_error_sec(&self) -> u32

The stale-if-error limit in seconds

Source

pub fn serve_stale_while_revalidate(&self, time: SystemTime) -> bool

Can the asset be used to serve stale during revalidation at the given time.

NOTE: the serve stale functions do not check !is_fresh(time), i.e. the object is already assumed to be stale.

Source

pub fn serve_stale_if_error(&self, time: SystemTime) -> bool

Can the asset be used to serve stale after error at the given time.

NOTE: the serve stale functions do not check !is_fresh(time), i.e. the object is already assumed to be stale.

Source

pub fn disable_serve_stale(&mut self)

Disable serve stale for this asset

Source

pub fn variance(&self) -> Option<HashBinary>

Get the variance hash of this asset

Source

pub fn set_variance_key(&mut self, variance_key: HashBinary)

Set the variance key of this asset

Source

pub fn set_variance(&mut self, variance: HashBinary)

Set the variance (hash) of this asset

Source

pub fn remove_variance(&mut self)

Removes the variance (hash) of this asset

Source

pub fn response_header(&self) -> &ResponseHeader

Get the response header in this asset

Source

pub fn response_header_mut(&mut self) -> &mut ResponseHeader

Modify the header in this asset

Source

pub fn extensions(&self) -> &Extensions

Expose the extensions to read

Source

pub fn extensions_mut(&mut self) -> &mut Extensions

Expose the extensions to modify

Source

pub fn response_header_copy(&self) -> ResponseHeader

Get a copy of the response header

Source

pub fn headers(&self) -> &HMap

get all the headers of this asset

Source

pub fn serialize(&self) -> Result<(Vec<u8>, Vec<u8>)>

Serialize this object

Source

pub fn deserialize(internal: &[u8], header: &[u8]) -> Result<Self>

Deserialize from the binary format

Trait Implementations§

Source§

impl Debug for CacheMeta

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more