Skip to main content

CacheControl

Struct CacheControl 

Source
pub struct CacheControl {
Show 16 fields pub max_age: Option<u64>, pub s_maxage: Option<u64>, pub max_stale: Option<Option<u64>>, pub min_fresh: Option<u64>, pub no_cache: bool, pub no_cache_fields: Vec<String>, pub no_store: bool, pub no_transform: bool, pub only_if_cached: bool, pub must_revalidate: bool, pub must_understand: bool, pub private: bool, pub private_fields: Vec<String>, pub proxy_revalidate: bool, pub public: bool, pub extensions: Vec<(String, Option<String>)>,
}
Expand description

A parsed Cache-Control field value per RFC 9111 §5.2.

The §5.2 grammar Cache-Control = #cache-directive and cache-directive = token [ "=" ( token / quoted-string ) ] is a single production shared by request directives (§5.2.1) and response directives (§5.2.2); a recipient parses the wire form the same way in both roles and applies role-appropriate semantics afterwards, so this one struct carries every §5.2.1 / §5.2.2 directive. Fields are None / false / empty when the corresponding directive is absent.

§5.2.3: “A cache MUST ignore unrecognized cache directives.” Any directive token not defined in §5.2.1 / §5.2.2 is preserved in extensions (so a behavioural-extension consumer can still inspect it) rather than discarded — ignoring is a behaviour, not a parse failure.

Duplicate-directive policy follows RFC 9111 §4.2.1: “When there is more than one value present for a given directive … either the first occurrence should be used or the response should be considered stale.” This parser takes the first-occurrence option for every valued directive (later duplicates of max-age, s-maxage, etc. are dropped). A boolean directive appearing more than once is idempotent.

Fields§

§max_age: Option<u64>

max-age (§5.2.1.1 request / §5.2.2.1 response) delta-seconds, §1.2.2-saturated. None when absent or carrying a non-1*DIGIT argument.

§s_maxage: Option<u64>

s-maxage (§5.2.2.10) delta-seconds, §1.2.2-saturated.

§max_stale: Option<Option<u64>>

max-stale (§5.2.1.2). Some(None) is the no-argument form (“accept a stale response of any age”); Some(Some(n)) carries the §1.2.2-saturated bound. None when the directive is absent.

§min_fresh: Option<u64>

min-fresh (§5.2.1.3) delta-seconds, §1.2.2-saturated.

§no_cache: bool

Unqualified no-cache — §5.2.1.4 (request) / the argument-free §5.2.2.4 (response) form. true whenever a no-cache directive is present without an argument.

§no_cache_fields: Vec<String>

Qualified no-cache="field1, field2" field names (§5.2.2.4), lowercased (“Field names are case-insensitive”). Empty unless the quoted-string argument form is present.

§no_store: bool

no-store (§5.2.1.5 request / §5.2.2.5 response).

§no_transform: bool

no-transform (§5.2.1.6 request / §5.2.2.6 response).

§only_if_cached: bool

only-if-cached (§5.2.1.7, request directive).

§must_revalidate: bool

must-revalidate (§5.2.2.2, response directive).

§must_understand: bool

must-understand (§5.2.2.3, response directive).

§private: bool

Unqualified private (§5.2.2.7, response directive).

§private_fields: Vec<String>

Qualified private="field1, field2" field names (§5.2.2.7), lowercased. Empty unless the quoted-string argument form is present.

§proxy_revalidate: bool

proxy-revalidate (§5.2.2.8, response directive).

§public: bool

public (§5.2.2.9, response directive).

§extensions: Vec<(String, Option<String>)>

Unrecognized / extension directives (§5.2.3), preserved as (lowercased token, optional decoded argument) in wire order.

Trait Implementations§

Source§

impl Clone for CacheControl

Source§

fn clone(&self) -> CacheControl

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Default for CacheControl

Source§

fn default() -> CacheControl

Returns the “default value” for a type. Read more
Source§

impl Eq for CacheControl

Source§

impl PartialEq for CacheControl

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.