pub struct URIString { /* private fields */ }Implementations§
Source§impl URIString
impl URIString
Sourcepub fn parse(uri: impl AsRef<str>) -> Result<URIString, ParseRIError>
pub fn parse(uri: impl AsRef<str>) -> Result<URIString, 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.
Sourcepub fn parse_system_id(uri: impl AsRef<str>) -> Result<URIString, ParseRIError>
pub fn parse_system_id(uri: impl AsRef<str>) -> Result<URIString, 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:
- Each character to be escaped is represented in UTF-8 [Unicode] as one or more bytes.
- 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).
- The original character is replaced by the resulting character sequence.
Sourcepub fn parse_file_path(
path: impl AsRef<Path>,
) -> Result<URIString, ParseRIError>
pub fn parse_file_path( path: impl AsRef<Path>, ) -> Result<URIString, 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.
pub fn into_boxed_uri_str(self) -> Box<URIStr>
Methods from Deref<Target = URIStr>§
Sourcepub fn resolve(&self, reference: &URIStr) -> URIString
pub fn resolve(&self, reference: &URIStr) -> 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
Sourcepub fn as_escaped_str(&self) -> &str
pub fn as_escaped_str(&self) -> &str
Return the escaped URI string.
Sourcepub fn as_unescaped_str(&self) -> Option<Cow<'_, str>>
pub fn as_unescaped_str(&self) -> Option<Cow<'_, str>>
Return the unescaped URI string.
If unescaping fails, return None.
Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
§Reference
Sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
§Reference
§Reference
Sourcepub fn components(&self) -> Components<'_> ⓘ
pub fn components(&self) -> Components<'_> ⓘ
Return an iterator that scans the URI components.