Open Mingun opened 1 year ago
This is potentially correct, though postcard generally doesn't support many of the serde attributes such as alias, external tagging, etc.
If there is a better way to handle this if we'd like to disregard these attributes, I'm defintiely interested!
Thanks for the report.
During investigation of correct serde deserializers behavior I found, that postcard implements struct deserialization incorrectly:
Visitor::visit_seq
: https://github.com/jamesmunns/postcard/blob/a095b49935f7bd1bab04e6c5914ab11c3bbd5fee/src/de/deserializer.rs#L500-L510 That method is intended only to provide data for sequential types. To provide data for map types you should callvisit_map
which would use a special deserializer to deserialize keysfields.len()
as expected tuple size, which is not correct if some fields has aliases. You are never known the count of fields in a struct.