[−][src]Struct uriparse::authority::Password
The password component of the authority as defined in [RFC3986, Section 3.2.1].
Even though this library supports parsing the password from the user information, it should be noted that the format "username:password" is deprecated. Also, be careful logging this!
The password is case-sensitive. Furthermore, percent-encoding plays no role in equality checking
for characters in the unreserved character set meaning that "password"
and "p%61ssword"
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 password is normalized. If the password needs to be normalized, use the
Password::normalize
function.
Implementations
impl<'_> Password<'_>
[src]
pub fn as_borrowed(&self) -> Password<'_>
[src]
Returns a new password which is identical but has a lifetime tied to this password.
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the password.
Examples
use std::convert::TryFrom; use uriparse::Password; let password = Password::try_from("password").unwrap(); assert_eq!(password, "password");
pub fn into_owned(self) -> Password<'static>
[src]
Converts the Password
into an owned copy.
If you construct the authority 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 password will just copy the references, and thus the lifetime will remain the same.
pub fn is_normalized(&self) -> bool
[src]
Returns whether the password is normalized.
A normalized password 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::Password; let password = Password::try_from("password").unwrap(); assert!(password.is_normalized()); let mut password = Password::try_from("%ff%ff").unwrap(); assert!(!password.is_normalized()); password.normalize(); assert!(password.is_normalized());
pub fn normalize(&mut self)
[src]
Normalizes the password 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 password is already normalized, the function will return immediately. Otherwise, if the password 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::Password; let mut password = Password::try_from("password").unwrap(); password.normalize(); assert_eq!(password, "password"); let mut password = Password::try_from("%ff%41").unwrap(); assert_eq!(password, "%ff%41"); password.normalize(); assert_eq!(password, "%FFA");
Trait Implementations
impl<'_> AsRef<[u8]> for Password<'_>
[src]
impl<'_> AsRef<str> for Password<'_>
[src]
impl<'password> Clone for Password<'password>
[src]
impl<'password> Debug for Password<'password>
[src]
impl<'_> Deref for Password<'_>
[src]
impl<'_> Display for Password<'_>
[src]
impl<'_> Eq for Password<'_>
[src]
impl<'password> From<Password<'password>> for String
[src]
impl<'_> Hash for Password<'_>
[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 Password<'_>
[src]
impl<'a, '_> PartialEq<&'a str> for Password<'_>
[src]
impl<'_> PartialEq<[u8]> for Password<'_>
[src]
impl<'_> PartialEq<Password<'_>> for Password<'_>
[src]
fn eq(&self, other: &Password<'_>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'password> PartialEq<Password<'password>> for [u8]
[src]
fn eq(&self, other: &Password<'password>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'password> PartialEq<Password<'password>> for &'a [u8]
[src]
fn eq(&self, other: &Password<'password>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'password> PartialEq<Password<'password>> for str
[src]
fn eq(&self, other: &Password<'password>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'password> PartialEq<Password<'password>> for &'a str
[src]
fn eq(&self, other: &Password<'password>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<str> for Password<'_>
[src]
impl<'password> TryFrom<&'password [u8]> for Password<'password>
[src]
type Error = PasswordError
The type returned in the event of a conversion error.
fn try_from(value: &'password [u8]) -> Result<Self, Self::Error>
[src]
impl<'password> TryFrom<&'password str> for Password<'password>
[src]
Auto Trait Implementations
impl<'password> RefUnwindSafe for Password<'password>
impl<'password> Send for Password<'password>
impl<'password> Sync for Password<'password>
impl<'password> Unpin for Password<'password>
impl<'password> UnwindSafe for Password<'password>
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>,