[−][src]Struct uriparse::authority::Username
The username component of the authority as defined in [RFC3986, Section 3.2.1].
The username is case-sensitive. Furthermore, percent-encoding plays no role in equality checking
for characters in the unreserved character set meaning that "username"
and "usern%61me"
are
identical. Both of these attributes are reflected in the equality and hash functions.
Be aware that just because percent-encoding plays no role in equality checking does not
mean that the username is normalized. If the username needs to be normalized, use the
Username::normalize
function.
Implementations
impl<'_> Username<'_>
[src]
pub fn as_borrowed(&self) -> Username<'_>
[src]
Returns a new username which is identical but has a lifetime tied to this username.
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the username.
Examples
use std::convert::TryFrom; use uriparse::Username; let username = Username::try_from("username").unwrap(); assert_eq!(username.as_str(), "username");
pub fn into_owned(self) -> Username<'static>
[src]
Converts the Username
into an owned copy.
If you construct the username from a source with a non-static lifetime, you may run into lifetime problems due to the way the struct is designed. Calling this function will ensure that the returned value has a static lifetime.
This is different from just cloning. Cloning the username will just copy the references, and thus the lifetime will remain the same.
pub fn is_normalized(&self) -> bool
[src]
Returns whether the username is normalized.
A normalized username will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
This function runs in constant-time.
Examples
use std::convert::TryFrom; use uriparse::Username; let username = Username::try_from("username").unwrap(); assert!(username.is_normalized()); let mut username = Username::try_from("%ff%ff").unwrap(); assert!(!username.is_normalized()); username.normalize(); assert!(username.is_normalized());
pub fn normalize(&mut self)
[src]
Normalizes the username such that it will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
If the username is already normalized, the function will return immediately. Otherwise, if the username is not owned, this function will perform an allocation to clone it. The normalization itself though, is done in-place with no extra memory allocations required.
Examples
use std::convert::TryFrom; use uriparse::Username; let mut username = Username::try_from("username").unwrap(); username.normalize(); assert_eq!(username, "username"); let mut username = Username::try_from("%ff%41").unwrap(); assert_eq!(username, "%ff%41"); username.normalize(); assert_eq!(username, "%FFA");
Trait Implementations
impl<'_> AsRef<[u8]> for Username<'_>
[src]
impl<'_> AsRef<str> for Username<'_>
[src]
impl<'username> Clone for Username<'username>
[src]
impl<'username> Debug for Username<'username>
[src]
impl<'_> Deref for Username<'_>
[src]
impl<'_> Display for Username<'_>
[src]
impl<'username> Eq for Username<'username>
[src]
impl<'username> From<Username<'username>> for String
[src]
impl<'_> Hash for Username<'_>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, '_> PartialEq<&'a [u8]> for Username<'_>
[src]
impl<'a, '_> PartialEq<&'a str> for Username<'_>
[src]
impl<'_> PartialEq<[u8]> for Username<'_>
[src]
impl<'_> PartialEq<Username<'_>> for Username<'_>
[src]
fn eq(&self, other: &Username<'_>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'username> PartialEq<Username<'username>> for [u8]
[src]
fn eq(&self, other: &Username<'username>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'username> PartialEq<Username<'username>> for &'a [u8]
[src]
fn eq(&self, other: &Username<'username>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'username> PartialEq<Username<'username>> for str
[src]
fn eq(&self, other: &Username<'username>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'username> PartialEq<Username<'username>> for &'a str
[src]
fn eq(&self, other: &Username<'username>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<str> for Username<'_>
[src]
impl<'username> TryFrom<&'username [u8]> for Username<'username>
[src]
type Error = UsernameError
The type returned in the event of a conversion error.
fn try_from(value: &'username [u8]) -> Result<Self, Self::Error>
[src]
impl<'username> TryFrom<&'username str> for Username<'username>
[src]
Auto Trait Implementations
impl<'username> RefUnwindSafe for Username<'username>
impl<'username> Send for Username<'username>
impl<'username> Sync for Username<'username>
impl<'username> Unpin for Username<'username>
impl<'username> UnwindSafe for Username<'username>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,