i3ipc-rs icon indicating copy to clipboard operation
i3ipc-rs copied to clipboard

Derive Serialize, Deserialize on data structures

Open ToonSpin opened this issue 4 years ago • 0 comments

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

ToonSpin avatar Oct 27 '20 23:10 ToonSpin