Struct Segment

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

IRI path segment.

Implementations§

Source§

impl Segment

Source

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

Creates a new URI path segment by parsing the input value

Source

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

Creates a new URI path segment from the input value without validation.

§Safety

The input data must be a valid URI path segment.

Source

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

Checks that the input iterator produces a valid URI path segment

Source§

impl Segment

Source

pub const EMPTY: &'static Self

Source§

impl Segment

Source

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

Source§

impl Segment

Source

pub fn as_str(&self) -> &str

Source§

impl Segment

Source

pub const CURRENT: &'static Self

Source

pub const PARENT: &'static Self

Source

pub fn as_pct_str(&self) -> &PctStr

Returns the segment as a percent-encoded string slice.

Source

pub fn looks_like_scheme(&self) -> bool

Checks if this segments looks like a scheme part.

Returns true is of the form prefix:suffix where prefix is a valid scheme, of false otherwise.

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 Segment

Source§

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

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

impl AsRef<Segment> for Segment

Source§

fn as_ref(&self) -> &Segment

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

impl AsRef<Segment> for SegmentBuf

Source§

fn as_ref(&self) -> &Segment

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

impl AsRef<str> for Segment

Source§

fn as_ref(&self) -> &str

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

impl Borrow<[u8]> for Segment

Source§

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

Immutably borrows from an owned value. Read more
Source§

impl Borrow<Segment> for SegmentBuf

Source§

fn borrow(&self) -> &Segment

Immutably borrows from an owned value. Read more
Source§

impl Debug for Segment

Source§

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

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

impl Deref for Segment

Source§

type Target = PctStr

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Display for Segment

Source§

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

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

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl Hash for Segment

Source§

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

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

impl Ord for Segment

Source§

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

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

impl<'a> PartialEq<&'a Segment> for SegmentBuf

Source§

fn eq(&self, other: &&'a Segment) -> 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<Segment> for SegmentBuf

Source§

fn eq(&self, other: &Segment) -> 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 Segment

Source§

fn eq(&self, other: &Self) -> 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 Segment> for SegmentBuf

Source§

fn partial_cmp(&self, other: &&'a Segment) -> 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<Segment> for SegmentBuf

Source§

fn partial_cmp(&self, other: &Segment) -> 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 Segment

Source§

fn partial_cmp(&self, other: &Self) -> 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 Segment

Source§

type Owned = SegmentBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> SegmentBuf

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 Segment

Source§

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

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

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

Performs the conversion.
Source§

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

Source§

type Error = InvalidSegment<&'a str>

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

fn try_from(input: &'a str) -> Result<&'a Segment, InvalidSegment<&'a str>>

Performs the conversion.
Source§

impl Eq for Segment

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