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
sourceimpl Url
impl Url
sourcepub fn host_str(&self) -> Option<String>
pub fn host_str(&self) -> Option<String>
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);sourcepub fn port_or_known_default(&self) -> Option<u32>
pub fn port_or_known_default(&self) -> Option<u32>
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);sourcepub fn username(&self) -> Option<String>
pub fn username(&self) -> Option<String>
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);sourcepub fn password(&self) -> Option<String>
pub fn password(&self) -> Option<String>
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);sourcepub fn path_segments(&self) -> Option<Vec<String>>
pub fn path_segments(&self) -> Option<Vec<String>>
Extract the password from the url.
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);Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Url
impl Send for Url
impl Sync for Url
impl Unpin for Url
impl UnwindSafe for Url
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more