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
Represents the components of a parsed HTTP URL.
Fields§
§protocol: Protocol
The URL scheme, such as “http” or “https”.
host: Option<String>
The host part of the URL (e.g., “example.com”).
port: Option<u16>
The port number in the URL, if specified.
path: Option<String>
The path in the URL (e.g., “/index.html”).
query: Option<String>
The query string in the URL (e.g., “?a=1”).
fragment: Option<String>
The fragment identifier (e.g., “#section”).
Implementations§
Source§impl HttpUrlComponents
impl HttpUrlComponents
Sourcepub fn parse(url_str: &str) -> Result<HttpUrlComponents, HttpUrlError>
pub fn parse(url_str: &str) -> Result<HttpUrlComponents, 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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more