rscarson/rustyscript

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

Boscop opened this issue ยท 5 comments

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 ๐Ÿ™

Can you show me an example of what you mean?

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?

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

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 ๐Ÿ™‚

Looking to implement this soon

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