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
username: String
The username of the URL, as a possibly empty, percent-encoded string.
Percent encoded strings are within the ASCII range.
See also the lossy_percent_decode_username
method.
password: Option<String>
The password of the URL.
None
if the :
delimiter character was not part of the parsed input,
otherwise a possibly empty, percent-encoded string.
Percent encoded strings are within the ASCII range.
See also the lossy_percent_decode_password
method.
host: Host
The host of the URL, either a domain name or an IPv4 address
port: Option<u16>
The port number of the URL.
None
for file-like schemes, or to indicate the default port number.
default_port: Option<u16>
The default port number for the URL’s scheme.
None
for file-like schemes.
path: Vec<String>
The path of the URL, as vector of percent-encoded strings.
Percent encoded strings are within the ASCII range.
See also the serialize_path
method and,
for URLs in the file
scheme, the to_file_path
method.
Methods
impl RelativeSchemeData
[src]
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(&self) -> Result<PathBuf, ()>
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.
let path = url.to_file_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(&self) -> Option<&str>
If the host is a domain, return the domain as a string.
fn domain_mut(&mut self) -> Option<&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: "
Trait Implementations
impl Debug for RelativeSchemeData
[src]
impl Clone for RelativeSchemeData
[src]
fn clone(&self) -> RelativeSchemeData
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for RelativeSchemeData
[src]
fn eq(&self, other: &RelativeSchemeData) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for RelativeSchemeData
[src]
impl Hash for RelativeSchemeData
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl PartialOrd for RelativeSchemeData
[src]
fn partial_cmp(&self, other: &RelativeSchemeData) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for RelativeSchemeData
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more