Hello all.
I'm having trouble to find export_host!
macro which was stated in the Rust example.
error: cannot find macro `export_host` in this scope
--> rust_module/src/lib.rs:18:1
|
18 | export_host!(MyTransformer);
| ^^^^^^^^^^^
I couldn't either spot it in the wit-bindgen
code base.
Would you point me to the right direction?
Thanks for your help in advance.
Where is the example from?
It is from the README.md
in wit-bindgen
code base.
I slightly modified the names but it is the same.
The original example is
// src/lib.rs
// Use a procedural macro to generate bindings for the world we specified in
// `host.wit`
wit_bindgen::generate!("host");
// Define a custom type and implement the generated `Host` trait for it which
// represents implementing all the necesssary exported interfaces for this
// component.
struct MyHost;
impl Host for MyHost {
fn run() {
print("Hello, world!");
}
}
export_host!(MyHost);
Which is trying to generate from this wit
I suppose.
// wit/host.wit
package example:host
world host {
import print: func(msg: string)
export run: func()
}
You won't find a macro named export_host
in the wit-bindgen repo because wit-bindgen creates that macro when you use it to generate and the name is formatted as export_{}
where the parameter is the name of the world which just happens to be host
in this case.
Now I got it :)
Since the host is such a generic name it confused me.
Thanks for the help!
you're welcome!
Here is a PR which imo clarifies this potential confusion, if you'd like to consider.
https://github.com/bytecodealliance/wit-bindgen/pull/599
alisomay has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC