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 upstruct deserialization should offer field-names to the passed visitor #48
Comments
|
Would "offering" field names during deserialization require serializing them? |
|
nope, You get a static array of the names. So basically it'd just be iterating through that array and using them as keys to pass to a |
|
I'll look into it today, thanks! |
|
@erickt Could you take a look at this? I tried playing with it, but I'm still really unsure about the serde interface. Since you wrote the original implementation, do you think this would be a reasonable thing to add? |
|
We no longer need this. Serde has embraced visit_seq as a way to deserialize braced structs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now you treat structs like tuples, because they are laid out the same way in bincode's format. During serialization that works mostly fine (since serializers usually pass struct fields in the order in which they are declared). During deserialization you deserialize the struct through
visit_seq. Structs are meant to be deserialized throughvisit_map.See some context here: serde-rs/serde#177
I think there could be room for improvement in serde wrt struct serialization to make sure that the serializer can choose the order of the elements it receives instead of the struct's
Deserializeimplementation.cc @erickt