pub struct Url {
    pub scheme: Option<String>,
    pub user_pass: (Option<String>, Option<String>),
    pub subdomain: Option<String>,
    pub domain: Option<String>,
    pub top_level_domain: Option<String>,
    pub port: Option<u32>,
    pub path: Option<Vec<String>>,
    pub query: Option<String>,
    pub anchor: Option<String>,
}

Fields

scheme: Option<String>user_pass: (Option<String>, Option<String>)subdomain: Option<String>domain: Option<String>top_level_domain: Option<String>port: Option<u32>path: Option<Vec<String>>query: Option<String>anchor: Option<String>

Implementations

Extract the representation of the host for this URL.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
let input = "https://user:pass@www.example.com:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "example.com";
let parsed = Parser::new(None).parse(input).unwrap();
let result = parsed.host_str().unwrap();
assert_eq!(result, expected);

Extract the username from the url.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
let input = "https://user:pass@www.example.com:443/blog/article/search?docid=720&hl=en#dayone";
let expected = 443;
let parsed = Parser::new(None).parse(input).unwrap();
let result = parsed.port_or_known_default().unwrap();
assert_eq!(result, expected);

Extract the username from the url.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
let input = "https://user:pass@www.example.com:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "user";
let parsed = Parser::new(None).parse(input).unwrap();
let result = parsed.username().unwrap();
assert_eq!(result, expected);

Extract the password from the url.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
let input = "https://user:pass@www.example.com:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "pass";
let parsed = Parser::new(None).parse(input).unwrap();
let result = parsed.password().unwrap();
assert_eq!(result, expected);

Extract the path segments from the path.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let result = Parser::new(None).path(input).unwrap();
let expected = vec!["blog", "article", "search"];
assert_eq!(result, expected);

Serialize an URL struct to a String.

Example
use url_parse::core::Parser;
use url_parse::core::global::Domain;
use url_parse::url::Url;

let input = Url {
   scheme: Some("https".to_string()),
   user_pass: (Some("user".to_string()), Some("pass".to_string())),
   subdomain: Some("www".to_string()),
   domain: Some("example.co".to_string()),
   top_level_domain: Some("uk".to_string()),
   port: Some(443),
   path: Some(vec![
       "blog".to_string(),
       "article".to_string(),
       "search".to_string(),
   ]),
   query: Some("docid=720&hl=en".to_string()),
   anchor: Some("dayone".to_string()),
};
let expected =
   "https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";

let result = input.serialize();
assert_eq!(result, expected);

Create a new empty instance with all fields set to none.

Trait Implementations

Formats the value using the given formatter. Read more

Display the serialization of this URL.

Formats the value using the given formatter. Read more

Compare two objects of this type.

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.