I’m brand new to serde, and I’m having trouble figuring out how to accomplish a deserialize task at hand.
I have a YAML config file, with a map entry called ‘selection’. The value of this entry is either 1) a single string, or 2) a list of strings. Some examples:
selection: *.flac ---- selection: - *.mp3 - *.jpg - *.mkv
I’d like to use serde_yaml to deserialize this config file (no serialization needed), process the one or more strings as glob patterns, and create a GlobSet object. However, I’m having trouble with figuring out the custom deserialization. I’ve found examples of both coercing single values and lists of values into lists, and converting a value to a new value, but not both together. How would I go about this?
Some issues I’ve faced:
- GlobSet isn’t deserializable, so I’d need to use custom deserialization logic.
- I’d like to use my existing error handling, using the