pub struct ReferrerPolicy(/* private fields */);Expand description
Referrer-Policy header, part of
Referrer Policy
The Referrer-Policy HTTP header specifies the referrer
policy that the user agent applies when determining what
referrer information should be included with requests made,
and with browsing contexts created from the context of the
protected resource.
§Fallback chains
Per the Referrer Policy spec § 3.2
the wire form is 1#policy-token — a comma-separated list where the
user agent walks RIGHT-TO-LEFT and picks the last token it
recognises. This lets a server ship a modern policy with a fallback
for older clients:
use rama_http_headers::ReferrerPolicy;
// Emits: `no-referrer, strict-origin-when-cross-origin`.
// A pre-CSP3 browser falls back to `no-referrer`; a modern browser
// picks `strict-origin-when-cross-origin`.
let rp = ReferrerPolicy::NO_REFERRER
.with_fallback(ReferrerPolicy::STRICT_ORIGIN_WHEN_CROSS_ORIGIN);with_fallback appends; emitted order is preserved on the wire
(oldest-known first → newest-known last).
§ABNF
Referrer-Policy: 1#policy-token
policy-token = "no-referrer" / "no-referrer-when-downgrade"
/ "same-origin" / "origin"
/ "origin-when-cross-origin" / "unsafe-url"
/ "strict-origin" / "strict-origin-when-cross-origin"§Example values
no-referrerno-referrer, strict-origin-when-cross-origin
§Example
use rama_http_headers::ReferrerPolicy;
let rp = ReferrerPolicy::NO_REFERRER;Implementations§
Source§impl ReferrerPolicy
impl ReferrerPolicy
Sourcepub const NO_REFERRER: ReferrerPolicy
pub const NO_REFERRER: ReferrerPolicy
no-referrer
Sourcepub const NO_REFERRER_WHEN_DOWNGRADE: ReferrerPolicy
pub const NO_REFERRER_WHEN_DOWNGRADE: ReferrerPolicy
no-referrer-when-downgrade
Sourcepub const SAME_ORIGIN: ReferrerPolicy
pub const SAME_ORIGIN: ReferrerPolicy
same-origin
Sourcepub const ORIGIN: ReferrerPolicy
pub const ORIGIN: ReferrerPolicy
origin
Sourcepub const ORIGIN_WHEN_CROSS_ORIGIN: ReferrerPolicy
pub const ORIGIN_WHEN_CROSS_ORIGIN: ReferrerPolicy
origin-when-cross-origin
Sourcepub const UNSAFE_URL: ReferrerPolicy
pub const UNSAFE_URL: ReferrerPolicy
unsafe-url
Sourcepub const STRICT_ORIGIN: ReferrerPolicy
pub const STRICT_ORIGIN: ReferrerPolicy
strict-origin
Sourcepub const STRICT_ORIGIN_WHEN_CROSS_ORIGIN: ReferrerPolicy
pub const STRICT_ORIGIN_WHEN_CROSS_ORIGIN: ReferrerPolicy
strict-origin-when-cross-origin
Sourcepub fn with_fallback(self, policy: ReferrerPolicy) -> ReferrerPolicy
pub fn with_fallback(self, policy: ReferrerPolicy) -> ReferrerPolicy
Append a fallback policy.
Multiple calls compound; emitted order is preserved on the wire (oldest-known first → newest-known last). Browsers walk right-to-left and select the last token they recognise, so the appended policy is the one a modern client will pick — call this on your older / pre-CSP3 baseline and pass the modern token you want.
The argument’s full policy list is appended in order (so chaining preserves any fallback chain it already carried).
Sourcepub fn set_fallback(&mut self, policy: ReferrerPolicy) -> &mut ReferrerPolicy
pub fn set_fallback(&mut self, policy: ReferrerPolicy) -> &mut ReferrerPolicy
Append a fallback policy.
Multiple calls compound; emitted order is preserved on the wire (oldest-known first → newest-known last). Browsers walk right-to-left and select the last token they recognise, so the appended policy is the one a modern client will pick — call this on your older / pre-CSP3 baseline and pass the modern token you want.
The argument’s full policy list is appended in order (so chaining preserves any fallback chain it already carried).
Trait Implementations§
Source§impl Clone for ReferrerPolicy
impl Clone for ReferrerPolicy
Source§fn clone(&self) -> ReferrerPolicy
fn clone(&self) -> ReferrerPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReferrerPolicy
impl Debug for ReferrerPolicy
impl Eq for ReferrerPolicy
Source§impl Hash for ReferrerPolicy
impl Hash for ReferrerPolicy
Source§impl HeaderDecode for ReferrerPolicy
impl HeaderDecode for ReferrerPolicy
Source§fn decode<'i, I>(values: &mut I) -> Result<ReferrerPolicy, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<ReferrerPolicy, Error>where
I: Iterator<Item = &'i HeaderValue>,
HeaderValues.Source§impl HeaderEncode for ReferrerPolicy
impl HeaderEncode for ReferrerPolicy
Source§fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
HeaderValue, and add it to a container
which has HeaderValue type as each element. Read moreSource§fn encode_to_value(&self) -> Option<HeaderValue>
fn encode_to_value(&self) -> Option<HeaderValue>
HeaderValue. Read moreSource§impl PartialEq for ReferrerPolicy
impl PartialEq for ReferrerPolicy
Source§fn eq(&self, other: &ReferrerPolicy) -> bool
fn eq(&self, other: &ReferrerPolicy) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ReferrerPolicy
Source§impl TypedHeader for ReferrerPolicy
impl TypedHeader for ReferrerPolicy
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
Auto Trait Implementations§
impl Freeze for ReferrerPolicy
impl RefUnwindSafe for ReferrerPolicy
impl Send for ReferrerPolicy
impl Sync for ReferrerPolicy
impl Unpin for ReferrerPolicy
impl UnsafeUnpin for ReferrerPolicy
impl UnwindSafe for ReferrerPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more