-
Notifications
You must be signed in to change notification settings - Fork 644
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
interpreter: Add API to do JSON encoding/decoding for Value
#7498
Conversation
Any reason not to put that in a module in the slint-interpreter crate? |
It should be behind a feature flag. |
5868617
to
cfc108c
Compare
I have the same feeling, I think it makes sense to create a separate crate when there is a need/use for it, but at the moment I think everyone who needs this functionality also needs the interpreter. |
OK, I'll merge it into the interpreter. |
780acd4
to
920aed0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds public API, with a public dependency on serde_json when the json feature is added.
Should it be documented, either document it that this is an internal feature (and then it should be renamed with "internal") or polish the documentation (of the feature, and of the functions, and make sure it is on docs.rs)
9849b99
to
89b0013
Compare
A bit better docs... not great, but the new functions should be pretty obvious. |
This also disambiguates the rust test driver: The workspace turns on the |
954c5eb
to
07ec501
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to do proper API review on this.
I wonder if a better API wouldn't be to implement the From trait between serde_json::Value and slint_interpreter::Value
Or maybe the best would be to implement manually the serde::Serialize and serde::Deserialize trait for Value
Value
07ec501
to
faff175
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that using Serialize/Decerialize or just From don't work because we need the type.
I think we probably need to create a public Type. But we can't just make our Type public.
IMHO it would be better to actually keep this feature internal under the internal
feature flag and not having it as public.
Have it under slint-interpreter::internal::value_from_json/value_to_json functions.
That said eventually we would need to expose a proper type for our properties. We could discuss about that
PS: I took the liberty to edit the PR title
3862a11
to
0ded3f2
Compare
So I moved back to the state from late last week, but made I did keep the I should probably test more error conditions, but most of them are todo items than things that should report an error ;-) |
I hope I also fixed the image path test on windows this time round. |
df0bc86
to
29256a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Looks good now.
Extract the `from_json` and `to_json` code from the viewer into the `interpreter`. Extend the `from_json` and `to_json` a bit. Add some simple tests while at it.
29256a4
to
cd980f9
Compare
…terpreter
I need to enccode/decode interpreter values into JSON for the viewer and the live-preview.
Extract the from-json code from the viewer into a new crate
interpreter-json
, so that the normal interpreter does not need to gain a dependency onserde_json
.Extend the
from_json
code a bit and implementto_json
. Add some simple tests while at it.