Struct rstml_component::Sanitized

source ·
pub struct Sanitized<V>(/* private fields */);
Expand description

A wrapper struct for adding potentially unsanitized HTML content that will be sanitized before rendering.

The Sanitized struct allows you to include HTML content that might be potentially unsafe, and ensures that it’s properly sanitized before being rendered within your HTML components. This is particularly useful when you want to include user-generated content or any content that might contain unsafe HTML elements or scripts.

Implementations§

source§

impl<V> Sanitized<V>
where V: AsRef<[u8]>,

source

pub fn new(value: V) -> Self

Creates a new Sanitized instance with the HTML content to be sanitized before rendering.

§Arguments
  • value: The HTML content to be sanitized as a byte slice.
§Returns

A Sanitized instance wrapping the HTML content that will be sanitized before rendering.

source

pub fn new_with_sanitizer(value: V, sanitizer: &'static SanitizeConfig) -> Self

Creates a new Sanitized instance with the HTML content and a custom sanitizer.

§Arguments
  • value: The HTML content to be sanitized as a byte slice.
  • sanitizer: The custom sanitizer to be used for this specific instance.
§Returns

A Sanitized instance wrapping the HTML content that will be sanitized using the specified sanitizer.

source

pub fn with_sanitizer(self, sanitizer: &'static SanitizeConfig) -> Self

Sets a custom sanitizer for this Sanitized instance.

This method allows you to override the default sanitizer for a specific Sanitized instance.

§Arguments
  • sanitizer: The custom sanitizer to be used for this specific instance.
§Returns

A new Sanitized instance with the specified sanitizer.

Trait Implementations§

source§

impl<V: Clone> Clone for Sanitized<V>

source§

fn clone(&self) -> Sanitized<V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug> Debug for Sanitized<V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V: AsRef<[u8]>> HtmlContent for Sanitized<V>

source§

fn fmt(self, formatter: &mut HtmlFormatter<'_>) -> Result

Formats the content and writes it to the provided HtmlFormatter. Read more
source§

fn write_to(self, buffer: &mut BytesMut) -> Result

Writes the formatted content to the provided byte buffer. Read more
source§

fn into_bytes(self) -> Result<Bytes, Error>

Converts the formatted content into a Bytes buffer. Read more
source§

fn into_string(self) -> Result<String, Error>

Converts the formatted content into a String. Read more

Auto Trait Implementations§

§

impl<V> Freeze for Sanitized<V>
where V: Freeze,

§

impl<V> !RefUnwindSafe for Sanitized<V>

§

impl<V> Send for Sanitized<V>
where V: Send,

§

impl<V> Sync for Sanitized<V>
where V: Sync,

§

impl<V> Unpin for Sanitized<V>
where V: Unpin,

§

impl<V> !UnwindSafe for Sanitized<V>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.