[−][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.
Methods
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<'_> PartialEq<Fragment<'_>> for Fragment<'_>
[src]
fn eq(&self, other: &Fragment) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'_> PartialEq<[u8]> for Fragment<'_>
[src]
fn eq(&self, other: &[u8]) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
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]
This method tests for !=
.
impl<'a, '_> PartialEq<&'a [u8]> for Fragment<'_>
[src]
fn eq(&self, other: &&'a [u8]) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
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]
This method tests for !=
.
impl<'_> PartialEq<str> for Fragment<'_>
[src]
fn eq(&self, other: &str) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
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]
This method tests for !=
.
impl<'a, '_> PartialEq<&'a str> for Fragment<'_>
[src]
fn eq(&self, other: &&'a str) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
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]
This method tests for !=
.
impl<'fragment> From<Fragment<'fragment>> for String
[src]
impl<'fragment> Clone for Fragment<'fragment>
[src]
fn clone(&self) -> Fragment<'fragment>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'_> Eq for Fragment<'_>
[src]
impl<'_> Display for Fragment<'_>
[src]
impl<'fragment> Debug for Fragment<'fragment>
[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,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'_> Deref for Fragment<'_>
[src]
impl<'fragment> TryFrom<&'fragment [u8]> for Fragment<'fragment>
[src]
type Error = InvalidFragment
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
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,