534 次发布
新 0.2.525 | 2024 年 8 月 24 日 |
---|---|
0.2.502 | 2024 年 7 月 31 日 |
0.2.385 | 2024 年 3 月 31 日 |
0.2.294 | 2023 年 12 月 31 日 |
0.0.3 | 2021 年 11 月 15 日 |
在 解析器实现 中排名 330
每月下载量 4,020
在 nexus-acto-rs 中使用
240KB
6K SLoC
oni-comb-uri-rs
用于 URI 的 Rust 包。
规范
本包基于以下规范。
RFC3986:统一资源标识符(URI):通用语法
用法
use oni_comb_uri::uri::Uri;
let s = "http://user1:pass1@localhost:8080/example?key1=value1&key2=value2&key1=value2#f1";
match Uri::parse(s) {
Ok(uri) => {
uri.schema().into_iter().for_each(|s| assert_eq!(s.to_string(), "http"));
uri
.host_name()
.into_iter()
.for_each(|hn| assert_eq!(hn.to_string(), "localhost"));
uri.port().into_iter().for_each(|p| assert_eq!(p, 8080));
uri.user_info().into_iter().for_each(|ui| {
assert_eq!(ui.user_name(), "user1");
assert_eq!(ui.password(), Some("pass1"));
});
uri
.path()
.into_iter()
.for_each(|p| assert_eq!(p.to_string(), "/example"));
uri.query().into_iter().for_each(|q| {
q.get_param("key1".to_string()).into_iter().for_each(|v| {
assert_eq!(v.len(), 2);
assert_eq!(v[0], "value1");
assert_eq!(v[1], "value2");
});
q.get_param("key2".to_string()).into_iter().for_each(|v| {
assert_eq!(v.len(), 1);
assert_eq!(v[0], "value2");
});
});
uri.fragment().into_iter().for_each(|f| assert_eq!(f, "f1"));
println!("{:?}", uri);
}
Err(e) => println!("{:?}", e),
}
依赖
~2.2–3.5MB
~55K SLoC