A field that returns a serde deserialize error will always have the field set to None.
impl SerdeError for DeserializeError {
fn custom<T: fmt::Display>(msg: T) -> DeserializeError {
DeserializeError { field: None, kind: DEK::Message(msg.to_string()) }
}
}
It does not appear we can determine the field that failed to deserialize from serde to report to the user.
One option is to modify the deserialize_string_record function to manually set the err.field in the map_err closure
D::deserialize(&mut deser).map_err(|mut err| {
err.set_field(Some(deser.0.field.saturating_sub(1));
Error::new(ErrorKind::Deserialize {
pos: record.position().map(Clone::clone),
err,
})
})
I am unsure if this is a valid solution or if there are edge cases that will cause the field index to not be accurate.
A field that returns a serde deserialize error will always have the
fieldset toNone.It does not appear we can determine the field that failed to deserialize from serde to report to the user.
One option is to modify the
deserialize_string_recordfunction to manually set theerr.fieldin themap_errclosureI am unsure if this is a valid solution or if there are edge cases that will cause the field index to not be accurate.