Skip to main content

CachingHeadersExt

Trait CachingHeadersExt 

Source
pub trait CachingHeadersExt: Sized {
Show 16 methods // Required methods fn etag(&self) -> Option<EntityTag>; fn set_etag(&mut self, entity_tag: &EntityTag); fn last_modified(&self) -> Option<SystemTime>; fn set_last_modified(&mut self, system_time: SystemTime); fn cache_control(&self) -> Option<CacheControlHeader>; fn set_cache_control( &mut self, cache_control: impl Into<CacheControlHeader>, ); fn cdn_cache_control(&self) -> Option<CacheControlHeader>; fn set_cdn_cache_control( &mut self, cache_control: impl Into<CacheControlHeader>, ); fn if_modified_since(&self) -> Option<SystemTime>; fn if_none_match(&self) -> Option<EntityTag>; fn set_vary<I, N>(&mut self, vary: I) where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>>; // Provided methods fn with_cache_control( self, cache_control: impl Into<CacheControlHeader>, ) -> Self { ... } fn with_last_modified(self, system_time: SystemTime) -> Self { ... } fn with_etag(self, entity_tag: &EntityTag) -> Self { ... } fn with_vary<I, N>(self, vary: I) -> Self where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>> { ... } fn with_cdn_cache_control( self, cache_control: impl Into<CacheControlHeader>, ) -> Self { ... }
}
Expand description

Provides an extension trait for both trillium::Headers and also trillium::Conn for setting and getting various parsed caching headers.

Required Methods§

Source

fn etag(&self) -> Option<EntityTag>

returns an EntityTag if these headers contain an Etag header.

Source

fn set_etag(&mut self, entity_tag: &EntityTag)

sets an etag header from an EntityTag.

Source

fn last_modified(&self) -> Option<SystemTime>

returns a parsed timestamp if these headers contain a Last-Modified header.

Source

fn set_last_modified(&mut self, system_time: SystemTime)

sets a formatted Last-Modified header from a timestamp.

Source

fn cache_control(&self) -> Option<CacheControlHeader>

Returns a parsed CacheControlHeader if these headers include a Cache-Control header. Note that if this is called on a Conn, it returns the request’s Cache-Control header.

Source

fn set_cache_control(&mut self, cache_control: impl Into<CacheControlHeader>)

sets a Cache-Control header on these headers. Note that this is valid in both request and response contexts, and specific directives have different meanings.

Source

fn cdn_cache_control(&self) -> Option<CacheControlHeader>

Returns a parsed CacheControlHeader if these headers include a CDN-Cache-Control header (RFC 9213). Unlike cache_control, CDN-Cache-Control is response-only by spec, so when called on a Conn this reads the response headers.

Source

fn set_cdn_cache_control( &mut self, cache_control: impl Into<CacheControlHeader>, )

Sets a CDN-Cache-Control (RFC 9213) header on these headers. Targeted at CDN / shared-intermediary caches, ignored by other caches.

Source

fn if_modified_since(&self) -> Option<SystemTime>

returns a parsed If-Modified-Since header if one exists

Source

fn if_none_match(&self) -> Option<EntityTag>

returns a parsed EntityTag header if there is an If-None-Match header.

Source

fn set_vary<I, N>(&mut self, vary: I)
where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>>,

sets the Vary header to a collection of Into<HeaderName>

Provided Methods§

Source

fn with_cache_control( self, cache_control: impl Into<CacheControlHeader>, ) -> Self

chainable method to set cache control and return self. primarily useful on Conn

Source

fn with_last_modified(self, system_time: SystemTime) -> Self

chainable method to set last modified and return self. primarily useful on Conn

Source

fn with_etag(self, entity_tag: &EntityTag) -> Self

chainable method to set etag and return self. primarily useful on Conn

Source

fn with_vary<I, N>(self, vary: I) -> Self
where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>>,

chainable method to set vary and return self. primarily useful on Conn

Source

fn with_cdn_cache_control( self, cache_control: impl Into<CacheControlHeader>, ) -> Self

chainable method to set CDN-Cache-Control and return self. primarily useful on Conn

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl CachingHeadersExt for Conn

Source§

fn etag(&self) -> Option<EntityTag>

Source§

fn set_etag(&mut self, entity_tag: &EntityTag)

Source§

fn last_modified(&self) -> Option<SystemTime>

Source§

fn set_last_modified(&mut self, system_time: SystemTime)

Source§

fn cache_control(&self) -> Option<CacheControlHeader>

Source§

fn set_cache_control(&mut self, cache_control: impl Into<CacheControlHeader>)

Source§

fn cdn_cache_control(&self) -> Option<CacheControlHeader>

Source§

fn set_cdn_cache_control( &mut self, cache_control: impl Into<CacheControlHeader>, )

Source§

fn if_modified_since(&self) -> Option<SystemTime>

Source§

fn if_none_match(&self) -> Option<EntityTag>

Source§

fn set_vary<I, N>(&mut self, vary: I)
where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>>,

Source§

impl CachingHeadersExt for Headers

Source§

fn etag(&self) -> Option<EntityTag>

Source§

fn set_etag(&mut self, entity_tag: &EntityTag)

Source§

fn last_modified(&self) -> Option<SystemTime>

Source§

fn set_last_modified(&mut self, system_time: SystemTime)

Source§

fn cache_control(&self) -> Option<CacheControlHeader>

Source§

fn set_cache_control(&mut self, cache_control: impl Into<CacheControlHeader>)

Source§

fn cdn_cache_control(&self) -> Option<CacheControlHeader>

Source§

fn set_cdn_cache_control( &mut self, cache_control: impl Into<CacheControlHeader>, )

Source§

fn if_modified_since(&self) -> Option<SystemTime>

Source§

fn if_none_match(&self) -> Option<EntityTag>

Source§

fn set_vary<I, N>(&mut self, vary: I)
where I: IntoIterator<Item = N>, N: Into<HeaderName<'static>>,

Implementors§