Struct quick_xml::events::attributes::Attribute [−][src]
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 unescaped_value and unescape_and_decode_value
functions.
Fields
key: &'a [u8]
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.
Methods
impl<'a> Attribute<'a>[src]
impl<'a> Attribute<'a>pub fn unescaped_value(&self) -> Result<Cow<[u8]>>[src]
pub fn unescaped_value(&self) -> Result<Cow<[u8]>>Returns the unescaped value.
This is normally the value you are interested in. Escape sequences such as > are
replaced with their unescaped equivalents such as >.
This will allocate if the value contains any escape sequences.
pub fn unescape_and_decode_value<B: BufRead>(
&self,
reader: &Reader<B>
) -> Result<String>[src]
pub fn unescape_and_decode_value<B: BufRead>(
&self,
reader: &Reader<B>
) -> Result<String>Returns the unescaped and decoded string value.
This allocates a String in all cases. For performance reasons it might be a better idea to
instead use one of:
unescaped_value(), as it doesn't allocate when no escape sequences are used.Reader::decode(), as it only allocates when the decoding can't be performed otherwise.
Trait Implementations
impl<'a> Debug for Attribute<'a>[src]
impl<'a> Debug for Attribute<'a>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<'a> Clone for Attribute<'a>[src]
impl<'a> Clone for Attribute<'a>fn clone(&self) -> Attribute<'a>[src]
fn clone(&self) -> Attribute<'a>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<'a> PartialEq for Attribute<'a>[src]
impl<'a> PartialEq for Attribute<'a>fn eq(&self, other: &Attribute<'a>) -> bool[src]
fn eq(&self, other: &Attribute<'a>) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Attribute<'a>) -> bool[src]
fn ne(&self, other: &Attribute<'a>) -> boolThis method tests for !=.
impl<'a> From<(&'a [u8], &'a [u8])> for Attribute<'a>[src]
impl<'a> From<(&'a [u8], &'a [u8])> for Attribute<'a>fn from(val: (&'a [u8], &'a [u8])) -> Attribute<'a>[src]
fn from(val: (&'a [u8], &'a [u8])) -> Attribute<'a>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 & whistles".as_bytes())); assert_eq!(features.value, "Bells & whistles".as_bytes());
impl<'a> From<(&'a str, &'a str)> for Attribute<'a>[src]
impl<'a> From<(&'a str, &'a str)> for Attribute<'a>fn from(val: (&'a str, &'a str)) -> Attribute<'a>[src]
fn from(val: (&'a str, &'a str)) -> Attribute<'a>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 & whistles".as_bytes());