pub struct StrictTransportSecurity { /* private fields */ }Expand description
StrictTransportSecurity header, defined in RFC6797
This specification defines a mechanism enabling web sites to declare themselves accessible only via secure connections and/or for users to be able to direct their user agent(s) to interact with given sites only over secure connections. This overall policy is referred to as HTTP Strict Transport Security (HSTS). The policy is declared by web sites via the Strict-Transport-Security HTTP response header field and/or by other means, such as user agent configuration, for example.
§ABNF
[ directive ] *( ";" [ directive ] )
directive = directive-name [ "=" directive-value ]
directive-name = token
directive-value = token | quoted-string
§Example values
max-age=31536000max-age=15768000 ; includeSubdomainsmax-age=31536000; includeSubDomains; preload
§Example
use std::time::Duration;
use rama_http_headers::StrictTransportSecurity;
let sts = StrictTransportSecurity::including_subdomains_for_max_seconds(31_536_000)
.with_preload(true);Implementations§
Source§impl StrictTransportSecurity
impl StrictTransportSecurity
Sourcepub fn including_subdomains_for_max_seconds(
max_age: u64,
) -> StrictTransportSecurity
pub fn including_subdomains_for_max_seconds( max_age: u64, ) -> StrictTransportSecurity
Create an STS header that includes subdomains
Sourcepub fn including_subdomains_for_max_duration_rounded(
dur: Duration,
) -> StrictTransportSecurity
pub fn including_subdomains_for_max_duration_rounded( dur: Duration, ) -> StrictTransportSecurity
Create an STS header that includes subdomains
The given Duration is rounded by ignoring any sub nano seconds.
Use Self::including_subdomains_for_max_duration in case you want to make
that a fallible case instead.
Sourcepub fn including_subdomains_for_max_duration(
dur: Duration,
) -> Option<StrictTransportSecurity>
pub fn including_subdomains_for_max_duration( dur: Duration, ) -> Option<StrictTransportSecurity>
Try to create a STS header that includes subdomains
§Error
Errors in case the given Duration contains sub nano seconds,
use Self::including_subdomains_for_max_seconds or
Self::including_subdomains_for_max_duration_rounded for a infallible constructor.
Sourcepub fn excluding_subdomains_for_max_seconds(
max_age: u64,
) -> StrictTransportSecurity
pub fn excluding_subdomains_for_max_seconds( max_age: u64, ) -> StrictTransportSecurity
Create an STS header that excludes subdomains
Sourcepub fn excluding_subdomains_for_max_duration_rounded(
dur: Duration,
) -> StrictTransportSecurity
pub fn excluding_subdomains_for_max_duration_rounded( dur: Duration, ) -> StrictTransportSecurity
Create an STS header that excludes subdomains
The given Duration is rounded by ignoring any sub nano seconds.
Use Self::excluding_subdomains_for_max_duration in case you want to make
that a fallible case instead.
Sourcepub fn excluding_subdomains_for_max_duration(
dur: Duration,
) -> Option<StrictTransportSecurity>
pub fn excluding_subdomains_for_max_duration( dur: Duration, ) -> Option<StrictTransportSecurity>
Try to create a STS header that excludes subdomains
§Error
Errors in case the given Duration contains sub nano seconds,
use Self::excluding_subdomains_for_max_seconds or
Self::excluding_subdomains_for_max_duration_rounded for a infallible constructor.
Sourcepub fn with_preload(self, preload: bool) -> StrictTransportSecurity
pub fn with_preload(self, preload: bool) -> StrictTransportSecurity
Mark this STS header as preload-eligible.
The preload directive is a Chromium/Mozilla extension required for
HSTS preload list eligibility — sites
listed there get HSTS protection on the user’s very first visit.
Per the preload list submission rules preload is only meaningful
alongside max-age ≥ 31536000 and includeSubDomains; this builder
does not enforce that, but callers should set both.
Sourcepub fn set_preload(&mut self, preload: bool) -> &mut StrictTransportSecurity
pub fn set_preload(&mut self, preload: bool) -> &mut StrictTransportSecurity
Mark this STS header as preload-eligible.
The preload directive is a Chromium/Mozilla extension required for
HSTS preload list eligibility — sites
listed there get HSTS protection on the user’s very first visit.
Per the preload list submission rules preload is only meaningful
alongside max-age ≥ 31536000 and includeSubDomains; this builder
does not enforce that, but callers should set both.
Sourcepub fn include_subdomains(&self) -> bool
pub fn include_subdomains(&self) -> bool
Get whether this should include subdomains.
Trait Implementations§
Source§impl Clone for StrictTransportSecurity
impl Clone for StrictTransportSecurity
Source§fn clone(&self) -> StrictTransportSecurity
fn clone(&self) -> StrictTransportSecurity
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 StrictTransportSecurity
impl Debug for StrictTransportSecurity
Source§impl HeaderDecode for StrictTransportSecurity
impl HeaderDecode for StrictTransportSecurity
Source§fn decode<'i, I>(values: &mut I) -> Result<StrictTransportSecurity, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<StrictTransportSecurity, Error>where
I: Iterator<Item = &'i HeaderValue>,
HeaderValues.Source§impl HeaderEncode for StrictTransportSecurity
impl HeaderEncode for StrictTransportSecurity
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 StrictTransportSecurity
impl PartialEq for StrictTransportSecurity
Source§fn eq(&self, other: &StrictTransportSecurity) -> bool
fn eq(&self, other: &StrictTransportSecurity) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for StrictTransportSecurity
Source§impl TypedHeader for StrictTransportSecurity
impl TypedHeader for StrictTransportSecurity
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
Auto Trait Implementations§
impl Freeze for StrictTransportSecurity
impl RefUnwindSafe for StrictTransportSecurity
impl Send for StrictTransportSecurity
impl Sync for StrictTransportSecurity
impl Unpin for StrictTransportSecurity
impl UnsafeUnpin for StrictTransportSecurity
impl UnwindSafe for StrictTransportSecurity
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<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