pub struct SourceList { /* private fields */ }Expand description
Ordered list of SourceExpressions — the value of one CSP
directive.
Builder methods come in two flavours: with_* consumes self and
returns Self for chaining; set_* / add
mutate in place.
Implementations§
Source§impl SourceList
impl SourceList
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Empty list — for directives like upgrade-insecure-requests
that carry no source value.
Sourcepub fn self_origin() -> Self
pub fn self_origin() -> Self
'self'-only list. Equivalent to
SourceList::empty().with_self_keyword().
Sourcepub fn as_slice(&self) -> &[SourceExpression]
pub fn as_slice(&self) -> &[SourceExpression]
Borrow the underlying sources in declared (emit) order.
Sourcepub fn iter(&self) -> Iter<'_, SourceExpression>
pub fn iter(&self) -> Iter<'_, SourceExpression>
Iterate sources in declared (emit) order.
Sourcepub fn with(self, expr: SourceExpression) -> Self
pub fn with(self, expr: SourceExpression) -> Self
Push any source expression and return Self.
Sourcepub fn add(&mut self, expr: SourceExpression) -> &mut Self
pub fn add(&mut self, expr: SourceExpression) -> &mut Self
Push any source expression in place.
Sourcepub fn with_self_keyword(self) -> Self
pub fn with_self_keyword(self) -> Self
Append the 'self' keyword.
Sourcepub fn set_self_keyword(&mut self) -> &mut Self
pub fn set_self_keyword(&mut self) -> &mut Self
Append the 'self' keyword.
Sourcepub fn with_unsafe_inline(self) -> Self
pub fn with_unsafe_inline(self) -> Self
Append the 'unsafe-inline' keyword.
Sourcepub fn set_unsafe_inline(&mut self) -> &mut Self
pub fn set_unsafe_inline(&mut self) -> &mut Self
Append the 'unsafe-inline' keyword.
Sourcepub fn with_unsafe_eval(self) -> Self
pub fn with_unsafe_eval(self) -> Self
Append the 'unsafe-eval' keyword.
Sourcepub fn set_unsafe_eval(&mut self) -> &mut Self
pub fn set_unsafe_eval(&mut self) -> &mut Self
Append the 'unsafe-eval' keyword.
Sourcepub fn with_strict_dynamic(self) -> Self
pub fn with_strict_dynamic(self) -> Self
Append the 'strict-dynamic' keyword.
Sourcepub fn set_strict_dynamic(&mut self) -> &mut Self
pub fn set_strict_dynamic(&mut self) -> &mut Self
Append the 'strict-dynamic' keyword.
Sourcepub fn with_wasm_unsafe_eval(self) -> Self
pub fn with_wasm_unsafe_eval(self) -> Self
Append the 'wasm-unsafe-eval' keyword.
Sourcepub fn set_wasm_unsafe_eval(&mut self) -> &mut Self
pub fn set_wasm_unsafe_eval(&mut self) -> &mut Self
Append the 'wasm-unsafe-eval' keyword.
Sourcepub fn with_report_sample(self) -> Self
pub fn with_report_sample(self) -> Self
Append the 'report-sample' keyword.
Sourcepub fn set_report_sample(&mut self) -> &mut Self
pub fn set_report_sample(&mut self) -> &mut Self
Append the 'report-sample' keyword.
Sourcepub fn with_wildcard(self) -> Self
pub fn with_wildcard(self) -> Self
Append the * wildcard.
Sourcepub fn set_wildcard(&mut self) -> &mut Self
pub fn set_wildcard(&mut self) -> &mut Self
Append the * wildcard.
Sourcepub fn with_scheme(self, scheme: Protocol) -> Self
pub fn with_scheme(self, scheme: Protocol) -> Self
Append a Protocol as a scheme source (<scheme>:).
Sourcepub fn set_scheme(&mut self, scheme: Protocol) -> &mut Self
pub fn set_scheme(&mut self, scheme: Protocol) -> &mut Self
Append a Protocol as a scheme source (<scheme>:).
Sourcepub fn with_host(self, host: impl Into<HostSource>) -> Self
pub fn with_host(self, host: impl Into<HostSource>) -> Self
Append a HostSource (or anything convertible into one —
Domain, a &str via HostSource::try_parse etc.).
Sourcepub fn set_host(&mut self, host: impl Into<HostSource>) -> &mut Self
pub fn set_host(&mut self, host: impl Into<HostSource>) -> &mut Self
Append a HostSource (or anything convertible into one —
Domain, a &str via HostSource::try_parse etc.).
Sourcepub fn with_domain(self, domain: Domain) -> Self
pub fn with_domain(self, domain: Domain) -> Self
Append a bare-domain host source (no scheme, port, or path).
Sourcepub fn set_domain(&mut self, domain: Domain) -> &mut Self
pub fn set_domain(&mut self, domain: Domain) -> &mut Self
Append a bare-domain host source (no scheme, port, or path).
Sourcepub fn with_nonce(self, nonce: impl Into<Cow<'static, str>>) -> Self
pub fn with_nonce(self, nonce: impl Into<Cow<'static, str>>) -> Self
Append a 'nonce-<base64>' source.
Sourcepub fn set_nonce(&mut self, nonce: impl Into<Cow<'static, str>>) -> &mut Self
pub fn set_nonce(&mut self, nonce: impl Into<Cow<'static, str>>) -> &mut Self
Append a 'nonce-<base64>' source.
Trait Implementations§
Source§impl Clone for SourceList
impl Clone for SourceList
Source§fn clone(&self) -> SourceList
fn clone(&self) -> SourceList
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 SourceList
impl Debug for SourceList
Source§impl Default for SourceList
impl Default for SourceList
Source§fn default() -> SourceList
fn default() -> SourceList
Source§impl Display for SourceList
impl Display for SourceList
impl Eq for SourceList
Source§impl From<SourceExpression> for SourceList
impl From<SourceExpression> for SourceList
Source§fn from(expr: SourceExpression) -> Self
fn from(expr: SourceExpression) -> Self
Source§impl<T: Into<SourceExpression>> FromIterator<T> for SourceList
impl<T: Into<SourceExpression>> FromIterator<T> for SourceList
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl PartialEq for SourceList
impl PartialEq for SourceList
Source§fn eq(&self, other: &SourceList) -> bool
fn eq(&self, other: &SourceList) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SourceList
Auto Trait Implementations§
impl Freeze for SourceList
impl RefUnwindSafe for SourceList
impl Send for SourceList
impl Sync for SourceList
impl Unpin for SourceList
impl UnsafeUnpin for SourceList
impl UnwindSafe for SourceList
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
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> 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