pub struct Url {
pub scheme: String,
pub netloc: String,
pub path: String,
pub query: Option<String>,
pub fragment: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub host: Option<String>,
pub port: u16,
}Expand description
url object
Fields§
§scheme: String§netloc: String§path: String§query: Option<String>§fragment: Option<String>§username: Option<String>§password: Option<String>§host: Option<String>§port: u16Implementations§
Source§impl Url
impl Url
Sourcepub fn parse<S: AsRef<str>>(s: S) -> Url
pub fn parse<S: AsRef<str>>(s: S) -> Url
Parses a URL.
§Examples
use miniurl::Url;
let url = Url::parse("http://admin:password@google.com/foo?a=1&b=2#top");
assert_eq!(url.scheme, "http");
assert_eq!(url.netloc, "admin:password@google.com");
assert_eq!(url.path, "/foo");
assert_eq!(url.query, Some("a=1&b=2".to_string()));
assert_eq!(url.fragment, Some("top".to_string()));
assert_eq!(url.username, Some("admin".to_string()));
assert_eq!(url.password, Some("password".to_string()));
assert_eq!(url.host, Some("google.com".to_string()));
assert_eq!(url.port, 80);Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Returns a URL string from a Url object.
§Examples
use miniurl::Url;
let ori_url = "http://www.google.com:80/?a=1&b=2";
let url = Url::parse(ori_url);
assert_eq!(url.as_string(),ori_url.to_string());Sourcepub fn request_string(&self) -> String
pub fn request_string(&self) -> String
Returns a request string
§Examples
use miniurl::Url;
let ori_url = "http://www.google.com:80/?a=1&b=2";
let url = Url::parse(ori_url);
assert_eq!("/?a=1&b=2".to_string(),url.request_string());Trait Implementations§
Source§impl Ord for Url
impl Ord for Url
Source§impl PartialOrd for Url
impl PartialOrd for Url
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