pub struct Url { /* private fields */ }Expand description
A URI by RFC 3986 in its normal form. Its text is fmt::Display.
Implementations§
Source§impl Url
impl Url
Sourcepub fn parse(text: &str) -> Option<Url>
pub fn parse(text: &str) -> Option<Url>
The URL text spells, in its normal form, or None when it spells
none: a relative reference is not a URL.
let url = flow_abi::Url::parse("HTTP://Example.COM/a/./b/../%7euser?q=%c3%a9").unwrap();
assert_eq!(url.to_string(), "http://example.com/a/~user?q=%C3%A9");
assert!(flow_abi::Url::parse("/a/b").is_none());Sourcepub fn resolve(&self, reference: &str) -> Option<Url>
pub fn resolve(&self, reference: &str) -> Option<Url>
reference resolved against this URL by RFC 3986 §5.2, or None
when reference is not a URI reference.
Sourcepub fn userinfo(&self) -> Option<&str>
pub fn userinfo(&self) -> Option<&str>
Its user information, None without an authority or without @.
Sourcepub fn host(&self) -> Option<&str>
pub fn host(&self) -> Option<&str>
Its host, None without an authority; an IP literal keeps its
brackets.
Sourcepub fn query_pairs(&self) -> Option<Vec<(String, String)>>
pub fn query_pairs(&self) -> Option<Vec<(String, String)>>
Its query as name and value pairs: split on &, each non-empty part
split at its first =, or paired with "" without one, each side
percent-decoded with + read as a space; None when a decoded side
is not UTF-8.
Sourcepub fn with_query(&self, pairs: &[(&str, &str)]) -> Url
pub fn with_query(&self, pairs: &[(&str, &str)]) -> Url
This URL with the query these pairs make, each side percent-encoded as UTF-8 except its unreserved characters; no pairs remove the query.
Sourcepub fn with_fragment(&self, fragment: Option<&str>) -> Url
pub fn with_fragment(&self, fragment: Option<&str>) -> Url
This URL with the fragment fragment, each character a fragment
cannot hold as itself, and %, percent-encoded; None removes it.