pub struct CspNonce(/* private fields */);Expand description
A cryptographically random CSP nonce associated with one request.
Handlers and renderers can extract this value with Extension<CspNonce> and add
nonce="..." to trusted inline <script> or <style> elements.
Implementations§
Source§impl CspNonce
impl CspNonce
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generates a fresh 128-bit nonce using the operating system random source.
Sourcepub fn get_or_insert(extensions: &mut Extensions) -> Self
pub fn get_or_insert(extensions: &mut Extensions) -> Self
Returns the nonce already associated with a request or creates and stores a fresh one.
Security layers should use this helper instead of unconditionally replacing the request extension so independently composed layers and the renderer share one nonce identity.
Trait Implementations§
impl Eq for CspNonce
impl StructuralPartialEq for CspNonce
Auto Trait Implementations§
impl Freeze for CspNonce
impl RefUnwindSafe for CspNonce
impl Send for CspNonce
impl Sync for CspNonce
impl Unpin for CspNonce
impl UnsafeUnpin for CspNonce
impl UnwindSafe for CspNonce
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
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP