pub struct XmlWriter { /* private fields */ }Expand description
Writes TTX-style XML into a string (XMLWriter).
Implementations§
Source§impl XmlWriter
impl XmlWriter
Sourcepub fn new() -> Self
pub fn new() -> Self
A writer with the default indentation and "\n" line endings, which has
already written the XML declaration.
Sourcepub fn with_options(indent_white: &str, newline_str: &str) -> Self
pub fn with_options(indent_white: &str, newline_str: &str) -> Self
A writer with custom indentation and line endings (indentwhite,
newlinestr).
Sourcepub fn indent_white(&self) -> &str
pub fn indent_white(&self) -> &str
The indentation of one level (indentwhite).
Sourcepub fn indent_level(&self) -> usize
pub fn indent_level(&self) -> usize
The current indentation level (indentlevel).
Sourcepub fn newline_str(&self) -> &str
pub fn newline_str(&self) -> &str
The line ending in use.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the writer and returns its output.
Sourcepub fn write_with_indent(&mut self, s: &str, indent: bool)
pub fn write_with_indent(&mut self, s: &str, indent: bool)
Writes escaped text, optionally without indentation (write(s, indent=…)).
Sourcepub fn writecdata(&mut self, s: &str)
pub fn writecdata(&mut self, s: &str)
Writes text in a CDATA section (writecdata).
Sourcepub fn write8bit(&mut self, data: &[u8], strip: bool)
pub fn write8bit(&mut self, data: &[u8], strip: bool)
Writes bytes, escaping everything outside printable ASCII as a character
reference, so that the bytes can be recovered by encoding to Latin-1
(write8bit).
Sourcepub fn write_noindent(&mut self, s: &str)
pub fn write_noindent(&mut self, s: &str)
Writes escaped text without indentation (write_noindent).
Sourcepub fn write_raw(&mut self, data: &str, indent: bool)
pub fn write_raw(&mut self, data: &str, indent: bool)
Writes text as-is, indenting first if at the start of a line (_writeraw).
Sourcepub fn comment(&mut self, data: &str)
pub fn comment(&mut self, data: &str)
Writes a comment; continuation lines are indented to align (comment).
Sourcepub fn simpletag(&mut self, tag: &str, attrs: &Attrs<'_>)
pub fn simpletag(&mut self, tag: &str, attrs: &Attrs<'_>)
Writes an empty element, with attributes sorted by name as when fontTools
passes them as keyword arguments (simpletag(tag, **kwargs)).
Sourcepub fn simpletag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)
pub fn simpletag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)
Writes an empty element, keeping the attribute order
(simpletag(tag, [(name, value), …])).
Sourcepub fn begintag(&mut self, tag: &str, attrs: &Attrs<'_>)
pub fn begintag(&mut self, tag: &str, attrs: &Attrs<'_>)
Opens an element, with attributes sorted by name (begintag(tag, **kwargs)).
Sourcepub fn begintag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)
pub fn begintag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)
Opens an element, keeping the attribute order
(begintag(tag, [(name, value), …])).
Sourcepub fn endtag(&mut self, tag: &str)
pub fn endtag(&mut self, tag: &str)
Closes the innermost element (endtag).
§Panics
Panics if tag does not match the open element, which is a programming
error (fontTools asserts the same).