Struct url::Url[src]
pub struct Url {
pub scheme: String,
pub user: Option<UserInfo>,
pub host: String,
pub port: Option<String>,
pub path: String,
pub query: Query,
pub fragment: Option<String>,
}A Uniform Resource Locator (URL). A URL is a form of URI (Uniform Resource Identifier) that includes network location information, such as hostname or port number.
Example
extern crate url; fn main() { use url::{Url, UserInfo}; let url = Url { scheme: "https".to_string(), user: Some(UserInfo { user: "username".to_string(), pass: None }), host: "example.com".to_string(), port: Some("8080".to_string()), path: "/foo/bar".to_string(), query: vec!(("baz".to_string(), "qux".to_string())), fragment: Some("quz".to_string()) }; // https://username@example.com:8080/foo/bar?baz=qux#quz }use url::{Url, UserInfo}; let url = Url { scheme: "https".to_string(), user: Some(UserInfo { user: "username".to_string(), pass: None }), host: "example.com".to_string(), port: Some("8080".to_string()), path: "/foo/bar".to_string(), query: vec!(("baz".to_string(), "qux".to_string())), fragment: Some("quz".to_string()) }; // https://username@example.com:8080/foo/bar?baz=qux#quz
Fields
scheme | The scheme part of a URL, such as |
user | A URL subcomponent for user authentication. |
host | A domain name or IP address. For example, |
port | A TCP port number, for example |
path | The path component of a URL, for example |
query | The query component of a URL.
|
fragment | The fragment component, such as |
Methods
impl Url
fn new(scheme: String, user: Option<UserInfo>, host: String, port: Option<String>, path: String, query: Query, fragment: Option<String>) -> Url
Trait Implementations
impl FromStr for Url
impl Show for Url
fn fmt(&self, f: &mut Formatter) -> Result
Converts a URL from Url to string representation.
Arguments
url - a URL.
Returns
A string that contains the formatted URL. Note that this will usually
be an inverse of from_str but might strip out unneeded separators;
for example, "http://somehost.com?", when parsed and formatted, will
result in just "http://somehost.com".