pub struct Parser { /* private fields */ }

Implementations

Extract the anchor from the url.

Example
use url_parse::url::Parser;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let result = Parser::new(None).mixout_anchor(input).unwrap();
assert_eq!(result, "dayone");

Extract the domain fields from the url.

Example
use url_parse::url::Parser;
use url_parse::url::global::DomainFields;
let input = "https://www.example.com:443/blog/article/search?docid=720&hl=en#dayone";
let expected = DomainFields {
    subdomain: Some("www"),
    domain: Some("example"),
    top_level_domain: Some("com"),
};
let result = Parser::new(None).mixout_domain_fields(input);
assert_eq!(result, expected);

Extract the domain fields from the url.

Example
use url_parse::url::Parser;
let input = "https://user:pass@www.example.co.uk";
let expected = (Some("user"), Some("pass"));
let result = Parser::new(None).mixout_login(input);
assert_eq!(result, expected);

Extract the path as a vector from the url.

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

Extract the port from the url. If no port is present, it will be deduced from the scheme. The default scheme provides well-known ports. The user can specify new schemes when constructing the Parser object with new().

Example
use url_parse::url::Parser;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let port = Parser::new(None).mixout_port(input);
assert_eq!(port.unwrap(), 443);

Extract the query from the url.

Example
use url_parse::url::Parser;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let result = Parser::new(None).mixout_query(input).unwrap();
assert_eq!(result, "docid=720&hl=en#dayone");

Extract the query from the url.

Example
use url_parse::url::Parser;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let scheme = Parser::new(None).mixout_scheme(input);
assert_eq!(scheme.unwrap(), "https");

Create a new parser object. Optionally pass in a hash map of default port mappings. Its fields are then directly accessible.

Example
use url_parse::url::Parser;
let parser = Parser::new(None);

Create a new parser object with Parser::new(). You can then use parser.parse(url) which will return a public Url parsed structure back. Its fields are then directly accessible.

Example
use url_parse::url::Parser;
use url_parse::url::Url;
let input = "https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let result = Parser::new(None).parse(input).unwrap();
assert_eq!(
    result,
    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#dayone".to_string()),
        anchor: Some("dayone".to_string()),
    }
)

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.

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.