Skip to main content

XmlWriter

Struct XmlWriter 

Source
pub struct XmlWriter { /* private fields */ }
Expand description

Writes TTX-style XML into a string (XMLWriter).

Implementations§

Source§

impl XmlWriter

Source

pub fn new() -> Self

A writer with the default indentation and "\n" line endings, which has already written the XML declaration.

Source

pub fn with_options(indent_white: &str, newline_str: &str) -> Self

A writer with custom indentation and line endings (indentwhite, newlinestr).

Source

pub fn indent_white(&self) -> &str

The indentation of one level (indentwhite).

Source

pub fn indent_level(&self) -> usize

The current indentation level (indentlevel).

Source

pub fn newline_str(&self) -> &str

The line ending in use.

Source

pub fn as_str(&self) -> &str

The output so far.

Source

pub fn into_string(self) -> String

Consumes the writer and returns its output.

Source

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

Writes escaped text (write).

Source

pub fn write_with_indent(&mut self, s: &str, indent: bool)

Writes escaped text, optionally without indentation (write(s, indent=…)).

Source

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

Writes text in a CDATA section (writecdata).

Source

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).

Source

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

Writes escaped text without indentation (write_noindent).

Source

pub fn write_raw(&mut self, data: &str, indent: bool)

Writes text as-is, indenting first if at the start of a line (_writeraw).

Source

pub fn newline(&mut self)

Ends the line (newline).

Source

pub fn comment(&mut self, data: &str)

Writes a comment; continuation lines are indented to align (comment).

Source

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)).

Source

pub fn simpletag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)

Writes an empty element, keeping the attribute order (simpletag(tag, [(name, value), …])).

Source

pub fn begintag(&mut self, tag: &str, attrs: &Attrs<'_>)

Opens an element, with attributes sorted by name (begintag(tag, **kwargs)).

Source

pub fn begintag_ordered(&mut self, tag: &str, attrs: &Attrs<'_>)

Opens an element, keeping the attribute order (begintag(tag, [(name, value), …])).

Source

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).

Source

pub fn dumphex(&mut self, data: &[u8])

Writes binary data as lines of hex digits, 16 bytes per line in groups of four bytes (dumphex).

Source

pub fn indent(&mut self)

Increases the indentation (indent).

Source

pub fn dedent(&mut self)

Decreases the indentation (dedent).

Trait Implementations§

Source§

impl Debug for XmlWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for XmlWriter

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for XmlWriter

§

impl Freeze for XmlWriter

§

impl Move for XmlWriter

§

impl RefUnwindSafe for XmlWriter

§

impl Send for XmlWriter
where RawVecInner: Send,

§

impl Sync for XmlWriter
where RawVecInner: Sync,

§

impl Unpin for XmlWriter
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for XmlWriter

§

impl UnwindSafe for XmlWriter
where RawVecInner: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.