I have been using serde with no_std support and the serde-json-core backend.
One of my structs had a field track_mode: bool which I now want to convert from bool into a dedicated enum:
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
pub enum TrackMode {
#[default]
Off,
Mid,
High,
}
For backward-compatibility, I now want to use the #[serde(deserialize_with="..")] attribute to use a custom deserialization function and either deserialize from a bool into OFF/HIGH, or use the TrackMode derived implementation otherwise.
Normally I would take advantage of a helper #[serde(untagged)] enum BoolOrTrackMode but unfortunately untagged is not supported without alloc support. So I am currently trying to implement a custom Visitor. Unfortunately it seems I can't reuse the existing TrackMode derived visitors, can I avoid having to re-write all of them by hand ?