Struct WriteOptions

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

A struct that define write options.

Implementations§

Source§

impl WriteOptions

Source

pub fn new() -> WriteOptions

Source

pub fn set_xml_prolog(self, prolog: Option<XmlProlog>) -> Self

Define which xml prolog will be displayed when rendering an Element.

Note that prolog is optional, an XML document with a missing prolog is well-formed but not valid.

See RFC: W3C XML 26 November 2008

Source

pub fn set_line_separator<I: Into<Cow<'static, str>>>(self, sep: I) -> Self

Line separator used to separate lines in formatted output. Default is "\n".

Source

pub fn set_indent_string<I: Into<Cow<'static, str>>>(self, indent: I) -> Self

A string which will be used for a single level of indentation. Default is " " (two spaces).

Source

pub fn set_perform_indent(self, yes: bool) -> Self

Whether or not the emitted document should be indented. Default is false.

The emitter is capable to perform automatic indentation of the emitted XML document. It is done in stream-like fashion and does not require the knowledge of the whole document in advance.

Sometimes, however, automatic indentation is undesirable, e.g. when you want to keep existing layout when processing an existing XML document. Also the indentiation algorithm is not thoroughly tested. Hence by default it is disabled.

Source

pub fn set_normalize_empty_elements(self, yes: bool) -> Self

Whether or not to convert elements with empty content to empty elements. Default is true.

This option allows turning elements like <a></a> (an element with empty content) into <a /> (an empty element).

Source

pub fn set_cdata_to_characters(self, yes: bool) -> Self

Whether or not to emit CDATA events as plain characters. Default is false.

This option forces the emitter to convert CDATA events into regular character events, performing all the necessary escaping beforehand. This may be occasionally useful for feeding the document into incorrect parsers which do not support CDATA.

Source

pub fn set_pad_self_closing(self, yes: bool) -> Self

Whether or not to automatically insert spaces before the trailing /> in self-closing elements. Default is true.

This option is only meaningful if normalize_empty_elements is true. For example, the element <a></a> would be unaffected. When normalize_empty_elements is true, then when this option is also true, the same element would appear <a />. If this option is false, then the same element would appear <a/>.

Source

pub fn set_autopad_comments(self, yes: bool) -> Self

Whether or not to automatically insert leading and trailing spaces in emitted comments, if necessary. Default is true.

This is a convenience option in order for the user not to append spaces before and after comments text in order to get more pretty comments: <!-- something --> instead of <!--something-->.

Trait Implementations§

Source§

impl Default for WriteOptions

Source§

fn default() -> WriteOptions

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