What does this mean from wasm-tools component new
, I thought one component would export and another import?
PS C:\github\cswasi> wasm-tools component new .\bin\Debug\net8.0\wasi-wasm\native\cswasi.wasm -o my-component-cs.wasm --adapt wasi_snapshot_preview1=c:\github\rustimpl\rustimpl\wasi_preview1_component_adapter.reactor.wasm
error: failed to encode a component from module
Caused by:
0: module is only allowed to import functions
I guess I might be confused about how to do this. With witx-bindgen it was possible to create a rust module and a c# module and link them together to run in wasmtime, with the c# module calling a function from the rust module. Is this not possible with wasm-tools components?
The component new command works on a pretty specific shape of module and is not reflective of the component model at large. You can create components via other means, we just don't have the tooling to do so at this time. The situation you are describing is possible with the component model
Alex Crichton said:
via other means
Thanks, is there any documentation about what these are?
Sorry I don't mean to imply there are tools that are missing. The component model can express what you're talking about, but I'm not aware of tooling that you can pull off the shelf to use for this. You'd have to write your own tool, perhaps using a library like wasm-encoder
, which would create the compoennt.
I see, so the tooling right now is focused on imports from the host, i.e. a WASI host?
I guess I'm a little confused about how the wit-bindgen tests (e.g. https://github.com/bytecodealliance/wit-bindgen/blob/main/tests/codegen/floats.wit) work, are they using wasm-encoder
?
Last updated: Dec 23 2024 at 13:07 UTC