pub struct HttpUrlComponents {
pub protocol: Protocol,
pub host: OptionString,
pub port: OptionU16,
pub path: OptionString,
pub query: OptionString,
pub fragment: OptionString,
}Expand description
A struct representing a parsed URL with various components.
This struct is used to store the different components of a URL, such as the scheme, username, password, host, port, path, query, and fragment. It allows for easy handling and manipulation of URL data.
§Fields
scheme: The URL scheme (e.g., “http”, “https”) as a string, orNoneif not specified.host: The host portion of the URL (e.g., “example.com”), orNoneif not specified.port: The port number, if specified, orNoneif not specified.path: The path portion of the URL (e.g., “/path/to/resource”), orNoneif not specified.query: The query string, if present, orNoneif not specified.fragment: The fragment identifier, if present, orNoneif not specified.
This struct is primarily used for holding the components of a URL after parsing, allowing for easy manipulation and access to the individual components.
Fields§
§protocol: Protocol§host: OptionString§port: OptionU16§path: OptionString§query: OptionString§fragment: OptionStringImplementations§
Source§impl HttpUrlComponents
impl HttpUrlComponents
Sourcepub fn parse(url_str: &str) -> Result<Self, HttpUrlError>
pub fn parse(url_str: &str) -> Result<Self, HttpUrlError>
Parses a URL string into a HttpUrlComponents instance.
This method attempts to parse a given URL string into its components such as
scheme, username, password, host, port, path, query, and fragment. If the URL
is invalid, it returns an Error::InvalidUrl error.
§Parameters
url_str: A string slice representing the URL to be parsed.
§Returns
Returns a Result containing either a HttpUrlComponents instance populated with the
parsed components or an Error::InvalidUrl if the parsing fails.
Trait Implementations§
Source§impl Clone for HttpUrlComponents
impl Clone for HttpUrlComponents
Source§fn clone(&self) -> HttpUrlComponents
fn clone(&self) -> HttpUrlComponents
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more