Closed TheButlah closed 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
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
.
And giving a bit more detail the objective of our crates:
edn-rs
: converts Rust structures back and fourth to Edn ones (either strings or "objects")edn-derive
: ease the conversion from edn-rs
using procedural macros, giving syntax sugar and a little bit of more functionality on top of the other crateGotcha, 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.
Hi, I'm currently using
edn-rs
to parse an edn file, and I want to serialize the parsedEdn
object into JSON. I was hoping that theEdn
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?