Trait rstml_component::HtmlContent

source ·
pub trait HtmlContent: Sized {
    // Required method
    fn fmt(self, formatter: &mut HtmlFormatter<'_>) -> Result;

    // Provided methods
    fn write_to(self, buffer: &mut BytesMut) -> Result { ... }
    fn into_bytes(self) -> Result<Bytes, Error> { ... }
    fn into_string(self) -> Result<String, Error> { ... }
}
Expand description

A trait representing content that can be formatted into HTML representation.

Types that implement this trait define how they should be formatted as HTML content. This trait provides methods to write the formatted content to various output formats, such as a byte buffer or a string.

Required Methods§

source

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

Formats the content and writes it to the provided HtmlFormatter.

This method defines how the implementing type’s content should be formatted as HTML. Implementations of this method should use the provided HtmlFormatter to write the formatted content according to the desired syntax and structure.

§Arguments
  • formatter: A mutable reference to the HtmlFormatter that handles the output.
§Returns

A std::fmt::Result indicating the success or failure of the formatting operation.

Provided Methods§

source

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

Writes the formatted content to the provided byte buffer.

This method creates an HtmlFormatter that writes to the given buffer and uses the fmt method to write the formatted content into the buffer.

§Arguments
  • buffer: A mutable reference to the byte buffer where the formatted content will be written.
§Returns

A std::fmt::Result indicating the success or failure of the formatting operation.

source

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

Converts the formatted content into a Bytes buffer.

This method writes the formatted content to a byte buffer and returns it as a Bytes object.

§Returns

A Result containing the Bytes object if successful, or a std::fmt::Error if formatting fails.

source

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

Converts the formatted content into a String.

This method writes the formatted content to a byte buffer, then attempts to convert it into a String.

§Returns

A Result containing the String if successful, or a std::fmt::Error if formatting or conversion to String fails.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl HtmlContent for &str

source§

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

source§

impl HtmlContent for &String

source§

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

source§

impl HtmlContent for bool

source§

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

source§

impl HtmlContent for f32

source§

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

source§

impl HtmlContent for f64

source§

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

source§

impl HtmlContent for i8

source§

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

source§

impl HtmlContent for i16

source§

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

source§

impl HtmlContent for i32

source§

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

source§

impl HtmlContent for i64

source§

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

source§

impl HtmlContent for i128

source§

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

source§

impl HtmlContent for isize

source§

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

source§

impl HtmlContent for u8

source§

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

source§

impl HtmlContent for u16

source§

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

source§

impl HtmlContent for u32

source§

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

source§

impl HtmlContent for u64

source§

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

source§

impl HtmlContent for u128

source§

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

source§

impl HtmlContent for ()

source§

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

source§

impl HtmlContent for usize

source§

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

source§

impl HtmlContent for Bytes

source§

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

source§

impl HtmlContent for String

source§

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

source§

impl<'a> HtmlContent for Arguments<'a>

source§

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

source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<N, O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (N, O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<O, P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (O, P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<P, Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (P, Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<Q, R, S, T, U, V, W, X, Y, Z> HtmlContent for (Q, R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<R, S, T, U, V, W, X, Y, Z> HtmlContent for (R, S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<S, T, U, V, W, X, Y, Z> HtmlContent for (S, T, U, V, W, X, Y, Z)

source§

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

source§

impl<T, U, V, W, X, Y, Z> HtmlContent for (T, U, V, W, X, Y, Z)

source§

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

source§

impl<T: HtmlContent> HtmlContent for Option<T>

source§

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

source§

impl<U, V, W, X, Y, Z> HtmlContent for (U, V, W, X, Y, Z)

source§

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

source§

impl<V, W, X, Y, Z> HtmlContent for (V, W, X, Y, Z)

source§

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

source§

impl<W, X, Y, Z> HtmlContent for (W, X, Y, Z)

source§

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

source§

impl<X, Y, Z> HtmlContent for (X, Y, Z)

source§

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

source§

impl<Y, Z> HtmlContent for (Y, Z)
where Y: HtmlContent, Z: HtmlContent,

source§

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

source§

impl<Z> HtmlContent for (Z,)
where Z: HtmlContent,

source§

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

Implementors§

source§

impl<F> HtmlContent for F
where F: FnOnce(&mut HtmlFormatter<'_>) -> Result,

source§

impl<I, F> HtmlContent for For<I, F>
where I: IntoIterator, F: FnMut(&mut HtmlFormatter<'_>, <I as IntoIterator>::Item) -> Result,

source§

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

source§

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