pub struct StrictTransportSecurity { /* private fields */ }Expand description
HTTP Strict Transport Security (HSTS) policy.
§Examples
use http_security_headers::StrictTransportSecurity;
use std::time::Duration;
// One year HSTS with subdomains
let hsts = StrictTransportSecurity::new(Duration::from_secs(31536000))
.include_subdomains(true);
// Custom configuration
let hsts = StrictTransportSecurity::new(Duration::from_secs(86400))
.include_subdomains(false)
.preload(true);Implementations§
Source§impl StrictTransportSecurity
impl StrictTransportSecurity
Sourcepub fn new(max_age: Duration) -> Self
pub fn new(max_age: Duration) -> Self
Creates a new HSTS policy with the specified max-age.
§Arguments
max_age- The time, in seconds, that the browser should remember to only access the site using HTTPS.
§Examples
use http_security_headers::StrictTransportSecurity;
use std::time::Duration;
let hsts = StrictTransportSecurity::new(Duration::from_secs(31536000)); // 1 yearSourcepub fn include_subdomains(self, include: bool) -> Self
pub fn include_subdomains(self, include: bool) -> Self
Sets whether the rule applies to all subdomains.
When enabled, this rule applies to all of the site’s subdomains as well.
Sourcepub fn preload(self, preload: bool) -> Self
pub fn preload(self, preload: bool) -> Self
Sets whether the site wishes to be included in the HSTS preload list.
Note: Before enabling preload, ensure your site meets the preload list requirements: https://hstspreload.org/
Sourcepub fn includes_subdomains(&self) -> bool
pub fn includes_subdomains(&self) -> bool
Returns whether subdomains are included.
Sourcepub fn is_preload(&self) -> bool
pub fn is_preload(&self) -> bool
Returns whether preload is enabled.
Sourcepub fn to_header_value(&self) -> Result<String>
pub fn to_header_value(&self) -> Result<String>
Converts the policy to its header value string.
Trait Implementations§
Source§impl Clone for StrictTransportSecurity
impl Clone for StrictTransportSecurity
Source§fn clone(&self) -> StrictTransportSecurity
fn clone(&self) -> StrictTransportSecurity
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StrictTransportSecurity
impl Debug for StrictTransportSecurity
Source§impl Display for StrictTransportSecurity
impl Display for StrictTransportSecurity
Source§impl PartialEq for StrictTransportSecurity
impl PartialEq for StrictTransportSecurity
impl Eq for StrictTransportSecurity
impl StructuralPartialEq for StrictTransportSecurity
Auto Trait Implementations§
impl Freeze for StrictTransportSecurity
impl RefUnwindSafe for StrictTransportSecurity
impl Send for StrictTransportSecurity
impl Sync for StrictTransportSecurity
impl Unpin for StrictTransportSecurity
impl UnwindSafe for StrictTransportSecurity
Blanket Implementations§
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
Mutably borrows from an owned value. Read more