4 releases

0.0.4 Aug 31, 2021
0.0.3 Aug 31, 2021
0.0.2 Aug 31, 2021
0.0.1 Aug 31, 2021

#2282 in Parser implementations

MIT/Apache

93KB
3K SLoC

uri-rs

A Rust crate for URI.

Workflow Status crates.io docs.rs dependency status tokei

Install to Cargo.toml

Add this to your Cargo.toml:

[dependencies]
uri-rs = "<<version>>"

Usage

use uri_rs::Uri;
let s = "http://user1:pass1@localhost:8080/example?key1=value1&key2=value2&key1=value2#f1";
let uri = Uri::parse(s).unwrap();
println!("{:?}", uri);
// Uri {
//    schema: Scheme("http"),
//    authority: Some(
//      Authority {
//        host_name: HostName("localhost"),
//        port: Some(8080),
//        user_info: Some(
//          UserInfo {
//            user_name: "user1",
//            password: Some("pass1")
//          }
//        )
//      }
//    ),
//    path: AbemptyPath {
//      type_name: "abempty_path",
//      parts: ["example"]
//    },
//    query: Some(
//      Query {
//        params: [
//          ("key1", Some("value1")),
//          ("key2", Some("value2")),
//          ("key1", Some("value2"))
//        ]
//      }
//    ),
//    fragment: Some("f1")
// }
println!("{}", uri.to_string());
// http://user1:pass1@localhost:8080/example?key1=value1&key2=value2&key1=value2#f1

Benchmarks

TODO

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.3–1.9MB
~35K SLoC