You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently messing around with serde creating my own binary format, and I encode the type of the data, but I don't encode fields names for struct like type, so a struct is treated as a sequence. encoding the type allows me to implement Deserializer::deserialize_any as I can peek the tag and call the appropriate function.
It worked well until I tried with an enum with the #[serde(untagged)] attribute. I kind of lose my sanity trying to understand what was wrong, until I checked the expanded #[derive(Deserialize)] macro. Struct variant Visitor only implement Visitor::visit_map.
Is there a reason why struct variant don't implement Visitor::visit_seq like normal struct does when the #[serde(untagged)] is present ?
The text was updated successfully, but these errors were encountered:
Thanks! I tried searching any related Issue but did not search through the PR. I kind of fixed the problem by looking throught the auto implemntation and found that the Field enum deserialized from the key of the map can be deserialized with a u64 representing the field index, so I now deserialize struct like types with a custom MapAccess that gives a u64 as a key, and just increment it. It feels a bit like a redneck solutions but everything seams to work fine.
I'm currently messing around with serde creating my own binary format, and I encode the type of the data, but I don't encode fields names for struct like type, so a struct is treated as a sequence. encoding the type allows me to implement
Deserializer::deserialize_any
as I can peek the tag and call the appropriate function.It worked well until I tried with an enum with the
#[serde(untagged)]
attribute. I kind of lose my sanity trying to understand what was wrong, until I checked the expanded#[derive(Deserialize)]
macro. Struct variantVisitor
only implementVisitor::visit_map
.Is there a reason why struct variant don't implement
Visitor::visit_seq
like normal struct does when the#[serde(untagged)]
is present ?The text was updated successfully, but these errors were encountered: