[−][src]Struct xml_string::names::Qname
String slice for QName
.
Implementations
impl Qname
[src]
pub fn from_str(s: &str) -> Result<&Self, NameError>
[src]
Creates a new &Qname
.
Failures
Fails if the given string is not a valid QName
.
Examples
let noprefix = Qname::from_str("hello")?; assert_eq!(noprefix, "hello"); let prefixed = Qname::from_str("foo:bar")?; assert_eq!(prefixed, "foo:bar"); assert!(Qname::from_str("").is_err(), "Empty string is not a QName"); assert!(Qname::from_str("foo bar").is_err(), "Whitespace is not allowed"); assert!(Qname::from_str("foo:bar:baz").is_err(), "Two or more colons are not allowed"); assert!(Qname::from_str("0foo").is_err(), "ASCII digit at the beginning is not allowed");
#[must_use]pub unsafe fn new_unchecked(s: &str) -> &Self
[src]
Creates a new &Qname
without validation.
Safety
The given string should be a valid QName
.
Examples
let name = unsafe { Qname::new_unchecked("foo:bar") }; assert_eq!(name, "foo:bar");
#[must_use]pub fn as_str(&self) -> &str
[src]
Returns the string as &str
.
Examples
let name = Qname::from_str("foo:bar")?; assert_eq!(name, "foo:bar"); let s: &str = name.as_str(); assert_eq!(s, "foo:bar");
pub fn parse_next(s: &str) -> Result<(&Self, &str), NameError>
[src]
Parses the leading Qname
and returns the value and the rest input.
Exmaples
let input = "hello:012"; let expected = Qname::from_str("hello").expect("valid Qname"); assert_eq!( Qname::parse_next(input), Ok((expected, ":012")) );
let input = "hello:world:foo"; let expected = Qname::from_str("hello:world").expect("valid Qname"); assert_eq!( Qname::parse_next(input), Ok((expected, ":foo")) );
let input = "012"; assert!(Qname::parse_next(input).is_err());
#[must_use]pub fn has_prefix(&self) -> bool
[src]
Returns whether the QName has a prefix.
Note that this is O(length) operation.
Consider using ParsedQname::has_prefix
method if possible.
Examples
let local_only = Qname::from_str("hello")?; assert!(!local_only.has_prefix()); let prefixed = Qname::from_str("foo:bar")?; assert!(prefixed.has_prefix());
#[must_use]pub fn prefix(&self) -> Option<&Ncname>
[src]
Returns the prefix if available.
Note that this is O(length) operation.
Consider using ParsedQname::prefix
method if possible.
Examples
let prefixed = Qname::from_str("foo:bar")?; assert_eq!(prefixed.prefix().map(|s| s.as_str()), Some("foo")); let noprefix = Qname::from_str("foo")?; assert_eq!(noprefix.prefix().map(|s| s.as_str()), None);
#[must_use]pub fn local_part(&self) -> &Ncname
[src]
Returns the local part.
Note that this is O(length) operation.
Consider using ParsedQname::local_part
method if possible.
Examples
let prefixed = Qname::from_str("foo:bar")?; assert_eq!(prefixed.local_part(), "bar"); let noprefix = Qname::from_str("foo")?; assert_eq!(noprefix.local_part(), "foo");
#[must_use]pub fn prefix_and_local(&self) -> (Option<&Ncname>, &Ncname)
[src]
Returns a pair of the prefix (if available) and the local part.
Note that this is O(length) operation.
Consider using ParsedQname::prefix_and_local
method if possible.
Examples
use std::convert::TryFrom; let noprefix = Qname::from_str("hello")?; assert_eq!(noprefix.prefix_and_local(), (noprefix.prefix(), noprefix.local_part())); let prefixed = Qname::from_str("foo:bar")?; assert_eq!(prefixed.prefix_and_local(), (prefixed.prefix(), prefixed.local_part()));
pub fn into_boxed_str(self: Box<Self>) -> Box<str>
[src]
Converts a Box<Qname>
into a Box<str>
without copying or allocating.
Examples
let name = Qname::from_str("q:name")?; let boxed_name: Box<Qname> = name.into(); assert_eq!(&*boxed_name, name); let boxed_str: Box<str> = boxed_name.into_boxed_str(); assert_eq!(&*boxed_str, name.as_str());
Trait Implementations
impl AsRef<Name> for Qname
[src]
impl AsRef<Nmtoken> for Qname
[src]
impl AsRef<Qname> for Ncname
[src]
impl AsRef<Qname> for Qname
[src]
impl<'_> AsRef<Qname> for ParsedQname<'_>
[src]
impl AsRef<str> for Qname
[src]
impl<'_> Debug for &'_ Qname
[src]
impl<'_> Display for &'_ Qname
[src]
impl Eq for Qname
[src]
impl<'_> From<&'_ Qname> for Box<Qname>
[src]
impl<'_> From<&'_ Qname> for Rc<Qname>
[src]
impl<'_> From<&'_ Qname> for Arc<Qname>
[src]
impl<'a> From<&'a Ncname> for &'a Qname
[src]
impl<'a> From<&'a Qname> for &'a Name
[src]
impl<'a> From<&'a Qname> for &'a Nmtoken
[src]
impl<'a> From<&'a Qname> for ParsedQname<'a>
[src]
impl<'a> From<ParsedQname<'a>> for &'a Qname
[src]
pub fn from(s: ParsedQname<'a>) -> Self
[src]
impl Hash for Qname
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Qname
[src]
pub fn cmp(&self, other: &Qname) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<'_> PartialEq<&'_ Qname> for str
[src]
impl<'_> PartialEq<&'_ String> for Qname
[src]
pub fn eq(&self, o: &&String) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ str> for Qname
[src]
impl PartialEq<Box<str, Global>> for Qname
[src]
pub fn eq(&self, o: &Box<str>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<Cow<'_, str>> for Qname
[src]
pub fn eq(&self, o: &Cow<'_, str>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<Qname> for Qname
[src]
impl PartialEq<Qname> for str
[src]
impl<'_> PartialEq<Qname> for &'_ str
[src]
impl PartialEq<Qname> for String
[src]
impl<'_> PartialEq<Qname> for &'_ String
[src]
impl PartialEq<Qname> for Box<str>
[src]
impl<'_> PartialEq<Qname> for Cow<'_, str>
[src]
impl PartialEq<String> for Qname
[src]
impl PartialEq<str> for Qname
[src]
impl<'_> PartialEq<str> for &'_ Qname
[src]
impl<'_> PartialOrd<&'_ Qname> for str
[src]
pub fn partial_cmp(&self, o: &&Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ String> for Qname
[src]
pub fn partial_cmp(&self, o: &&String) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ str> for Qname
[src]
pub fn partial_cmp(&self, o: &&str) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Box<str, Global>> for Qname
[src]
pub fn partial_cmp(&self, o: &Box<str>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<Cow<'_, str>> for Qname
[src]
pub fn partial_cmp(&self, o: &Cow<'_, str>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Qname> for Qname
[src]
pub fn partial_cmp(&self, other: &Qname) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Qname) -> bool
[src]
pub fn le(&self, other: &Qname) -> bool
[src]
pub fn gt(&self, other: &Qname) -> bool
[src]
pub fn ge(&self, other: &Qname) -> bool
[src]
impl PartialOrd<Qname> for str
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<Qname> for &'_ str
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Qname> for String
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<Qname> for &'_ String
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Qname> for Box<str>
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<Qname> for Cow<'_, str>
[src]
pub fn partial_cmp(&self, o: &Qname) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<String> for Qname
[src]
pub fn partial_cmp(&self, o: &String) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<str> for Qname
[src]
pub fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<str> for &'_ Qname
[src]
pub fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Qname
[src]
impl StructuralPartialEq for Qname
[src]
impl ToOwned for Qname
[src]
type Owned = Box<Qname>
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> Self::Owned
[src]
pub fn clone_into(&self, target: &mut Self::Owned)
[src]
impl<'a> TryFrom<&'a Qname> for &'a Ncname
[src]
type Error = NameError
The type returned in the event of a conversion error.