I need to deserialize some data using serde, currently I have implemented the serde::de::Visitor trait for the struct that needs to be deserialized. However, there are some unknown fields in the data, I can calculate the length of these fields to skip them, I saw someone recommend using the IgnoreAny type:
_ => {
let _ : serde::de::IgnoredAny = map.next_value()?;
}
These statements contradict each other. If you are implementing Visitor, then you are implementing a data structure. However, deserialize_ignored_any is a function on the trait Deserializer, which means you are implementing a serialization format. Which one is it? I suspect the recommendation of just using IgnoredAny is right, and you don't actually need to implement a custom deserializer.
I use a custom Deserializer to deserialize data, and some of the structures still need to be deserialized manually. So here we have both Visitor and deserialize_ignored_any