pub struct Url {
pub scheme: Scheme,
pub host: String,
pub port: Option<u16>,
pub path: String,
pub query: Option<String>,
}Expand description
Parsed URL.
Fields§
§scheme: SchemeURL scheme (http or https).
host: StringHost name or IP address.
port: Option<u16>Optional port number.
path: StringPath component (default “/”).
query: Option<String>Optional query string (without leading ‘?’).
Implementations§
Source§impl Url
impl Url
Sourcepub fn parse(url: &str) -> Result<Self>
pub fn parse(url: &str) -> Result<Self>
Parse a URL string.
Supports formats:
http://hosthttp://host:porthttp://host/pathhttp://host:port/pathhttp://host/path?queryhttps://...(same patterns)
§Errors
Returns NetworkError::InvalidUrl if:
- Missing or invalid scheme
- Missing host
- Invalid port number
Parse authority (host[:port]).
Sourcepub fn port_or_default(&self) -> u16
pub fn port_or_default(&self) -> u16
Get port, using scheme default if not specified.
Sourcepub fn host_header(&self) -> String
pub fn host_header(&self) -> String
Get the full host:port string for HTTP Host header.
Sourcepub fn request_uri(&self) -> String
pub fn request_uri(&self) -> String
Get the request URI (path + query) for HTTP request line.
Trait Implementations§
impl Eq for Url
impl StructuralPartialEq for Url
Auto Trait Implementations§
impl Freeze for Url
impl RefUnwindSafe for Url
impl Send for Url
impl Sync for Url
impl Unpin for Url
impl UnwindSafe for Url
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