When I use cargo component new to build a CLI component for Rust/Wasm/Wit, the cargo component build step will automatically translate a main function to .e.g. wasi:cli/run or println! statements to the according stream functions from the wasi world. With wasm-tools component wit I can even inspect a generated with world, though none was supplied. I would llike to know more about the magic involved. Is that documented somewhere, is this something carfgo component does, or is it coming from wit-bindgen? Any help or pointers appreciated.

#rust #wasm #wit #wasi #wasip2 #cargo #componentmodel

@io The magic is that components are self-describing, meaning they always contain enough information to describe what world they can run in. See here for some more information:

https://component-model.bytecodealliance.org/design/components.html

Components - The WebAssembly Component Model