Trait Serializer

Source
pub trait Serializer {
    // Required methods
    fn serialize_attribute(
        &mut self,
        key: &str,
        value: Cow<'_, str>,
    ) -> Result<()>;
    fn serialize_text(&mut self, text: Cow<'_, str>) -> Result<()>;
    fn serialize_element<E: Element>(&mut self, element: &E) -> Result<()>;
}
Expand description

Interface to serialize an element.

An element needs to serialize attributes first, then inner text and elements.

Required Methods§

Source

fn serialize_attribute(&mut self, key: &str, value: Cow<'_, str>) -> Result<()>

Add an attribute to the serialized element

Source

fn serialize_text(&mut self, text: Cow<'_, str>) -> Result<()>

Add inner text to the element.

Must be escaped automatically by the serializer.

Source

fn serialize_element<E: Element>(&mut self, element: &E) -> Result<()>

Add an inner element

The serializer will need to determine the Element::tag of the element and call its Element::serialize function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§