Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plans for serde support #51

Open
dzhou121 opened this issue Apr 9, 2024 · 2 comments
Open

Any plans for serde support #51

dzhou121 opened this issue Apr 9, 2024 · 2 comments

Comments

@dzhou121
Copy link

dzhou121 commented Apr 9, 2024

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.

@ruuda
Copy link
Owner

ruuda commented Apr 9, 2024

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.

@dzhou121
Copy link
Author

Thanks for the insight.

I ended up putting Span into Value as a quick hack, and manually traverse down the Value.

The error reporting in rcl is really good.

Screenshot 2024-04-10 at 09 15 35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants