Enum UriType

Source
pub enum UriType {
    Uri,
    UriNoAuthority,
    UriCannotBeABase,
    NetworkPath,
    AbsolutePath,
    RelativePath,
    Query,
    Fragment,
}
Expand description

Enum describing the type of a URI.

Variants§

§

Uri

An IETF-RFC3986 “URI”, including both scheme and authority components; E.g. http://example.com/abcd

assert_eq!(UriType::Uri, uri_ref!("http://example.com/abcd").uri_type());

URI references with this type can borrowed as a &Uri.

§

UriNoAuthority

An IETF-RFC3986 “URI” that has a scheme but no authority component, where the path begins with a slash; E.g. unix:/run/foo.socket

assert_eq!(UriType::UriNoAuthority, uri_ref!("unix:/run/foo.socket").uri_type());

URI references with this type can borrowed as a &Uri.

§

UriCannotBeABase

An IETF-RFC3986 “URI” that has a scheme but no authority component, where the path does not start with a slash (/); E.g. tel:+1-555-867-5309

assert_eq!(UriType::UriCannotBeABase, uri_ref!("tel:+1-555-867-5309").uri_type());

URI references with this type can borrowed as a &Uri.

§

NetworkPath

An IETF-RFC3986 “network-path” that has an authority component but no scheme; E.g. //example.com/foo/bar?q

assert_eq!(UriType::NetworkPath, uri_ref!("//example.com/foo/bar").uri_type());

Note that according to IETF-RFC3986 this is a “relative-reference”, but because it includes an authority this library considers it to be borrowable as a &Uri.

§

AbsolutePath

An IETF-RFC3986 “relative-reference” with a “path-absolute” and optionally a query and/or fragment; E.g. /foo/bar?q

assert_eq!(UriType::AbsolutePath, uri_ref!("/foo/bar?q").uri_type());

URI references with this type can borrowed as a &RelRef.

§

RelativePath

An IETF-RFC3986 “relative-reference” with a “path-rootless” and optionally a query and/or fragment; E.g. foo/bar?q

An empty URI reference has this type, but the path is guaranteed to have a non-zero length if a query or fragment is present.

assert_eq!(UriType::RelativePath, uri_ref!("foo/bar?q").uri_type());
assert_eq!(UriType::RelativePath, uri_ref!("").uri_type());

URI references with this type can borrowed as a &RelRef.

§

Query

An IETF-RFC3986 “relative-reference” with a “path-empty”, a query, and optionally a fragment; E.g. ?q=blah, ?q=blah#foo-bar

assert_eq!(UriType::Query, uri_ref!("?q=blah").uri_type());
assert_eq!(UriType::Query, uri_ref!("?q=blah#foo-bar").uri_type());

URI references with this type can borrowed as a &RelRef.

§

Fragment

An IETF-RFC3986 “relative-reference” that includes only a fragment component; E.g. #foo-bar

assert_eq!(UriType::Fragment, uri_ref!("#foo-bar").uri_type());

URI references with this type can borrowed as a &RelRef.

Implementations§

Source§

impl UriType

Source

pub fn can_borrow_as_uri(&self) -> bool

Returns true if this type can be borrowed as a [&Uri], false otherwise.

Source

pub fn can_borrow_as_rel_ref(&self) -> bool

Returns true if this type can be borrowed as a [&RelRef], false otherwise.

Source

pub fn has_absolute_path(&self) -> bool

Returns true if this type can be assumed to have an absolute path.

Source

pub fn is_ietf_rfc3986_relative_reference(&self) -> bool

Returns true if IETF-RFC3986 considers this type to be a “relative-reference”.

Source

pub fn cannot_be_a_base(&self) -> bool

Returns true if this type cannot be used as a base when performing URI reference resolution.

Trait Implementations§

Source§

impl Clone for UriType

Source§

fn clone(&self) -> UriType

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 UriType

Source§

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

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

impl Hash for UriType

Source§

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

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 UriType

Source§

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

Source§

impl Eq for UriType

Source§

impl StructuralPartialEq for UriType

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<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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V