Skip to main content

XmlBuf

Struct XmlBuf 

Source
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

Source

pub fn new() -> Self

Source

pub fn with_capacity(n: usize) -> Self

Source

pub fn with_charset(n: usize, charset: OutputCharset) -> Self

Buffer that escapes characters outside charset as numeric character references in text / attribute content.

Source

pub fn push_str(&mut self, s: &str)

Source

pub fn push_byte(&mut self, b: u8)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn into_bytes(self) -> Vec<u8>

Source

pub fn into_string(self) -> String

Infallible: the buffer only ever receives valid UTF-8.

Source

pub fn push_escaped_text(&mut self, s: &str)

Write s with XML text content escaping (&, <, >).

Also escapes \r (U+000D) as &#xD; 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.

Source

pub fn push_escaped_attr(&mut self, s: &str)

Write s with XML attribute value escaping (&, <, ").

Also escapes \t / \n / \r as &#x9; / &#xA; / &#xD; 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.

Trait Implementations§

Source§

impl Default for XmlBuf

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.