-
Notifications
You must be signed in to change notification settings - Fork 285
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
Automatic conversion of types between Rust and Javascript via serde #213
Comments
I've been working on this https://github.com/GabrielCastro/neon-serde , It's got most of the uses cases covered, but is lacking in documentation |
Thanks a lot, @GabrielCastro! I've used it in my project and it worked great! Here's some feedback:
|
@matklad Thanks for the feed back, I've made a couple issues from your comments. Please feel free to comment there |
Just stumbled upon this. I think in principle it should be possible for neon to implement a function wrapper with generic implementations for: fn<R>() -> R
fn<A, R>(A) -> R
fn<A, B, R>(A, B) -> R
fn<A, B, C, R>(A, B, C) -> R
...
fn<A, B, C, D, E, F, G, H, R>(A, B, C, D, E, F, G, H) -> R With generics being: where
A: Deserialize,
B: Deserialize,
C: Deserialize,
D: Deserialize,
E: Deserialize,
F: Deserialize,
G: Deserialize,
H: Deserialize,
R: Serialize, With that in place the end user can just write a |
Turns out doing it with traits as I intended wasn't possible (at least not without some nightly features to create a 0-type structs that implement |
@dherman @kjvalencik would there be any interest in getting As it stands currently, the most up-to-date one I could find is matrix-org's fork which has about 1200 lines of Rust code. It's not tiny, but compared to the current |
@antonok-edm I considered that here, mostly for performance, but was disappointed that it was slower than However, given the popularity of |
@kjvalencik ah, that's good to know! The main benefit of But regardless of implementation, I think |
@antonok-edm do you happen to use the the RE: Performance. I don't have a good sense of how much serialization is a bottleneck in Neon apps overall. My view is a bit skewed because it's by far the largest cost in the app I build at work. I've tried a few things--including implementing |
I'm not using any macros at the moment. (code is here if you're curious) edit: other than |
I needed this for work so we ended up forking neon-serde and bringing it up to date. It can be found at https://github.com/formbird/neon-serde |
Hi!
I've been using neon successfully in my side-project and everything works great, except that there's quite a bit of boilerplate required to marshal types between Rust and JS. I wonder if this can be automated away with the help of
serde
. It's sort of possible today, if you literally serialize and deserialize JSON from strings, but it would be cool to be able to use serde withJsValue
s directly!The text was updated successfully, but these errors were encountered: