Struct UriRawComponents

Source
pub struct UriRawComponents<'a> { /* private fields */ }
Expand description

Struct that holds parsed URI components.

Internally, all components are referenced in raw/escaped form, but this type does provide methods for convenient decoded/unescaped access.

Instances of this type are usually created by calling a method named components() on the URI type you are working with.

That this struct implements AnyUriRef, allowing it to be used as an argument wherever a AnyUriRef is accepted.

Implementations§

Source§

impl<'a> UriRawComponents<'a>

Source

pub fn from_str(uri: &'a str) -> Result<UriRawComponents<'a>, ParseError>

Constructs a new UriRawComponents from the given string slice, which is assumed to contain a URI-reference.

Source

pub fn scheme(&self) -> Option<&'a str>

Returns the slice of the URI that describes the URI scheme, if present. Percent encoding is not allowed in the scheme, so no decoding is required.

Source

pub fn raw_authority(&self) -> Option<&'a str>

Returns the escaped slice of the URI that contains the “authority”, if present.

See UriRawComponents::authority for the percent-decoded version.

Source

pub fn raw_userinfo(&self) -> Option<&'a str>

Returns the escaped slice of the URI that contains the “userinfo”, if present.

See UriRawComponents::userinfo for the percent-decoded version.

Source

pub fn raw_host(&self) -> Option<&'a str>

Returns the escaped slice of the URI that contains the “host”, if present.

See UriRawComponents::host for the percent-decoded version.

Source

pub fn port(&self) -> Option<u16>

Returns the 16-bit representation of the port number, if present in the authority.

Source

pub fn raw_path(&self) -> &'a str

Returns the escaped slice of the URI that contains the “path”.

See UriRawComponents::path for the percent-decoded version.

Source

pub fn path_as_rel_ref(&self) -> &'a RelRef

Returns the subset of this URI that is a path, without the scheme, authority, query, or fragment. Since this is itself a valid relative URI, it returns a &RelRef.

Source

pub fn raw_query(&self) -> Option<&'a str>

Returns the escaped substring of the URI that contains the “query”, if present.

See StrExt for details on unescaping the results.

Source

pub fn raw_fragment(&self) -> Option<&'a str>

Returns the escaped substring of the URI that contains the “fragment”, if present.

See UriRawComponents::fragment for the percent-decoded version.

Source

pub fn raw_path_segments(&self) -> impl Iterator<Item = &'a str>

An iterator which returns each individual escaped path item.

See UriRawComponents::path_segments for the percent-decoded version.

Source

pub fn raw_query_items(&self) -> impl Iterator<Item = &'a str>

An iterator which returns each individual escaped query item.

See UriRawComponents::query_items for the percent-decoded version.

Source

pub fn raw_query_key_values(&self) -> impl Iterator<Item = (&'a str, &'a str)>

An iterator which returns each individual escaped query item as a key/value pair. Note that neither are unescaped.

See UriRawComponents::query_key_values for the percent-decoded version.

Source

pub fn fragment(&self) -> Option<Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_fragment, using std::borrow::Cow<str> instead of &str.

Source

pub fn host(&self) -> Option<Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_host, using std::borrow::Cow<str> instead of &str.

Source

pub fn authority(&self) -> Option<Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_authority, using std::borrow::Cow<str> instead of &str.

Source

pub fn userinfo(&self) -> Option<Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_userinfo, using std::borrow::Cow<str> instead of &str.

Source

pub fn query(&self) -> Option<Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_query, using std::borrow::Cow<str> instead of &str.

Source

pub fn path_segments(&self) -> impl Iterator<Item = Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_path_segments, using std::borrow::Cow<str> instead of &str.

Source

pub fn query_items(&self) -> impl Iterator<Item = Cow<'_, str>>

Unescaped (percent-decoded) version of UriRawComponents::raw_query_items, using std::borrow::Cow<str> instead of &str.

Source

pub fn query_key_values( &self, ) -> impl Iterator<Item = (Cow<'_, str>, Cow<'_, str>)>

Unescaped (percent-decoded) version of UriRawComponents::raw_query_key_values, using std::borrow::Cow<str> instead of &str.

Source

pub fn trim_leading_dot_slashes(&self) -> Self

Returns a UriRawComponents with any leading dot-slashes trimmed from the path.

Source

pub fn trim_query(&self) -> Self

Returns a UriRawComponents with the query and fragment cleared.

Source

pub fn trim_fragment(&self) -> Self

Returns a UriRawComponents with the query cleared.

Source§

impl<'a> UriRawComponents<'a>

Source

pub unsafe fn from_components_unchecked( scheme: Option<&'a str>, authority: Option<&'a str>, path: &'a str, query: Option<&'a str>, fragment: Option<&'a str>, ) -> UriRawComponents<'a>

Constructs a new UriRawComponents from the given raw, percent-encoded components, without checking that the components are valid.

This method is unsafe because the components are not checked to ensure they are valid.

Trait Implementations§

Source§

impl AnyUriRef for UriRawComponents<'_>

Source§

fn write_to<T: Write + ?Sized>(&self, f: &mut T) -> Result<(), Error>

Note that the implementation of this method for UriRawComponents ignores the value of self.userinfo, self.host, and self.port; instead relying entirely on self.authority.

Source§

fn is_empty(&self) -> bool

Returns true if the underlying URI-reference is actually the empty reference.
Source§

fn components(&self) -> UriRawComponents<'_>

Returns a UriRawComponents instance which contains all of the components for this URI reference. Read more
Source§

fn uri_type(&self) -> UriType

Gets the UriType of the underlying URI-reference.
Source§

fn display(&self) -> UriDisplay<'_, Self>

Wraps this AnyUriRef instance in a UriDisplay object for use with formatting macros like write! and format!. Read more
Source§

fn to_uri_ref_buf(&self) -> UriRefBuf

Creates a new UriRefBuf from this AnyUriRef. Read more
Source§

fn write_resolved<T: Write + ?Sized, D: AnyUriRef + ?Sized>( &self, target: &D, f: &mut T, ) -> Result<(), ResolveError>

Writes out to a core::fmt::Write instance the result of performing URI resolution against target, with self being the base URI.
Source§

fn resolved<T: AnyUriRef + ?Sized>( &self, dest: &T, ) -> Result<UriRefBuf, ResolveError>

Creates a new UriRefBuf that contains the result of performing URI resolution with dest.
Source§

impl<'a> Clone for UriRawComponents<'a>

Source§

fn clone(&self) -> UriRawComponents<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for UriRawComponents<'a>

Source§

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

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

impl Display for UriRawComponents<'_>

Source§

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

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

impl From<&UriRawComponents<'_>> for String

Source§

fn from(comp: &UriRawComponents<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<UriRawComponents<'_>> for String

Source§

fn from(comp: UriRawComponents<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Hash for UriRawComponents<'a>

Source§

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

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

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for UriRawComponents<'a>

Source§

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

Source§

impl<'a> Eq for UriRawComponents<'a>

Source§

impl<'a> StructuralPartialEq for UriRawComponents<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for UriRawComponents<'a>

§

impl<'a> RefUnwindSafe for UriRawComponents<'a>

§

impl<'a> Send for UriRawComponents<'a>

§

impl<'a> Sync for UriRawComponents<'a>

§

impl<'a> Unpin for UriRawComponents<'a>

§

impl<'a> UnwindSafe for UriRawComponents<'a>

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.