#serialization #url #url-parameters #serde-derive #type #http #traits

url_params_serializer

允许将类型序列化为URL GET参数

2个版本

0.1.1 2018年12月23日
0.1.0 2018年12月23日

#2131 in 编码

Download history 15/week @ 2024-03-11 13/week @ 2024-03-18 15/week @ 2024-03-25 68/week @ 2024-04-01 10/week @ 2024-04-08 2/week @ 2024-04-22 2/week @ 2024-04-29 9/week @ 2024-05-13 7/week @ 2024-05-20 13/week @ 2024-05-27 2/week @ 2024-06-03 17/week @ 2024-06-10 17/week @ 2024-06-17 15/week @ 2024-06-24

每月51次下载

Apache-2.0

22KB
498

url_params_serializer

允许将实现Serde的Serializer特质的类型序列化为HTTP GET查询参数。典型用法

use serde_derive::Serialize;
use url::Url;
use url_params_serializer::to_url_params;

#[derive(Serialize)]
struct Params {
    bar: &'static str;
    baz: usize
}

let params = Params { bar: "spam", baz: 5 };
let url = Url::parse_with_params("https://foo.com", to_url_params(params));

assert_eq!(url.into_string(), "https://foo.com/?bar=spam&baz=5");

一些更复杂的类型也可以序列化;有关更多信息,请参阅to_url_params的文档。


lib.rs:

允许将实现Serde的Serializer特质的类型序列化为HTTP GET查询参数。典型用法

use serde_derive::Serialize;
use url::Url;
use url_params_serializer::to_url_params;

#[derive(Serialize)]
struct Params {
    bar: &'static str,
    baz: usize,
}

let params = Params { bar: "spam", baz: 5 };
let url = Url::parse_with_params("https://foo.com", to_url_params(params)).unwrap();

assert_eq!(url.into_string(), "https://foo.com/?bar=spam&baz=5");

一些更复杂的类型也可以序列化;有关更多信息,请参阅to_url_params的文档。

依赖项

~110–345KB