Struct FetchMetadata
pub struct FetchMetadata {
pub site: Option<SecFetchSite>,
pub mode: Option<SecFetchMode>,
pub dest: Option<SecFetchDest>,
pub user: bool,
}http and std only.Expand description
The Fetch Metadata request headers of a request, read together.
This is a view over SecFetchSite, SecFetchMode, SecFetchDest
and SecFetchUser, not a TypedHeader of its own: it spans four
header names. A header that is absent or fails to decode leaves its field
empty, so a partial set (some embedded browsers only send Sec-Fetch-Site)
still yields the fields that were sent.
§Example
use rama_http_headers::{FetchMetadata, SecFetchDest, SecFetchMode, SecFetchSite};
use rama_http_types::HeaderMap;
let navigation = FetchMetadata::default()
.with_site(SecFetchSite::None)
.with_mode(SecFetchMode::Navigate)
.with_dest(SecFetchDest::Document)
.with_user(true);
let mut headers = HeaderMap::new();
navigation.insert_into(&mut headers);
assert_eq!(headers["sec-fetch-user"], "?1");
assert_eq!(FetchMetadata::from_headers(&headers), Some(navigation));
assert_eq!(FetchMetadata::from_headers(&HeaderMap::new()), None);Fields§
§site: Option<SecFetchSite>The Sec-Fetch-Site header.
mode: Option<SecFetchMode>The Sec-Fetch-Mode header.
dest: Option<SecFetchDest>The Sec-Fetch-Dest header.
user: boolWhether the Sec-Fetch-User header was sent, marking a navigation
triggered by user activation.
Implementations§
§impl FetchMetadata
impl FetchMetadata
pub fn from_headers(headers: &HeaderMap) -> Option<FetchMetadata>
pub fn from_headers(headers: &HeaderMap) -> Option<FetchMetadata>
Read the fetch metadata headers from headers.
Returns None when none of them is present with a valid value: a
non-browser client, or a browser too old to send them. That is a
different answer from “sent, with these values”.
pub fn insert_into(&self, headers: &mut HeaderMap)
pub fn insert_into(&self, headers: &mut HeaderMap)
Write this metadata into headers.
Present fields replace their header; absent fields remove it, so the map carries exactly this metadata afterwards.
pub fn maybe_with_site(self, site: Option<SecFetchSite>) -> FetchMetadata
pub fn maybe_with_site(self, site: Option<SecFetchSite>) -> FetchMetadata
Set the Sec-Fetch-Site value.
pub fn maybe_set_site(
&mut self,
site: Option<SecFetchSite>,
) -> &mut FetchMetadata
pub fn maybe_set_site( &mut self, site: Option<SecFetchSite>, ) -> &mut FetchMetadata
Set the Sec-Fetch-Site value.
pub fn with_site(self, site: SecFetchSite) -> FetchMetadata
pub fn with_site(self, site: SecFetchSite) -> FetchMetadata
Set the Sec-Fetch-Site value.
pub fn set_site(&mut self, site: SecFetchSite) -> &mut FetchMetadata
pub fn set_site(&mut self, site: SecFetchSite) -> &mut FetchMetadata
Set the Sec-Fetch-Site value.
pub fn without_site(self) -> FetchMetadata
pub fn without_site(self) -> FetchMetadata
Set the Sec-Fetch-Site value.
pub fn unset_site(&mut self) -> &mut FetchMetadata
pub fn unset_site(&mut self) -> &mut FetchMetadata
Set the Sec-Fetch-Site value.
pub fn maybe_with_mode(self, mode: Option<SecFetchMode>) -> FetchMetadata
pub fn maybe_with_mode(self, mode: Option<SecFetchMode>) -> FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn maybe_set_mode(
&mut self,
mode: Option<SecFetchMode>,
) -> &mut FetchMetadata
pub fn maybe_set_mode( &mut self, mode: Option<SecFetchMode>, ) -> &mut FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn with_mode(self, mode: SecFetchMode) -> FetchMetadata
pub fn with_mode(self, mode: SecFetchMode) -> FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn set_mode(&mut self, mode: SecFetchMode) -> &mut FetchMetadata
pub fn set_mode(&mut self, mode: SecFetchMode) -> &mut FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn without_mode(self) -> FetchMetadata
pub fn without_mode(self) -> FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn unset_mode(&mut self) -> &mut FetchMetadata
pub fn unset_mode(&mut self) -> &mut FetchMetadata
Set the Sec-Fetch-Mode value.
pub fn maybe_with_dest(self, dest: Option<SecFetchDest>) -> FetchMetadata
pub fn maybe_with_dest(self, dest: Option<SecFetchDest>) -> FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn maybe_set_dest(
&mut self,
dest: Option<SecFetchDest>,
) -> &mut FetchMetadata
pub fn maybe_set_dest( &mut self, dest: Option<SecFetchDest>, ) -> &mut FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn with_dest(self, dest: SecFetchDest) -> FetchMetadata
pub fn with_dest(self, dest: SecFetchDest) -> FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn set_dest(&mut self, dest: SecFetchDest) -> &mut FetchMetadata
pub fn set_dest(&mut self, dest: SecFetchDest) -> &mut FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn without_dest(self) -> FetchMetadata
pub fn without_dest(self) -> FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn unset_dest(&mut self) -> &mut FetchMetadata
pub fn unset_dest(&mut self) -> &mut FetchMetadata
Set the Sec-Fetch-Dest value.
pub fn with_user(self, user: bool) -> FetchMetadata
pub fn with_user(self, user: bool) -> FetchMetadata
Set whether the request was triggered by user activation (Sec-Fetch-User).
pub fn set_user(&mut self, user: bool) -> &mut FetchMetadata
pub fn set_user(&mut self, user: bool) -> &mut FetchMetadata
Set whether the request was triggered by user activation (Sec-Fetch-User).
Trait Implementations§
§impl Clone for FetchMetadata
impl Clone for FetchMetadata
§fn clone(&self) -> FetchMetadata
fn clone(&self) -> FetchMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for FetchMetadata
impl Debug for FetchMetadata
§impl Default for FetchMetadata
impl Default for FetchMetadata
§fn default() -> FetchMetadata
fn default() -> FetchMetadata
impl Eq for FetchMetadata
§impl Hash for FetchMetadata
impl Hash for FetchMetadata
§impl<State> OptionalFromPartsStateRefPair<State> for FetchMetadata
impl<State> OptionalFromPartsStateRefPair<State> for FetchMetadata
§async fn from_parts_state_ref_pair(
parts: &Parts,
_state: &State,
) -> Result<Option<FetchMetadata>, <FetchMetadata as OptionalFromPartsStateRefPair<State>>::Rejection>
async fn from_parts_state_ref_pair( parts: &Parts, _state: &State, ) -> Result<Option<FetchMetadata>, <FetchMetadata as OptionalFromPartsStateRefPair<State>>::Rejection>
§impl PartialEq for FetchMetadata
impl PartialEq for FetchMetadata
impl StructuralPartialEq for FetchMetadata
Auto Trait Implementations§
impl Freeze for FetchMetadata
impl RefUnwindSafe for FetchMetadata
impl Send for FetchMetadata
impl Sync for FetchMetadata
impl Unpin for FetchMetadata
impl UnsafeUnpin for FetchMetadata
impl UnwindSafe for FetchMetadata
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more