Attempt to add FlexBuffers format

This commit is contained in:
Zykino 2022-10-29 20:33:38 +02:00
parent f5b2a25eaf
commit 91d5fc666f
3 changed files with 31 additions and 6 deletions

View File

@ -28,6 +28,7 @@ serde-transcode = "1.1"
#ciborium = "0.2" #ciborium = "0.2"
#envy = "0.4" # No `Deserializer` exposed. #envy = "0.4" # No `Deserializer` exposed.
#envy-store = "0.1" # No `Deserializer` exposed. #envy-store = "0.1" # No `Deserializer` exposed.
#flexbuffers = "2.0" # `Serializer` and `Deserializer` exposed does not provieded required API.
serde_json = "1.0" serde_json = "1.0"
json5 = "0.4" json5 = "0.4"
#serde-lexpr = "0.1" #serde-lexpr = "0.1"

View File

@ -27,21 +27,24 @@ tradaf RON json < examples/gameConfig.ron | jq .key_bindings | tradaf Json yaml
* [ ] Implement all [data formats](https://serde.rs/#data-formats), or at least the one that expose a serde serializer or deserializer. * [ ] Implement all [data formats](https://serde.rs/#data-formats), or at least the one that expose a serde serializer or deserializer.
* [ ] BSON * [ ] BSON
* [ ] CBOR * [ ] CBOR
* [ ] DBus (not sure it is working, but it compile…) * [-] DBus (not sure it is working, but it compile…)
* [ ] Envy (deserialization only) * [ ] Envy (deserialization only)
* [ ] Envy store (deserialization only) * [ ] Envy store (deserialization only)
* [ ] GVariant => See DBus: the same crate propose both * [ ] FlexBuffer
* The `Serializer` and `Deserializer` exposed does not work with serde-transcode.
* [-] GVariant => See DBus: the same crate propose both
* [X] JSON * [X] JSON
* [ ] JSON5 * [-] JSON5
* [X] Deserialization * [X] Deserialization
* [ ] Serialization * [ ] Serialization
* [X] S-Expressions (lisp) * [ ] https://github.com/Lucretiel/kaydle
* [ ] S-Expressions (lisp)
* [X] Pickle * [X] Pickle
* [ ] Test properly both way * [ ] Test properly both way
* [ ] Query String (URL) * [-] Query String (URL)
* [ ] Deserialization * [ ] Deserialization
* [X] Serialization * [X] Serialization
* [ ] MessagePack * [-] MessagePack
* [ ] Deserialization * [ ] Deserialization
* [X] Serialization * [X] Serialization
* [X] RON * [X] RON

View File

@ -34,6 +34,7 @@ pub enum Input {
//Bson, //Bson,
//Cbor, //Cbor,
DBus, DBus,
//FlexBuffer,
GVariant, GVariant,
Json, Json,
Json5, Json5,
@ -51,6 +52,7 @@ pub enum Output {
//Bson, //Bson,
//Cbor, //Cbor,
DBus, DBus,
//FlexBuffer,
GVariant, GVariant,
Json, 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` //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`
@ -108,6 +110,14 @@ fn de(opt: &Opt, input: &mut dyn Read, output: &mut dyn Write) {
); );
ser(opt, &mut deserializer, output); ser(opt, &mut deserializer, output);
} }
/*
Input::FlexBuffer => {
use serde_yaml::Deserializer;
let deserializer = Deserializer::from_reader(input);
ser(opt, deserializer, output);
}
*/
Input::GVariant => { Input::GVariant => {
use zvariant::gvariant::Deserializer; use zvariant::gvariant::Deserializer;
use zvariant::EncodingContext; use zvariant::EncodingContext;
@ -219,6 +229,17 @@ where
// let mut deserializer = Deserializer::new(); // let mut deserializer = Deserializer::new();
serde_transcode::transcode(deserializer, serializer).unwrap(); serde_transcode::transcode(deserializer, serializer).unwrap();
} }
/*
Output::FlexBuffer => {
use flexbuffers::FlexbufferSerializer as Serializer;
let serializer = &mut Serializer::new(/*output*/);
// serde_transcode::transcode(deserializer, serializer).unwrap();
let r = flexbuffers::Reader::get_root(serializer.view()).unwrap();
println!("{}", r);
}
*/
Output::GVariant => { Output::GVariant => {
use zvariant::gvariant::Serializer; use zvariant::gvariant::Serializer;
use zvariant::EncodingContext; use zvariant::EncodingContext;