tokio-rs / valuable

MIT License
185 stars 19 forks source link

Constructing objects from `Value` #128

Open AmateurECE opened 6 months ago

AmateurECE commented 6 months ago

I have a use case where I need to "deserialize" Values into instances of struct Foo.

This feels related to #17. Perhaps the impedance mismatch between valuable::Visit and serde::de::Visit is slight enough to be overcome with a generic implementation that allows deserializing a valuable::Value into anything that implements serde::de::Deserialize?

A while ago, I decided to start on an implementation that relies on a FromValue trait and a corresponding proc-macro, which can fallibly convert valuable::Value to any type that it's implemented for. I guess at the time, I must not have considered the serde solution. That implementation is available here.

Is this kind of functionality something that the team would be interested in incorporating into valuable or valuable-serde? If so, what should be the shape of that solution? Alternatively, if something seems fundamentally wrong about my use of tokio tracing, I would appreciate your feedback. Thanks very much!