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§
sourcefn fmt(self, formatter: &mut HtmlFormatter<'_>) -> Result
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§
sourcefn write_to(self, buffer: &mut BytesMut) -> Result
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.