Any plans for serde support
dzhou121 opened this issue · comments
Hi, I’m trying to build an Ansible alternative on top of rcl. One thing that would be nice is to be able to serde_rcl::from_value(value) which will tell which part of the file didn’t match the type.
I’m trying to build an Ansible alternative on top of rcl
Cool!
One thing that would be nice is to be able to
serde_rcl::from_value(value)
which will tell which part of the file didn’t match the type.
Yes, I agree. I do have plans to make deserialization into Rust structs nicer, currently it’s not very ergonomic. I ran into this myself in #41, for now I do deserialization there like this: https://github.com/ruuda/rcl/pull/41/files#diff-e699e5fa1bf29e0fdd266cc76a2f808fb429b0ee90d7167f732a7b28b4ce3706R72-R162.
I’m not yet sure what the best way to go about it is. One way is to traverse the Rust type definition and generate a deserializer that emits errors like above, but possibly nicer would be to generate an RCL type. Currently the top-level expression can be anything, but if a particular type is expected, then the typechecker can highlight the spans in the source code that don’t match the type (as opposed to evaluating first and then checking that the value fits the type, which loses information about where in the source file the value came from).
I don’t have a timeline for deserialization support, at this point some other features have higher priority for me.