evaporei / edn-derive

[DEPRECATED]: Edn derive procedural macros for (De)Serialization
GNU Lesser General Public License v3.0
9 stars 2 forks source link

Relationship between this crate and serde? #29

Closed TheButlah closed 4 years ago

TheButlah commented 4 years ago

Hi, I'm currently using edn-rs to parse an edn file, and I want to serialize the parsed Edn object into JSON. I was hoping that the Edn object would implement serde's Serialize trait, but it doesn't look like that is the case.

Does edn-derive fill this role? What relationship does it have with serde?

naomijub commented 4 years ago

as answered at https://github.com/naomijub/edn-rs/issues/63, edn-derive can do the heavy Serialization and Deserialization, but it doesn't implement serde. The visitor pattern in a complex edn structure is a nightmare

evaporei commented 4 years ago

So our libs edn-rs and edn-derive serve the purpose of converting Rust structures back and fourth to Edn ones (either strings or "objects").

They don't have the objective of following the serde interfaces, however we did try to make a very similar interface to ease usage, since the most popular serialization/deserialization library on the Rust community is serde.

evaporei commented 4 years ago

And giving a bit more detail the objective of our crates:

TheButlah commented 4 years ago

Gotcha, so the role of edn-rs makes sense to me. I realized that serde's role is to have rust datastructures as the ground truth for the structure of the data, where general purpose edn does not necessarily fit a rust datastructure, or at least it doesn't make sense to define the Edn object as the "ground truth" datastructure.

For context I'm trying to convert .orcbrew files (which are in edn) into json (or other formats). It sounds like what I really ought to be doing is parsing the orcbrew file string into my own data structure that represents the expected structure of an orcbrew file. My Orcbrew structure can implement edn_derive::{Deserialize, Serialize} as well as serde::{Serialize, Deserialize}. That way Orcbrew serves as a model for how the data ought to be described, and edn is just a particular format for it. Does that sound about right?

It would still be nice to have a way of using edn as a particular format for serde's data model, to make it easy to send data between rust, javascript, and clojure for example, but I understand that that would be a slightly different use case.