pub struct CacheMeta(/* private fields */);
Expand description
The cacheable response header and cache metadata
Implementations§
Source§impl CacheMeta
impl CacheMeta
Sourcepub fn new(
fresh_until: SystemTime,
created: SystemTime,
stale_while_revalidate_sec: u32,
stale_if_error_sec: u32,
header: ResponseHeader,
) -> CacheMeta
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
Sourcepub fn created(&self) -> SystemTime
pub fn created(&self) -> SystemTime
When the asset was created/admitted to cache
Sourcepub fn updated(&self) -> SystemTime
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
Sourcepub fn is_fresh(&self, time: SystemTime) -> bool
pub fn is_fresh(&self, time: SystemTime) -> bool
Is the asset still valid
Sourcepub fn fresh_sec(&self) -> u64
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)
Sourcepub fn fresh_until(&self) -> SystemTime
pub fn fresh_until(&self) -> SystemTime
Until when the asset is considered fresh
Sourcepub fn stale_while_revalidate_sec(&self) -> u32
pub fn stale_while_revalidate_sec(&self) -> u32
The stale-while-revalidate limit in seconds
Sourcepub fn stale_if_error_sec(&self) -> u32
pub fn stale_if_error_sec(&self) -> u32
The stale-if-error limit in seconds
Sourcepub fn serve_stale_while_revalidate(&self, time: SystemTime) -> bool
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.
Sourcepub fn serve_stale_if_error(&self, time: SystemTime) -> bool
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.
Sourcepub fn disable_serve_stale(&mut self)
pub fn disable_serve_stale(&mut self)
Disable serve stale for this asset
Sourcepub fn variance(&self) -> Option<HashBinary>
pub fn variance(&self) -> Option<HashBinary>
Get the variance hash of this asset
Sourcepub fn set_variance_key(&mut self, variance_key: HashBinary)
pub fn set_variance_key(&mut self, variance_key: HashBinary)
Set the variance key of this asset
Sourcepub fn set_variance(&mut self, variance: HashBinary)
pub fn set_variance(&mut self, variance: HashBinary)
Set the variance (hash) of this asset
Sourcepub fn remove_variance(&mut self)
pub fn remove_variance(&mut self)
Removes the variance (hash) of this asset
Sourcepub fn response_header(&self) -> &ResponseHeader
pub fn response_header(&self) -> &ResponseHeader
Get the response header in this asset
Sourcepub fn response_header_mut(&mut self) -> &mut ResponseHeader
pub fn response_header_mut(&mut self) -> &mut ResponseHeader
Modify the header in this asset
Sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Expose the extensions to read
Sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Expose the extensions to modify
Sourcepub fn response_header_copy(&self) -> ResponseHeader
pub fn response_header_copy(&self) -> ResponseHeader
Get a copy of the response header
Sourcepub fn deserialize(internal: &[u8], header: &[u8]) -> Result<Self>
pub fn deserialize(internal: &[u8], header: &[u8]) -> Result<Self>
Deserialize from the binary format