I have a toml configuration that has a retries field. This can be none, an integer or inf/infinite. Currently I require that the user specify this as a string in all cases, and there's a piece of code that tries to convert the string into a number:
While I've used serde quite a bit, it has been very superficial. I basically only know about simple use-cases of #[derive(Deserialize)]. How can the enum Retries be implemented to support the Config use-case? Will implementing Deserialize manually allow this? Is there a shortcut? deserialize_with? Is there some way to tag the Retries enum with magic serde pixie dust to make it work the way I want?
Thank you -- sticking the #[serde(rename = "inf/infinite")] on the InfiniteRetries variant of the InfiniteRetries enum, rather than within the Retries, makes it work.
I'm a little impressed by the amount of things one can do without manually implementing Deserialize.