pub enum Attr<T> {
DoubleQ(T, T),
SingleQ(T, T),
Unquoted(T, T),
Empty(T),
}
Expand description
A struct representing a key/value XML or HTML attribute.
Variants
DoubleQ(T, T)
Attribute with value enclosed in double quotes ("
). Attribute key and
value provided. This is a canonical XML-style attribute.
SingleQ(T, T)
Attribute with value enclosed in single quotes ('
). Attribute key and
value provided. This is an XML-style attribute.
Unquoted(T, T)
Attribute with value not enclosed in quotes. Attribute key and value
provided. This is HTML-style attribute, it can be returned in HTML-mode
parsing only. In an XML mode AttrError::UnquotedValue
will be raised
instead.
Attribute value can be invalid according to the HTML specification,
in particular, it can contain "
, '
, =
, <
, and `
characters. The absence of the >
character is nevertheless guaranteed,
since the parser extracts events based on them even before the start
of parsing attributes.
Empty(T)
Attribute without value. Attribute key provided. This is HTML-style attribute,
it can be returned in HTML-mode parsing only. In XML mode
AttrError::ExpectedEq
will be raised instead.
Implementations
sourceimpl<'a> Attr<&'a [u8]>
impl<'a> Attr<&'a [u8]>
sourcepub fn key(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn key(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns the key value
sourcepub fn value(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn value(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns the attribute value. For Self::Empty
variant an empty slice
is returned according to the HTML specification.
Trait Implementations
sourceimpl<T> From<Attr<T>> for (T, Option<T>)
impl<T> From<Attr<T>> for (T, Option<T>)
Unpacks attribute key and value into tuple of this two elements.
None
value element is returned only for Attr::Empty
variant.
sourceimpl<T: Ord> Ord for Attr<T>
impl<T: Ord> Ord for Attr<T>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq> PartialEq<Attr<T>> for Attr<T>
impl<T: PartialEq> PartialEq<Attr<T>> for Attr<T>
sourceimpl<T: PartialOrd> PartialOrd<Attr<T>> for Attr<T>
impl<T: PartialOrd> PartialOrd<Attr<T>> for Attr<T>
sourcefn partial_cmp(&self, other: &Attr<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Attr<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Eq> Eq for Attr<T>
impl<T> StructuralEq for Attr<T>
impl<T> StructuralPartialEq for Attr<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Attr<T>where
T: RefUnwindSafe,
impl<T> Send for Attr<T>where
T: Send,
impl<T> Sync for Attr<T>where
T: Sync,
impl<T> Unpin for Attr<T>where
T: Unpin,
impl<T> UnwindSafe for Attr<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more