Add Message Pack serialization

This commit is contained in:
Zykino 2022-09-21 00:42:58 +02:00
parent d13a167ac8
commit f17e13fe25
3 changed files with 41 additions and 2 deletions

29
Cargo.lock generated
View File

@ -232,6 +232,12 @@ version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "paste"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]]
name = "percent-encoding"
version = "2.2.0"
@ -324,6 +330,28 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rmp"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f"
dependencies = [
"byteorder",
"num-traits",
"paste",
]
[[package]]
name = "rmp-serde"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25786b0d276110195fa3d6f3f31299900cf71dfbd6c28450f3f58a0e7f7a347e"
dependencies = [
"byteorder",
"rmp",
"serde",
]
[[package]]
name = "ron"
version = "0.8.0"
@ -487,6 +515,7 @@ version = "0.1.0"
dependencies = [
"clap",
"json5",
"rmp-serde",
"ron",
"serde",
"serde-pickle",

View File

@ -30,6 +30,7 @@ serde_json = "1.0"
json5 = "0.4"
serde-pickle = "1.0"
serde_qs = "0.10"
rmp-serde = "1.1"
ron = "0.8"
#toml = "0.5"
serde_yaml = "0.9"

View File

@ -28,7 +28,8 @@ pub enum Input {
Json,
Json5,
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`
//Qs, // NOTE: The crate is not noted "(serialization only)" on the [serde listing](https://serde.rs/#data-formats) but it does not expose a `Deserializer`
//Rmp, // NOTE: It appears that we are forced to deserialize into a concrete type
Ron,
//Toml
Yaml,
@ -39,9 +40,10 @@ pub enum Output {
//Bson,
//Cbor,
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 noted "(deserialization only)" on the [serde listing](https://serde.rs/#data-formats) but it does not expose a `Serializer`
Pickle,
Qs,
Rmp,
Ron,
//Toml,
Yaml,
@ -168,6 +170,13 @@ where
serde_transcode::transcode(deserializer, serializer).unwrap();
}
Output::Rmp => {
use rmp_serde::Serializer;
let serializer = &mut Serializer::new(output);
serde_transcode::transcode(deserializer, serializer).unwrap();
}
Output::Ron => {
use ron::Serializer;