bytecodealliance / bytecodealliance/wasm-tools
World::name is always "root"
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
Hello,
I am following this tutorial:
https://component-model.bytecodealliance.org/language-support/rust.html
Here is my WIT file:
```wit
package example:component;
world example {
// A function to add two 32bit signed integers.
export add: func(x: s32, y: s32) -> s32;
}
```
Yet, `World::name` is apparently set to `"root"` anyway.
Here is the code that loads/decode the WASM component's WIT:
```rust
// Load the WASM module
let module = fs::read(&args.file).expect("Failed to load module");
let wit = wit_component::decode(&module).expect("Failed to decode WIT component");
// Find the exported functions
let functions = wit.resolve().worlds.iter().flat_map(|(_id, world)| {
world.exports.iter().filter_map(|(_, item)| match item {
WorldItem::Function(func) => Some((&world.name, func)),
_ => None,
})
});
```
Am I doing something wrong?
Contributor guide
Assessment
This issue has not been assessed yet.