tmerr / i3ipc-rs

A Rust library for controlling i3-wm through its IPC interface
MIT License
107 stars 33 forks source link

Derive Serialize, Deserialize on data structures #62

Open ToonSpin opened 4 years ago

ToonSpin commented 4 years ago

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