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>
impl<'a> UriRawComponents<'a>
Sourcepub fn from_str(uri: &'a str) -> Result<UriRawComponents<'a>, ParseError>
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.
Sourcepub fn scheme(&self) -> Option<&'a str>
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.
Returns the escaped slice of the URI that contains the “authority”, if present.
See UriRawComponents::authority
for the percent-decoded version.
Sourcepub fn raw_userinfo(&self) -> Option<&'a str>
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.
Sourcepub fn raw_host(&self) -> Option<&'a str>
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.
Sourcepub fn port(&self) -> Option<u16>
pub fn port(&self) -> Option<u16>
Returns the 16-bit representation of the port number, if present in the authority.
Sourcepub fn raw_path(&self) -> &'a str
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.
Sourcepub fn path_as_rel_ref(&self) -> &'a RelRef
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
.
Sourcepub fn raw_query(&self) -> Option<&'a str>
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.
Sourcepub fn raw_fragment(&self) -> Option<&'a str>
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.
Sourcepub fn raw_path_segments(&self) -> impl Iterator<Item = &'a str>
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.
Sourcepub fn raw_query_items(&self) -> impl Iterator<Item = &'a str>
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.
Sourcepub fn raw_query_key_values(&self) -> impl Iterator<Item = (&'a str, &'a str)>
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.
Sourcepub fn fragment(&self) -> Option<Cow<'_, str>>
pub fn fragment(&self) -> Option<Cow<'_, str>>
Unescaped (percent-decoded) version of UriRawComponents::raw_fragment
, using
std::borrow::Cow<str>
instead of &str
.
Sourcepub fn host(&self) -> Option<Cow<'_, str>>
pub fn host(&self) -> Option<Cow<'_, str>>
Unescaped (percent-decoded) version of UriRawComponents::raw_host
, using
std::borrow::Cow<str>
instead of &str
.
Unescaped (percent-decoded) version of UriRawComponents::raw_authority
, using
std::borrow::Cow<str>
instead of &str
.
Sourcepub fn userinfo(&self) -> Option<Cow<'_, str>>
pub fn userinfo(&self) -> Option<Cow<'_, str>>
Unescaped (percent-decoded) version of UriRawComponents::raw_userinfo
, using
std::borrow::Cow<str>
instead of &str
.
Sourcepub fn query(&self) -> Option<Cow<'_, str>>
pub fn query(&self) -> Option<Cow<'_, str>>
Unescaped (percent-decoded) version of UriRawComponents::raw_query
, using
std::borrow::Cow<str>
instead of &str
.
Sourcepub fn path_segments(&self) -> impl Iterator<Item = Cow<'_, str>>
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
.
Sourcepub fn query_items(&self) -> impl Iterator<Item = Cow<'_, str>>
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
.
Sourcepub fn query_key_values(
&self,
) -> impl Iterator<Item = (Cow<'_, str>, Cow<'_, str>)>
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
.
Sourcepub fn trim_leading_dot_slashes(&self) -> Self
pub fn trim_leading_dot_slashes(&self) -> Self
Returns a UriRawComponents
with any leading dot-slashes trimmed from the path.
Sourcepub fn trim_query(&self) -> Self
pub fn trim_query(&self) -> Self
Returns a UriRawComponents
with the query and fragment cleared.
Sourcepub fn trim_fragment(&self) -> Self
pub fn trim_fragment(&self) -> Self
Returns a UriRawComponents
with the query cleared.
Source§impl<'a> UriRawComponents<'a>
impl<'a> UriRawComponents<'a>
Sourcepub 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>
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<'_>
impl AnyUriRef for UriRawComponents<'_>
Source§fn write_to<T: Write + ?Sized>(&self, f: &mut T) -> Result<(), Error>
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
fn is_empty(&self) -> bool
Source§fn components(&self) -> UriRawComponents<'_>
fn components(&self) -> UriRawComponents<'_>
UriRawComponents
instance which contains all of the components for this
URI reference. Read moreSource§fn display(&self) -> UriDisplay<'_, Self>
fn display(&self) -> UriDisplay<'_, Self>
AnyUriRef
instance in a UriDisplay
object for use with formatting
macros like write!
and format!
. Read moreSource§fn write_resolved<T: Write + ?Sized, D: AnyUriRef + ?Sized>(
&self,
target: &D,
f: &mut T,
) -> Result<(), ResolveError>
fn write_resolved<T: Write + ?Sized, D: AnyUriRef + ?Sized>( &self, target: &D, f: &mut T, ) -> Result<(), ResolveError>
core::fmt::Write
instance the result of performing URI resolution
against target
, with self
being the base URI.Source§impl<'a> Clone for UriRawComponents<'a>
impl<'a> Clone for UriRawComponents<'a>
Source§fn clone(&self) -> UriRawComponents<'a>
fn clone(&self) -> UriRawComponents<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more