Stream: wit-bindgen

Topic: How best can I map this example Rust crate to WIT?


view this post on Zulip Jacob Hummer (Jan 17 2024 at 21:52):

From https://github.com/WebAssembly/component-model/issues/295
_might also be a question for seasoned Rustaceans from cargo-component. im just a beginner._

If I want to turn this very simple Rust package https://docs.rs/unicode-math-class/latest/unicode_math_class/ into a WebAssembly component using https://github.com/bytecodealliance/cargo-component, what should I call the package, world, and interface?

For instance in the example Rust package, there's these levels of hierarchy:

In my brain those map _relatively_ cleanly onto the package/world/interface model like so:

<details><summary>WIT snippet of that</summary>

package jcbhmr:unicode-math-class;

world unicode-math-class {
  // Can't export enum without a wrapping interface! What do you call the interface tho?
  export x: interface {
    enum math-class { ... }
    // No consts; compromise with getter func.
    revision: func() -> u8;
    // No char type; compromise with string.
    class: func(c: string) -> math-class;
  }
}

</details>

Is there a better way? :thinking:

I'm looking for the convention. Or just some general "well here's what I do" ideas. I'm having decision paralysis and I'd like to get some other opinions besides my own biased one.

Here's a concrete example: If I want to turn this very simple Rust package https://docs.rs/unicode-math-class/latest/unicode_math_class/ into a WebAssembly component using https://github.com/byteco...
A Cargo subcommand for creating WebAssembly components based on the component model proposal. - GitHub - bytecodealliance/cargo-component: A Cargo subcommand for creating WebAssembly components bas...

Last updated: Oct 23 2024 at 20:03 UTC