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

A struct representing a key/value XML attribute.

Field value stores raw bytes, possibly containing escape-sequences. Most users will likely want to access the value using one of the unescape_value and decode_and_unescape_value functions.

Fields

key: QName<'a>

The key to uniquely define the attribute.

If Attributes::with_checks is turned off, the key might not be unique.

value: Cow<'a, [u8]>

The raw value of the attribute.

Implementations

Available on non-crate feature encoding only.

Decodes using UTF-8 then unescapes the value.

This is normally the value you are interested in. Escape sequences such as &gt; are replaced with their unescaped equivalents such as >.

This will allocate if the value contains any escape sequences.

See also unescape_value_with()

This method is available only if encoding feature is not enabled.

Available on non-crate feature encoding only.

Decodes using UTF-8 then unescapes the value, using custom entities.

This is normally the value you are interested in. Escape sequences such as &gt; are replaced with their unescaped equivalents such as >. A fallback resolver for additional custom entities can be provided via resolve_entity.

This will allocate if the value contains any escape sequences.

See also unescape_value()

This method is available only if encoding feature is not enabled.

Decodes then unescapes the value.

This will allocate if the value contains any escape sequences or in non-UTF-8 encoding.

Decodes then unescapes the value with custom entities.

This will allocate if the value contains any escape sequences or in non-UTF-8 encoding.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Examples
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());

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

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

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

Converts to this type from the input type.

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.