Add URL QueryString serialization

This commit is contained in:
Zykino 2022-09-20 23:23:58 +02:00
parent 2e75ffea68
commit d13a167ac8
3 changed files with 29 additions and 1 deletions

18
Cargo.lock generated
View File

@ -232,6 +232,12 @@ version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]] [[package]]
name = "pest" name = "pest"
version = "2.3.1" version = "2.3.1"
@ -388,6 +394,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_qs"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cac3f1e2ca2fe333923a1ae72caca910b98ed0630bb35ef6f8c8517d6e81afa"
dependencies = [
"percent-encoding",
"serde",
"thiserror",
]
[[package]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.9.11" version = "0.9.11"
@ -475,6 +492,7 @@ dependencies = [
"serde-pickle", "serde-pickle",
"serde-transcode", "serde-transcode",
"serde_json", "serde_json",
"serde_qs",
"serde_yaml", "serde_yaml",
] ]

View File

@ -29,6 +29,7 @@ serde-transcode = "1.1.1"
serde_json = "1.0" serde_json = "1.0"
json5 = "0.4" json5 = "0.4"
serde-pickle = "1.0" serde-pickle = "1.0"
serde_qs = "0.10"
ron = "0.8" ron = "0.8"
#toml = "0.5" #toml = "0.5"
serde_yaml = "0.9" serde_yaml = "0.9"

View File

@ -28,6 +28,7 @@ pub enum Input {
Json, Json,
Json5, Json5,
Pickle, Pickle,
//Qs, // NOTE: The crate is not notted "(serialization only)" on the [serde listing](https://serde.rs/#data-formats) but it does not expose a `Deserializer`
Ron, Ron,
//Toml //Toml
Yaml, Yaml,
@ -38,8 +39,9 @@ pub enum Output {
//Bson, //Bson,
//Cbor, //Cbor,
Json, Json,
//Json5, // NOTE: The crate is not notted "(deserialization only)" on the [serde listing](https://serde.rs/#data-formats) but it does not expose a serializer //Json5, // NOTE: The crate is not notted "(deserialization only)" on the [serde listing](https://serde.rs/#data-formats) but it does not expose a `Serializer`
Pickle, Pickle,
Qs,
Ron, Ron,
//Toml, //Toml,
Yaml, Yaml,
@ -159,6 +161,13 @@ where
serde_transcode::transcode(deserializer, serializer).unwrap(); serde_transcode::transcode(deserializer, serializer).unwrap();
} }
Output::Qs => {
use serde_qs::Serializer;
let serializer = &mut Serializer::new(output);
serde_transcode::transcode(deserializer, serializer).unwrap();
}
Output::Ron => { Output::Ron => {
use ron::Serializer; use ron::Serializer;