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:
serde::de
so it's just the root module.In my brain those map _relatively_ cleanly onto the package/world/interface model like so:
jcbhmr:unicode-math-class
from my username + Rust package name. Sorta Docker-like two-part names.unicode_math_class
unicode-math-class
due to no underscoresenum math-class {}
inside an interface... but the MathClass
is in the root module... What should I do? Is there a naming convention like interface crate { ... }
? Or mod
, root
, module
, iface
, exports
, main
, lib
, it
, default
, or something else? Single metacharacters like $
,_
,-
aren't allowed :cry:. If it had any sub-modules I guess those would map well to serde::de
=> world serde {}; interface de {}
.<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.
Last updated: Dec 23 2024 at 12:05 UTC