| 1 | //! This crate contains the binaries of three WebAssembly modules: |
| 2 | //! |
| 3 | //! - [`WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER`] |
| 4 | //! - [`WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER`] |
| 5 | //! - [`WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER`] |
| 6 | //! |
| 7 | //! These three modules bridge the wasip1 ABI to the wasip2 ABI of the component |
| 8 | //! model. |
| 9 | //! |
| 10 | //! They can be given to the [`wit_component::ComponentEncoder::adapter`] |
| 11 | //! method, using the [`WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME`], to translate a |
| 12 | //! module from the historical WASM ABI to the canonical ABI. |
| 13 | //! |
| 14 | //! [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter |
| 15 | |
| 16 | /// The name of the adapters in this crate, which may be provided to |
| 17 | /// [`wit_component::ComponentEncoder::adapter`]. |
| 18 | /// |
| 19 | /// [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter |
| 20 | pub const WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME: &str = "wasi_snapshot_preview1" ; |
| 21 | |
| 22 | /// The "reactor" adapter provides the default adaptation from preview1 to |
| 23 | /// preview2. |
| 24 | /// |
| 25 | /// This adapter implements the [`wasi:cli/imports`] world. |
| 26 | /// |
| 27 | /// [`wasi:cli/imports`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/imports.wit |
| 28 | pub const WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER: &[u8] = |
| 29 | include_bytes!("../artefacts/wasi_snapshot_preview1.reactor.wasm" ); |
| 30 | |
| 31 | /// The "command" adapter extends the ["reactor" adapter] and additionally |
| 32 | /// exports a `run` function entrypoint. |
| 33 | /// |
| 34 | /// This adapter implements the [`wasi:cli/command`] world. |
| 35 | /// |
| 36 | /// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER |
| 37 | /// [`wasi:cli/command`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/command.wit |
| 38 | pub const WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER: &[u8] = |
| 39 | include_bytes!("../artefacts/wasi_snapshot_preview1.command.wasm" ); |
| 40 | |
| 41 | /// The "proxy" adapter provides implements a HTTP proxy which is more |
| 42 | /// restricted than the ["reactor" adapter] adapter, as it lacks filesystem, |
| 43 | /// socket, environment, exit, and terminal support, but includes HTTP handlers |
| 44 | /// for incoming and outgoing requests. |
| 45 | /// |
| 46 | /// This adapter implements the [`wasi:http/proxy`] world. |
| 47 | /// |
| 48 | /// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER |
| 49 | /// [`wasi:http/proxy`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/http/proxy.wit |
| 50 | pub const WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER: &[u8] = |
| 51 | include_bytes!("../artefacts/wasi_snapshot_preview1.proxy.wasm" ); |
| 52 | |