Struct quick_xml::events::attributes::Attribute [] [src]

pub struct Attribute<'a> {
    pub key: &'a [u8],
    pub value: Cow<'a, [u8]>,
}

A struct representing a key/value for a xml attribute

Parses either key="value" or key='value'. Field value stores raw bytes, possibly containing escape-sequences.

Fields

the key to uniquely define the attribute

the raw value of attribute

Methods

impl<'a> Attribute<'a>
[src]

[src]

unescapes the value

[src]

unescapes then decode the value

for performance reasons (could avoid allocating a String), it might be wiser to manually use 1. Attributes::unescaped_value() 2. Reader::decode(...)

Trait Implementations

impl<'a> Debug for Attribute<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> Clone for Attribute<'a>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> PartialEq for Attribute<'a>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<'a> From<(&'a [u8], &'a [u8])> for Attribute<'a>
[src]

[src]

Creates new attribute from raw bytes. Does not apply any transformation to both key and value.

Example

use quick_xml::events::attributes::Attribute;

let features = Attribute::from(("features".as_bytes(), "Bells &amp; whistles".as_bytes()));
assert_eq!(features.value, "Bells &amp; whistles".as_bytes());

impl<'a> From<(&'a str, &'a str)> for Attribute<'a>
[src]

[src]

Creates new attribute from text representation. Key is stored as-is, but the value will be escaped.

Example

use quick_xml::events::attributes::Attribute;

let features = Attribute::from(("features", "Bells & whistles"));
assert_eq!(features.value, "Bells &amp; whistles".as_bytes());