bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.21k stars 1.28k forks source link

Change WASI trait impls back to being blanket impls #8766

Closed alexcrichton closed 3 months ago

alexcrichton commented 3 months ago

This commit is a partial revert of #8609 to return wasmtime-wasi and wasmtime-wasi-http back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required &mut dyn WasiView to exist but sometimes only a Foo<'a> is held which is not easy to get a &mut dyn ... view of. By changing to a blanket impl in terms of a newtype wrapper, WasiImpl, it's possible to call bindgen!-generated add_to_linker_get_host functions with a return value of WasiImpl<Foo<'a>> which enables hooking into all the generated bindings.