Event

Enum Event 

Source
pub enum Event<P>{
    StartDocument {
        span: StreamCharSpan<P>,
        version: usize,
    },
    EndDocument {
        span: StreamCharSpan<P>,
    },
    StartElement {
        span: StreamCharSpan<P>,
        tag: Tag,
    },
    EndElement {
        span: StreamCharSpan<P>,
        name: Name,
    },
    Content {
        span: StreamCharSpan<P>,
        ctype: ContentType,
        data: String,
    },
    ProcessingInstruction {
        span: StreamCharSpan<P>,
        name: NSNameId,
        data: Option<String>,
    },
    Comment {
        span: StreamCharSpan<P>,
        data: String,
        lengths: Vec<usize>,
    },
}
Expand description

A markup event occupying a [Span] on a stream

Variants§

§

StartDocument

The start of the document

Fields

§span: StreamCharSpan<P>

File position of start of the document

§version: usize

Version as an integer - 100 for 1.00, etc

§

EndDocument

The end of the document

Fields

§span: StreamCharSpan<P>

File position of end of the document

§

StartElement

Denotes a beginning of an XML element.

Fields

§span: StreamCharSpan<P>

The span of the start element ‘tag’

§tag: Tag

The actual tag (prefix, URI, name, attributes)

§

EndElement

Denotes an end of an XML element.

Fields

§span: StreamCharSpan<P>

The span of the end element ‘tag’

§name: Name

The (prefix, URI, name) of the element (equal to the same value as the StartElement that this closes)

§

Content

Denotes one part of the content of an element

Fields

§span: StreamCharSpan<P>

The span of the content

§ctype: ContentType

The type of the content: raw, whitespace, needs unescaping

§data: String

The string content

§

ProcessingInstruction

Denotes an XML processing instruction.

Fields

§span: StreamCharSpan<P>

The span of the PI

§name: NSNameId

A NSNameId within the namespace that is the name of the processing instruction

§data: Option<String>

An optional value for the processing instruction

§

Comment

Denotes a comment.

Fields

§span: StreamCharSpan<P>

The span of the comment

§data: String

One string containing all the lines of comment (separated by \n)

The last line does not have \n appended, so single line comments have no newline

§lengths: Vec<usize>

Length of each original comment line (not including any additional \n)

Implementations§

Source§

impl<P> Event<P>

Source

pub fn start_document(span: StreamCharSpan<P>, version: usize) -> Self

Create a StartDocument event

Source

pub fn end_document(span: StreamCharSpan<P>) -> Self

Create an EndDocument event

Source

pub fn start_element(span: StreamCharSpan<P>, tag: Tag) -> Self

Create a StartElement event with a given Tag

Source

pub fn end_element(span: StreamCharSpan<P>, name: Name) -> Self

Create an EndElement event with a given Name

Source

pub fn comment( span: StreamCharSpan<P>, data: String, lengths: Vec<usize>, ) -> Self

Create an event of a vec of comment strings

Source

pub fn content( span: StreamCharSpan<P>, ctype: ContentType, data: String, ) -> Self

Create an event of content of the given type

Source

pub fn content_raw(span: StreamCharSpan<P>, data: String) -> Self

Create an event of raw content

Source

pub fn content_int(span: StreamCharSpan<P>, data: String) -> Self

Create an event of interpretable content

Source

pub fn content_ws(span: StreamCharSpan<P>, data: String) -> Self

Create an event of whitespace content

Source

pub fn get_type(&self) -> EventType

Get the EventType corresponding to the Event

Source

pub fn borrow_span(&self) -> &StreamCharSpan<P>

Borrow the span of the event, for logging or errors etc.

Source

pub fn as_start_document(&self) -> Option<usize>

Return Some(version number) if the Event is a StartDocument event; else return None

Source

pub fn as_start_element(self) -> Option<Tag>

Return Some(Tag) if the Event is a StartElement event; else return None

Source

pub fn as_end_element(&self) -> Option<&Name>

Return Some(Name) if the Event is an EndElement event; else return None

Source

pub fn as_content(&self) -> Option<(ContentType, &str)>

Return Some(ContentType, string) if the Event is a Content event; else return None

Source

pub fn is_start_document(&self) -> bool

Return true if the Event is a StartDocument event

Source

pub fn is_end_document(&self) -> bool

Return true if the Event is an EndDocument event

Source§

impl<P> Event<P>

Source

pub fn as_xml_writer<'a>( &'a self, ns: &'a NamespaceStack<'_>, ) -> Option<XmlEvent<'a>>

Get an [xml::writer::XmlEvent<’a>] from this Name

Source

pub fn as_xml_reader( &self, ns: &NamespaceStack<'_>, _fill_namespaces: bool, ) -> Option<XmlEvent>

Get an [xml::reader::XmlEvent<’a>] from this Name

Trait Implementations§

Source§

impl<P> Debug for Event<P>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for Event<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for Event<P>
where P: RefUnwindSafe,

§

impl<P> Send for Event<P>
where P: Send,

§

impl<P> Sync for Event<P>
where P: Sync,

§

impl<P> Unpin for Event<P>
where P: Unpin,

§

impl<P> UnwindSafe for Event<P>
where P: 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 = 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.