Serde_yaml: custom action on duplicate keys

serde_yaml throws an error on duplicate map keys when deserializing to a serde_yaml::Value. Is there a way to prevent this, or even customize the action somehow? Ideally, I'd like to apply a name transformation.

I know that deserializing to a HashMap prevents this, but I'm deserializing quite a large, deeply nested document with some oddities from a YAML implementation I have from about 15 years ago, that I'm trying to adapt without breaking anything.

Thanks for any pointers.

I've looked at GitHub - dtolnay/serde-stacker: Serializer and Deserializer adapters that avoid stack overflows by dynamically growing the stack for writing an adaptor, I have mostly implemented this wrapper, but still don't quite see how I can support the behavior I'd like here.

The duplicate key error originates from the Value type or more precisely the Mapping type - source
A Deserializer does not have any influence over that, so I don't think using an adaptor works. You need to invoke a different Deserialize implementation. The easiest will be to copy the value type and customize it with your renaming.