Skip to main content

StoredEntry

Trait StoredEntry 

Source
pub trait StoredEntry:
    Clone
    + Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn policy(&self) -> &CachePolicy;
    fn refresh_policy(
        &mut self,
        new_policy: CachePolicy,
    ) -> impl Future<Output = Result<()>> + Send;
    fn open(self) -> impl Future<Output = Result<Body>> + Send;
}
Expand description

One stored response.

Returned by CacheStorage::get. Cheap to hold and pass around — in-memory backends share underlying buffers via Arc, and other backends typically hold only metadata until open is called. The Clone bound supports the cache handler’s stale-while-revalidate flow, which needs one handle to serve the stale entry to the user and another to drive background revalidation; for typical backends clone is a cheap pointer copy.

Required Methods§

Source

fn policy(&self) -> &CachePolicy

Borrow the CachePolicy this entry was stored with.

Source

fn refresh_policy( &mut self, new_policy: CachePolicy, ) -> impl Future<Output = Result<()>> + Send

Replace the stored policy without rewriting the body.

Used on a successful 304 revalidation (RFC 9111 §3.2) to refresh validators and freshness directives while keeping the previously stored body bytes. The supplied policy carries the merged stored+304 headers and a fresh response_time.

Source

fn open(self) -> impl Future<Output = Result<Body>> + Send

Open the stored response body for replay.

Consumes the entry and returns a Body that yields the stored bytes when read. If trailers were captured on store, they are attached via Body::new_with_trailers and surface to readers after EOF via BodySource::trailers.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§