Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Serialize, Deserialize on data structures #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ToonSpin
Copy link

Hi Trevor,

I was writing a small program using your crate and found that I could not easily "serde" the event data to JSON. There are ways around this but that would be a lot of work - it would be much more convenient for me if the Serialize and Deserialize traits were already on the types in your crate.

Turns out the Rust API guidelines recommend that authors implement the serde Serialize and Deserialize traits on all data structures, presumably for this sort of reason.

I went ahead and derived Serialize and Deserialize on all data structures I could find, given the fact that you use serde anyway. One notable exception is the Event enum, it didn't seem like enough of a data structure to me.

Also (this is in the same link above) they recommend a specific way to pull in serde and serde_json, I went ahead and put that in Cargo.toml. All unit tests still pass.

Don't hesitate to let me know if you'd like me to change anything in this PR, I'd be happy to. Thanks for your time!

Toon

The Rust API guidelines recommend that authors implement the serde
Serialize and Deserialize traits on data structures. Also a
standardized way is suggested of declaring a dependency on serde.
Both of these recommendations are implemented in this commit.

Source for the recommendation:

https://rust-lang.github.io/api-guidelines/interoperability.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant