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: boolUnqualified 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: boolno-store (§5.2.1.5 request / §5.2.2.5 response).
no_transform: boolno-transform (§5.2.1.6 request / §5.2.2.6 response).
only_if_cached: boolonly-if-cached (§5.2.1.7, request directive).
must_revalidate: boolmust-revalidate (§5.2.2.2, response directive).
must_understand: boolmust-understand (§5.2.2.3, response directive).
private: boolUnqualified 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: boolproxy-revalidate (§5.2.2.8, response directive).
public: boolpublic (§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
impl Clone for CacheControl
Source§fn clone(&self) -> CacheControl
fn clone(&self) -> CacheControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more