Skip to content

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

Open

Description

@Boscop

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 馃檹

Activity

  1. rscarson commented on Oct 2, 2024

    @rscarson
    Owner

    Can you show me an example of what you mean?

  2. Boscop commented on Oct 2, 2024

    @Boscop
    Author

    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?

  3. rscarson commented on Oct 2, 2024

    @rscarson
    Owner

    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

  4. Boscop commented on Oct 2, 2024

    @Boscop
    Author

    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 馃檪

  5. rscarson commented on Nov 4, 2024

    @rscarson
    Owner

    Looking to implement this soon

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

  6. Boscop commented on Jan 10, 2025

    @Boscop
    Author

    Sorry for the late reply..
    This page describes exactly what I meant:

    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

    It doesn't have to be #[wasm-bindgen] attributes if that's not possible, but a similar proc-macro attribute would be nice.
    This would make marshalling as ergonomic as it could be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions