pub struct QName<'a>(pub &'a [u8]);
Expand description
A qualified name of an element or an attribute, including an optional namespace prefix and a local name.
Tuple Fields
0: &'a [u8]
Implementations
sourceimpl<'a> QName<'a>
impl<'a> QName<'a>
sourcepub fn into_inner(self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn into_inner(self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Converts this name to an internal slice representation.
sourcepub fn local_name(&self) -> LocalName<'a>
pub fn local_name(&self) -> LocalName<'a>
Returns local part of this qualified name.
All content up to and including the first :
character is removed from
the tag name.
Examples
let simple = QName(b"simple-name");
assert_eq!(simple.local_name().as_ref(), b"simple-name");
let qname = QName(b"namespace:simple-name");
assert_eq!(qname.local_name().as_ref(), b"simple-name");
sourcepub fn prefix(&self) -> Option<Prefix<'a>>
pub fn prefix(&self) -> Option<Prefix<'a>>
Returns namespace part of this qualified name or None
if namespace part
is not defined (symbol ':'
not found).
Examples
let simple = QName(b"simple-name");
assert_eq!(simple.prefix(), None);
let qname = QName(b"prefix:simple-name");
assert_eq!(qname.prefix().as_ref().map(|n| n.as_ref()), Some(b"prefix".as_ref()));
sourcepub fn decompose(&self) -> (LocalName<'a>, Option<Prefix<'a>>)
pub fn decompose(&self) -> (LocalName<'a>, Option<Prefix<'a>>)
The same as (qname.local_name(), qname.prefix())
, but does only one
lookup for a ':'
symbol.
sourcepub fn as_namespace_binding(&self) -> Option<PrefixDeclaration<'a>>
pub fn as_namespace_binding(&self) -> Option<PrefixDeclaration<'a>>
If that QName
represents "xmlns"
series of names, returns Some
,
otherwise None
is returned.
Examples
let qname = QName(b"xmlns");
assert_eq!(qname.as_namespace_binding(), Some(PrefixDeclaration::Default));
let qname = QName(b"xmlns:prefix");
assert_eq!(qname.as_namespace_binding(), Some(PrefixDeclaration::Named(b"prefix")));
// Be aware that this method does not check the validity of the prefix - it can be empty!
let qname = QName(b"xmlns:");
assert_eq!(qname.as_namespace_binding(), Some(PrefixDeclaration::Named(b"")));
let qname = QName(b"other-name");
assert_eq!(qname.as_namespace_binding(), None);
// https://www.w3.org/TR/xml-names11/#xmlReserved
let qname = QName(b"xmlns-reserved-name");
assert_eq!(qname.as_namespace_binding(), None);
Trait Implementations
sourceimpl<'de: 'a, 'a> Deserialize<'de> for QName<'a>
impl<'de: 'a, 'a> Deserialize<'de> for QName<'a>
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a> Ord for QName<'a>
impl<'a> Ord for QName<'a>
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<'a> PartialOrd<QName<'a>> for QName<'a>
impl<'a> PartialOrd<QName<'a>> for QName<'a>
sourcefn partial_cmp(&self, other: &QName<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &QName<'a>) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moreimpl<'a> Copy for QName<'a>
impl<'a> Eq for QName<'a>
impl<'a> StructuralEq for QName<'a>
impl<'a> StructuralPartialEq for QName<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for QName<'a>
impl<'a> Send for QName<'a>
impl<'a> Sync for QName<'a>
impl<'a> Unpin for QName<'a>
impl<'a> UnwindSafe for QName<'a>
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