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]
impl RelativeSchemeData
pub fn lossy_percent_decode_username(&self) -> String
[src]
pub 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.
pub fn lossy_percent_decode_password(&self) -> Option<String>
[src]
pub 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.
pub fn to_file_path(&self) -> Result<PathBuf, ()>
[src]
pub 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.)
pub fn domain(&self) -> Option<&str>
[src]
pub fn domain(&self) -> Option<&str>
If the host is a domain, return the domain as a string.
pub fn domain_mut(&mut self) -> Option<&mut String>
[src]
pub fn domain_mut(&mut self) -> Option<&mut String>
If the host is a domain, return a mutable reference to the domain string.
pub fn port_or_default(&self) -> Option<u16>
[src]
pub 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.
pub fn serialize_path(&self) -> String
[src]
pub 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.
pub fn serialize_userinfo(&self) -> String
[src]
pub fn serialize_userinfo(&self) -> String
Serialize the userinfo as a string.
Format: "
Trait Implementations
impl Clone for RelativeSchemeData
[src]
impl Clone for RelativeSchemeData
fn clone(&self) -> RelativeSchemeData
[src]
fn clone(&self) -> RelativeSchemeData
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for RelativeSchemeData
[src]
impl Debug for RelativeSchemeData
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for RelativeSchemeData
[src]
impl PartialEq for RelativeSchemeData
fn eq(&self, other: &RelativeSchemeData) -> bool
[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[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for RelativeSchemeData
[src]
impl Eq for RelativeSchemeData
impl Hash for RelativeSchemeData
[src]
impl Hash for RelativeSchemeData
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for RelativeSchemeData
[src]
impl PartialOrd for RelativeSchemeData
fn partial_cmp(&self, other: &RelativeSchemeData) -> Option<Ordering>
[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[src]
fn lt(&self, other: &Rhs) -> bool
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[src]
fn le(&self, other: &Rhs) -> bool
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[src]
fn gt(&self, other: &Rhs) -> bool
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[src]
fn ge(&self, other: &Rhs) -> bool
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]
impl Ord for RelativeSchemeData
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Display for RelativeSchemeData
[src]
impl Display for RelativeSchemeData
Auto Trait Implementations
impl Send for RelativeSchemeData
impl Send for RelativeSchemeData
impl Sync for RelativeSchemeData
impl Sync for RelativeSchemeData