Enum xml::writer::events::XmlEvent

source ·
pub enum XmlEvent<'a> {
    StartDocument {
        version: XmlVersion,
        encoding: Option<&'a str>,
        standalone: Option<bool>,
    },
    ProcessingInstruction {
        name: &'a str,
        data: Option<&'a str>,
    },
    StartElement {
        name: Name<'a>,
        attributes: Cow<'a, [Attribute<'a>]>,
        namespace: Cow<'a, Namespace>,
    },
    EndElement {
        name: Option<Name<'a>>,
    },
    CData(&'a str),
    Comment(&'a str),
    Characters(&'a str),
}
Expand description

A part of an XML output stream.

Objects of this enum are consumed by EventWriter. They correspond to different parts of an XML document.

Variants§

§

StartDocument

Fields

§version: XmlVersion

XML version.

Defaults to XmlVersion::Version10.

§encoding: Option<&'a str>

XML document encoding.

Defaults to Some("UTF-8").

§standalone: Option<bool>

XML standalone declaration.

Defaults to None.

Corresponds to XML document declaration.

This event should always be written before any other event. If it is not written at all, a default XML declaration will be outputted if the corresponding option is set in the configuration. Otherwise an error will be returned.

§

ProcessingInstruction

Fields

§name: &'a str

Processing instruction target.

§data: Option<&'a str>

Processing instruction content.

Denotes an XML processing instruction.

§

StartElement

Fields

§name: Name<'a>

Qualified name of the element.

§attributes: Cow<'a, [Attribute<'a>]>

A list of attributes associated with the element.

Currently attributes are not checked for duplicates (TODO). Attribute values will be escaped, and all characters invalid for attribute values like " or < will be changed into character entities.

§namespace: Cow<'a, Namespace>

Contents of the namespace mapping at this point of the document.

This mapping will be inspected for “new” entries, and if at this point of the document a particular pair of prefix and namespace URI is already defined, no namespace attributes will be emitted.

Denotes a beginning of an XML element.

§

EndElement

Fields

§name: Option<Name<'a>>

Optional qualified name of the element.

If None, then it is assumed that the element name should be the last valid one. If Some and element names tracking is enabled, then the writer will check it for correctness.

Denotes an end of an XML element.

§

CData(&'a str)

Denotes CDATA content.

This event contains unparsed data, and no escaping will be performed when writing it to the output stream.

§

Comment(&'a str)

Denotes a comment.

The string will be checked for invalid sequences and error will be returned by the write operation

§

Characters(&'a str)

Denotes character data outside of tags.

Contents of this event will be escaped if perform_escaping option is enabled, that is, every character invalid for PCDATA will appear as a character entity.

Implementations§

source§

impl<'a> XmlEvent<'a>

source

pub fn processing_instruction( name: &'a str, data: Option<&'a str> ) -> XmlEvent<'a>

Returns an writer event for a processing instruction.

source

pub fn start_element<S>(name: S) -> StartElementBuilder<'a>where S: Into<Name<'a>>,

Returns a builder for a starting element.

This builder can then be used to tweak attributes and namespace starting at this element.

source

pub fn end_element() -> EndElementBuilder<'a>

Returns a builder for an closing element.

This method, unline start_element(), does not accept a name because by default the writer is able to determine it automatically. However, when this functionality is disabled, it is possible to specify the name with name() method on the builder.

source

pub fn cdata(data: &'a str) -> XmlEvent<'a>

Returns a CDATA event.

Naturally, the provided string won’t be escaped, except for closing CDATA token ]]> (depending on the configuration).

source

pub fn characters(data: &'a str) -> XmlEvent<'a>

Returns a regular characters (PCDATA) event.

All offending symbols, in particular, & and <, will be escaped by the writer.

source

pub fn comment(data: &'a str) -> XmlEvent<'a>

Returns a comment event.

Trait Implementations§

source§

impl<'a> Clone for XmlEvent<'a>

source§

fn clone(&self) -> XmlEvent<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for XmlEvent<'a>

source§

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

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

impl<'a> From<&'a str> for XmlEvent<'a>

source§

fn from(s: &'a str) -> XmlEvent<'a>

Converts to this type from the input type.
source§

impl<'a> From<EndElementBuilder<'a>> for XmlEvent<'a>

source§

fn from(b: EndElementBuilder<'a>) -> XmlEvent<'a>

Converts to this type from the input type.
source§

impl<'a> From<StartElementBuilder<'a>> for XmlEvent<'a>

source§

fn from(b: StartElementBuilder<'a>) -> XmlEvent<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for XmlEvent<'a>

§

impl<'a> Send for XmlEvent<'a>

§

impl<'a> Sync for XmlEvent<'a>

§

impl<'a> Unpin for XmlEvent<'a>

§

impl<'a> UnwindSafe for XmlEvent<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.