Struct url::RelativeSchemeData
[-] [+]
[src]
pub struct RelativeSchemeData { pub username: String, pub password: Option<String>, pub host: Host, pub port: Option<u16>, pub default_port: Option<u16>, pub path: Vec<String>, }
Components for URLs in a relative scheme such as HTTP.
Fields
Methods
impl RelativeSchemeData
fn lossy_percent_decode_username(&self) -> String
Percent-decode the URL’s username.
This is “lossy”: invalid UTF-8 percent-encoded byte sequences will be replaced � U+FFFD, the replacement character.
fn lossy_percent_decode_password(&self) -> Option<String>
Percent-decode the URL’s password, if any.
This is “lossy”: invalid UTF-8 percent-encoded byte sequences will be replaced � U+FFFD, the replacement character.
fn to_file_path<T: FromUrlPath>(&self) -> Result<T, ()>
Assuming the URL is in the file
scheme or similar,
convert its path to an absolute std::path::Path
.
Note: This does not actually check the URL’s scheme
,
and may give nonsensical results for other schemes.
It is the user’s responsibility to check the URL’s scheme before calling this.
The return type (when Ok()
) is generic and can be either std::path::posix::Path
or std::path::windows::Path
.
(Use std::path::Path
to pick one of them depending on the local system.)
If the compiler can not infer the desired type from context, you may have to specifiy it:
let path = url.to_file_path::<std::path::posix::Path>();
Returns Err
if the host is neither empty nor "localhost"
,
or if Path::new_opt()
returns None
.
(That is, if the percent-decoded path contains a NUL byte or,
for a Windows path, is not UTF-8.)
fn domain<'a>(&'a self) -> Option<&'a str>
If the host is a domain, return the domain as a string.
fn domain_mut<'a>(&'a mut self) -> Option<&'a mut String>
If the host is a domain, return a mutable reference to the domain string.
fn port_or_default(&self) -> Option<u16>
Return the port number of the URL, even if it is the default.
Return None
for file-like URLs.
fn serialize_path(&self) -> String
Serialize the path as a string.
The returned string starts with a "/" slash, and components are separated by slashes. A trailing slash represents an empty last component.
fn serialize_userinfo(&self) -> String
Serialize the userinfo as a string.
Format: "