CacheControl

Struct CacheControl 

Source
pub struct CacheControl { /* private fields */ }
Expand description

Cache-Control header, defined in RFC7234 with extensions in RFC8246

The Cache-Control header field is used to specify directives for caches along the request/response chain. Such cache directives are unidirectional in that the presence of a directive in a request does not imply that the same directive is to be given in the response.

§ABNF

Cache-Control   = 1#cache-directive
cache-directive = token [ "=" ( token / quoted-string ) ]

§Example values

  • no-cache
  • private, community="UCI"
  • max-age=30

§Example

use headers::CacheControl;

let cc = CacheControl::new();

Implementations§

Source§

impl CacheControl

Source

pub fn new() -> Self

Construct a new empty CacheControl header.

Source

pub fn no_cache(&self) -> bool

Check if the no-cache directive is set.

Source

pub fn no_store(&self) -> bool

Check if the no-store directive is set.

Source

pub fn no_transform(&self) -> bool

Check if the no-transform directive is set.

Source

pub fn only_if_cached(&self) -> bool

Check if the only-if-cached directive is set.

Source

pub fn public(&self) -> bool

Check if the public directive is set.

Source

pub fn private(&self) -> bool

Check if the private directive is set.

Source

pub fn immutable(&self) -> bool

Check if the immutable directive is set.

Source

pub fn must_revalidate(&self) -> bool

Check if the must-revalidate directive is set.

Source

pub fn must_understand(&self) -> bool

Check if the must-understand directive is set.

Source

pub fn max_age(&self) -> Option<Duration>

Get the value of the max-age directive if set.

Source

pub fn max_stale(&self) -> Option<Duration>

Get the value of the max-stale directive if set.

Source

pub fn min_fresh(&self) -> Option<Duration>

Get the value of the min-fresh directive if set.

Source

pub fn s_max_age(&self) -> Option<Duration>

Get the value of the s-maxage directive if set.

Source

pub fn with_no_cache(self) -> Self

Set the no-cache directive.

Source

pub fn with_no_store(self) -> Self

Set the no-store directive.

Source

pub fn with_no_transform(self) -> Self

Set the no-transform directive.

Source

pub fn with_only_if_cached(self) -> Self

Set the only-if-cached directive.

Source

pub fn with_private(self) -> Self

Set the private directive.

Source

pub fn with_public(self) -> Self

Set the public directive.

Source

pub fn with_immutable(self) -> Self

Set the immutable directive.

Source

pub fn with_must_revalidate(self) -> Self

Set the must-revalidate directive.

Source

pub fn with_must_understand(self) -> Self

Set the must-understand directive.

Source

pub fn with_max_age(self, duration: Duration) -> Self

Set the max-age directive.

Source

pub fn with_max_stale(self, duration: Duration) -> Self

Set the max-stale directive.

Source

pub fn with_min_fresh(self, duration: Duration) -> Self

Set the min-fresh directive.

Source

pub fn with_s_max_age(self, duration: Duration) -> Self

Set the s-maxage directive.

Trait Implementations§

Source§

impl Clone for CacheControl

Source§

fn clone(&self) -> CacheControl

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CacheControl

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Header for CacheControl

Source§

fn name() -> &'static HeaderName

The name of this header.
Source§

fn decode<'i, I: Iterator<Item = &'i HeaderValue>>( values: &mut I, ) -> Result<Self, Error>

Decode this type from an iterator of HeaderValues.
Source§

fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)

Encode this type to a HeaderMap. Read more
Source§

impl PartialEq for CacheControl

Source§

fn eq(&self, other: &CacheControl) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CacheControl

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 72 bytes