pub struct HttpUrlComponents {
pub protocol: Protocol,
pub host: Option<String>,
pub port: Option<u16>,
pub path: Option<String>,
pub query: Option<String>,
pub fragment: Option<String>,
}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: Option<String>§port: Option<u16>§path: Option<String>§query: Option<String>§fragment: Option<String>Implementations§
Source§impl HttpUrlComponents
impl HttpUrlComponents
Sourcepub fn parse(url_str: &str) -> Result<HttpUrlComponents, Error>
pub fn parse(url_str: &str) -> Result<HttpUrlComponents, Error>
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 moreSource§impl Debug for HttpUrlComponents
impl Debug for HttpUrlComponents
Source§impl Default for HttpUrlComponents
impl Default for HttpUrlComponents
Source§fn default() -> HttpUrlComponents
fn default() -> HttpUrlComponents
Source§impl PartialEq for HttpUrlComponents
impl PartialEq for HttpUrlComponents
impl Eq for HttpUrlComponents
impl StructuralPartialEq for HttpUrlComponents
Auto Trait Implementations§
impl Freeze for HttpUrlComponents
impl RefUnwindSafe for HttpUrlComponents
impl Send for HttpUrlComponents
impl Sync for HttpUrlComponents
impl Unpin for HttpUrlComponents
impl UnwindSafe for HttpUrlComponents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.