jonasbb / serde_with

This crate provides custom de/serialization helpers to use in combination with serde's `with`-annotation and with the improved `serde_as`-annotation.
https://docs.rs/serde_with
Apache License 2.0
667 stars 72 forks source link

Incorporate serde_tuple functionality into this crate #800

Open UnlimitedCookies opened 2 weeks ago

UnlimitedCookies commented 2 weeks ago

The crate serde_tuple seems to be abandoned and I think its functionality would be a good fit for this crate.

Basically it omits the field names when (de)serializing a struct and just outputs a tuple (in JSON also a list) with the values, making them dependent on the order when de-serializing the the struct.

The serde_tuple crate is also missing functionality like (de)serializing an enum with struct fields into a tuple (where the first entry is the enum variant identifier), so it would be awesome if this crate could accomplish that as well.

ShayBox commented 1 week ago

I also came to say this, what are the odds lol

jonasbb commented 1 week ago

Hey, thanks for the suggestion. I would love to see some better serde derives, but I can't maintain that. The implementation of serde_tuple seems relatively simple, but it requires serde_derive to perform the heavy lifting. This does restrict its design too, so support for enums might be some effort.

ShayBox commented 1 week ago

My use case would be to remap a struct like Vec3 to a tuple struct using something like "(x, y, z)" where the letters are the fields of the struct