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
key: &'a [u8]
the key to uniquely define the attribute
value: Cow<'a, [u8]>
the raw value of attribute
Methods
impl<'a> Attribute<'a>
[src]
fn unescaped_value(&self) -> Result<Cow<[u8]>>
[src]
unescapes the value
fn unescape_and_decode_value<B: BufRead>(
&self,
reader: &Reader<B>
) -> Result<String>
[src]
&self,
reader: &Reader<B>
) -> Result<String>
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]
impl<'a> Clone for Attribute<'a>
[src]
fn clone(&self) -> Attribute<'a>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> PartialEq for Attribute<'a>
[src]
fn eq(&self, __arg_0: &Attribute<'a>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Attribute<'a>) -> bool
[src]
This method tests for !=
.
impl<'a> From<(&'a [u8], &'a [u8])> for Attribute<'a>
[src]
fn from(val: (&'a [u8], &'a [u8])) -> Attribute<'a>
[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 & whistles".as_bytes())); assert_eq!(features.value, "Bells & whistles".as_bytes());
impl<'a> From<(&'a str, &'a str)> for Attribute<'a>
[src]
fn from(val: (&'a str, &'a str)) -> Attribute<'a>
[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 & whistles".as_bytes());