Stream: rust-toolchain

Topic: `wasi` crate export macros


view this post on Zulip Lann Martin (Feb 26 2024 at 15:24):

Would it make sense for the wasi crate to have specialized (per-world) macros for defining exports? These would wrap wit-bindgen::generate with appropriate exports:, with:, etc.

view this post on Zulip Alex Crichton (Feb 26 2024 at 15:28):

That seems reasonable to me yeah!

view this post on Zulip Lann Martin (Feb 26 2024 at 16:22):

https://github.com/bytecodealliance/wasi/issues/76

Implementing WASI exports correctly is verbose and requires a somewhat-deep understanding of wit-bindgen features, especially if you want to reuse the types from this crate: wit_bindgen::generate!(...

view this post on Zulip Lann Martin (Feb 27 2024 at 14:50):

https://github.com/bytecodealliance/wasi/pull/77

Also update bindings.rs with wit-bindgen 0.19.2. Closes #76 use wasi::http::types::{IncomingRequest, ResponseOutparam}; wasi::http::incoming_handler::export!(Handler); struct Handler; impl expor...

view this post on Zulip Yoshua Wuyts (Feb 28 2024 at 19:29):

oh lol, I think I might have filed the same question about that just now here: https://github.com/bytecodealliance/wasi/issues/79

In this example the entry point for the proxy world is generated via wit-bindgen like so: mod bindings; pub use bindings::wasi::http::types::{IncomingRequest, ResponseOutparam}; struct Component; i...

view this post on Zulip Lann Martin (Feb 28 2024 at 19:33):

I believe @Alex Crichton is planning to make the macros-generating-macros story easier by overhauling wit-bindgen-rust's resources as well

view this post on Zulip Yoshua Wuyts (Feb 28 2024 at 19:35):

oh neat!

view this post on Zulip Alex Crichton (Feb 28 2024 at 19:44):

indeed! that was done in https://github.com/bytecodealliance/wit-bindgen/pull/871

This commit is unfortunately a bit of whiplash for Rust users as it transitions the wit_bindgen::generate! macro to what it was a few months ago in terms of how exports work. Before describing that...

view this post on Zulip Lann Martin (Feb 28 2024 at 19:45):

see I only looked for open PR when I wrote "planning"


Last updated: Nov 22 2024 at 16:03 UTC