Enum magnesium::XmlElement[][src]

pub enum XmlElement<'s> {
    StartTag {
        name: &'s str,
        attrs: &'s str,
    },
    EndTag {
        name: &'s str,
    },
    EmptyTag {
        name: &'s str,
        attrs: &'s str,
    },
    Text(&'s str),
    Comment(&'s str),
}

An element within an XML structure.

Variants

StartTag

An opening tag with a name and some attributes.

Eg: <books attr1="val1">

If the XML is well formed, then there will be an EndTag with a matching name later on. In between there can be any number of sub-entries.

Fields of StartTag

name: &'s str

Name of this tag.

attrs: &'s str

Attribute string, parse this with a TagAttributeIterator.

EndTag

Closes the StartTag of the same name.

Eg: </books>

Fields of EndTag

name: &'s str

Name of the tag being closed.

EmptyTag

An "empty" tag has no inner content, just attributes.

Eg: <enum name="GRAPHICS_POLYGON value="0x0001"/>

Fields of EmptyTag

name: &'s str

The tag's name.

attrs: &'s str

The tag's attribute string.

Parse this with a TagAttributeIterator.

Text(&'s str)

Text between tags.

If there's a "CDATA" entry it is parsed as a Text element.

Comment(&'s str)

Text between <!-- and -->.

Implementations

impl<'s> XmlElement<'s>[src]

pub fn unwrap_start_tag(&self) -> (&'s str, &'s str)[src]

Unwraps a StartTag variant into the inner (name, attrs) pair.

Panics

If the variant isn't StartTag this will panic.

pub fn unwrap_end_tag(&self) -> &'s str[src]

Unwraps an EndTag variant into the inner name.

Panics

If the variant isn't EndTag this will panic.

pub fn unwrap_text(&self) -> &'s str[src]

Unwraps a Text variant into the inner &str value.

Panics

If the variant isn't Text this will panic.

pub fn unwrap_comment(&self) -> &'s str[src]

Unwraps a Comment variant into the inner &str value.

Panics

If the variant isn't Comment this will panic.

Trait Implementations

impl<'s> Clone for XmlElement<'s>[src]

impl<'s> Copy for XmlElement<'s>[src]

impl<'s> Debug for XmlElement<'s>[src]

impl<'s> Eq for XmlElement<'s>[src]

impl<'s> Hash for XmlElement<'s>[src]

impl<'s> PartialEq<XmlElement<'s>> for XmlElement<'s>[src]

impl<'s> StructuralEq for XmlElement<'s>[src]

impl<'s> StructuralPartialEq for XmlElement<'s>[src]

Auto Trait Implementations

impl<'s> Send for XmlElement<'s>[src]

impl<'s> Sync for XmlElement<'s>[src]

impl<'s> Unpin for XmlElement<'s>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.