(&self, serializer: &mut S, traversal_scope: TraversalScope) -> io::Result<()>
where
S: Serializer;
}
/// Types that are capable of serializing implement this trait
pub trait Serializer {
/// Serialize the start of an element, for example ``.
fn start_elem<'a, AttrIter>(&mut self, name: QualName, attrs: AttrIter) -> io::Result<()>
where
AttrIter: Iterator- >;
/// Serialize the end of an element, for example `
`.
fn end_elem(&mut self, name: QualName) -> io::Result<()>;
/// Serialize a plain text node.
fn write_text(&mut self, text: &str) -> io::Result<()>;
/// Serialize a comment node, for example ``.
fn write_comment(&mut self, text: &str) -> io::Result<()>;
/// Serialize a doctype node, for example ``.
fn write_doctype(&mut self, name: &str) -> io::Result<()>;
/// Serialize a processing instruction node, for example
/// ``.
fn write_processing_instruction(&mut self, target: &str, data: &str) -> io::Result<()>;
}
/// A type alias for an attribute name and value (e.g. the `class="test"` in ``
/// is represented as `(, "test")`.
///
/// This is used in [`Serializer::start_elem`] where the value being serialized must supply an
/// iterator over the attributes for the current element
///
/// [`Serializer::start_elem`]: trait.Serializer.html#tymethod.start_elem
pub type AttrRef<'a> = (&'a QualName, &'a str);