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

Marshalling of Rust functions/types like with #[wasm-bindgen] attributes? #220

Open
Boscop opened this issue Oct 2, 2024 · 5 comments
Open

Comments

@Boscop
Copy link

Boscop commented Oct 2, 2024

Thanks for making this crate, it seems very useful 🙂

It it possible to do marshalling of Rust functions/types like with #[wasm-bindgen] attributes?

Or anything that's not as verbose as manual deserialization of the function arguments on the Rust side? :)

Thanks 🙏

@rscarson
Copy link
Owner

rscarson commented Oct 2, 2024

Can you show me an example of what you mean?

@Boscop
Copy link
Author

Boscop commented Oct 2, 2024

I mean like this:

On Rust items:
https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-rust-exports/constructor.html

On JS items:
https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/constructor.html

This would make interop much easier :)


Btw, I have another question:
Is this crate the least-opinionated-possible layer on top of deno to make it useable inside a Rust host?
In other words, would it make sense for me to use deno directly or always this crate, if my goal is to have an embedded JS runtime to extend the capabilities of my Rust host via JS scripting?

@rscarson
Copy link
Owner

rscarson commented Oct 2, 2024

I mean like this:

On Rust items:
https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-rust-exports/constructor.html

On JS items:
https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/constructor.html

This would make interop much easier :)


Btw, I have another question:
Is this crate the least-opinionated-possible layer on top of deno to make it useable inside a Rust host?
In other words, would it make sense for me to use deno directly or always this crate, if my goal is to have an embedded JS runtime to extend the capabilities of my Rust host via JS scripting?

That was the goal of the project, yes

An unopinionated layer on top of deno existing only to simplify integration tasks with minimal overhead

@Boscop
Copy link
Author

Boscop commented Oct 2, 2024

That was the goal of the project, yes
An unopinionated layer on top of deno existing only to simplify integration tasks with minimal overhead

Ok great, just what I had hoped this would be :)

Sorry, I didn't want to derail the topic of this issue..
But yeah, considering this crate could be considered the "canonical" way to use Deno in a Rust host, it definitely would be super nice & ergonomic to have #[wasm-bindgen]-like attributes for marshalling 🙂

@rscarson
Copy link
Owner

rscarson commented Nov 4, 2024

Looking to implement this soon

Can I get more examples of how you picture this being used?

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