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 https in the above example.

user

A URL subcomponent for user authentication. username in the above example.

host

A domain name or IP address. For example, example.com.

port

A TCP port number, for example 8080.

path

The path component of a URL, for example /foo/bar.

query

The query component of a URL. vec!(("baz".to_string(), "qux".to_string())) represents the fragment baz=qux in the above example.

fragment

The fragment component, such as quz. Doesn't include the leading # character.

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

fn from_str(s: &str) -> Option<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".

impl<S: Writer> Hash<S> for Url

fn hash(&self, state: &mut S)

Derived Implementations

impl Eq for Url

fn assert_receiver_is_total_eq(&self)

impl PartialEq for Url

fn eq(&self, __arg_0: &Url) -> bool

fn ne(&self, __arg_0: &Url) -> bool

impl Clone for Url

fn clone(&self) -> Url

fn clone_from(&mut self, source: &Self)