I would like to use WASI-HTTP components in my project and generate function something like:
fn handle(_request: IncomingRequest, response_out: ResponseOutparam) {
// some code
}
in rust file I can import it without problem:
use wasi::http::types::{
Fields, IncomingRequest, OutgoingBody, OutgoingResponse, ResponseOutparam,
};
but when I would like to declare components in WIT file
package component-model:example;
use wasi:http/types@1.0.0
and using wit_bindgen generate code for kotlin:
wit_bindgen::generate!({
path: "wit",
exports: {
"component-model:example/test": Test,
},
});
I got this error:
error: failed to find package `wasi:http@0.2.3` in `deps` directory
--> C:\rust-component\wit\example.wit:5:5
|
5 | use wasi:http/types@0.2.3;
| ^--------
I have already specified wasi
version in Cargo.toml
file
wasi = "0.14.1"
Looks like I have missed something or make mistake...
When you use wit-bindgen, its expecting to find wit files at the path:
you specify in the macro, which is relative to the crate root. You probably don't actually want to do that, though. I fyou are just trying to export your wasi-http incoming handler from your function, you can do that with the wasi crate (no need for wit-bindgen) with https://docs.rs/wasi/latest/wasi/http/proxy/macro.export.html
Last updated: Feb 28 2025 at 02:27 UTC