WebAssembly / wasi-http

Other
149 stars 24 forks source link

streams are not implemented in `wit-bindgen` for C bindings #112

Open brendandburns opened 6 months ago

brendandburns commented 6 months ago

If you try to generate bindings for 0.3.0 for C it fails:

RUST_BACKTRACE=1 wit-bindgen c --autodrop-borrows yes ./wasi-http/wit-0.3.0-draft -w client
thread 'main' panicked at crates/c/src/lib.rs:780:43:
not implemented
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: wit_bindgen_c::push_ty_name
   4: wit_bindgen_c::gen_type_name
   5: wit_bindgen_c::InterfaceGenerator::define_live_types
   6: <wit_bindgen_c::C as wit_bindgen_core::WorldGenerator>::import_interface
   7: wit_bindgen_core::WorldGenerator::generate
   8: wit_bindgen::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I realize that this is actually a wit-bindgen issue, but I think C bindings should be a blocker for an 0.3.0 release.

dicej commented 6 months ago

Yeah, the only tool that can handle stream and future at this point (AFAIK) is isyswasfa and its temporary forks of wit-bindgen and componentize-py (and those only handle Rust and Python at the moment). It emulates support by transforming the stream and future references in the WIT into resource imports.

I'm currently working on adding support for async lifts and lowers, along with proper (not just emulated) support for stream and future to wit-bindgen, wasm-tools, and wasmtime, and plan to start opening PRs on those projects in the next few weeks. See https://github.com/dicej/component-async-demo for the progress I've made so far.

I agree that C binding support will be a blocker, and I plan to take a crack at it once the other foundational pieces are in place. If you or anyone else are interested in contributing to those efforts, I'd be happy to collaborate.