Try to add S-Expressions (LISP family)

This commit is contained in:
Zykino 2022-09-25 22:47:52 +02:00
parent f17e13fe25
commit 20022a54e8
2 changed files with 25 additions and 3 deletions

View File

@ -26,11 +26,15 @@ serde-transcode = "1.1.1"
# Should tend to be equal to the official list of data formats supported by serde: https://serde.rs/#data-formats
#bson = "2.3"
#ciborium = "0.2"
#envy = "0.4" # No `Deserializer` exposed.
#envy-store = "0.1" # No `Deserializer` exposed.
serde_json = "1.0"
json5 = "0.4"
#serde-lexpr = "0.1"
serde-pickle = "1.0"
serde_qs = "0.10"
rmp-serde = "1.1"
ron = "0.8"
#toml = "0.5"
serde_yaml = "0.9"

View File

@ -27,6 +27,7 @@ pub enum Input {
//Cbor,
Json,
Json5,
//SExpression,
Pickle,
//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
@ -41,6 +42,7 @@ pub enum Output {
//Cbor,
Json,
//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`
//SExpression,
Pickle,
Qs,
Rmp,
@ -72,8 +74,8 @@ fn de(opt: &Opt, input: &mut dyn Read, output: &mut dyn Write) {
Input::Bson => {
use bson::Deserializer;
let mut deserializer = bson::from_reader(input).unwrap(); // FIXME: need which type annotation?
ser(opt, &mut deserializer, output);
let deserializer = bson::from_reader(input).unwrap(); // FIXME: can we skip the type annotation?
ser(opt, deserializer, output);
}
*/
Input::Json => {
@ -93,6 +95,14 @@ fn de(opt: &Opt, input: &mut dyn Read, output: &mut dyn Write) {
let mut deserializer = Deserializer::from_str(&buf).unwrap();
ser(opt, &mut deserializer, output);
}
/*
Input::SExpression => {
use serde_lexpr as Deserializer;
let deserializer = Deserializer::from_reader(input).unwrap(); // FIXME: can we skip the type annotation?
ser(opt, deserializer, output);
}
*/
Input::Pickle => {
use serde_pickle::Deserializer;
@ -135,7 +145,7 @@ where
options.human_readable(false)
};
let serializer = Serializer::new_with_options(options.build()); // FIXME: why no way to tell the serializer were we want the output?
let serializer = Serializer::new_with_options(options.build()); // FIXME: why no way to tell the serializer were we want the output?
serde_transcode::transcode(deserializer, serializer).unwrap();
}
*/
@ -156,6 +166,14 @@ where
// NOTE: serde_jsons PrettyFormatter and CompactFormatter are incompatibles…
// serde_transcode::transcode(deserializer, serializer).unwrap();
}
/*
Output::SExpression => {
use serde_lexpr::to_writer as Serializer;
let serializer = Serializer::new(output); // FIXME: There is a `to_writer` but the Serializer is not exposed directly.
serde_transcode::transcode(deserializer, serializer).unwrap();
}
*/
Output::Pickle => {
use serde_pickle::Serializer;