URIString

Struct URIString 

Source
pub struct URIString { /* private fields */ }

Implementations§

Source§

impl URIString

Source

pub fn parse(uri: impl AsRef<str>) -> Result<Self, ParseRIError>

Parse the string as a URI by escaping all characters not specified as reserved or unreserved in RFC 3986.

Because certain characters containing % are escaped, the result of URIStr::as_unescaped_str is equal to uri, but the result of URIStr::as_escaped_str may differ from uri.

Since it escapes nearly all characters—including control characters, %, and non-ASCII characters—it will successfully parse any string that roughly follows URI notation.

Source

pub fn parse_system_id(uri: impl AsRef<str>) -> Result<Self, ParseRIError>

Parse the string as a URI after applying escaping according to XML 1.0 “4.2.2 External Entities”.

Some characters are escaped without escaping the % character, so both the result of URIStr::as_unescaped_str and the result of URIStr::as_escaped_str may differ from uri.

System identifiers (and other XML strings meant to be used as URI references) may contain characters that, according to [IETF RFC 3986], must be escaped before a URI can be used to retrieve the referenced resource. The characters to be escaped are the control characters #x0 to #x1F and #x7F (most of which cannot appear in XML), space #x20, the delimiters ‘<’ #x3C, ‘>’ #x3E and ‘“’ #x22, the unwise characters ‘{’ #x7B, ‘}’ #x7D, ‘|’ #x7C, ’' #x5C, ‘^’ #x5E and ‘`’ #x60, as well as all characters above #x7F. Since escaping is not always a fully reversible process, it MUST be performed only when absolutely necessary and as late as possible in a processing chain. In particular, neither the process of converting a relative URI to an absolute one nor the process of passing a URI reference to a process or software component responsible for dereferencing it SHOULD trigger escaping. When escaping does occur, it MUST be performed as follows:

  1. Each character to be escaped is represented in UTF-8 [Unicode] as one or more bytes.
  2. The resulting bytes are escaped with the URI escaping mechanism (that is, converted to % HH, where HH is the hexadecimal notation of the byte value).
  3. The original character is replaced by the resulting character sequence.
Source

pub fn parse_file_path(path: impl AsRef<Path>) -> Result<Self, ParseRIError>

§Note

In the current implementation, paths that cannot be converted to UTF-8 strings cannot be handled.
I don’t think there will be any problems in most environments, but there may be some paths that cannot be handled.

Source

pub fn into_boxed_uri_str(self) -> Box<URIStr>

Source

pub fn normalize(&mut self)

Methods from Deref<Target = URIStr>§

Source

pub fn resolve(&self, reference: &Self) -> URIString

Resolve the relative reference reference using self as the base URI.

self must be convertible to an absolute URI through fragment removal and normalization.

§Reference
Source

pub fn as_escaped_str(&self) -> &str

Return the escaped URI string.

Source

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

Return the unescaped URI string.
If unescaping fails, return None.

Source

pub fn is_absolute(&self) -> bool

Source

pub fn is_relative(&self) -> bool

Source

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

§Reference

3.1. Scheme

Source

pub fn authority(&self) -> Option<&str>

§Reference

3.2. Authority

Source

pub fn userinfo(&self) -> Option<&str>

Source

pub fn host(&self) -> Option<&str>

§Reference

3.2.2. Host

Source

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

§Reference

3.2.3. Port

Source

pub fn path(&self) -> &str

§Reference

3.3. Path

Source

pub fn query(&self) -> Option<&str>

§Reference

3.4. Query

Source

pub fn fragment(&self) -> Option<&str>

§Reference

3.5. Fragment

Source

pub fn components(&self) -> Components<'_>

Return an iterator that scans the URI components.

Trait Implementations§

Source§

impl AsRef<URIStr> for URIString

Source§

fn as_ref(&self) -> &URIStr

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

impl Borrow<URIStr> for URIString

Source§

fn borrow(&self) -> &URIStr

Immutably borrows from an owned value. Read more
Source§

impl Clone for URIString

Source§

fn clone(&self) -> URIString

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 Debug for URIString

Source§

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

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

impl Deref for URIString

Source§

type Target = URIStr

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Display for URIString

Source§

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

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

impl From<&URIStr> for URIString

Source§

fn from(value: &URIStr) -> Self

Converts to this type from the input type.
Source§

impl From<URIString> for Arc<URIStr>

Source§

fn from(value: URIString) -> Arc<URIStr>

Converts to this type from the input type.
Source§

impl From<URIString> for Box<URIStr>

Source§

fn from(value: URIString) -> Box<URIStr>

Converts to this type from the input type.
Source§

impl From<URIString> for Rc<URIStr>

Source§

fn from(value: URIString) -> Rc<URIStr>

Converts to this type from the input type.
Source§

impl Hash for URIString

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 PartialEq for URIString

Source§

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

Source§

impl StructuralPartialEq for URIString

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<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<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> 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.