[−][src]Struct uriparse::fragment::Fragment
The fragment component as defined in [RFC3986, Section 3.5].
The fragment is case-sensitive. Furthermore, percent-encoding plays no role in equality checking
for characters in the unreserved character set meaning that "fragment"
and "fr%61gment"
are
identical. Both of these attributes are reflected in the equality and hash functions.
However, be aware that just because percent-encoding plays no role in equality checking does not
mean that the fragment is normalized. If the fragment needs to be normalized, use the
Fragment::normalize
function.
Implementations
impl<'_> Fragment<'_>
[src]
pub fn as_borrowed(&self) -> Fragment<'_>
[src]
Returns a new fragment which is identical but has a lifetime tied to this fragment.
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the fragment.
Examples
use std::convert::TryFrom; use uriparse::Fragment; let fragment = Fragment::try_from("fragment").unwrap(); assert_eq!(fragment.as_str(), "fragment");
pub fn into_owned(self) -> Fragment<'static>
[src]
Converts the Fragment
into an owned copy.
If you construct the fragment 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 fragment will just copy the references, and thus the lifetime will remain the same.
pub fn is_normalized(&self) -> bool
[src]
Returns whether the fragment is normalized.
A normalized fragment 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::Fragment; let fragment = Fragment::try_from("fragment").unwrap(); assert!(fragment.is_normalized()); let mut fragment = Fragment::try_from("%ff%ff").unwrap(); assert!(!fragment.is_normalized()); fragment.normalize(); assert!(fragment.is_normalized());
pub fn normalize(&mut self)
[src]
Normalizes the fragment 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 fragment is already normalized, the function will return immediately. Otherwise, if the fragment 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::Fragment; let mut fragment = Fragment::try_from("fragment").unwrap(); fragment.normalize(); assert_eq!(fragment, "fragment"); let mut fragment = Fragment::try_from("%ff%41").unwrap(); assert_eq!(fragment, "%ff%41"); fragment.normalize(); assert_eq!(fragment, "%FFA");
Trait Implementations
impl<'_> AsRef<[u8]> for Fragment<'_>
[src]
impl<'_> AsRef<str> for Fragment<'_>
[src]
impl<'fragment> Clone for Fragment<'fragment>
[src]
impl<'fragment> Debug for Fragment<'fragment>
[src]
impl<'_> Deref for Fragment<'_>
[src]
impl<'_> Display for Fragment<'_>
[src]
impl<'_> Eq for Fragment<'_>
[src]
impl<'fragment> From<Fragment<'fragment>> for String
[src]
impl<'_> Hash for Fragment<'_>
[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 Fragment<'_>
[src]
impl<'a, '_> PartialEq<&'a str> for Fragment<'_>
[src]
impl<'_> PartialEq<[u8]> for Fragment<'_>
[src]
impl<'_> PartialEq<Fragment<'_>> for Fragment<'_>
[src]
fn eq(&self, other: &Fragment<'_>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'fragment> PartialEq<Fragment<'fragment>> for [u8]
[src]
fn eq(&self, other: &Fragment<'fragment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'fragment> PartialEq<Fragment<'fragment>> for &'a [u8]
[src]
fn eq(&self, other: &Fragment<'fragment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'fragment> PartialEq<Fragment<'fragment>> for str
[src]
fn eq(&self, other: &Fragment<'fragment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'fragment> PartialEq<Fragment<'fragment>> for &'a str
[src]
fn eq(&self, other: &Fragment<'fragment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<str> for Fragment<'_>
[src]
impl<'fragment> TryFrom<&'fragment [u8]> for Fragment<'fragment>
[src]
type Error = FragmentError
The type returned in the event of a conversion error.
fn try_from(value: &'fragment [u8]) -> Result<Self, Self::Error>
[src]
impl<'fragment> TryFrom<&'fragment str> for Fragment<'fragment>
[src]
Auto Trait Implementations
impl<'fragment> RefUnwindSafe for Fragment<'fragment>
impl<'fragment> Send for Fragment<'fragment>
impl<'fragment> Sync for Fragment<'fragment>
impl<'fragment> Unpin for Fragment<'fragment>
impl<'fragment> UnwindSafe for Fragment<'fragment>
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>,