Struct rstml_component::HtmlAttributeFormatter
source · pub struct HtmlAttributeFormatter<'a> { /* private fields */ }
Expand description
A formatter for serializing HTML attribute values.
Implementations§
source§impl<'a> HtmlAttributeFormatter<'a>
impl<'a> HtmlAttributeFormatter<'a>
sourcepub fn write_bytes(&mut self, raw: &[u8])
pub fn write_bytes(&mut self, raw: &[u8])
sourcepub fn write(&mut self, value: &[u8])
pub fn write(&mut self, value: &[u8])
Writes escaped bytes to the attribute formatter, ensuring valid HTML attribute characters.
This method accepts a reference to a byte slice containing the content to be written to the
formatter’s buffer. The provided value
is escaped to ensure that it only contains valid HTML
attribute characters, preventing any unintentional issues with attribute values. The escaped
content is then written to the formatter’s buffer.
§Arguments
value
: A reference to the raw byte slice containing the content to be escaped and written.
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves space in the buffer for writing additional bytes without re-allocation.
This method ensures that enough space is reserved in the formatter’s buffer to accommodate
the writing of additional
bytes without needing to reallocate memory. It’s useful to call
this method before writing a significant amount of content, as it can help prevent frequent
reallocations and improve performance.
§Arguments
additional
: The number of additional bytes to reserve space for in the buffer.