I'm finding serde custom deserialization impls to be alot more error prone than I expect.
I'm wondering if there is a library that lets me do the following:
-
Suppose we want to custom derive on type
T -
I want to specify types
Ualong with two functions
f :: T -> Result<U, String>
g :: U -> Result<T, String>
-
Uis serialized via standard derive macro. -
If serde comes across
Tduring serialization, it callsfand uses that output. -
If serde comes across
Tduring deserialization, it gets aUfrom the data, then callsg.
Is there a library that does this? The main here is that I'd rather write f and g rather than write all the visitor patterns.