#uri #url #http #safe

safe_uri

Simple and safe URI types

4 releases

Uses new Rust 2021

0.1.0-beta.4 Mar 12, 2022
0.1.0-beta.3 Dec 19, 2021
0.1.0-beta.2 Dec 5, 2021

#22 in #uri

Download history 24/week @ 2022-10-07 5/week @ 2022-10-14 11/week @ 2022-10-21 33/week @ 2022-10-28 30/week @ 2022-11-04 26/week @ 2022-11-11 21/week @ 2022-11-18 10/week @ 2022-11-25 11/week @ 2022-12-02 30/week @ 2022-12-09 12/week @ 2022-12-16 21/week @ 2022-12-23 7/week @ 2022-12-30 11/week @ 2023-01-06 7/week @ 2023-01-13 27/week @ 2023-01-20

59 downloads per month
Used in 5 crates

MIT/Apache

59KB
2K SLoC


lib.rs:

Examples

Constructing all parts of a Uri with and without tap and Tap::tap_mut.

use safe_uri::*;
use tap::Tap;

let uri_with_tap = Uri::new().tap_mut(|u| {
u.scheme = Scheme::try_from("https").unwrap();
u.authority = Some(Authority::new().tap_mut(|a| {
a.user_info = Some(UserInfo::try_from("alice").unwrap());
a.host = Host::Name(HostName::try_from("example.com").unwrap());
a.port = Some(443);
}));
u.resource = Resource::new().tap_mut(|r| {
r.path = Path::try_from("/hello").unwrap();
r.query = Some(Query::try_from("country=NL&city=Amsterdam").unwrap());
r.fragment = Some(Fragment::try_from("greeting").unwrap());
})
});

let mut authority = Authority::new();
authority.user_info = Some(UserInfo::try_from("alice").unwrap());
authority.host = Host::Name(HostName::try_from("example.com").unwrap());
authority.port = Some(443);
let mut resource = Resource::new();
resource.path = Path::try_from("/hello").unwrap();
resource.query = Some(Query::try_from("country=NL&city=Amsterdam").unwrap());
resource.fragment = Some(Fragment::try_from("greeting").unwrap());
let mut uri = Uri::new();
uri.scheme = Scheme::try_from("https").unwrap();
uri.authority = Some(authority);
uri.resource = resource;

assert_eq!(uri_with_tap, uri);

Dependencies