pub struct Parser { /* private fields */ }
Implementations
sourceimpl Parser
impl Parser
pub fn mixout_domain_fields<'a>(&self, input: &'a str) -> DomainFields
sourceimpl Parser
impl Parser
sourcepub fn new(
port_mappings: Option<HashMap<&'static str, (u32, &'static str)>>
) -> Self
pub fn new(
port_mappings: Option<HashMap<&'static str, (u32, &'static str)>>
) -> Self
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);
sourcepub fn parse(&self, url: &str) -> Result<Url, ParseError>
pub fn parse(&self, url: &str) -> Result<Url, ParseError>
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())),
top_level_domain: Some("www".to_string()),
domain: Some("example.co.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
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnwindSafe for Parser
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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