Struct Fragment

Source
pub struct Fragment(/* private fields */);
Expand description

URI fragment.

Implementations§

Source§

impl Fragment

Source

pub fn new<T: ?Sized + AsRef<[u8]>>( input: &T, ) -> Result<&Self, InvalidFragment<&T>>

Creates a new URI fragment by parsing the input value

Source

pub const unsafe fn new_unchecked(input: &[u8]) -> &Self

Creates a new URI fragment from the input value without validation.

§Safety

The input data must be a valid URI fragment.

Source

pub fn validate(input: impl Iterator<Item = u8>) -> bool

Checks that the input iterator produces a valid URI fragment

Source§

impl Fragment

Source

pub const EMPTY: &'static Self

Source§

impl Fragment

Source

pub fn as_bytes(&self) -> &[u8]

Source§

impl Fragment

Source

pub fn as_str(&self) -> &str

Source§

impl Fragment

Source

pub fn as_pct_str(&self) -> &PctStr

Returns the fragment as a percent-encoded string slice.

Methods from Deref<Target = PctStr>§

Source

pub fn len(&self) -> usize

Length of the decoded string (character count).

Computed in linear time. This is different from the byte length, which can be retrieved using value.as_bytes().len().

Source

pub fn is_empty(&self) -> bool

Checks if the string is empty.

Source

pub fn as_bytes(&self) -> &[u8]

Returns the underlying percent-encoding bytes.

Source

pub fn as_str(&self) -> &str

Get the underlying percent-encoded string slice.

Source

pub fn chars(&self) -> Chars<'_>

Iterate over the encoded characters of the string.

Source

pub fn bytes(&self) -> Bytes<'_>

Iterate over the encoded bytes of the string.

Source

pub fn decode(&self) -> String

Decoding.

Return the string with the percent-encoded characters decoded.

Trait Implementations§

Source§

impl AsRef<[u8]> for Fragment

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Fragment> for Fragment

Source§

fn as_ref(&self) -> &Fragment

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Fragment> for FragmentBuf

Source§

fn as_ref(&self) -> &Fragment

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for Fragment

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<[u8]> for Fragment

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<Fragment> for FragmentBuf

Source§

fn borrow(&self) -> &Fragment

Immutably borrows from an owned value. Read more
Source§

impl Debug for Fragment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Fragment

Source§

type Target = PctStr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for Fragment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Fragment> for &'a [u8]

Source§

fn from(value: &'a Fragment) -> &'a [u8]

Converts to this type from the input type.
Source§

impl<'a> From<&'a Fragment> for &'a str

Source§

fn from(value: &'a Fragment) -> &'a str

Converts to this type from the input type.
Source§

impl Hash for Fragment

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl Ord for Fragment

Source§

fn cmp(&self, other: &Fragment) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<'a> PartialEq<&'a Fragment> for FragmentBuf

Source§

fn eq(&self, other: &&'a Fragment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<&'a str> for Fragment

Source§

fn eq(&self, other: &&'a str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Fragment> for FragmentBuf

Source§

fn eq(&self, other: &Fragment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Fragment

Source§

fn eq(&self, other: &Fragment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd<&'a Fragment> for FragmentBuf

Source§

fn partial_cmp(&self, other: &&'a Fragment) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Fragment> for FragmentBuf

Source§

fn partial_cmp(&self, other: &Fragment) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Fragment

Source§

fn partial_cmp(&self, other: &Fragment) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToOwned for Fragment

Source§

type Owned = FragmentBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> FragmentBuf

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<'a> TryFrom<&'a [u8]> for &'a Fragment

Source§

type Error = InvalidFragment<&'a [u8]>

The type returned in the event of a conversion error.
Source§

fn try_from(input: &'a [u8]) -> Result<&'a Fragment, InvalidFragment<&'a [u8]>>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a str> for &'a Fragment

Source§

type Error = InvalidFragment<&'a str>

The type returned in the event of a conversion error.
Source§

fn try_from(input: &'a str) -> Result<&'a Fragment, InvalidFragment<&'a str>>

Performs the conversion.
Source§

impl Eq for Fragment

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more