Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRevise the serialization semantics #322
Comments
|
That would serialise the point as an object with keys "x" and "y" with We could see with @dtolnay if he would be ok with a new attribute (or maybe one exists already? If so I didn't find it) in |
|
Where is this output used? Are we talking about the debug printing of some structures, or does it actually affect any logic? |
We are talking about the (de)serialization format of points, matrices and vectors, which shouldn't serialize to verbose JSON objects when used with |
|
https://github.com/kardeiz/serde_tuple provides derives that serialize a struct to JSON array. |
|
Thanks @dtolnay, that's neat but it doesn't support |
|
A straightforward way to support those attributes would be to naively include them in the |
|
This is not a sufficiently common use case for me to accept in serde_derive. It is better for us to establish idioms for how to best implement less common use cases outside of serde_derive. Regardless of where the line is drawn between sufficiently-common and insufficiently-common, there needs to be some line drawn because it is not feasible to put everything anyone has wanted to do into serde_derive. So the idioms for doing this stuff out of tree is something we need to solve either way. I think the comment about optimization is FUD. I would expect the same generated code either way. |
|
So to get back to the original topic, @kvark was your issue that |
|
Right. I don't know what the best way to proceed here. Obviously there are downsides in any of the choices. Double-checking the RON serialization output for stuff like rectangles:
It does appear compact, but then it's not clear where the origin and where the size... How about we keep the tuples for vectors and points, but leave the straight-derived serialization for anything more complex, like rectangles and boxes? |
|
Sounds fine with me, I completely forgot about We can indeed use |
|
I am also very keen on keeping tuples for points, vectors and sizes, and have field names for rectangles and boxes. Waiting for other motivating breaking changes before doing this one sounds good to me unless anyone wants to do the euclid bumps just for this. |
|
It's not urgent matter, just need to keep in mind before releasing a new breaking version. I wonder if there is a place in Serde for some generic mechanism:
I could imagine this used for all the |
|
I'm going to make some breaking changes soon. Is there still something we want to change here? |
|
Basically this:
|
#141 made it so we serialize the tuples for some objects. I don't quite understand why this crate needs to go such a long way to achieve serialization, with lots of manual implementations around. Can't we achieve the same (or better) effect by just requiring the space type to derive serialization and ignoring the phantom?
cc @nox