pub struct XmlBuf { /* private fields */ }Expand description
64-bit clean output buffer. Replaces the libxml2 xmlBuf / xmlBuffer
duality — only one type here, always size_t-indexed.
Implementations§
Source§impl XmlBuf
impl XmlBuf
pub fn new() -> Self
pub fn with_capacity(n: usize) -> Self
Sourcepub fn with_charset(n: usize, charset: OutputCharset) -> Self
pub fn with_charset(n: usize, charset: OutputCharset) -> Self
Buffer that escapes characters outside charset as numeric
character references in text / attribute content.
pub fn push_str(&mut self, s: &str)
pub fn push_byte(&mut self, b: u8)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Infallible: the buffer only ever receives valid UTF-8.
Sourcepub fn push_escaped_text(&mut self, s: &str)
pub fn push_escaped_text(&mut self, s: &str)
Write s with XML text content escaping (&, <, >).
Also escapes \r (U+000D) as 
 so that text containing a
literal carriage return survives a parse → serialize → parse
round-trip — without the char-ref, the second parse’s §2.11
end-of-line normalization would rewrite the \r to \n. The
same reasoning applies to NEL (U+0085) and LS (U+2028) under
XML 1.1, but those are rare enough in text content that we let
them through verbatim; documents written by sup-xml are
version=“1.0” by default and so won’t trigger NEL/LS
normalization on the receiving end.
Sourcepub fn push_escaped_attr(&mut self, s: &str)
pub fn push_escaped_attr(&mut self, s: &str)
Write s with XML attribute value escaping (&, <, ").
Also escapes \t / \n / \r as 	 / 
 / 
so the value survives a parse → serialize → parse round-trip
— XML §3.3.3 attribute-value normalization rewrites literal
tab / LF / CR to a single space on the receiving end, so
preserving them through the wire requires char-ref escaping.