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
impl UriType
Sourcepub fn can_borrow_as_uri(&self) -> bool
pub fn can_borrow_as_uri(&self) -> bool
Returns true if this type can be borrowed as a [&Uri
], false otherwise.
Sourcepub fn can_borrow_as_rel_ref(&self) -> bool
pub fn can_borrow_as_rel_ref(&self) -> bool
Returns true if this type can be borrowed as a [&RelRef
], false otherwise.
Sourcepub fn has_absolute_path(&self) -> bool
pub fn has_absolute_path(&self) -> bool
Returns true if this type can be assumed to have an absolute path.
Sourcepub fn is_ietf_rfc3986_relative_reference(&self) -> bool
pub fn is_ietf_rfc3986_relative_reference(&self) -> bool
Returns true if IETF-RFC3986 considers this type to be a “relative-reference”.
Sourcepub fn cannot_be_a_base(&self) -> bool
pub fn cannot_be_a_base(&self) -> bool
Returns true if this type cannot be used as a base when performing URI reference resolution.