pub struct Url { /* private fields */ }Expand description
A parsed URL. Getters and setters are named after the URL interface’s
attributes and behave as they do: a setter given a value the spec
rejects leaves the URL as it was.
It’s the serialization, in one string, and where each component of it starts. Two URLs are equal, and ordered, by their serializations.
Implementations§
Source§impl Url
impl Url
Sourcepub fn parse(input: &str) -> Result<Url, ParseError>
pub fn parse(input: &str) -> Result<Url, ParseError>
Parses an absolute URL, as new URL(input) does.
Sourcepub fn parse_with_base(input: &str, base: &Url) -> Result<Url, ParseError>
pub fn parse_with_base(input: &str, base: &Url) -> Result<Url, ParseError>
Parses input against base, as new URL(input, base) does.
Sourcepub fn can_parse(input: &str, base: Option<&Url>) -> bool
pub fn can_parse(input: &str, base: Option<&Url>) -> bool
Whether input parses, against base if there is one: URL.canParse.
Sourcepub fn set_href(&mut self, value: &str) -> Result<(), ParseError>
pub fn set_href(&mut self, value: &str) -> Result<(), ParseError>
Replaces the whole URL; unlike the other setters, this one fails
when the new value doesn’t parse, as the href setter throws.
Sourcepub fn origin(&self) -> String
pub fn origin(&self) -> String
The serialized origin, "null" for an opaque one. A blob: URL’s
is its inner URL’s, when that’s http, https or file.
pub fn set_protocol(&mut self, value: &str)
pub fn username(&self) -> &str
pub fn set_username(&mut self, value: &str)
pub fn password(&self) -> &str
pub fn set_password(&mut self, value: &str)
pub fn set_host(&mut self, value: &str)
pub fn set_hostname(&mut self, value: &str)
pub fn set_port(&mut self, value: &str)
pub fn pathname(&self) -> &str
pub fn set_pathname(&mut self, value: &str)
pub fn set_search(&mut self, value: &str)
pub fn set_hash(&mut self, value: &str)
Sourcepub fn search_params(&self) -> SearchParams
pub fn search_params(&self) -> SearchParams
The query parsed as application/x-www-form-urlencoded, the list
url.searchParams starts from.
Sourcepub fn set_search_params(&mut self, params: &SearchParams)
pub fn set_search_params(&mut self, params: &SearchParams)
Writes params back as the query, as changing url.searchParams
does: an empty list removes the query, ? and all.