pub struct Url { /* private fields */ }
Expand description
URL representation.
Implementations§
Source§impl Url
impl Url
Sourcepub fn path_with_query(&self) -> &str
pub fn path_with_query(&self) -> &str
Get the path including the query string.
Sourcepub fn path_with_query_and_fragment(&self) -> &str
pub fn path_with_query_and_fragment(&self) -> &str
Get the path including the query string and the fragment.
Sourcepub fn with_auth(&self, auth: Option<&str>) -> Result<Self, UrlParseError>
pub fn with_auth(&self, auth: Option<&str>) -> Result<Self, UrlParseError>
Create a new URL with a given authentication string.
The authentication string must be URL-encoded.
Sourcepub fn with_credentials(
&self,
username: &str,
password: &str,
) -> Result<Self, UrlParseError>
pub fn with_credentials( &self, username: &str, password: &str, ) -> Result<Self, UrlParseError>
Create a new URL with a given username and password.
The username and password must be URL-encoded.
Sourcepub fn with_netloc(&self, netloc: &str) -> Result<Self, UrlParseError>
pub fn with_netloc(&self, netloc: &str) -> Result<Self, UrlParseError>
Create a new URL with a given network location.
Sourcepub fn with_query(&self, query: Option<&str>) -> Result<Self, UrlParseError>
pub fn with_query(&self, query: Option<&str>) -> Result<Self, UrlParseError>
Create a new URL with a given query string.
The query string must be URL-encoded.
Sourcepub fn with_fragment(
&self,
fragment: Option<&str>,
) -> Result<Self, UrlParseError>
pub fn with_fragment( &self, fragment: Option<&str>, ) -> Result<Self, UrlParseError>
Create a new URL with a given fragment.
The fragment must be URL-encoded.
Sourcepub fn join(&self, input: &str) -> Result<Self, UrlParseError>
pub fn join(&self, input: &str) -> Result<Self, UrlParseError>
Create a new URL by joining this URL with a given input.
The output will depend on the provided input:
- If the input is empty, the current URL is returned.
- If the input starts with
//
, the input is treated as an absolute URL without a scheme, and the scheme of the current URL is used. - If the input starts with
/
, the input is treated as an absolute path and the path of the current URL is replaced with the input. - If the input is an absolute URL, the input is returned as a new URL.
- Otherwise, the input is treated as a relative path and is appended to the current URL’s path, replacing the rightmost path segment.
Trait Implementations§
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