From e5921aea8e797d1dc9b848b9c9e6843c93f0ba91 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 26 Jan 2024 14:15:57 -0700 Subject: [PATCH] update to Wasmtime 17 and WASI 0.2.0 (#2250) I've taken this opportunity to rename the wit directories to reflect the WASI snapshots they correspond to. Note that the Rust and Go SDKs continue to target the 2023-10-18 snapshot for compatibility. Likewise, `spin-world`. `spin-trigger-http`, however, can handle components targeting either 2023-10-18, 2023-11-10, or the final 0.2.0 release of WASI. Signed-off-by: Joel Dice --- Cargo.lock | 114 +- Cargo.toml | 11 +- crates/core/src/wasi_2023_10_18.rs | 34 +- crates/core/src/wasi_2023_11_10.rs | 1617 ++++++++++++++++- crates/redis/tests/rust/src/lib.rs | 2 +- .../benches/spin-http-benchmark/src/lib.rs | 2 +- crates/trigger-http/src/handler.rs | 6 +- .../tests/rust-http-test/src/lib.rs | 2 +- crates/trigger/src/lib.rs | 2 +- crates/world/src/lib.rs | 2 +- examples/spin-timer/Cargo.lock | 114 +- examples/spin-timer/Cargo.toml | 2 +- sdk/rust/src/lib.rs | 2 +- sdk/rust/wit | 1 - sdk/rust/wit-2023-10-18 | 1 + tests/spinup_tests.rs | 4 +- ...-12-05.reactor.wasm => 0.2.0.reactor.wasm} | Bin 98689 -> 96719 bytes tests/test-components/build.rs | 2 +- tests/test-components/components/Cargo.lock | 5 +- .../wit/command-extended.wit | 6 - .../wit/deps/cli/imports.wit | 20 - .../wit/test.wit | 22 - .../Cargo.toml | 2 +- .../src/lib.rs | 4 +- tests/test-components/helper/Cargo.toml | 1 + tests/test-components/helper/src/lib.rs | 4 +- .../spin.toml | 4 +- .../wit => wit-0.2.0}/deps/cli/command.wit | 2 +- .../deps/cli/environment.wit | 0 .../wit => wit-0.2.0}/deps/cli/exit.wit | 0 wit-0.2.0/deps/cli/imports.wit | 20 + .../wit => wit-0.2.0}/deps/cli/run.wit | 0 .../wit => wit-0.2.0}/deps/cli/stdio.wit | 6 +- {wit => wit-0.2.0}/deps/cli/terminal.wit | 18 +- .../deps/clocks/monotonic-clock.wit | 4 +- .../deps/clocks/wall-clock.wit | 2 +- .../wit => wit-0.2.0}/deps/clocks/world.wit | 2 +- .../deps/filesystem/preopens.wit | 2 +- .../deps/filesystem/types.wit | 6 +- .../deps/filesystem/world.wit | 2 +- .../wit => wit-0.2.0}/deps/http/handler.wit | 0 .../wit => wit-0.2.0}/deps/http/proxy.wit | 12 +- .../wit => wit-0.2.0}/deps/http/types.wit | 8 +- .../wit => wit-0.2.0}/deps/io/error.wit | 2 +- .../wit => wit-0.2.0}/deps/io/poll.wit | 4 +- .../wit => wit-0.2.0}/deps/io/streams.wit | 23 +- .../wit => wit-0.2.0}/deps/io/world.wit | 2 +- .../deps/random/insecure-seed.wit | 2 +- .../deps/random/insecure.wit | 2 +- .../wit => wit-0.2.0}/deps/random/random.wit | 2 +- .../wit => wit-0.2.0}/deps/random/world.wit | 2 +- .../deps/sockets/instance-network.wit | 0 .../deps/sockets/ip-name-lookup.wit | 2 +- .../deps/sockets/network.wit | 36 +- .../deps/sockets/tcp-create-socket.wit | 3 +- .../wit => wit-0.2.0}/deps/sockets/tcp.wit | 170 +- .../deps/sockets/udp-create-socket.wit | 1 + .../wit => wit-0.2.0}/deps/sockets/udp.wit | 27 +- .../wit => wit-0.2.0}/deps/sockets/world.wit | 2 +- .../deps/spin@unversioned/config.wit | 0 .../deps/spin@unversioned/http-types.wit | 0 .../deps/spin@unversioned/http.wit | 0 .../deps/spin@unversioned/inbound-http.wit | 0 .../deps/spin@unversioned/inbound-redis.wit | 0 .../deps/spin@unversioned/key-value.wit | 0 .../deps/spin@unversioned/llm.wit | 0 .../deps/spin@unversioned/mysql.wit | 0 .../deps/spin@unversioned/postgres.wit | 0 .../deps/spin@unversioned/rdbms-types.wit | 0 .../deps/spin@unversioned/redis-types.wit | 0 .../deps/spin@unversioned/redis.wit | 0 .../deps/spin@unversioned/sqlite.wit | 0 .../deps/spin@unversioned/world.wit | 0 {wit => wit-0.2.0}/key-value.wit | 0 {wit => wit-0.2.0}/llm.wit | 0 {wit => wit-0.2.0}/mysql.wit | 0 {wit => wit-0.2.0}/postgres.wit | 0 {wit => wit-0.2.0}/rdbms-types.wit | 0 {wit => wit-0.2.0}/redis.wit | 0 {wit => wit-0.2.0}/sqlite.wit | 0 {wit => wit-0.2.0}/variables.wit | 0 wit-0.2.0/world.wit | 20 + {wit => wit-2023-10-18}/deps/cli/command.wit | 0 .../deps/cli/environment.wit | 0 {wit => wit-2023-10-18}/deps/cli/exit.wit | 0 {wit => wit-2023-10-18}/deps/cli/reactor.wit | 0 {wit => wit-2023-10-18}/deps/cli/run.wit | 0 {wit => wit-2023-10-18}/deps/cli/stdio.wit | 0 .../deps/cli/terminal.wit | 0 .../deps/clocks/monotonic-clock.wit | 0 .../deps/clocks/timezone.wit | 0 .../deps/clocks/wall-clock.wit | 0 {wit => wit-2023-10-18}/deps/clocks/world.wit | 0 .../deps/filesystem/preopens.wit | 0 .../deps/filesystem/types.wit | 0 .../deps/filesystem/world.wit | 0 .../deps/http/incoming-handler.wit | 0 .../deps/http/outgoing-handler.wit | 0 {wit => wit-2023-10-18}/deps/http/proxy.wit | 0 {wit => wit-2023-10-18}/deps/http/types.wit | 0 {wit => wit-2023-10-18}/deps/io/poll.wit | 0 {wit => wit-2023-10-18}/deps/io/streams.wit | 0 {wit => wit-2023-10-18}/deps/io/world.wit | 0 .../deps/random/insecure-seed.wit | 0 .../deps/random/insecure.wit | 0 .../deps/random/random.wit | 0 {wit => wit-2023-10-18}/deps/random/world.wit | 0 .../deps/sockets/instance-network.wit | 0 .../deps/sockets/ip-name-lookup.wit | 0 .../deps/sockets/network.wit | 0 .../deps/sockets/tcp-create-socket.wit | 0 {wit => wit-2023-10-18}/deps/sockets/tcp.wit | 0 .../deps/sockets/udp-create-socket.wit | 0 {wit => wit-2023-10-18}/deps/sockets/udp.wit | 0 .../deps/sockets/world.wit | 0 .../deps/spin@unversioned/config.wit | 12 + .../deps/spin@unversioned/http-types.wit | 44 + wit-2023-10-18/deps/spin@unversioned/http.wit | 5 + .../deps/spin@unversioned/inbound-http.wit | 5 + .../deps/spin@unversioned/inbound-redis.wit | 6 + .../deps/spin@unversioned/key-value.wit | 80 + wit-2023-10-18/deps/spin@unversioned/llm.wit | 70 + .../deps/spin@unversioned/mysql.wit | 19 + .../deps/spin@unversioned/postgres.wit | 19 + .../deps/spin@unversioned/rdbms-types.wit | 65 + .../deps/spin@unversioned/redis-types.wit | 24 + .../deps/spin@unversioned/redis.wit | 31 + .../deps/spin@unversioned/sqlite.wit | 52 + .../deps/spin@unversioned/world.wit | 29 + wit-2023-10-18/key-value.wit | 47 + wit-2023-10-18/llm.wit | 70 + wit-2023-10-18/mysql.wit | 15 + wit-2023-10-18/postgres.wit | 15 + wit-2023-10-18/rdbms-types.wit | 80 + wit-2023-10-18/redis.wit | 70 + wit-2023-10-18/sqlite.wit | 50 + wit-2023-10-18/variables.wit | 18 + {wit => wit-2023-10-18}/world.wit | 0 138 files changed, 2814 insertions(+), 382 deletions(-) delete mode 120000 sdk/rust/wit create mode 120000 sdk/rust/wit-2023-10-18 rename tests/test-components/adapters/{0.2.0-rc-2023-12-05.reactor.wasm => 0.2.0.reactor.wasm} (58%) delete mode 100644 tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/command-extended.wit delete mode 100644 tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/imports.wit delete mode 100644 tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/test.wit rename tests/test-components/components/{integration-wasi-http-v0.2.0-rc-2023-12-05 => integration-wasi-http-v0.2.0}/Cargo.toml (77%) rename tests/test-components/components/{integration-wasi-http-v0.2.0-rc-2023-12-05 => integration-wasi-http-v0.2.0}/src/lib.rs (98%) rename tests/testcases/{wasi-http-0.2.0-rc-2023-12-05 => wasi-http-0.2.0}/spin.toml (66%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/cli/command.wit (58%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/cli/environment.wit (100%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/cli/exit.wit (100%) create mode 100644 wit-0.2.0/deps/cli/imports.wit rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/cli/run.wit (100%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/cli/stdio.wit (50%) rename {wit => wit-0.2.0}/deps/cli/terminal.wit (75%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/clocks/monotonic-clock.wit (93%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/clocks/wall-clock.wit (97%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/clocks/world.wit (63%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/filesystem/preopens.wit (80%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/filesystem/types.wit (99%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/filesystem/world.wit (56%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/http/handler.wit (100%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/http/proxy.wit (81%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/http/types.wit (98%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/io/error.wit (97%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/io/poll.wit (92%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/io/streams.wit (92%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/io/world.wit (60%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/random/insecure-seed.wit (96%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/random/insecure.wit (95%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/random/random.wit (96%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/random/world.wit (67%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/instance-network.wit (100%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/ip-name-lookup.wit (97%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/network.wit (86%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/tcp-create-socket.wit (90%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/tcp.wit (70%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/udp-create-socket.wit (93%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/udp.wit (92%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-0.2.0}/deps/sockets/world.wit (81%) rename {wit => wit-0.2.0}/deps/spin@unversioned/config.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/http-types.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/http.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/inbound-http.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/inbound-redis.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/key-value.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/llm.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/mysql.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/postgres.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/rdbms-types.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/redis-types.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/redis.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/sqlite.wit (100%) rename {wit => wit-0.2.0}/deps/spin@unversioned/world.wit (100%) rename {wit => wit-0.2.0}/key-value.wit (100%) rename {wit => wit-0.2.0}/llm.wit (100%) rename {wit => wit-0.2.0}/mysql.wit (100%) rename {wit => wit-0.2.0}/postgres.wit (100%) rename {wit => wit-0.2.0}/rdbms-types.wit (100%) rename {wit => wit-0.2.0}/redis.wit (100%) rename {wit => wit-0.2.0}/sqlite.wit (100%) rename {wit => wit-0.2.0}/variables.wit (100%) create mode 100644 wit-0.2.0/world.wit rename {wit => wit-2023-10-18}/deps/cli/command.wit (100%) rename {wit => wit-2023-10-18}/deps/cli/environment.wit (100%) rename {wit => wit-2023-10-18}/deps/cli/exit.wit (100%) rename {wit => wit-2023-10-18}/deps/cli/reactor.wit (100%) rename {wit => wit-2023-10-18}/deps/cli/run.wit (100%) rename {wit => wit-2023-10-18}/deps/cli/stdio.wit (100%) rename {tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit => wit-2023-10-18}/deps/cli/terminal.wit (100%) rename {wit => wit-2023-10-18}/deps/clocks/monotonic-clock.wit (100%) rename {wit => wit-2023-10-18}/deps/clocks/timezone.wit (100%) rename {wit => wit-2023-10-18}/deps/clocks/wall-clock.wit (100%) rename {wit => wit-2023-10-18}/deps/clocks/world.wit (100%) rename {wit => wit-2023-10-18}/deps/filesystem/preopens.wit (100%) rename {wit => wit-2023-10-18}/deps/filesystem/types.wit (100%) rename {wit => wit-2023-10-18}/deps/filesystem/world.wit (100%) rename {wit => wit-2023-10-18}/deps/http/incoming-handler.wit (100%) rename {wit => wit-2023-10-18}/deps/http/outgoing-handler.wit (100%) rename {wit => wit-2023-10-18}/deps/http/proxy.wit (100%) rename {wit => wit-2023-10-18}/deps/http/types.wit (100%) rename {wit => wit-2023-10-18}/deps/io/poll.wit (100%) rename {wit => wit-2023-10-18}/deps/io/streams.wit (100%) rename {wit => wit-2023-10-18}/deps/io/world.wit (100%) rename {wit => wit-2023-10-18}/deps/random/insecure-seed.wit (100%) rename {wit => wit-2023-10-18}/deps/random/insecure.wit (100%) rename {wit => wit-2023-10-18}/deps/random/random.wit (100%) rename {wit => wit-2023-10-18}/deps/random/world.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/instance-network.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/ip-name-lookup.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/network.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/tcp-create-socket.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/tcp.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/udp-create-socket.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/udp.wit (100%) rename {wit => wit-2023-10-18}/deps/sockets/world.wit (100%) create mode 100644 wit-2023-10-18/deps/spin@unversioned/config.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/http-types.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/http.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/inbound-http.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/inbound-redis.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/key-value.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/llm.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/mysql.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/postgres.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/rdbms-types.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/redis-types.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/redis.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/sqlite.wit create mode 100644 wit-2023-10-18/deps/spin@unversioned/world.wit create mode 100644 wit-2023-10-18/key-value.wit create mode 100644 wit-2023-10-18/llm.wit create mode 100644 wit-2023-10-18/mysql.wit create mode 100644 wit-2023-10-18/postgres.wit create mode 100644 wit-2023-10-18/rdbms-types.wit create mode 100644 wit-2023-10-18/redis.wit create mode 100644 wit-2023-10-18/sqlite.wit create mode 100644 wit-2023-10-18/variables.wit rename {wit => wit-2023-10-18}/world.wit (100%) diff --git a/Cargo.lock b/Cargo.lock index 625e14511..eb2f0cf99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1238,7 +1238,8 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d819feeda4c420a18f1e28236ca0ce1177b22bf7c8a44ddee92dfe40de15bcf0" dependencies = [ "cranelift-entity", ] @@ -1246,7 +1247,8 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9b8d03d5bdbca7e5f72b0e0a0f69933ed1f09e24be6c075aa6fe3f802b0cc0c" dependencies = [ "bumpalo", "cranelift-bforest", @@ -1266,7 +1268,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3fd3664e38e51649b17dc30cfdd561273fe2f590dcd013fb75d9eabc6272dfb" dependencies = [ "cranelift-codegen-shared", ] @@ -1274,12 +1277,14 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b031ec5e605828975952622b5a77d49126f20ffe88d33719a0af66b23a0fc36" [[package]] name = "cranelift-control" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fada054d017cf2ed8f7ed2336e0517fc1b19e6825be1790de9eb00c94788362b" dependencies = [ "arbitrary", ] @@ -1287,7 +1292,8 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177b6f94ae8de6348eb45bf977c79ab9e3c40fc3ac8cb7ed8109560ea39bee7d" dependencies = [ "serde", "serde_derive", @@ -1296,7 +1302,8 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebebd23a69a23e3ddea78e98ff3a2de222e88c8e045d81ef4a72f042e0d79dbd" dependencies = [ "cranelift-codegen", "log", @@ -1307,12 +1314,14 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1571bfc14df8966d12c6121b5325026591a4b4009e22fea0fe3765ab7cd33b96" [[package]] name = "cranelift-native" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35a69c37e0c10b46fe5527f2397ac821046efbf5f7ec112c8b84df25712f465b" dependencies = [ "cranelift-codegen", "libc", @@ -1322,7 +1331,8 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3fef8bbceb8cb56d3f1778b0418d75c5cf12ec571a35fc01eb41abb0227a25" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -7363,7 +7373,8 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db014d2ced91f17d1f1a8f2b76d6ea8d731bc1dbc8c2bbaec689d6a242568e5d" dependencies = [ "anyhow", "async-trait", @@ -7385,7 +7396,8 @@ dependencies = [ [[package]] name = "wasi-common" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449d17849e3c83a931374442fe2deee4d6bd1ebf469719ef44192e9e82e19c89" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -7404,7 +7416,8 @@ dependencies = [ [[package]] name = "wasi-tokio" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcb815cab6d4688a72de1c2fd4c4f32925b6f5200d268fedba6ce6958124b25" dependencies = [ "anyhow", "cap-std", @@ -7582,7 +7595,8 @@ dependencies = [ [[package]] name = "wasmtime" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "910fabce77e660f0e0e41cfd5f69fc8bf020a025f059718846e918db7177f469" dependencies = [ "anyhow", "async-trait", @@ -7620,7 +7634,8 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37288142e9b4a61655a3bcbdc7316c2e4bb9e776b10ce3dd758f8186b4469572" dependencies = [ "cfg-if", ] @@ -7628,7 +7643,8 @@ dependencies = [ [[package]] name = "wasmtime-cache" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45cbd74a636f09d2108f9405c79857f061e19323e4abeed22e837cfe7b08a22b" dependencies = [ "anyhow", "base64 0.21.5", @@ -7647,7 +7663,8 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad63de18eb42e586386b6091f787c82707cbd5ac5e9343216dba1976190cd03a" dependencies = [ "anyhow", "proc-macro2", @@ -7661,12 +7678,14 @@ dependencies = [ [[package]] name = "wasmtime-component-util" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e0a160c0c44369aa4bee6d311a8e4366943bab1651040cc8b0fcec2c9eb8906" [[package]] name = "wasmtime-cranelift" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3734cc01b7cd37bc62fdbcd9529ca9547440052d4b3886cfdec3b8081a5d3647" dependencies = [ "anyhow", "cfg-if", @@ -7690,7 +7709,8 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0eb33cd30c47844aa228d4d0030587e65c1108343f311fe9f7248b5bd9cb65c" dependencies = [ "anyhow", "cranelift-codegen", @@ -7705,7 +7725,8 @@ dependencies = [ [[package]] name = "wasmtime-environ" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a056b041fdea604f0972e2fae97958e7748d629a55180228348baefdfc217" dependencies = [ "anyhow", "cranelift-entity", @@ -7727,7 +7748,8 @@ dependencies = [ [[package]] name = "wasmtime-fiber" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43987d0977c07f15c3608c2f255870c127ffd19e35eeedb1ac1dccedf9932a42" dependencies = [ "anyhow", "cc", @@ -7741,7 +7763,8 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3e48395ac672b386ed588d97a9612aa13a345008f26466f0dfb2a91628aa9f" dependencies = [ "addr2line", "anyhow", @@ -7767,7 +7790,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd21fd0f5ca68681d3d5b636eea00f182d0f9d764144469e9257fd7e3f55ae0e" dependencies = [ "object", "once_cell", @@ -7778,7 +7802,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdc26415bb89e9ccd3bdc498fef63aabf665c4c0dd710c107691deb9694955da" dependencies = [ "cfg-if", "libc", @@ -7788,7 +7813,8 @@ dependencies = [ [[package]] name = "wasmtime-runtime" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0abddaf17912aabaf39be0802d5eba9a002e956e902d1ebd438a2fe1c88769a2" dependencies = [ "anyhow", "cc", @@ -7817,7 +7843,8 @@ dependencies = [ [[package]] name = "wasmtime-types" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35a95cdc1433729085beab42c0a5c742b431f25b17c40d7718e46df63d5ffc7" dependencies = [ "cranelift-entity", "serde", @@ -7829,7 +7856,8 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad322733fe67e45743784d8b1df452bcb54f581572a4f1a646a4332deecbcc2" dependencies = [ "proc-macro2", "quote", @@ -7839,7 +7867,8 @@ dependencies = [ [[package]] name = "wasmtime-wasi" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "902cc299b73655c36679b77efdfce4bb5971992f1a4a8a436dd3809a6848ff0e" dependencies = [ "anyhow", "async-trait", @@ -7874,7 +7903,8 @@ dependencies = [ [[package]] name = "wasmtime-wasi-http" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151fc711fad35034b8a6df00a5bcd5a7b1acb89ca12c2407f564a36ebd382e26" dependencies = [ "anyhow", "async-trait", @@ -7896,7 +7926,8 @@ dependencies = [ [[package]] name = "wasmtime-winch" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e63aeca929f84560eec52c5af43bf5d623b92683b0195d9fb06da8ed860e092" dependencies = [ "anyhow", "cranelift-codegen", @@ -7912,7 +7943,8 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41e5675998fdc74495afdd90ad2bd221206a258075b23048af0535a969b07893" dependencies = [ "anyhow", "heck 0.4.1", @@ -7923,7 +7955,8 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a19e10d8cb50b45412fb21192982b7ce85c0122dc33bb71f1813e25dc6e52" [[package]] name = "wast" @@ -8075,7 +8108,8 @@ dependencies = [ [[package]] name = "wiggle" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "737728db69a7657a5f6a7bac445c02d8564d603d62c46c95edf928554e67d072" dependencies = [ "anyhow", "async-trait", @@ -8089,7 +8123,8 @@ dependencies = [ [[package]] name = "wiggle-generate" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2460c7163b79ffefd9a564eaeab0a5b0e84bb91afdfeeb84d36f304ddbe08982" dependencies = [ "anyhow", "heck 0.4.1", @@ -8103,7 +8138,8 @@ dependencies = [ [[package]] name = "wiggle-macro" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8d8412375ba8325d61fbae56dead51dabfaec85d620ce36427922fb9cece83" dependencies = [ "proc-macro2", "quote", @@ -8145,7 +8181,8 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" version = "0.15.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d2b346bad5397b219b4ff0a8fa7230936061ff07c61f05d589d8d81e06fb7b2" dependencies = [ "anyhow", "cranelift-codegen", @@ -8551,7 +8588,8 @@ dependencies = [ [[package]] name = "witx" version = "0.9.1" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", diff --git a/Cargo.toml b/Cargo.toml index cb040645b..32c14c9ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,15 +130,12 @@ hyper = { version = "1.0.0", features = ["full"] } reqwest = { version = "0.11", features = ["stream", "blocking"] } tracing = { version = "0.1", features = ["log"] } -# TODO: update to final 17.0.0 release once it's available -wasi-common-preview1 = { git = "https://github.com/bytecodealliance/wasmtime", rev = "0b632023", package = "wasi-common" } -wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "0b632023", features = [ - "component-model", -] } -wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime", rev = "0b632023", features = [ +wasi-common-preview1 = { version = "17.0.0", package = "wasi-common" } +wasmtime = "17.0.0" +wasmtime-wasi = { version = "17.0.0", features = [ "tokio", ] } -wasmtime-wasi-http = { git = "https://github.com/bytecodealliance/wasmtime", rev = "0b632023" } +wasmtime-wasi-http = "17.0.0" spin-componentize = { git = "https://github.com/fermyon/spin-componentize", rev = "191789170abde10cd55590466c0660dd6c7d472a" } diff --git a/crates/core/src/wasi_2023_10_18.rs b/crates/core/src/wasi_2023_10_18.rs index 6382f2b82..2766fe536 100644 --- a/crates/core/src/wasi_2023_10_18.rs +++ b/crates/core/src/wasi_2023_10_18.rs @@ -15,7 +15,7 @@ mod latest { } wasmtime::component::bindgen!({ - path: "../../wit", + path: "../../wit-2023-10-18", interfaces: r#" include wasi:http/proxy@0.2.0-rc-2023-10-18; @@ -1093,21 +1093,17 @@ where fn ipv6_only( &mut self, - self_: Resource, + _self_: Resource, ) -> wasmtime::Result> { - convert_result(::ipv6_only( - self, self_, - )) + anyhow::bail!("ipv6-only API no longer supported") } fn set_ipv6_only( &mut self, - self_: Resource, - value: bool, + _self_: Resource, + _value: bool, ) -> wasmtime::Result> { - convert_result(::set_ipv6_only( - self, self_, value, - )) + anyhow::bail!("ipv6-only API no longer supported") } fn set_listen_backlog_size( @@ -1467,23 +1463,17 @@ where fn ipv6_only( &mut self, - self_: Resource, + _self_: Resource, ) -> wasmtime::Result> { - let socket = self.table().get(&self_)?.inner()?; - convert_result(::ipv6_only( - self, socket, - )) + anyhow::bail!("ipv6-only API no longer supported") } fn set_ipv6_only( &mut self, - self_: Resource, - value: bool, + _self_: Resource, + _value: bool, ) -> wasmtime::Result> { - let socket = self.table().get(&self_)?.inner()?; - convert_result(::set_ipv6_only( - self, socket, value, - )) + anyhow::bail!("ipv6-only API no longer supported") } fn unicast_hop_limit( @@ -2150,7 +2140,7 @@ where } } -fn convert_result( +pub fn convert_result( result: Result>, ) -> wasmtime::Result> where diff --git a/crates/core/src/wasi_2023_11_10.rs b/crates/core/src/wasi_2023_11_10.rs index 7b846925c..1e7687c1e 100644 --- a/crates/core/src/wasi_2023_11_10.rs +++ b/crates/core/src/wasi_2023_11_10.rs @@ -1,7 +1,8 @@ #![doc(hidden)] // internal implementation detail used in tests and spin-trigger -use super::wasi_2023_10_18::convert; +use super::wasi_2023_10_18::{convert, convert_result}; use anyhow::Result; +use async_trait::async_trait; use wasmtime::component::{Linker, Resource}; use wasmtime_wasi::preview2::WasiView; use wasmtime_wasi_http::WasiHttpView; @@ -19,29 +20,67 @@ wasmtime::component::bindgen!({ include wasi:http/proxy@0.2.0-rc-2023-11-10; // NB: this is handling the historical behavior where Spin supported - // more than "just" this snaphsot of the proxy world but additionally + // more than "just" this snapshot of the proxy world but additionally // other CLI-related interfaces. - import wasi:cli/environment@0.2.0-rc-2023-11-10; - import wasi:cli/exit@0.2.0-rc-2023-11-10; - import wasi:cli/stdin@0.2.0-rc-2023-11-10; - import wasi:cli/stdout@0.2.0-rc-2023-11-10; - import wasi:cli/stderr@0.2.0-rc-2023-11-10; - import wasi:cli/terminal-input@0.2.0-rc-2023-11-10; - import wasi:cli/terminal-output@0.2.0-rc-2023-11-10; - import wasi:cli/terminal-stdin@0.2.0-rc-2023-11-10; - import wasi:cli/terminal-stdout@0.2.0-rc-2023-11-10; - import wasi:cli/terminal-stderr@0.2.0-rc-2023-11-10; + include wasi:cli/reactor@0.2.0-rc-2023-11-10; "#, async: { - only_imports: [] + only_imports: [ + "[method]descriptor.advise", + "[method]descriptor.create-directory-at", + "[method]descriptor.get-flags", + "[method]descriptor.get-type", + "[method]descriptor.is-same-object", + "[method]descriptor.link-at", + "[method]descriptor.metadata-hash", + "[method]descriptor.metadata-hash-at", + "[method]descriptor.open-at", + "[method]descriptor.read", + "[method]descriptor.read-directory", + "[method]descriptor.readlink-at", + "[method]descriptor.remove-directory-at", + "[method]descriptor.rename-at", + "[method]descriptor.set-size", + "[method]descriptor.set-times", + "[method]descriptor.set-times-at", + "[method]descriptor.stat", + "[method]descriptor.stat-at", + "[method]descriptor.symlink-at", + "[method]descriptor.sync", + "[method]descriptor.sync-data", + "[method]descriptor.unlink-file-at", + "[method]descriptor.write", + "[method]input-stream.read", + "[method]input-stream.blocking-read", + "[method]input-stream.blocking-skip", + "[method]input-stream.skip", + "[method]output-stream.splice", + "[method]output-stream.blocking-splice", + "[method]output-stream.blocking-flush", + "[method]output-stream.blocking-write", + "[method]output-stream.blocking-write-and-flush", + "[method]output-stream.blocking-write-zeroes-and-flush", + "[method]directory-entry-stream.read-directory-entry", + "[method]pollable.block", + "[method]pollable.ready", + "poll", + ] }, with: { "wasi:io/poll/pollable": latest::io::poll::Pollable, "wasi:io/streams/input-stream": latest::io::streams::InputStream, "wasi:io/streams/output-stream": latest::io::streams::OutputStream, "wasi:io/error/error": latest::io::error::Error, + "wasi:filesystem/types/directory-entry-stream": latest::filesystem::types::DirectoryEntryStream, + "wasi:filesystem/types/descriptor": latest::filesystem::types::Descriptor, "wasi:cli/terminal-input/terminal-input": latest::cli::terminal_input::TerminalInput, "wasi:cli/terminal-output/terminal-output": latest::cli::terminal_output::TerminalOutput, + "wasi:sockets/tcp/tcp-socket": latest::sockets::tcp::TcpSocket, + "wasi:sockets/udp/udp-socket": latest::sockets::udp::UdpSocket, + "wasi:sockets/udp/outgoing-datagram-stream": latest::sockets::udp::OutgoingDatagramStream, + "wasi:sockets/udp/incoming-datagram-stream": latest::sockets::udp::IncomingDatagramStream, + "wasi:sockets/network/network": latest::sockets::network::Network, + "wasi:sockets/ip-name-lookup/resolve-address-stream": latest::sockets::ip_name_lookup::ResolveAddressStream, "wasi:http/types/incoming-response": latest::http::types::IncomingResponse, "wasi:http/types/incoming-request": latest::http::types::IncomingRequest, "wasi:http/types/incoming-body": latest::http::types::IncomingBody, @@ -58,7 +97,13 @@ wasmtime::component::bindgen!({ use wasi::cli::terminal_input::TerminalInput; use wasi::cli::terminal_output::TerminalOutput; +use wasi::clocks::monotonic_clock::{Duration, Instant}; use wasi::clocks::wall_clock::Datetime; +use wasi::filesystem::types::{ + Advice, Descriptor, DescriptorFlags, DescriptorStat, DescriptorType, DirectoryEntry, + DirectoryEntryStream, ErrorCode as FsErrorCode, Filesize, MetadataHashValue, NewTimestamp, + OpenFlags, PathFlags, +}; use wasi::http::types::{ DnsErrorPayload, ErrorCode as HttpErrorCode, FieldSizePayload, Fields, FutureIncomingResponse, FutureTrailers, HeaderError, Headers, IncomingBody, IncomingRequest, IncomingResponse, Method, @@ -66,13 +111,30 @@ use wasi::http::types::{ StatusCode, TlsAlertReceivedPayload, Trailers, }; use wasi::io::poll::Pollable; -use wasi::io::streams::{Error, InputStream, OutputStream}; +use wasi::io::streams::{Error as IoError, InputStream, OutputStream, StreamError}; +use wasi::sockets::ip_name_lookup::{IpAddress, ResolveAddressStream}; +use wasi::sockets::network::{Ipv4SocketAddress, Ipv6SocketAddress}; +use wasi::sockets::tcp::{ + ErrorCode as SocketErrorCode, IpAddressFamily, IpSocketAddress, Network, ShutdownType, + TcpSocket, +}; +use wasi::sockets::udp::{ + IncomingDatagram, IncomingDatagramStream, OutgoingDatagram, OutgoingDatagramStream, UdpSocket, +}; pub fn add_to_linker(linker: &mut Linker) -> Result<()> where T: WasiView + WasiHttpView, { // interfaces from the "command" world + wasi::clocks::monotonic_clock::add_to_linker(linker, |t| t)?; + wasi::clocks::wall_clock::add_to_linker(linker, |t| t)?; + wasi::filesystem::types::add_to_linker(linker, |t| t)?; + wasi::filesystem::preopens::add_to_linker(linker, |t| t)?; + wasi::io::error::add_to_linker(linker, |t| t)?; + wasi::io::poll::add_to_linker(linker, |t| t)?; + wasi::io::streams::add_to_linker(linker, |t| t)?; + wasi::random::random::add_to_linker(linker, |t| t)?; wasi::cli::exit::add_to_linker(linker, |t| t)?; wasi::cli::environment::add_to_linker(linker, |t| t)?; wasi::cli::stdin::add_to_linker(linker, |t| t)?; @@ -83,111 +145,1383 @@ where wasi::cli::terminal_stdin::add_to_linker(linker, |t| t)?; wasi::cli::terminal_stdout::add_to_linker(linker, |t| t)?; wasi::cli::terminal_stderr::add_to_linker(linker, |t| t)?; + wasi::sockets::tcp::add_to_linker(linker, |t| t)?; + wasi::sockets::tcp_create_socket::add_to_linker(linker, |t| t)?; + wasi::sockets::udp::add_to_linker(linker, |t| t)?; + wasi::sockets::udp_create_socket::add_to_linker(linker, |t| t)?; + wasi::sockets::instance_network::add_to_linker(linker, |t| t)?; + wasi::sockets::network::add_to_linker(linker, |t| t)?; + wasi::sockets::ip_name_lookup::add_to_linker(linker, |t| t)?; wasi::http::types::add_to_linker(linker, |t| t)?; wasi::http::outgoing_handler::add_to_linker(linker, |t| t)?; Ok(()) } -impl wasi::cli::exit::Host for T +impl wasi::clocks::monotonic_clock::Host for T +where + T: WasiView, +{ + fn now(&mut self) -> wasmtime::Result { + ::now(self) + } + + fn resolution(&mut self) -> wasmtime::Result { + ::resolution(self) + } + + fn subscribe_instant(&mut self, when: Instant) -> wasmtime::Result> { + ::subscribe_instant(self, when) + } + + fn subscribe_duration(&mut self, when: Duration) -> wasmtime::Result> { + ::subscribe_duration(self, when) + } +} + +impl wasi::clocks::wall_clock::Host for T +where + T: WasiView, +{ + fn now(&mut self) -> wasmtime::Result { + Ok(::now(self)?.into()) + } + + fn resolution(&mut self) -> wasmtime::Result { + Ok(::resolution(self)?.into()) + } +} + +impl wasi::filesystem::types::Host for T +where + T: WasiView, +{ + fn filesystem_error_code( + &mut self, + err: Resource, + ) -> wasmtime::Result> { + Ok( + ::filesystem_error_code(self, err)? + .map(|e| e.into()), + ) + } +} + +#[async_trait] +impl wasi::filesystem::types::HostDescriptor for T +where + T: WasiView, +{ + fn read_via_stream( + &mut self, + self_: Resource, + offset: Filesize, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::read_via_stream(self, self_, offset), + ) + } + + fn write_via_stream( + &mut self, + self_: Resource, + offset: Filesize, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::write_via_stream(self, self_, offset), + ) + } + + fn append_via_stream( + &mut self, + self_: Resource, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::append_via_stream(self, self_), + ) + } + + async fn advise( + &mut self, + self_: Resource, + offset: Filesize, + length: Filesize, + advice: Advice, + ) -> wasmtime::Result> { + convert_result( + ::advise( + self, + self_, + offset, + length, + advice.into(), + ) + .await, + ) + } + + async fn sync_data( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::sync_data(self, self_).await, + ) + } + + async fn get_flags( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::get_flags(self, self_).await, + ) + } + + async fn get_type( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::get_type(self, self_).await, + ) + } + + async fn set_size( + &mut self, + self_: Resource, + size: Filesize, + ) -> wasmtime::Result> { + convert_result( + ::set_size(self, self_, size).await, + ) + } + + async fn set_times( + &mut self, + self_: Resource, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> wasmtime::Result> { + convert_result( + ::set_times( + self, + self_, + data_access_timestamp.into(), + data_modification_timestamp.into(), + ) + .await, + ) + } + + async fn read( + &mut self, + self_: Resource, + length: Filesize, + offset: Filesize, + ) -> wasmtime::Result, bool), FsErrorCode>> { + convert_result( + ::read(self, self_, length, offset) + .await, + ) + } + + async fn write( + &mut self, + self_: Resource, + buffer: Vec, + offset: Filesize, + ) -> wasmtime::Result> { + convert_result( + ::write(self, self_, buffer, offset) + .await, + ) + } + + async fn read_directory( + &mut self, + self_: Resource, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::read_directory(self, self_).await, + ) + } + + async fn sync( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::sync(self, self_).await) + } + + async fn create_directory_at( + &mut self, + self_: Resource, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::create_directory_at( + self, self_, path, + ) + .await, + ) + } + + async fn stat( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::stat(self, self_).await) + } + + async fn stat_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::stat_at( + self, + self_, + path_flags.into(), + path, + ) + .await, + ) + } + + async fn set_times_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> wasmtime::Result> { + convert_result( + ::set_times_at( + self, + self_, + path_flags.into(), + path, + data_access_timestamp.into(), + data_modification_timestamp.into(), + ) + .await, + ) + } + + async fn link_at( + &mut self, + self_: Resource, + old_path_flags: PathFlags, + old_path: String, + new_descriptor: Resource, + new_path: String, + ) -> wasmtime::Result> { + convert_result( + ::link_at( + self, + self_, + old_path_flags.into(), + old_path, + new_descriptor, + new_path, + ) + .await, + ) + } + + async fn open_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + open_flags: OpenFlags, + flags: DescriptorFlags, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::open_at( + self, + self_, + path_flags.into(), + path, + open_flags.into(), + flags.into(), + ) + .await, + ) + } + + async fn readlink_at( + &mut self, + self_: Resource, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::readlink_at(self, self_, path).await, + ) + } + + async fn remove_directory_at( + &mut self, + self_: Resource, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::remove_directory_at( + self, self_, path, + ) + .await, + ) + } + + async fn rename_at( + &mut self, + self_: Resource, + old_path: String, + new_descriptor: Resource, + new_path: String, + ) -> wasmtime::Result> { + convert_result( + ::rename_at( + self, + self_, + old_path, + new_descriptor, + new_path, + ) + .await, + ) + } + + async fn symlink_at( + &mut self, + self_: Resource, + old_path: String, + new_path: String, + ) -> wasmtime::Result> { + convert_result( + ::symlink_at( + self, self_, old_path, new_path, + ) + .await, + ) + } + + async fn unlink_file_at( + &mut self, + self_: Resource, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::unlink_file_at(self, self_, path) + .await, + ) + } + + async fn is_same_object( + &mut self, + self_: Resource, + other: Resource, + ) -> wasmtime::Result { + ::is_same_object(self, self_, other).await + } + + async fn metadata_hash( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::metadata_hash(self, self_).await, + ) + } + + async fn metadata_hash_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + ) -> wasmtime::Result> { + convert_result( + ::metadata_hash_at( + self, + self_, + path_flags.into(), + path, + ) + .await, + ) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +#[async_trait] +impl wasi::filesystem::types::HostDirectoryEntryStream for T +where + T: WasiView, +{ + async fn read_directory_entry( + &mut self, + self_: Resource, + ) -> wasmtime::Result, FsErrorCode>> { + convert_result( + ::read_directory_entry( + self, self_, + ) + .await + .map(|e| e.map(DirectoryEntry::from)), + ) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +impl wasi::filesystem::preopens::Host for T +where + T: WasiView, +{ + fn get_directories(&mut self) -> wasmtime::Result, String)>> { + ::get_directories(self) + } +} + +#[async_trait] +impl wasi::io::poll::Host for T +where + T: WasiView, +{ + async fn poll(&mut self, list: Vec>) -> wasmtime::Result> { + ::poll(self, list).await + } +} + +#[async_trait] +impl wasi::io::poll::HostPollable for T +where + T: WasiView, +{ + async fn block(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::block(self, rep).await + } + + async fn ready(&mut self, rep: Resource) -> wasmtime::Result { + ::ready(self, rep).await + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +impl wasi::io::error::Host for T where T: WasiView {} + +impl wasi::io::error::HostError for T +where + T: WasiView, +{ + fn to_debug_string(&mut self, self_: Resource) -> wasmtime::Result { + ::to_debug_string(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +fn convert_stream_result( + view: &mut dyn WasiView, + result: Result, +) -> wasmtime::Result> +where + T2: From, +{ + match result { + Ok(e) => Ok(Ok(e.into())), + Err(wasmtime_wasi::preview2::StreamError::Closed) => Ok(Err(StreamError::Closed)), + Err(wasmtime_wasi::preview2::StreamError::LastOperationFailed(e)) => { + let e = view.table_mut().push(e)?; + Ok(Err(StreamError::LastOperationFailed(e))) + } + Err(wasmtime_wasi::preview2::StreamError::Trap(e)) => Err(e), + } +} + +impl wasi::io::streams::Host for T where T: WasiView {} + +#[async_trait] +impl wasi::io::streams::HostInputStream for T +where + T: WasiView, +{ + async fn read( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result, StreamError>> { + let result = ::read(self, self_, len).await; + convert_stream_result(self, result) + } + + async fn blocking_read( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result, StreamError>> { + let result = + ::blocking_read(self, self_, len).await; + convert_stream_result(self, result) + } + + async fn skip( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = ::skip(self, self_, len).await; + convert_stream_result(self, result) + } + + async fn blocking_skip( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = + ::blocking_skip(self, self_, len).await; + convert_stream_result(self, result) + } + + fn subscribe(&mut self, self_: Resource) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +#[async_trait] +impl wasi::io::streams::HostOutputStream for T +where + T: WasiView, +{ + fn check_write( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + let result = ::check_write(self, self_); + convert_stream_result(self, result) + } + + fn write( + &mut self, + self_: Resource, + contents: Vec, + ) -> wasmtime::Result> { + let result = ::write(self, self_, contents); + convert_stream_result(self, result) + } + + async fn blocking_write_and_flush( + &mut self, + self_: Resource, + contents: Vec, + ) -> wasmtime::Result> { + let result = ::blocking_write_and_flush( + self, self_, contents, + ) + .await; + convert_stream_result(self, result) + } + + fn flush( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + let result = ::flush(self, self_); + convert_stream_result(self, result) + } + + async fn blocking_flush( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + let result = + ::blocking_flush(self, self_).await; + convert_stream_result(self, result) + } + + fn subscribe(&mut self, self_: Resource) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn write_zeroes( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = ::write_zeroes(self, self_, len); + convert_stream_result(self, result) + } + + async fn blocking_write_zeroes_and_flush( + &mut self, + self_: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = ::blocking_write_zeroes_and_flush( + self, self_, len, + ) + .await; + convert_stream_result(self, result) + } + + async fn splice( + &mut self, + self_: Resource, + src: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = + ::splice(self, self_, src, len).await; + convert_stream_result(self, result) + } + + async fn blocking_splice( + &mut self, + self_: Resource, + src: Resource, + len: u64, + ) -> wasmtime::Result> { + let result = + ::blocking_splice(self, self_, src, len) + .await; + convert_stream_result(self, result) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +impl wasi::random::random::Host for T +where + T: WasiView, +{ + fn get_random_bytes(&mut self, len: u64) -> wasmtime::Result> { + ::get_random_bytes(self, len) + } + + fn get_random_u64(&mut self) -> wasmtime::Result { + ::get_random_u64(self) + } +} + +impl wasi::cli::exit::Host for T +where + T: WasiView, +{ + fn exit(&mut self, status: Result<(), ()>) -> wasmtime::Result<()> { + ::exit(self, status) + } +} + +impl wasi::cli::environment::Host for T +where + T: WasiView, +{ + fn get_environment(&mut self) -> wasmtime::Result> { + ::get_environment(self) + } + + fn get_arguments(&mut self) -> wasmtime::Result> { + ::get_arguments(self) + } + + fn initial_cwd(&mut self) -> wasmtime::Result> { + ::initial_cwd(self) + } +} + +impl wasi::cli::stdin::Host for T +where + T: WasiView, +{ + fn get_stdin(&mut self) -> wasmtime::Result> { + ::get_stdin(self) + } +} + +impl wasi::cli::stdout::Host for T +where + T: WasiView, +{ + fn get_stdout(&mut self) -> wasmtime::Result> { + ::get_stdout(self) + } +} + +impl wasi::cli::stderr::Host for T +where + T: WasiView, +{ + fn get_stderr(&mut self) -> wasmtime::Result> { + ::get_stderr(self) + } +} + +impl wasi::cli::terminal_stdin::Host for T +where + T: WasiView, +{ + fn get_terminal_stdin(&mut self) -> wasmtime::Result>> { + ::get_terminal_stdin(self) + } +} + +impl wasi::cli::terminal_stdout::Host for T +where + T: WasiView, +{ + fn get_terminal_stdout(&mut self) -> wasmtime::Result>> { + ::get_terminal_stdout(self) + } +} + +impl wasi::cli::terminal_stderr::Host for T +where + T: WasiView, +{ + fn get_terminal_stderr(&mut self) -> wasmtime::Result>> { + ::get_terminal_stderr(self) + } +} + +impl wasi::cli::terminal_input::Host for T where T: WasiView {} + +impl wasi::cli::terminal_input::HostTerminalInput for T +where + T: WasiView, +{ + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) + } +} + +impl wasi::cli::terminal_output::Host for T where T: WasiView {} + +impl wasi::cli::terminal_output::HostTerminalOutput for T where T: WasiView, { - fn exit(&mut self, status: Result<(), ()>) -> wasmtime::Result<()> { - ::exit(self, status) + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::environment::Host for T +impl wasi::sockets::tcp::Host for T where T: WasiView {} + +impl wasi::sockets::tcp::HostTcpSocket for T where T: WasiView, { - fn get_environment(&mut self) -> wasmtime::Result> { - ::get_environment(self) + fn start_bind( + &mut self, + self_: Resource, + network: Resource, + local_address: IpSocketAddress, + ) -> wasmtime::Result> { + convert_result(::start_bind( + self, + self_, + network, + local_address.into(), + )) } - fn get_arguments(&mut self) -> wasmtime::Result> { - ::get_arguments(self) + fn finish_bind( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::finish_bind( + self, self_, + )) } - fn initial_cwd(&mut self) -> wasmtime::Result> { - ::initial_cwd(self) + fn start_connect( + &mut self, + self_: Resource, + network: Resource, + remote_address: IpSocketAddress, + ) -> wasmtime::Result> { + convert_result(::start_connect( + self, + self_, + network, + remote_address.into(), + )) + } + + fn finish_connect( + &mut self, + self_: Resource, + ) -> wasmtime::Result, Resource), SocketErrorCode>> + { + convert_result(::finish_connect( + self, self_, + )) + } + + fn start_listen( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::start_listen( + self, self_, + )) + } + + fn finish_listen( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::finish_listen( + self, self_, + )) + } + + fn accept( + &mut self, + self_: Resource, + ) -> wasmtime::Result< + Result< + ( + Resource, + Resource, + Resource, + ), + SocketErrorCode, + >, + > { + convert_result(::accept( + self, self_, + )) + } + + fn local_address( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::local_address( + self, self_, + )) + } + + fn remote_address( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::remote_address( + self, self_, + )) + } + + fn address_family(&mut self, self_: Resource) -> wasmtime::Result { + ::address_family(self, self_).map(|e| e.into()) + } + + fn ipv6_only( + &mut self, + _self_: Resource, + ) -> wasmtime::Result> { + anyhow::bail!("ipv6-only API no longer supported") + } + + fn set_ipv6_only( + &mut self, + _self_: Resource, + _value: bool, + ) -> wasmtime::Result> { + anyhow::bail!("ipv6-only API no longer supported") + } + + fn set_listen_backlog_size( + &mut self, + self_: Resource, + value: u64, + ) -> wasmtime::Result> { + convert_result( + ::set_listen_backlog_size(self, self_, value), + ) + } + + fn is_listening(&mut self, self_: Resource) -> wasmtime::Result { + ::is_listening(self, self_) + } + + fn keep_alive_enabled( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::keep_alive_enabled(self, self_)) + } + + fn set_keep_alive_enabled( + &mut self, + self_: Resource, + value: bool, + ) -> wasmtime::Result> { + convert_result( + ::set_keep_alive_enabled(self, self_, value), + ) + } + + fn keep_alive_idle_time( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::keep_alive_idle_time(self, self_), + ) + } + + fn set_keep_alive_idle_time( + &mut self, + self_: Resource, + value: Duration, + ) -> wasmtime::Result> { + convert_result( + ::set_keep_alive_idle_time( + self, self_, value, + ), + ) + } + + fn keep_alive_interval( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::keep_alive_interval(self, self_)) + } + + fn set_keep_alive_interval( + &mut self, + self_: Resource, + value: Duration, + ) -> wasmtime::Result> { + convert_result( + ::set_keep_alive_interval(self, self_, value), + ) + } + + fn keep_alive_count( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::keep_alive_count(self, self_)) + } + + fn set_keep_alive_count( + &mut self, + self_: Resource, + value: u32, + ) -> wasmtime::Result> { + convert_result( + ::set_keep_alive_count(self, self_, value), + ) + } + + fn hop_limit( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::hop_limit( + self, self_, + )) + } + + fn set_hop_limit( + &mut self, + self_: Resource, + value: u8, + ) -> wasmtime::Result> { + convert_result(::set_hop_limit( + self, self_, value, + )) + } + + fn receive_buffer_size( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::receive_buffer_size(self, self_)) + } + + fn set_receive_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> wasmtime::Result> { + convert_result( + ::set_receive_buffer_size(self, self_, value), + ) + } + + fn send_buffer_size( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::send_buffer_size(self, self_)) + } + + fn set_send_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> wasmtime::Result> { + convert_result( + ::set_send_buffer_size(self, self_, value), + ) + } + + fn subscribe(&mut self, self_: Resource) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn shutdown( + &mut self, + self_: Resource, + shutdown_type: ShutdownType, + ) -> wasmtime::Result> { + convert_result(::shutdown( + self, + self_, + shutdown_type.into(), + )) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::stdin::Host for T +impl wasi::sockets::tcp_create_socket::Host for T where T: WasiView, { - fn get_stdin(&mut self) -> wasmtime::Result> { - ::get_stdin(self) + fn create_tcp_socket( + &mut self, + address_family: IpAddressFamily, + ) -> wasmtime::Result, SocketErrorCode>> { + convert_result( + ::create_tcp_socket( + self, + address_family.into(), + ), + ) } } -impl wasi::cli::stdout::Host for T +impl wasi::sockets::udp::Host for T where T: WasiView {} + +impl wasi::sockets::udp::HostUdpSocket for T where T: WasiView, { - fn get_stdout(&mut self) -> wasmtime::Result> { - ::get_stdout(self) + fn start_bind( + &mut self, + self_: Resource, + network: Resource, + local_address: IpSocketAddress, + ) -> wasmtime::Result> { + convert_result(::start_bind( + self, + self_, + network, + local_address.into(), + )) + } + + fn finish_bind( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::finish_bind( + self, self_, + )) + } + + fn local_address( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::local_address( + self, self_, + )) + } + + fn remote_address( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::remote_address( + self, self_, + )) + } + + fn address_family(&mut self, self_: Resource) -> wasmtime::Result { + ::address_family(self, self_).map(|e| e.into()) + } + + fn ipv6_only( + &mut self, + _self_: Resource, + ) -> wasmtime::Result> { + anyhow::bail!("ipv6-only API no longer supported") + } + + fn set_ipv6_only( + &mut self, + _self_: Resource, + _value: bool, + ) -> wasmtime::Result> { + anyhow::bail!("ipv6-only API no longer supported") + } + + fn unicast_hop_limit( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::unicast_hop_limit(self, self_)) + } + + fn set_unicast_hop_limit( + &mut self, + self_: Resource, + value: u8, + ) -> wasmtime::Result> { + convert_result( + ::set_unicast_hop_limit(self, self_, value), + ) + } + + fn receive_buffer_size( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::receive_buffer_size(self, self_)) + } + + fn set_receive_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> wasmtime::Result> { + convert_result( + ::set_receive_buffer_size(self, self_, value), + ) + } + + fn send_buffer_size( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result(::send_buffer_size(self, self_)) + } + + fn set_send_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> wasmtime::Result> { + convert_result( + ::set_send_buffer_size(self, self_, value), + ) + } + + fn stream( + &mut self, + self_: Resource, + remote_address: Option, + ) -> wasmtime::Result< + Result< + ( + Resource, + Resource, + ), + SocketErrorCode, + >, + > { + convert_result(::stream( + self, + self_, + remote_address.map(|a| a.into()), + )) + } + + fn subscribe(&mut self, self_: Resource) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::stderr::Host for T +impl wasi::sockets::udp::HostOutgoingDatagramStream for T where T: WasiView, { - fn get_stderr(&mut self) -> wasmtime::Result> { - ::get_stderr(self) + fn check_send( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + convert_result( + ::check_send(self, self_), + ) + } + + fn send( + &mut self, + self_: Resource, + datagrams: Vec, + ) -> wasmtime::Result> { + convert_result( + ::send( + self, + self_, + datagrams.into_iter().map(|d| d.into()).collect(), + ), + ) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::terminal_stdin::Host for T +impl wasi::sockets::udp::HostIncomingDatagramStream for T where T: WasiView, { - fn get_terminal_stdin(&mut self) -> wasmtime::Result>> { - ::get_terminal_stdin(self) + fn receive( + &mut self, + self_: Resource, + max_results: u64, + ) -> wasmtime::Result, SocketErrorCode>> { + convert_result( + ::receive( + self, + self_, + max_results, + ), + ) + .map(|r| r.map(|r: Vec<_>| r.into_iter().map(|d| d.into()).collect())) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::terminal_stdout::Host for T +impl wasi::sockets::udp_create_socket::Host for T where T: WasiView, { - fn get_terminal_stdout(&mut self) -> wasmtime::Result>> { - ::get_terminal_stdout(self) + fn create_udp_socket( + &mut self, + address_family: IpAddressFamily, + ) -> wasmtime::Result, SocketErrorCode>> { + convert_result( + ::create_udp_socket( + self, + address_family.into(), + ), + ) } } -impl wasi::cli::terminal_stderr::Host for T +impl wasi::sockets::instance_network::Host for T where T: WasiView, { - fn get_terminal_stderr(&mut self) -> wasmtime::Result>> { - ::get_terminal_stderr(self) + fn instance_network(&mut self) -> wasmtime::Result> { + ::instance_network(self) } } -impl wasi::cli::terminal_input::Host for T where T: WasiView {} +impl wasi::sockets::network::Host for T where T: WasiView {} -impl wasi::cli::terminal_input::HostTerminalInput for T +impl wasi::sockets::network::HostNetwork for T where T: WasiView, { - fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { - ::drop(self, rep) + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } -impl wasi::cli::terminal_output::Host for T where T: WasiView {} +impl wasi::sockets::ip_name_lookup::Host for T +where + T: WasiView, +{ + fn resolve_addresses( + &mut self, + network: Resource, + name: String, + ) -> wasmtime::Result, SocketErrorCode>> { + convert_result( + ::resolve_addresses(self, network, name), + ) + } +} -impl wasi::cli::terminal_output::HostTerminalOutput for T +impl wasi::sockets::ip_name_lookup::HostResolveAddressStream for T where T: WasiView, { - fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { - ::drop(self, rep) + fn resolve_next_address( + &mut self, + self_: Resource, + ) -> wasmtime::Result, SocketErrorCode>> { + convert_result( + ::resolve_next_address( + self, self_, + ) + .map(|e| e.map(|e| e.into())), + ) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> wasmtime::Result> { + ::subscribe(self, self_) + } + + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { + ::drop(self, rep) } } @@ -197,7 +1531,7 @@ where { fn http_error_code( &mut self, - error: Resource, + error: Resource, ) -> wasmtime::Result> { ::http_error_code(self, error).map(|e| e.map(|e| e.into())) } @@ -666,6 +2000,165 @@ convert! { nanoseconds, } + enum latest::filesystem::types::ErrorCode => FsErrorCode { + Access, + WouldBlock, + Already, + BadDescriptor, + Busy, + Deadlock, + Quota, + Exist, + FileTooLarge, + IllegalByteSequence, + InProgress, + Interrupted, + Invalid, + Io, + IsDirectory, + Loop, + TooManyLinks, + MessageSize, + NameTooLong, + NoDevice, + NoEntry, + NoLock, + InsufficientMemory, + InsufficientSpace, + NotDirectory, + NotEmpty, + NotRecoverable, + Unsupported, + NoTty, + NoSuchDevice, + Overflow, + NotPermitted, + Pipe, + ReadOnly, + InvalidSeek, + TextFileBusy, + CrossDevice, + } + + enum Advice => latest::filesystem::types::Advice { + Normal, + Sequential, + Random, + WillNeed, + DontNeed, + NoReuse, + } + + flags DescriptorFlags [<=>] latest::filesystem::types::DescriptorFlags { + READ, + WRITE, + FILE_INTEGRITY_SYNC, + DATA_INTEGRITY_SYNC, + REQUESTED_WRITE_SYNC, + MUTATE_DIRECTORY, + } + + enum DescriptorType [<=>] latest::filesystem::types::DescriptorType { + Unknown, + BlockDevice, + CharacterDevice, + Directory, + Fifo, + SymbolicLink, + RegularFile, + Socket, + } + + enum NewTimestamp => latest::filesystem::types::NewTimestamp { + NoChange, + Now, + Timestamp(e), + } + + flags PathFlags => latest::filesystem::types::PathFlags { + SYMLINK_FOLLOW, + } + + flags OpenFlags => latest::filesystem::types::OpenFlags { + CREATE, + DIRECTORY, + EXCLUSIVE, + TRUNCATE, + } + + struct latest::filesystem::types::MetadataHashValue => MetadataHashValue { + lower, + upper, + } + + struct latest::filesystem::types::DirectoryEntry => DirectoryEntry { + type_, + name, + } + + + enum latest::sockets::network::ErrorCode => SocketErrorCode { + Unknown, + AccessDenied, + NotSupported, + InvalidArgument, + OutOfMemory, + Timeout, + ConcurrencyConflict, + NotInProgress, + WouldBlock, + InvalidState, + NewSocketLimit, + AddressNotBindable, + AddressInUse, + RemoteUnreachable, + ConnectionRefused, + ConnectionReset, + ConnectionAborted, + DatagramTooLarge, + NameUnresolvable, + TemporaryResolverFailure, + PermanentResolverFailure, + } + + enum latest::sockets::network::IpAddress [<=>] IpAddress { + Ipv4(e), + Ipv6(e), + } + + enum latest::sockets::network::IpSocketAddress [<=>] IpSocketAddress { + Ipv4(e), + Ipv6(e), + } + + struct latest::sockets::network::Ipv4SocketAddress [<=>] Ipv4SocketAddress { + port, + address, + } + + struct latest::sockets::network::Ipv6SocketAddress [<=>] Ipv6SocketAddress { + port, + flow_info, + scope_id, + address, + } + + enum latest::sockets::network::IpAddressFamily [<=>] IpAddressFamily { + Ipv4, + Ipv6, + } + + enum ShutdownType => latest::sockets::tcp::ShutdownType { + Receive, + Send, + Both, + } + + struct latest::sockets::udp::IncomingDatagram => IncomingDatagram { + data, + remote_address, + } + enum latest::http::types::Method [<=>] Method { Get, Head, @@ -707,6 +2200,28 @@ convert! { } } +impl From for DescriptorStat { + fn from(e: latest::filesystem::types::DescriptorStat) -> DescriptorStat { + DescriptorStat { + type_: e.type_.into(), + link_count: e.link_count, + size: e.size, + data_access_timestamp: e.data_access_timestamp.map(|e| e.into()), + data_modification_timestamp: e.data_modification_timestamp.map(|e| e.into()), + status_change_timestamp: e.status_change_timestamp.map(|e| e.into()), + } + } +} + +impl From for latest::sockets::udp::OutgoingDatagram { + fn from(d: OutgoingDatagram) -> Self { + Self { + data: d.data, + remote_address: d.remote_address.map(|a| a.into()), + } + } +} + impl From for HttpErrorCode { fn from(e: latest::http::types::ErrorCode) -> Self { match e { diff --git a/crates/redis/tests/rust/src/lib.rs b/crates/redis/tests/rust/src/lib.rs index 8371614b9..f8c19e689 100644 --- a/crates/redis/tests/rust/src/lib.rs +++ b/crates/redis/tests/rust/src/lib.rs @@ -2,7 +2,7 @@ use std::str::{from_utf8, Utf8Error}; wit_bindgen::generate!({ world: "redis-trigger", - path: "../../../../wit/deps/spin@unversioned", + path: "../../../../wit-2023-10-18/deps/spin@unversioned", exports: { "fermyon:spin/inbound-redis": SpinRedis, } diff --git a/crates/trigger-http/benches/spin-http-benchmark/src/lib.rs b/crates/trigger-http/benches/spin-http-benchmark/src/lib.rs index 52e883529..de82215f8 100644 --- a/crates/trigger-http/benches/spin-http-benchmark/src/lib.rs +++ b/crates/trigger-http/benches/spin-http-benchmark/src/lib.rs @@ -1,6 +1,6 @@ wit_bindgen::generate!({ world: "http-trigger", - path: "../../../../wit/deps/spin@unversioned", + path: "../../../../wit-2023-10-18/deps/spin@unversioned", exports: { "fermyon:spin/inbound-http": SpinHttp, } diff --git a/crates/trigger-http/src/handler.rs b/crates/trigger-http/src/handler.rs index 08fc6ce98..621649ce8 100644 --- a/crates/trigger-http/src/handler.rs +++ b/crates/trigger-http/src/handler.rs @@ -56,7 +56,7 @@ impl HttpExecutor for HttpHandlerExecutor { } None => bail!( "Expected component to either export `{WASI_HTTP_EXPORT_2023_10_18}`, \ - `{WASI_HTTP_EXPORT_2023_11_10}`, `{WASI_HTTP_EXPORT_2023_12_05}`, \ + `{WASI_HTTP_EXPORT_2023_11_10}`, `{WASI_HTTP_EXPORT_0_2_0}`, \ or `fermyon:spin/inbound-http` but it exported none of those" ), }; @@ -327,14 +327,14 @@ enum HandlerType { const WASI_HTTP_EXPORT_2023_10_18: &str = "wasi:http/incoming-handler@0.2.0-rc-2023-10-18"; const WASI_HTTP_EXPORT_2023_11_10: &str = "wasi:http/incoming-handler@0.2.0-rc-2023-11-10"; -const WASI_HTTP_EXPORT_2023_12_05: &str = "wasi:http/incoming-handler@0.2.0-rc-2023-12-05"; +const WASI_HTTP_EXPORT_0_2_0: &str = "wasi:http/incoming-handler@0.2.0"; impl HandlerType { /// Determine the handler type from the exports fn from_exports(mut exports: wasmtime::component::Exports<'_>) -> Option { if exports.instance(WASI_HTTP_EXPORT_2023_10_18).is_some() || exports.instance(WASI_HTTP_EXPORT_2023_11_10).is_some() - || exports.instance(WASI_HTTP_EXPORT_2023_12_05).is_some() + || exports.instance(WASI_HTTP_EXPORT_0_2_0).is_some() { return Some(HandlerType::Wasi); } diff --git a/crates/trigger-http/tests/rust-http-test/src/lib.rs b/crates/trigger-http/tests/rust-http-test/src/lib.rs index 4c018371f..fe40c5e42 100644 --- a/crates/trigger-http/tests/rust-http-test/src/lib.rs +++ b/crates/trigger-http/tests/rust-http-test/src/lib.rs @@ -1,6 +1,6 @@ wit_bindgen::generate!({ world: "http-trigger", - path: "../../../../wit/deps/spin@unversioned", + path: "../../../../wit-2023-10-18/deps/spin@unversioned", exports: { "fermyon:spin/inbound-http": SpinHttp, } diff --git a/crates/trigger/src/lib.rs b/crates/trigger/src/lib.rs index 058a13294..13a40948f 100644 --- a/crates/trigger/src/lib.rs +++ b/crates/trigger/src/lib.rs @@ -111,7 +111,7 @@ impl TriggerExecutorBuilder { let mut builder = Engine::builder(&self.config)?; if !self.disable_default_host_components { - // Wasmtime 16 and 17: WASI@0.2.0-rc-2023-12-05 AKA WASI@0.2.0 + // Wasmtime 17: WASI@0.2.0 builder.link_import(|l, _| { wasmtime_wasi::preview2::command::add_to_linker(l)?; wasmtime_wasi_http::proxy::add_only_http_to_linker(l) diff --git a/crates/world/src/lib.rs b/crates/world/src/lib.rs index 36149a35b..fa18d764a 100644 --- a/crates/world/src/lib.rs +++ b/crates/world/src/lib.rs @@ -8,7 +8,7 @@ wasmtime::component::bindgen!({ include fermyon:spin/platform@2.0.0; } "#, - path: "../../wit", + path: "../../wit-2023-10-18", async: true }); diff --git a/examples/spin-timer/Cargo.lock b/examples/spin-timer/Cargo.lock index 0ba7943aa..d3b603a43 100644 --- a/examples/spin-timer/Cargo.lock +++ b/examples/spin-timer/Cargo.lock @@ -619,7 +619,8 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d819feeda4c420a18f1e28236ca0ce1177b22bf7c8a44ddee92dfe40de15bcf0" dependencies = [ "cranelift-entity", ] @@ -627,7 +628,8 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9b8d03d5bdbca7e5f72b0e0a0f69933ed1f09e24be6c075aa6fe3f802b0cc0c" dependencies = [ "bumpalo", "cranelift-bforest", @@ -647,7 +649,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3fd3664e38e51649b17dc30cfdd561273fe2f590dcd013fb75d9eabc6272dfb" dependencies = [ "cranelift-codegen-shared", ] @@ -655,12 +658,14 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b031ec5e605828975952622b5a77d49126f20ffe88d33719a0af66b23a0fc36" [[package]] name = "cranelift-control" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fada054d017cf2ed8f7ed2336e0517fc1b19e6825be1790de9eb00c94788362b" dependencies = [ "arbitrary", ] @@ -668,7 +673,8 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177b6f94ae8de6348eb45bf977c79ab9e3c40fc3ac8cb7ed8109560ea39bee7d" dependencies = [ "serde", "serde_derive", @@ -677,7 +683,8 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebebd23a69a23e3ddea78e98ff3a2de222e88c8e045d81ef4a72f042e0d79dbd" dependencies = [ "cranelift-codegen", "log", @@ -688,12 +695,14 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1571bfc14df8966d12c6121b5325026591a4b4009e22fea0fe3765ab7cd33b96" [[package]] name = "cranelift-native" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35a69c37e0c10b46fe5527f2397ac821046efbf5f7ec112c8b84df25712f465b" dependencies = [ "cranelift-codegen", "libc", @@ -703,7 +712,8 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.104.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3fef8bbceb8cb56d3f1778b0418d75c5cf12ec571a35fc01eb41abb0227a25" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -4654,7 +4664,8 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db014d2ced91f17d1f1a8f2b76d6ea8d731bc1dbc8c2bbaec689d6a242568e5d" dependencies = [ "anyhow", "async-trait", @@ -4676,7 +4687,8 @@ dependencies = [ [[package]] name = "wasi-common" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449d17849e3c83a931374442fe2deee4d6bd1ebf469719ef44192e9e82e19c89" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -4695,7 +4707,8 @@ dependencies = [ [[package]] name = "wasi-tokio" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcb815cab6d4688a72de1c2fd4c4f32925b6f5200d268fedba6ce6958124b25" dependencies = [ "anyhow", "cap-std", @@ -4874,7 +4887,8 @@ dependencies = [ [[package]] name = "wasmtime" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "910fabce77e660f0e0e41cfd5f69fc8bf020a025f059718846e918db7177f469" dependencies = [ "anyhow", "async-trait", @@ -4912,7 +4926,8 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37288142e9b4a61655a3bcbdc7316c2e4bb9e776b10ce3dd758f8186b4469572" dependencies = [ "cfg-if", ] @@ -4920,7 +4935,8 @@ dependencies = [ [[package]] name = "wasmtime-cache" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45cbd74a636f09d2108f9405c79857f061e19323e4abeed22e837cfe7b08a22b" dependencies = [ "anyhow", "base64 0.21.4", @@ -4939,7 +4955,8 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad63de18eb42e586386b6091f787c82707cbd5ac5e9343216dba1976190cd03a" dependencies = [ "anyhow", "proc-macro2", @@ -4953,12 +4970,14 @@ dependencies = [ [[package]] name = "wasmtime-component-util" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e0a160c0c44369aa4bee6d311a8e4366943bab1651040cc8b0fcec2c9eb8906" [[package]] name = "wasmtime-cranelift" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3734cc01b7cd37bc62fdbcd9529ca9547440052d4b3886cfdec3b8081a5d3647" dependencies = [ "anyhow", "cfg-if", @@ -4982,7 +5001,8 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0eb33cd30c47844aa228d4d0030587e65c1108343f311fe9f7248b5bd9cb65c" dependencies = [ "anyhow", "cranelift-codegen", @@ -4997,7 +5017,8 @@ dependencies = [ [[package]] name = "wasmtime-environ" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a056b041fdea604f0972e2fae97958e7748d629a55180228348baefdfc217" dependencies = [ "anyhow", "cranelift-entity", @@ -5019,7 +5040,8 @@ dependencies = [ [[package]] name = "wasmtime-fiber" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43987d0977c07f15c3608c2f255870c127ffd19e35eeedb1ac1dccedf9932a42" dependencies = [ "anyhow", "cc", @@ -5033,7 +5055,8 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3e48395ac672b386ed588d97a9612aa13a345008f26466f0dfb2a91628aa9f" dependencies = [ "addr2line 0.21.0", "anyhow", @@ -5059,7 +5082,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd21fd0f5ca68681d3d5b636eea00f182d0f9d764144469e9257fd7e3f55ae0e" dependencies = [ "object 0.32.1", "once_cell", @@ -5070,7 +5094,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdc26415bb89e9ccd3bdc498fef63aabf665c4c0dd710c107691deb9694955da" dependencies = [ "cfg-if", "libc", @@ -5080,7 +5105,8 @@ dependencies = [ [[package]] name = "wasmtime-runtime" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0abddaf17912aabaf39be0802d5eba9a002e956e902d1ebd438a2fe1c88769a2" dependencies = [ "anyhow", "cc", @@ -5109,7 +5135,8 @@ dependencies = [ [[package]] name = "wasmtime-types" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35a95cdc1433729085beab42c0a5c742b431f25b17c40d7718e46df63d5ffc7" dependencies = [ "cranelift-entity", "serde", @@ -5121,7 +5148,8 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad322733fe67e45743784d8b1df452bcb54f581572a4f1a646a4332deecbcc2" dependencies = [ "proc-macro2", "quote", @@ -5131,7 +5159,8 @@ dependencies = [ [[package]] name = "wasmtime-wasi" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "902cc299b73655c36679b77efdfce4bb5971992f1a4a8a436dd3809a6848ff0e" dependencies = [ "anyhow", "async-trait", @@ -5166,7 +5195,8 @@ dependencies = [ [[package]] name = "wasmtime-wasi-http" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151fc711fad35034b8a6df00a5bcd5a7b1acb89ca12c2407f564a36ebd382e26" dependencies = [ "anyhow", "async-trait", @@ -5188,7 +5218,8 @@ dependencies = [ [[package]] name = "wasmtime-winch" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e63aeca929f84560eec52c5af43bf5d623b92683b0195d9fb06da8ed860e092" dependencies = [ "anyhow", "cranelift-codegen", @@ -5204,7 +5235,8 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41e5675998fdc74495afdd90ad2bd221206a258075b23048af0535a969b07893" dependencies = [ "anyhow", "heck", @@ -5215,7 +5247,8 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a19e10d8cb50b45412fb21192982b7ce85c0122dc33bb71f1813e25dc6e52" [[package]] name = "wast" @@ -5285,7 +5318,8 @@ dependencies = [ [[package]] name = "wiggle" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "737728db69a7657a5f6a7bac445c02d8564d603d62c46c95edf928554e67d072" dependencies = [ "anyhow", "async-trait", @@ -5299,7 +5333,8 @@ dependencies = [ [[package]] name = "wiggle-generate" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2460c7163b79ffefd9a564eaeab0a5b0e84bb91afdfeeb84d36f304ddbe08982" dependencies = [ "anyhow", "heck", @@ -5313,7 +5348,8 @@ dependencies = [ [[package]] name = "wiggle-macro" version = "17.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8d8412375ba8325d61fbae56dead51dabfaec85d620ce36427922fb9cece83" dependencies = [ "proc-macro2", "quote", @@ -5355,7 +5391,8 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" version = "0.15.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d2b346bad5397b219b4ff0a8fa7230936061ff07c61f05d589d8d81e06fb7b2" dependencies = [ "anyhow", "cranelift-codegen", @@ -5665,7 +5702,8 @@ dependencies = [ [[package]] name = "witx" version = "0.9.1" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=0b632023#0b632023308d55275d595dfc3dc507620284fb16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", diff --git a/examples/spin-timer/Cargo.toml b/examples/spin-timer/Cargo.toml index 22be83147..91ca4c85b 100644 --- a/examples/spin-timer/Cargo.toml +++ b/examples/spin-timer/Cargo.toml @@ -14,6 +14,6 @@ spin-core = { path = "../../crates/core" } spin-trigger = { path = "../../crates/trigger" } tokio = { version = "1.11", features = ["full"] } tokio-scoped = "0.2.0" -wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "0b632023", features = ["component-model"] } +wasmtime = "17.0.0" [workspace] diff --git a/sdk/rust/src/lib.rs b/sdk/rust/src/lib.rs index d5c139139..f506cbb7c 100644 --- a/sdk/rust/src/lib.rs +++ b/sdk/rust/src/lib.rs @@ -23,7 +23,7 @@ pub mod wit { wit_bindgen::generate!({ world: "platform", - path: "./wit", + path: "./wit-2023-10-18", }); pub use fermyon::spin2_0_0 as v2; } diff --git a/sdk/rust/wit b/sdk/rust/wit deleted file mode 120000 index 902b54888..000000000 --- a/sdk/rust/wit +++ /dev/null @@ -1 +0,0 @@ -../../wit \ No newline at end of file diff --git a/sdk/rust/wit-2023-10-18 b/sdk/rust/wit-2023-10-18 new file mode 120000 index 000000000..36eef8dac --- /dev/null +++ b/sdk/rust/wit-2023-10-18 @@ -0,0 +1 @@ +../../wit-2023-10-18 \ No newline at end of file diff --git a/tests/spinup_tests.rs b/tests/spinup_tests.rs index 0ed02dd04..18c5000ab 100644 --- a/tests/spinup_tests.rs +++ b/tests/spinup_tests.rs @@ -589,8 +589,8 @@ Caused by: } #[test] - fn test_wasi_http_rc_12_05() -> anyhow::Result<()> { - test_wasi_http_rc("wasi-http-0.2.0-rc-2023-12-05") + fn test_wasi_http_0_2_0() -> anyhow::Result<()> { + test_wasi_http_rc("wasi-http-0.2.0") } fn test_wasi_http_rc(test_name: &str) -> anyhow::Result<()> { diff --git a/tests/test-components/adapters/0.2.0-rc-2023-12-05.reactor.wasm b/tests/test-components/adapters/0.2.0.reactor.wasm similarity index 58% rename from tests/test-components/adapters/0.2.0-rc-2023-12-05.reactor.wasm rename to tests/test-components/adapters/0.2.0.reactor.wasm index 7147590eefc2d362f002df06fb510f0d751c626f..ff8e501e49ddbfee86f92142c5a6191d5ee10e47 100644 GIT binary patch delta 10148 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 delta 11121 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 Some(v), + "0.2.0-rc-2023-11-10" | "0.2.0" => Some(v), _ => None, }); diff --git a/tests/test-components/components/Cargo.lock b/tests/test-components/components/Cargo.lock index 0cbf97cbe..8e91d430a 100644 --- a/tests/test-components/components/Cargo.lock +++ b/tests/test-components/components/Cargo.lock @@ -201,6 +201,7 @@ dependencies = [ name = "helper" version = "0.1.0" dependencies = [ + "anyhow", "wit-bindgen 0.16.0", ] @@ -662,7 +663,7 @@ dependencies = [ ] [[package]] -name = "wasi-http-rust-rc-2023-11-10" +name = "wasi-http-rust-0-2-0" version = "0.1.0" dependencies = [ "url", @@ -670,7 +671,7 @@ dependencies = [ ] [[package]] -name = "wasi-http-rust-rc-2023-12-05" +name = "wasi-http-rust-rc-2023-11-10" version = "0.1.0" dependencies = [ "url", diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/command-extended.wit b/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/command-extended.wit deleted file mode 100644 index 16f01bc23..000000000 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/command-extended.wit +++ /dev/null @@ -1,6 +0,0 @@ -// All of the same imports and exports available in the wasi:cli/command world -// with addition of HTTP proxy related imports: -world command-extended { - include wasi:cli/command@0.2.0-rc-2023-12-05; - import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05; -} diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/imports.wit b/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/imports.wit deleted file mode 100644 index 9965ea35e..000000000 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/imports.wit +++ /dev/null @@ -1,20 +0,0 @@ -package wasi:cli@0.2.0-rc-2023-12-05; - -world imports { - include wasi:clocks/imports@0.2.0-rc-2023-11-10; - include wasi:filesystem/imports@0.2.0-rc-2023-11-10; - include wasi:sockets/imports@0.2.0-rc-2023-11-10; - include wasi:random/imports@0.2.0-rc-2023-11-10; - include wasi:io/imports@0.2.0-rc-2023-11-10; - - import environment; - import exit; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; -} diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/test.wit b/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/test.wit deleted file mode 100644 index f3cc6151b..000000000 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/test.wit +++ /dev/null @@ -1,22 +0,0 @@ -package wasmtime:wasi; - -// only used as part of `test-programs` -world test-reactor { - include wasi:cli/imports@0.2.0-rc-2023-12-05; - - export add-strings: func(s: list) -> u32; - export get-strings: func() -> list; - - use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream}; - - export write-strings-to: func(o: output-stream) -> result; - - use wasi:filesystem/types@0.2.0-rc-2023-11-10.{descriptor-stat}; - export pass-an-imported-record: func(d: descriptor-stat) -> string; -} - -world test-command { - include wasi:cli/imports@0.2.0-rc-2023-12-05; - import wasi:http/types@0.2.0-rc-2023-12-05; - import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05; -} diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/Cargo.toml b/tests/test-components/components/integration-wasi-http-v0.2.0/Cargo.toml similarity index 77% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/Cargo.toml rename to tests/test-components/components/integration-wasi-http-v0.2.0/Cargo.toml index 41b4f20a3..66c6dcefd 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/Cargo.toml +++ b/tests/test-components/components/integration-wasi-http-v0.2.0/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasi-http-rust-rc-2023-12-05" +name = "wasi-http-rust-0-2-0" version = "0.1.0" edition = "2021" diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/src/lib.rs b/tests/test-components/components/integration-wasi-http-v0.2.0/src/lib.rs similarity index 98% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/src/lib.rs rename to tests/test-components/components/integration-wasi-http-v0.2.0/src/lib.rs index 847b62f50..957d53dd4 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/src/lib.rs +++ b/tests/test-components/components/integration-wasi-http-v0.2.0/src/lib.rs @@ -1,6 +1,6 @@ wit_bindgen::generate!({ - path: "wit", - world: "wasi:http/proxy@0.2.0-rc-2023-12-05", + path: "../../../../wit-0.2.0", + world: "wasi:http/proxy@0.2.0", exports: { "wasi:http/incoming-handler": Component } diff --git a/tests/test-components/helper/Cargo.toml b/tests/test-components/helper/Cargo.toml index a78965888..b6e20eca5 100644 --- a/tests/test-components/helper/Cargo.toml +++ b/tests/test-components/helper/Cargo.toml @@ -5,3 +5,4 @@ edition = "2021" [dependencies] wit-bindgen = "0.16.0" +anyhow = "1.0" diff --git a/tests/test-components/helper/src/lib.rs b/tests/test-components/helper/src/lib.rs index fa07e4422..0ba8bbe5c 100644 --- a/tests/test-components/helper/src/lib.rs +++ b/tests/test-components/helper/src/lib.rs @@ -1,7 +1,7 @@ pub mod bindings { wit_bindgen::generate!({ world: "platform", - path: "../../../wit", + path: "../../../wit-2023-10-18", runtime_path: "::wit_bindgen::rt" }); } @@ -20,7 +20,7 @@ macro_rules! define_component { mod bindings { $crate::wit_bindgen::generate!({ world: "http-trigger", - path: "../../../../wit", + path: "../../../../wit-2023-10-18", exports: { "wasi:http/incoming-handler": super::Component }, diff --git a/tests/testcases/wasi-http-0.2.0-rc-2023-12-05/spin.toml b/tests/testcases/wasi-http-0.2.0/spin.toml similarity index 66% rename from tests/testcases/wasi-http-0.2.0-rc-2023-12-05/spin.toml rename to tests/testcases/wasi-http-0.2.0/spin.toml index f12241e26..1b96ebbee 100644 --- a/tests/testcases/wasi-http-0.2.0-rc-2023-12-05/spin.toml +++ b/tests/testcases/wasi-http-0.2.0/spin.toml @@ -2,7 +2,7 @@ spin_manifest_version = 2 [application] authors = ["Fermyon Engineering "] -description = "Test using wasi:http/incoming-handler@0.2.0-rc-2023-12-05." +description = "Test using wasi:http/incoming-handler@0.2.0." name = "wasi-http" version = "1.0.0" @@ -11,5 +11,5 @@ route = "/..." component = "wasi-http" [component.wasi-http] -source = "%{source=integration-wasi-http-v0.2.0-rc-2023-12-05}" +source = "%{source=integration-wasi-http-v0.2.0}" allowed_outbound_hosts = ["http://*:*", "https://*:*"] diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/command.wit b/wit-0.2.0/deps/cli/command.wit similarity index 58% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/command.wit rename to wit-0.2.0/deps/cli/command.wit index cc82ae5dc..d8005bd38 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/command.wit +++ b/wit-0.2.0/deps/cli/command.wit @@ -1,4 +1,4 @@ -package wasi:cli@0.2.0-rc-2023-12-05; +package wasi:cli@0.2.0; world command { include imports; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/environment.wit b/wit-0.2.0/deps/cli/environment.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/environment.wit rename to wit-0.2.0/deps/cli/environment.wit diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/exit.wit b/wit-0.2.0/deps/cli/exit.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/exit.wit rename to wit-0.2.0/deps/cli/exit.wit diff --git a/wit-0.2.0/deps/cli/imports.wit b/wit-0.2.0/deps/cli/imports.wit new file mode 100644 index 000000000..083b84a03 --- /dev/null +++ b/wit-0.2.0/deps/cli/imports.wit @@ -0,0 +1,20 @@ +package wasi:cli@0.2.0; + +world imports { + include wasi:clocks/imports@0.2.0; + include wasi:filesystem/imports@0.2.0; + include wasi:sockets/imports@0.2.0; + include wasi:random/imports@0.2.0; + include wasi:io/imports@0.2.0; + + import environment; + import exit; + import stdin; + import stdout; + import stderr; + import terminal-input; + import terminal-output; + import terminal-stdin; + import terminal-stdout; + import terminal-stderr; +} diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/run.wit b/wit-0.2.0/deps/cli/run.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/run.wit rename to wit-0.2.0/deps/cli/run.wit diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/stdio.wit b/wit-0.2.0/deps/cli/stdio.wit similarity index 50% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/stdio.wit rename to wit-0.2.0/deps/cli/stdio.wit index 1b653b6e2..31ef35b5a 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/stdio.wit +++ b/wit-0.2.0/deps/cli/stdio.wit @@ -1,17 +1,17 @@ interface stdin { - use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream}; + use wasi:io/streams@0.2.0.{input-stream}; get-stdin: func() -> input-stream; } interface stdout { - use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream}; + use wasi:io/streams@0.2.0.{output-stream}; get-stdout: func() -> output-stream; } interface stderr { - use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream}; + use wasi:io/streams@0.2.0.{output-stream}; get-stderr: func() -> output-stream; } diff --git a/wit/deps/cli/terminal.wit b/wit-0.2.0/deps/cli/terminal.wit similarity index 75% rename from wit/deps/cli/terminal.wit rename to wit-0.2.0/deps/cli/terminal.wit index 47495769b..38c724efc 100644 --- a/wit/deps/cli/terminal.wit +++ b/wit-0.2.0/deps/cli/terminal.wit @@ -1,19 +1,21 @@ +/// Terminal input. +/// +/// In the future, this may include functions for disabling echoing, +/// disabling input buffering so that keyboard events are sent through +/// immediately, querying supported features, and so on. interface terminal-input { /// The input side of a terminal. resource terminal-input; - - // In the future, this may include functions for disabling echoing, - // disabling input buffering so that keyboard events are sent through - // immediately, querying supported features, and so on. } +/// Terminal output. +/// +/// In the future, this may include functions for querying the terminal +/// size, being notified of terminal size changes, querying supported +/// features, and so on. interface terminal-output { /// The output side of a terminal. resource terminal-output; - - // In the future, this may include functions for querying the terminal - // size, being notified of terminal size changes, querying supported - // features, and so on. } /// An interface providing an optional `terminal-input` for stdin as a diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/monotonic-clock.wit b/wit-0.2.0/deps/clocks/monotonic-clock.wit similarity index 93% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/monotonic-clock.wit rename to wit-0.2.0/deps/clocks/monotonic-clock.wit index 09ef32c36..4e4dc3a19 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/monotonic-clock.wit +++ b/wit-0.2.0/deps/clocks/monotonic-clock.wit @@ -1,4 +1,4 @@ -package wasi:clocks@0.2.0-rc-2023-11-10; +package wasi:clocks@0.2.0; /// WASI Monotonic Clock is a clock API intended to let users measure elapsed /// time. /// @@ -10,7 +10,7 @@ package wasi:clocks@0.2.0-rc-2023-11-10; /// /// It is intended for measuring elapsed time. interface monotonic-clock { - use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable}; + use wasi:io/poll@0.2.0.{pollable}; /// An instant in time, in nanoseconds. An instant is relative to an /// unspecified initial value, and can only be compared to instances from diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/wall-clock.wit b/wit-0.2.0/deps/clocks/wall-clock.wit similarity index 97% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/wall-clock.wit rename to wit-0.2.0/deps/clocks/wall-clock.wit index 8abb9a0c0..440ca0f33 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/wall-clock.wit +++ b/wit-0.2.0/deps/clocks/wall-clock.wit @@ -1,4 +1,4 @@ -package wasi:clocks@0.2.0-rc-2023-11-10; +package wasi:clocks@0.2.0; /// WASI Wall Clock is a clock API intended to let users query the current /// time. The name "wall" makes an analogy to a "clock on the wall", which /// is not necessarily monotonic as it may be reset. diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/world.wit b/wit-0.2.0/deps/clocks/world.wit similarity index 63% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/world.wit rename to wit-0.2.0/deps/clocks/world.wit index 8fa080f0e..c0224572a 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/clocks/world.wit +++ b/wit-0.2.0/deps/clocks/world.wit @@ -1,4 +1,4 @@ -package wasi:clocks@0.2.0-rc-2023-11-10; +package wasi:clocks@0.2.0; world imports { import monotonic-clock; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/preopens.wit b/wit-0.2.0/deps/filesystem/preopens.wit similarity index 80% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/preopens.wit rename to wit-0.2.0/deps/filesystem/preopens.wit index 95ec67843..da801f6d6 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/preopens.wit +++ b/wit-0.2.0/deps/filesystem/preopens.wit @@ -1,4 +1,4 @@ -package wasi:filesystem@0.2.0-rc-2023-11-10; +package wasi:filesystem@0.2.0; interface preopens { use types.{descriptor}; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/types.wit b/wit-0.2.0/deps/filesystem/types.wit similarity index 99% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/types.wit rename to wit-0.2.0/deps/filesystem/types.wit index 059722ab8..11108fcda 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/types.wit +++ b/wit-0.2.0/deps/filesystem/types.wit @@ -1,4 +1,4 @@ -package wasi:filesystem@0.2.0-rc-2023-11-10; +package wasi:filesystem@0.2.0; /// WASI filesystem is a filesystem API primarily intended to let users run WASI /// programs that access their files on their existing filesystems, without /// significant overhead. @@ -24,8 +24,8 @@ package wasi:filesystem@0.2.0-rc-2023-11-10; /// /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md interface types { - use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream, error}; - use wasi:clocks/wall-clock@0.2.0-rc-2023-11-10.{datetime}; + use wasi:io/streams@0.2.0.{input-stream, output-stream, error}; + use wasi:clocks/wall-clock@0.2.0.{datetime}; /// File size or length of a region within a file. type filesize = u64; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/world.wit b/wit-0.2.0/deps/filesystem/world.wit similarity index 56% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/world.wit rename to wit-0.2.0/deps/filesystem/world.wit index 285e0bae9..663f57920 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/filesystem/world.wit +++ b/wit-0.2.0/deps/filesystem/world.wit @@ -1,4 +1,4 @@ -package wasi:filesystem@0.2.0-rc-2023-11-10; +package wasi:filesystem@0.2.0; world imports { import types; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/handler.wit b/wit-0.2.0/deps/http/handler.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/handler.wit rename to wit-0.2.0/deps/http/handler.wit diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/proxy.wit b/wit-0.2.0/deps/http/proxy.wit similarity index 81% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/proxy.wit rename to wit-0.2.0/deps/http/proxy.wit index 0f466c93c..687c24d23 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/proxy.wit +++ b/wit-0.2.0/deps/http/proxy.wit @@ -1,4 +1,4 @@ -package wasi:http@0.2.0-rc-2023-12-05; +package wasi:http@0.2.0; /// The `wasi:http/proxy` world captures a widely-implementable intersection of /// hosts that includes HTTP forward and reverse proxies. Components targeting @@ -6,19 +6,19 @@ package wasi:http@0.2.0-rc-2023-12-05; /// outgoing HTTP requests. world proxy { /// HTTP proxies have access to time and randomness. - include wasi:clocks/imports@0.2.0-rc-2023-11-10; - import wasi:random/random@0.2.0-rc-2023-11-10; + include wasi:clocks/imports@0.2.0; + import wasi:random/random@0.2.0; /// Proxies have standard output and error streams which are expected to /// terminate in a developer-facing console provided by the host. - import wasi:cli/stdout@0.2.0-rc-2023-12-05; - import wasi:cli/stderr@0.2.0-rc-2023-12-05; + import wasi:cli/stdout@0.2.0; + import wasi:cli/stderr@0.2.0; /// TODO: this is a temporary workaround until component tooling is able to /// gracefully handle the absence of stdin. Hosts must return an eof stream /// for this import, which is what wasi-libc + tooling will do automatically /// when this import is properly removed. - import wasi:cli/stdin@0.2.0-rc-2023-12-05; + import wasi:cli/stdin@0.2.0; /// This is the default handler to use when user code simply wants to make an /// HTTP request (e.g., via `fetch()`). diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/types.wit b/wit-0.2.0/deps/http/types.wit similarity index 98% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/types.wit rename to wit-0.2.0/deps/http/types.wit index 0f698e769..755ac6a6b 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/http/types.wit +++ b/wit-0.2.0/deps/http/types.wit @@ -2,10 +2,10 @@ /// HTTP Requests and Responses, both incoming and outgoing, as well as /// their headers, trailers, and bodies. interface types { - use wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10.{duration}; - use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream}; - use wasi:io/error@0.2.0-rc-2023-11-10.{error as io-error}; - use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; + use wasi:io/streams@0.2.0.{input-stream, output-stream}; + use wasi:io/error@0.2.0.{error as io-error}; + use wasi:io/poll@0.2.0.{pollable}; /// This type corresponds to HTTP standard Methods. variant method { diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/error.wit b/wit-0.2.0/deps/io/error.wit similarity index 97% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/error.wit rename to wit-0.2.0/deps/io/error.wit index 31918acbb..22e5b6489 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/error.wit +++ b/wit-0.2.0/deps/io/error.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; interface error { diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/poll.wit b/wit-0.2.0/deps/io/poll.wit similarity index 92% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/poll.wit rename to wit-0.2.0/deps/io/poll.wit index bddde3c19..ddc67f8b7 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/poll.wit +++ b/wit-0.2.0/deps/io/poll.wit @@ -1,9 +1,9 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; /// A poll API intended to let users wait for I/O events on multiple handles /// at once. interface poll { - /// `pollable` epresents a single I/O event which may be ready, or not. + /// `pollable` represents a single I/O event which may be ready, or not. resource pollable { /// Return the readiness of a pollable. This function never blocks. diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/streams.wit b/wit-0.2.0/deps/io/streams.wit similarity index 92% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/streams.wit rename to wit-0.2.0/deps/io/streams.wit index e7e1b689a..6d2f871e3 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/streams.wit +++ b/wit-0.2.0/deps/io/streams.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; /// WASI I/O is an I/O abstraction API which is currently focused on providing /// stream types. @@ -32,6 +32,11 @@ interface streams { resource input-stream { /// Perform a non-blocking read from the stream. /// + /// When the source of a `read` is binary data, the bytes from the source + /// are returned verbatim. When the source of a `read` is known to the + /// implementation to be text, bytes containing the UTF-8 encoding of the + /// text are returned. + /// /// This function returns a list of bytes containing the read data, /// when successful. The returned list will contain up to `len` bytes; /// it may return fewer than requested, but not more. The list is @@ -111,6 +116,12 @@ interface streams { /// Perform a write. This function never blocks. /// + /// When the destination of a `write` is binary data, the bytes from + /// `contents` are written verbatim. When the destination of a `write` is + /// known to the implementation to be text, the bytes of `contents` are + /// transcoded from UTF-8 into the encoding of the destination and then + /// written. + /// /// Precondition: check-write gave permit of Ok(n) and contents has a /// length of less than or equal to n. Otherwise, this function will trap. /// @@ -131,7 +142,7 @@ interface streams { /// let pollable = this.subscribe(); /// while !contents.is_empty() { /// // Wait for the stream to become writable - /// poll-one(pollable); + /// pollable.block(); /// let Ok(n) = this.check-write(); // eliding error handling /// let len = min(n, contents.len()); /// let (chunk, rest) = contents.split_at(len); @@ -140,7 +151,7 @@ interface streams { /// } /// this.flush(); /// // Wait for completion of `flush` - /// poll-one(pollable); + /// pollable.block(); /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` @@ -178,7 +189,7 @@ interface streams { /// Write zeroes to a stream. /// - /// this should be used precisely like `write` with the exact same + /// This should be used precisely like `write` with the exact same /// preconditions (must use check-write first), but instead of /// passing a list of bytes, you simply pass the number of zero-bytes /// that should be written. @@ -199,7 +210,7 @@ interface streams { /// let pollable = this.subscribe(); /// while num_zeroes != 0 { /// // Wait for the stream to become writable - /// poll-one(pollable); + /// pollable.block(); /// let Ok(n) = this.check-write(); // eliding error handling /// let len = min(n, num_zeroes); /// this.write-zeroes(len); // eliding error handling @@ -207,7 +218,7 @@ interface streams { /// } /// this.flush(); /// // Wait for completion of `flush` - /// poll-one(pollable); + /// pollable.block(); /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/world.wit b/wit-0.2.0/deps/io/world.wit similarity index 60% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/world.wit rename to wit-0.2.0/deps/io/world.wit index 8243da2ee..5f0b43fe5 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/io/world.wit +++ b/wit-0.2.0/deps/io/world.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; world imports { import streams; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure-seed.wit b/wit-0.2.0/deps/random/insecure-seed.wit similarity index 96% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure-seed.wit rename to wit-0.2.0/deps/random/insecure-seed.wit index f76e87dad..47210ac6b 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure-seed.wit +++ b/wit-0.2.0/deps/random/insecure-seed.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.0-rc-2023-11-10; +package wasi:random@0.2.0; /// The insecure-seed interface for seeding hash-map DoS resistance. /// /// It is intended to be portable at least between Unix-family platforms and diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure.wit b/wit-0.2.0/deps/random/insecure.wit similarity index 95% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure.wit rename to wit-0.2.0/deps/random/insecure.wit index ec7b99737..c58f4ee85 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/insecure.wit +++ b/wit-0.2.0/deps/random/insecure.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.0-rc-2023-11-10; +package wasi:random@0.2.0; /// The insecure interface for insecure pseudo-random numbers. /// /// It is intended to be portable at least between Unix-family platforms and diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/random.wit b/wit-0.2.0/deps/random/random.wit similarity index 96% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/random.wit rename to wit-0.2.0/deps/random/random.wit index 7a7dfa27a..0c017f093 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/random.wit +++ b/wit-0.2.0/deps/random/random.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.0-rc-2023-11-10; +package wasi:random@0.2.0; /// WASI Random is a random data API. /// /// It is intended to be portable at least between Unix-family platforms and diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/world.wit b/wit-0.2.0/deps/random/world.wit similarity index 67% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/world.wit rename to wit-0.2.0/deps/random/world.wit index 49e5743b4..3da34914a 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/random/world.wit +++ b/wit-0.2.0/deps/random/world.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.0-rc-2023-11-10; +package wasi:random@0.2.0; world imports { import random; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/instance-network.wit b/wit-0.2.0/deps/sockets/instance-network.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/instance-network.wit rename to wit-0.2.0/deps/sockets/instance-network.wit diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/ip-name-lookup.wit b/wit-0.2.0/deps/sockets/ip-name-lookup.wit similarity index 97% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/ip-name-lookup.wit rename to wit-0.2.0/deps/sockets/ip-name-lookup.wit index 931ccf7e0..8e639ec59 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/ip-name-lookup.wit +++ b/wit-0.2.0/deps/sockets/ip-name-lookup.wit @@ -1,6 +1,6 @@ interface ip-name-lookup { - use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable}; + use wasi:io/poll@0.2.0.{pollable}; use network.{network, error-code, ip-address}; diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/network.wit b/wit-0.2.0/deps/sockets/network.wit similarity index 86% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/network.wit rename to wit-0.2.0/deps/sockets/network.wit index 6bb07cd6f..9cadf0650 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/network.wit +++ b/wit-0.2.0/deps/sockets/network.wit @@ -18,8 +18,6 @@ interface network { /// /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. enum error-code { - // ### GENERAL ERRORS ### - /// Unknown error unknown, @@ -64,9 +62,6 @@ interface network { would-block, - - // ### TCP & UDP SOCKET ERRORS ### - /// The operation is not valid in the socket's current state. invalid-state, @@ -83,24 +78,21 @@ interface network { remote-unreachable, - // ### TCP SOCKET ERRORS ### - - /// The connection was forcefully rejected + /// The TCP connection was forcefully rejected connection-refused, - /// The connection was reset. + /// The TCP connection was reset. connection-reset, - /// A connection was aborted. + /// A TCP connection was aborted. connection-aborted, - // ### UDP SOCKET ERRORS ### + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. datagram-too-large, - // ### NAME LOOKUP ERRORS ### - /// Name does not exist or has no suitable associated IP addresses. name-unresolvable, @@ -128,15 +120,21 @@ interface network { } record ipv4-socket-address { - port: u16, // sin_port - address: ipv4-address, // sin_addr + /// sin_port + port: u16, + /// sin_addr + address: ipv4-address, } record ipv6-socket-address { - port: u16, // sin6_port - flow-info: u32, // sin6_flowinfo - address: ipv6-address, // sin6_addr - scope-id: u32, // sin6_scope_id + /// sin6_port + port: u16, + /// sin6_flowinfo + flow-info: u32, + /// sin6_addr + address: ipv6-address, + /// sin6_scope_id + scope-id: u32, } variant ip-socket-address { diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp-create-socket.wit b/wit-0.2.0/deps/sockets/tcp-create-socket.wit similarity index 90% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp-create-socket.wit rename to wit-0.2.0/deps/sockets/tcp-create-socket.wit index 768a07c85..c7ddf1f22 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp-create-socket.wit +++ b/wit-0.2.0/deps/sockets/tcp-create-socket.wit @@ -6,9 +6,10 @@ interface tcp-create-socket { /// Create a new TCP socket. /// /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. /// /// This function does not require a network capability handle. This is considered to be safe because - /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`listen`/`connect` + /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect` /// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world. /// /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp.wit b/wit-0.2.0/deps/sockets/tcp.wit similarity index 70% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp.wit rename to wit-0.2.0/deps/sockets/tcp.wit index b01b65e6c..5902b9ee0 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/tcp.wit +++ b/wit-0.2.0/deps/sockets/tcp.wit @@ -1,8 +1,8 @@ interface tcp { - use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream}; - use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable}; - use wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10.{duration}; + use wasi:io/streams@0.2.0.{input-stream, output-stream}; + use wasi:io/poll@0.2.0.{pollable}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; use network.{network, error-code, ip-socket-address, ip-address-family}; enum shutdown-type { @@ -15,9 +15,28 @@ interface tcp { /// Similar to `SHUT_RDWR` in POSIX. both, } - - - /// A TCP socket handle. + + /// A TCP socket resource. + /// + /// The socket can be in one of the following states: + /// - `unbound` + /// - `bind-in-progress` + /// - `bound` (See note below) + /// - `listen-in-progress` + /// - `listening` + /// - `connect-in-progress` + /// - `connected` + /// - `closed` + /// See + /// for a more information. + /// + /// Note: Except where explicitly mentioned, whenever this documentation uses + /// the term "bound" without backticks it actually means: in the `bound` state *or higher*. + /// (i.e. `bound`, `listen-in-progress`, `listening`, `connect-in-progress` or `connected`) + /// + /// In addition to the general error codes documented on the + /// `network::error-code` type, TCP socket methods may always return + /// `error(invalid-state)` when in the `closed` state. resource tcp-socket { /// Bind the socket to a specific network on the provided IP address and port. /// @@ -25,23 +44,32 @@ interface tcp { /// network interface(s) to bind to. /// If the TCP/UDP port is zero, the socket will be bound to a random free port. /// - /// When a socket is not explicitly bound, the first invocation to a listen or connect operation will - /// implicitly bind the socket. - /// - /// Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts. + /// Bind can be attempted multiple times on the same socket, even with + /// different arguments on each iteration. But never concurrently and + /// only as long as the previous bind failed. Once a bind succeeds, the + /// binding can't be changed anymore. /// - /// # Typical `start` errors + /// # Typical errors /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) /// - `invalid-argument`: `local-address` is not a unicast address. (EINVAL) - /// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address, but the socket has `ipv6-only` enabled. (EINVAL) + /// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL) /// - `invalid-state`: The socket is already bound. (EINVAL) - /// - /// # Typical `finish` errors /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) /// - `address-in-use`: Address is already in use. (EADDRINUSE) /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) /// - `not-in-progress`: A `bind` operation is not in progress. /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT + /// state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR + /// socket option should be set implicitly on all platforms, except on Windows where this is the default behavior + /// and SO_REUSEADDR performs something different entirely. + /// + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. /// /// # References /// - @@ -54,39 +82,40 @@ interface tcp { /// Connect to a remote endpoint. /// /// On success: - /// - the socket is transitioned into the Connection state + /// - the socket is transitioned into the `connection` state. /// - a pair of streams is returned that can be used to read & write to the connection /// - /// POSIX mentions: - /// > If connect() fails, the state of the socket is unspecified. Conforming applications should - /// > close the file descriptor and create a new socket before attempting to reconnect. + /// After a failed connection attempt, the socket will be in the `closed` + /// state and the only valid action left is to `drop` the socket. A single + /// socket can not be used to connect more than once. /// - /// WASI prescribes the following behavior: - /// - If `connect` fails because an input/state validation error, the socket should remain usable. - /// - If a connection was actually attempted but failed, the socket should become unusable for further network communication. - /// Besides `drop`, any method after such a failure may return an error. - /// - /// # Typical `start` errors + /// # Typical errors /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) /// - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS) - /// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address, but the socket has `ipv6-only` enabled. (EINVAL, EADDRNOTAVAIL on Illumos) - /// - `invalid-argument`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa) + /// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos) /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows) /// - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows) /// - `invalid-argument`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`. - /// - `invalid-state`: The socket is already in the Connection state. (EISCONN) - /// - `invalid-state`: The socket is already in the Listener state. (EOPNOTSUPP, EINVAL on Windows) - /// - /// # Typical `finish` errors + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN) + /// - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows) /// - `timeout`: Connection timed out. (ETIMEDOUT) /// - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED) /// - `connection-reset`: The connection was reset. (ECONNRESET) /// - `connection-aborted`: The connection was aborted. (ECONNABORTED) /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) - /// - `not-in-progress`: A `connect` operation is not in progress. + /// - `not-in-progress`: A connect operation is not in progress. /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) /// + /// # Implementors note + /// The POSIX equivalent of `start-connect` is the regular `connect` syscall. + /// Because all WASI sockets are non-blocking this is expected to return + /// EINPROGRESS, which should be translated to `ok()` in WASI. + /// + /// The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT` + /// with a timeout of 0 on the socket descriptor. Followed by a check for + /// the `SO_ERROR` socket option, in case the poll signaled readiness. + /// /// # References /// - /// - @@ -97,22 +126,24 @@ interface tcp { /// Start listening for new connections. /// - /// Transitions the socket into the Listener state. + /// Transitions the socket into the `listening` state. /// - /// Unlike POSIX: - /// - this function is async. This enables interactive WASI hosts to inject permission prompts. - /// - the socket must already be explicitly bound. + /// Unlike POSIX, the socket must already be explicitly bound. /// - /// # Typical `start` errors + /// # Typical errors /// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ) - /// - `invalid-state`: The socket is already in the Connection state. (EISCONN, EINVAL on BSD) - /// - `invalid-state`: The socket is already in the Listener state. - /// - /// # Typical `finish` errors + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD) + /// - `invalid-state`: The socket is already in the `listening` state. /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) - /// - `not-in-progress`: A `listen` operation is not in progress. + /// - `not-in-progress`: A listen operation is not in progress. /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) /// + /// # Implementors note + /// Unlike in POSIX, in WASI the listen operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `listen` as part of either `start-listen` or `finish-listen`. + /// /// # References /// - /// - @@ -123,9 +154,8 @@ interface tcp { /// Accept a new client socket. /// - /// The returned socket is bound and in the Connection state. The following properties are inherited from the listener socket: + /// The returned socket is bound and in the `connected` state. The following properties are inherited from the listener socket: /// - `address-family` - /// - `ipv6-only` /// - `keep-alive-enabled` /// - `keep-alive-idle-time` /// - `keep-alive-interval` @@ -138,7 +168,7 @@ interface tcp { /// a pair of streams that can be used to read & write to the connection. /// /// # Typical errors - /// - `invalid-state`: Socket is not in the Listener state. (EINVAL) + /// - `invalid-state`: Socket is not in the `listening` state. (EINVAL) /// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN) /// - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED) /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) @@ -180,7 +210,7 @@ interface tcp { /// - remote-address: func() -> result; - /// Whether the socket is listening for new connections. + /// Whether the socket is in the `listening` state. /// /// Equivalent to the SO_ACCEPTCONN socket option. is-listening: func() -> bool; @@ -190,17 +220,6 @@ interface tcp { /// Equivalent to the SO_DOMAIN socket option. address-family: func() -> ip-address-family; - /// Whether IPv4 compatibility (dual-stack) mode is disabled or not. - /// - /// Equivalent to the IPV6_V6ONLY socket option. - /// - /// # Typical errors - /// - `invalid-state`: (set) The socket is already bound. - /// - `not-supported`: (get/set) `this` socket is an IPv4 socket. - /// - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.) - ipv6-only: func() -> result; - set-ipv6-only: func(value: bool) -> result<_, error-code>; - /// Hints the desired listen queue size. Implementations are free to ignore this. /// /// If the provided value is 0, an `invalid-argument` error is returned. @@ -209,7 +228,7 @@ interface tcp { /// # Typical errors /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. /// - `invalid-argument`: (set) The provided value was 0. - /// - `invalid-state`: (set) The socket is already in the Connection state. + /// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. set-listen-backlog-size: func(value: u64) -> result<_, error-code>; /// Enables or disables keepalive. @@ -269,8 +288,6 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. - /// - `invalid-state`: (set) The socket is already in the Connection state. - /// - `invalid-state`: (set) The socket is already in the Listener state. hop-limit: func() -> result; set-hop-limit: func(value: u8) -> result<_, error-code>; @@ -284,14 +301,25 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - /// - `invalid-state`: (set) The socket is already in the Connection state. - /// - `invalid-state`: (set) The socket is already in the Listener state. receive-buffer-size: func() -> result; set-receive-buffer-size: func(value: u64) -> result<_, error-code>; send-buffer-size: func() -> result; set-send-buffer-size: func(value: u64) -> result<_, error-code>; - /// Create a `pollable` which will resolve once the socket is ready for I/O. + /// Create a `pollable` which can be used to poll for, or block on, + /// completion of any of the asynchronous operations of this socket. + /// + /// When `finish-bind`, `finish-listen`, `finish-connect` or `accept` + /// return `error(would-block)`, this pollable can be used to wait for + /// their success or failure, after which the method can be retried. + /// + /// The pollable is not limited to the async operation that happens to be + /// in progress at the time of calling `subscribe` (if any). Theoretically, + /// `subscribe` only has to be called once per socket and can then be + /// (re)used for the remainder of the socket's lifetime. + /// + /// See + /// for a more information. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. @@ -299,17 +327,21 @@ interface tcp { /// Initiate a graceful shutdown. /// - /// - receive: the socket is not expecting to receive any more data from the peer. All subsequent read - /// operations on the `input-stream` associated with this socket will return an End Of Stream indication. - /// Any data still in the receive queue at time of calling `shutdown` will be discarded. - /// - send: the socket is not expecting to send any more data to the peer. All subsequent write - /// operations on the `output-stream` associated with this socket will return an error. - /// - both: same effect as receive & send combined. + /// - `receive`: The socket is not expecting to receive any data from + /// the peer. The `input-stream` associated with this socket will be + /// closed. Any data still in the receive queue at time of calling + /// this method will be discarded. + /// - `send`: The socket has no more data to send to the peer. The `output-stream` + /// associated with this socket will be closed and a FIN packet will be sent. + /// - `both`: Same effect as `receive` & `send` combined. + /// + /// This function is idempotent. Shutting a down a direction more than once + /// has no effect and returns `ok`. /// /// The shutdown function does not close (drop) the socket. /// /// # Typical errors - /// - `invalid-state`: The socket is not in the Connection state. (ENOTCONN) + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) /// /// # References /// - diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp-create-socket.wit b/wit-0.2.0/deps/sockets/udp-create-socket.wit similarity index 93% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp-create-socket.wit rename to wit-0.2.0/deps/sockets/udp-create-socket.wit index cc58234d8..0482d1fe7 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp-create-socket.wit +++ b/wit-0.2.0/deps/sockets/udp-create-socket.wit @@ -6,6 +6,7 @@ interface udp-create-socket { /// Create a new UDP socket. /// /// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. /// /// This function does not require a network capability handle. This is considered to be safe because /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is called, diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp.wit b/wit-0.2.0/deps/sockets/udp.wit similarity index 92% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp.wit rename to wit-0.2.0/deps/sockets/udp.wit index c8dafadfc..d987a0a90 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/udp.wit +++ b/wit-0.2.0/deps/sockets/udp.wit @@ -1,6 +1,6 @@ interface udp { - use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable}; + use wasi:io/poll@0.2.0.{pollable}; use network.{network, error-code, ip-socket-address, ip-address-family}; /// A received datagram. @@ -43,19 +43,21 @@ interface udp { /// network interface(s) to bind to. /// If the port is zero, the socket will be bound to a random free port. /// - /// Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts. - /// - /// # Typical `start` errors + /// # Typical errors /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) /// - `invalid-state`: The socket is already bound. (EINVAL) - /// - /// # Typical `finish` errors /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) /// - `address-in-use`: Address is already in use. (EADDRINUSE) /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) /// - `not-in-progress`: A `bind` operation is not in progress. /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) /// + /// # Implementors note + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. + /// /// # References /// - /// - @@ -92,7 +94,6 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) - /// - `invalid-argument`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa) /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) /// - `invalid-state`: The socket is not bound. @@ -142,17 +143,6 @@ interface udp { /// Equivalent to the SO_DOMAIN socket option. address-family: func() -> ip-address-family; - /// Whether IPv4 compatibility (dual-stack) mode is disabled or not. - /// - /// Equivalent to the IPV6_V6ONLY socket option. - /// - /// # Typical errors - /// - `not-supported`: (get/set) `this` socket is an IPv4 socket. - /// - `invalid-state`: (set) The socket is already bound. - /// - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.) - ipv6-only: func() -> result; - set-ipv6-only: func(value: bool) -> result<_, error-code>; - /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. /// /// If the provided value is 0, an `invalid-argument` error is returned. @@ -248,7 +238,6 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) - /// - `invalid-argument`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa) /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) /// - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` value that does not match the address passed to `stream`. (EISCONN) diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/world.wit b/wit-0.2.0/deps/sockets/world.wit similarity index 81% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/world.wit rename to wit-0.2.0/deps/sockets/world.wit index 49ad8d3d9..f8bb92ae0 100644 --- a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/sockets/world.wit +++ b/wit-0.2.0/deps/sockets/world.wit @@ -1,4 +1,4 @@ -package wasi:sockets@0.2.0-rc-2023-11-10; +package wasi:sockets@0.2.0; world imports { import instance-network; diff --git a/wit/deps/spin@unversioned/config.wit b/wit-0.2.0/deps/spin@unversioned/config.wit similarity index 100% rename from wit/deps/spin@unversioned/config.wit rename to wit-0.2.0/deps/spin@unversioned/config.wit diff --git a/wit/deps/spin@unversioned/http-types.wit b/wit-0.2.0/deps/spin@unversioned/http-types.wit similarity index 100% rename from wit/deps/spin@unversioned/http-types.wit rename to wit-0.2.0/deps/spin@unversioned/http-types.wit diff --git a/wit/deps/spin@unversioned/http.wit b/wit-0.2.0/deps/spin@unversioned/http.wit similarity index 100% rename from wit/deps/spin@unversioned/http.wit rename to wit-0.2.0/deps/spin@unversioned/http.wit diff --git a/wit/deps/spin@unversioned/inbound-http.wit b/wit-0.2.0/deps/spin@unversioned/inbound-http.wit similarity index 100% rename from wit/deps/spin@unversioned/inbound-http.wit rename to wit-0.2.0/deps/spin@unversioned/inbound-http.wit diff --git a/wit/deps/spin@unversioned/inbound-redis.wit b/wit-0.2.0/deps/spin@unversioned/inbound-redis.wit similarity index 100% rename from wit/deps/spin@unversioned/inbound-redis.wit rename to wit-0.2.0/deps/spin@unversioned/inbound-redis.wit diff --git a/wit/deps/spin@unversioned/key-value.wit b/wit-0.2.0/deps/spin@unversioned/key-value.wit similarity index 100% rename from wit/deps/spin@unversioned/key-value.wit rename to wit-0.2.0/deps/spin@unversioned/key-value.wit diff --git a/wit/deps/spin@unversioned/llm.wit b/wit-0.2.0/deps/spin@unversioned/llm.wit similarity index 100% rename from wit/deps/spin@unversioned/llm.wit rename to wit-0.2.0/deps/spin@unversioned/llm.wit diff --git a/wit/deps/spin@unversioned/mysql.wit b/wit-0.2.0/deps/spin@unversioned/mysql.wit similarity index 100% rename from wit/deps/spin@unversioned/mysql.wit rename to wit-0.2.0/deps/spin@unversioned/mysql.wit diff --git a/wit/deps/spin@unversioned/postgres.wit b/wit-0.2.0/deps/spin@unversioned/postgres.wit similarity index 100% rename from wit/deps/spin@unversioned/postgres.wit rename to wit-0.2.0/deps/spin@unversioned/postgres.wit diff --git a/wit/deps/spin@unversioned/rdbms-types.wit b/wit-0.2.0/deps/spin@unversioned/rdbms-types.wit similarity index 100% rename from wit/deps/spin@unversioned/rdbms-types.wit rename to wit-0.2.0/deps/spin@unversioned/rdbms-types.wit diff --git a/wit/deps/spin@unversioned/redis-types.wit b/wit-0.2.0/deps/spin@unversioned/redis-types.wit similarity index 100% rename from wit/deps/spin@unversioned/redis-types.wit rename to wit-0.2.0/deps/spin@unversioned/redis-types.wit diff --git a/wit/deps/spin@unversioned/redis.wit b/wit-0.2.0/deps/spin@unversioned/redis.wit similarity index 100% rename from wit/deps/spin@unversioned/redis.wit rename to wit-0.2.0/deps/spin@unversioned/redis.wit diff --git a/wit/deps/spin@unversioned/sqlite.wit b/wit-0.2.0/deps/spin@unversioned/sqlite.wit similarity index 100% rename from wit/deps/spin@unversioned/sqlite.wit rename to wit-0.2.0/deps/spin@unversioned/sqlite.wit diff --git a/wit/deps/spin@unversioned/world.wit b/wit-0.2.0/deps/spin@unversioned/world.wit similarity index 100% rename from wit/deps/spin@unversioned/world.wit rename to wit-0.2.0/deps/spin@unversioned/world.wit diff --git a/wit/key-value.wit b/wit-0.2.0/key-value.wit similarity index 100% rename from wit/key-value.wit rename to wit-0.2.0/key-value.wit diff --git a/wit/llm.wit b/wit-0.2.0/llm.wit similarity index 100% rename from wit/llm.wit rename to wit-0.2.0/llm.wit diff --git a/wit/mysql.wit b/wit-0.2.0/mysql.wit similarity index 100% rename from wit/mysql.wit rename to wit-0.2.0/mysql.wit diff --git a/wit/postgres.wit b/wit-0.2.0/postgres.wit similarity index 100% rename from wit/postgres.wit rename to wit-0.2.0/postgres.wit diff --git a/wit/rdbms-types.wit b/wit-0.2.0/rdbms-types.wit similarity index 100% rename from wit/rdbms-types.wit rename to wit-0.2.0/rdbms-types.wit diff --git a/wit/redis.wit b/wit-0.2.0/redis.wit similarity index 100% rename from wit/redis.wit rename to wit-0.2.0/redis.wit diff --git a/wit/sqlite.wit b/wit-0.2.0/sqlite.wit similarity index 100% rename from wit/sqlite.wit rename to wit-0.2.0/sqlite.wit diff --git a/wit/variables.wit b/wit-0.2.0/variables.wit similarity index 100% rename from wit/variables.wit rename to wit-0.2.0/variables.wit diff --git a/wit-0.2.0/world.wit b/wit-0.2.0/world.wit new file mode 100644 index 000000000..ccf54c526 --- /dev/null +++ b/wit-0.2.0/world.wit @@ -0,0 +1,20 @@ +package fermyon:spin@2.2.0; + +/// The full world of a guest targeting an http-trigger +world http-trigger { + include platform; + export wasi:http/incoming-handler@0.2.0; +} + +/// The imports needed for a guest to run on a Spin host +world platform { + include wasi:cli/imports@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import llm; + import redis; + import postgres; + import mysql; + import sqlite; + import key-value; + import variables; +} diff --git a/wit/deps/cli/command.wit b/wit-2023-10-18/deps/cli/command.wit similarity index 100% rename from wit/deps/cli/command.wit rename to wit-2023-10-18/deps/cli/command.wit diff --git a/wit/deps/cli/environment.wit b/wit-2023-10-18/deps/cli/environment.wit similarity index 100% rename from wit/deps/cli/environment.wit rename to wit-2023-10-18/deps/cli/environment.wit diff --git a/wit/deps/cli/exit.wit b/wit-2023-10-18/deps/cli/exit.wit similarity index 100% rename from wit/deps/cli/exit.wit rename to wit-2023-10-18/deps/cli/exit.wit diff --git a/wit/deps/cli/reactor.wit b/wit-2023-10-18/deps/cli/reactor.wit similarity index 100% rename from wit/deps/cli/reactor.wit rename to wit-2023-10-18/deps/cli/reactor.wit diff --git a/wit/deps/cli/run.wit b/wit-2023-10-18/deps/cli/run.wit similarity index 100% rename from wit/deps/cli/run.wit rename to wit-2023-10-18/deps/cli/run.wit diff --git a/wit/deps/cli/stdio.wit b/wit-2023-10-18/deps/cli/stdio.wit similarity index 100% rename from wit/deps/cli/stdio.wit rename to wit-2023-10-18/deps/cli/stdio.wit diff --git a/tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/terminal.wit b/wit-2023-10-18/deps/cli/terminal.wit similarity index 100% rename from tests/test-components/components/integration-wasi-http-v0.2.0-rc-2023-12-05/wit/deps/cli/terminal.wit rename to wit-2023-10-18/deps/cli/terminal.wit diff --git a/wit/deps/clocks/monotonic-clock.wit b/wit-2023-10-18/deps/clocks/monotonic-clock.wit similarity index 100% rename from wit/deps/clocks/monotonic-clock.wit rename to wit-2023-10-18/deps/clocks/monotonic-clock.wit diff --git a/wit/deps/clocks/timezone.wit b/wit-2023-10-18/deps/clocks/timezone.wit similarity index 100% rename from wit/deps/clocks/timezone.wit rename to wit-2023-10-18/deps/clocks/timezone.wit diff --git a/wit/deps/clocks/wall-clock.wit b/wit-2023-10-18/deps/clocks/wall-clock.wit similarity index 100% rename from wit/deps/clocks/wall-clock.wit rename to wit-2023-10-18/deps/clocks/wall-clock.wit diff --git a/wit/deps/clocks/world.wit b/wit-2023-10-18/deps/clocks/world.wit similarity index 100% rename from wit/deps/clocks/world.wit rename to wit-2023-10-18/deps/clocks/world.wit diff --git a/wit/deps/filesystem/preopens.wit b/wit-2023-10-18/deps/filesystem/preopens.wit similarity index 100% rename from wit/deps/filesystem/preopens.wit rename to wit-2023-10-18/deps/filesystem/preopens.wit diff --git a/wit/deps/filesystem/types.wit b/wit-2023-10-18/deps/filesystem/types.wit similarity index 100% rename from wit/deps/filesystem/types.wit rename to wit-2023-10-18/deps/filesystem/types.wit diff --git a/wit/deps/filesystem/world.wit b/wit-2023-10-18/deps/filesystem/world.wit similarity index 100% rename from wit/deps/filesystem/world.wit rename to wit-2023-10-18/deps/filesystem/world.wit diff --git a/wit/deps/http/incoming-handler.wit b/wit-2023-10-18/deps/http/incoming-handler.wit similarity index 100% rename from wit/deps/http/incoming-handler.wit rename to wit-2023-10-18/deps/http/incoming-handler.wit diff --git a/wit/deps/http/outgoing-handler.wit b/wit-2023-10-18/deps/http/outgoing-handler.wit similarity index 100% rename from wit/deps/http/outgoing-handler.wit rename to wit-2023-10-18/deps/http/outgoing-handler.wit diff --git a/wit/deps/http/proxy.wit b/wit-2023-10-18/deps/http/proxy.wit similarity index 100% rename from wit/deps/http/proxy.wit rename to wit-2023-10-18/deps/http/proxy.wit diff --git a/wit/deps/http/types.wit b/wit-2023-10-18/deps/http/types.wit similarity index 100% rename from wit/deps/http/types.wit rename to wit-2023-10-18/deps/http/types.wit diff --git a/wit/deps/io/poll.wit b/wit-2023-10-18/deps/io/poll.wit similarity index 100% rename from wit/deps/io/poll.wit rename to wit-2023-10-18/deps/io/poll.wit diff --git a/wit/deps/io/streams.wit b/wit-2023-10-18/deps/io/streams.wit similarity index 100% rename from wit/deps/io/streams.wit rename to wit-2023-10-18/deps/io/streams.wit diff --git a/wit/deps/io/world.wit b/wit-2023-10-18/deps/io/world.wit similarity index 100% rename from wit/deps/io/world.wit rename to wit-2023-10-18/deps/io/world.wit diff --git a/wit/deps/random/insecure-seed.wit b/wit-2023-10-18/deps/random/insecure-seed.wit similarity index 100% rename from wit/deps/random/insecure-seed.wit rename to wit-2023-10-18/deps/random/insecure-seed.wit diff --git a/wit/deps/random/insecure.wit b/wit-2023-10-18/deps/random/insecure.wit similarity index 100% rename from wit/deps/random/insecure.wit rename to wit-2023-10-18/deps/random/insecure.wit diff --git a/wit/deps/random/random.wit b/wit-2023-10-18/deps/random/random.wit similarity index 100% rename from wit/deps/random/random.wit rename to wit-2023-10-18/deps/random/random.wit diff --git a/wit/deps/random/world.wit b/wit-2023-10-18/deps/random/world.wit similarity index 100% rename from wit/deps/random/world.wit rename to wit-2023-10-18/deps/random/world.wit diff --git a/wit/deps/sockets/instance-network.wit b/wit-2023-10-18/deps/sockets/instance-network.wit similarity index 100% rename from wit/deps/sockets/instance-network.wit rename to wit-2023-10-18/deps/sockets/instance-network.wit diff --git a/wit/deps/sockets/ip-name-lookup.wit b/wit-2023-10-18/deps/sockets/ip-name-lookup.wit similarity index 100% rename from wit/deps/sockets/ip-name-lookup.wit rename to wit-2023-10-18/deps/sockets/ip-name-lookup.wit diff --git a/wit/deps/sockets/network.wit b/wit-2023-10-18/deps/sockets/network.wit similarity index 100% rename from wit/deps/sockets/network.wit rename to wit-2023-10-18/deps/sockets/network.wit diff --git a/wit/deps/sockets/tcp-create-socket.wit b/wit-2023-10-18/deps/sockets/tcp-create-socket.wit similarity index 100% rename from wit/deps/sockets/tcp-create-socket.wit rename to wit-2023-10-18/deps/sockets/tcp-create-socket.wit diff --git a/wit/deps/sockets/tcp.wit b/wit-2023-10-18/deps/sockets/tcp.wit similarity index 100% rename from wit/deps/sockets/tcp.wit rename to wit-2023-10-18/deps/sockets/tcp.wit diff --git a/wit/deps/sockets/udp-create-socket.wit b/wit-2023-10-18/deps/sockets/udp-create-socket.wit similarity index 100% rename from wit/deps/sockets/udp-create-socket.wit rename to wit-2023-10-18/deps/sockets/udp-create-socket.wit diff --git a/wit/deps/sockets/udp.wit b/wit-2023-10-18/deps/sockets/udp.wit similarity index 100% rename from wit/deps/sockets/udp.wit rename to wit-2023-10-18/deps/sockets/udp.wit diff --git a/wit/deps/sockets/world.wit b/wit-2023-10-18/deps/sockets/world.wit similarity index 100% rename from wit/deps/sockets/world.wit rename to wit-2023-10-18/deps/sockets/world.wit diff --git a/wit-2023-10-18/deps/spin@unversioned/config.wit b/wit-2023-10-18/deps/spin@unversioned/config.wit new file mode 100644 index 000000000..ac465fbe7 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/config.wit @@ -0,0 +1,12 @@ +interface config { + // Get a configuration value for the current component. + // The config key must match one defined in in the component manifest. + get-config: func(key: string) -> result; + + variant error { + provider(string), + invalid-key(string), + invalid-schema(string), + other(string), + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/http-types.wit b/wit-2023-10-18/deps/spin@unversioned/http-types.wit new file mode 100644 index 000000000..c941cc979 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/http-types.wit @@ -0,0 +1,44 @@ +interface http-types { + type http-status = u16; + + type body = list; + + type headers = list>; + + type params = list>; + + type uri = string; + + enum method { + get, + post, + put, + delete, + patch, + head, + options, + } + + record request { + method: method, + uri: uri, + headers: headers, + params: params, + body: option, + } + + record response { + status: http-status, + headers: option, + body: option, + } + + enum http-error { + success, + destination-not-allowed, + invalid-url, + request-error, + runtime-error, + too-many-requests, + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/http.wit b/wit-2023-10-18/deps/spin@unversioned/http.wit new file mode 100644 index 000000000..6ca943cfd --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/http.wit @@ -0,0 +1,5 @@ +interface http { + use http-types.{request, response, http-error}; + + send-request: func(req: request) -> result; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/inbound-http.wit b/wit-2023-10-18/deps/spin@unversioned/inbound-http.wit new file mode 100644 index 000000000..968c57625 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/inbound-http.wit @@ -0,0 +1,5 @@ +interface inbound-http { + use http-types.{request, response}; + + handle-request: func(req: request) -> response; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/inbound-redis.wit b/wit-2023-10-18/deps/spin@unversioned/inbound-redis.wit new file mode 100644 index 000000000..a991e5de1 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/inbound-redis.wit @@ -0,0 +1,6 @@ +interface inbound-redis { + use redis-types.{payload, error}; + + // The entrypoint for a Redis handler. + handle-message: func(message: payload) -> result<_, error>; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/key-value.wit b/wit-2023-10-18/deps/spin@unversioned/key-value.wit new file mode 100644 index 000000000..314a758c7 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/key-value.wit @@ -0,0 +1,80 @@ +interface key-value { + // A handle to an open key-value store + type store = u32; + + // The set of errors which may be raised by functions in this interface + variant error { + // Too many stores have been opened simultaneously. Closing one or more + // stores prior to retrying may address this. + store-table-full, + + // The host does not recognize the store name requested. Defining and + // configuring a store with that name in a runtime configuration file + // may address this. + no-such-store, + + // The requesting component does not have access to the specified store + // (which may or may not exist). + access-denied, + + // The store handle provided is not recognized, i.e. it was either never + // opened or has been closed. + invalid-store, + + // No key-value tuple exists for the specified key in the specified + // store. + no-such-key, + + // Some implementation-specific error has occurred (e.g. I/O) + io(string) + } + + // Open the store with the specified name. + // + // If `name` is "default", the default store is opened. Otherwise, + // `name` must refer to a store defined and configured in a runtime + // configuration file supplied with the application. + // + // `error::no-such-store` will be raised if the `name` is not recognized. + open: func(name: string) -> result; + + // Get the value associated with the specified `key` from the specified + // `store`. + // + // `error::invalid-store` will be raised if `store` is not a valid handle + // to an open store, and `error::no-such-key` will be raised if there is no + // tuple for `key` in `store`. + get: func(store: store, key: string) -> result, error>; + + // Set the `value` associated with the specified `key` in the specified + // `store`, overwriting any existing value. + // + // `error::invalid-store` will be raised if `store` is not a valid handle + // to an open store. + set: func(store: store, key: string, value: list) -> result<_, error>; + + // Delete the tuple with the specified `key` from the specified `store`. + // + // `error::invalid-store` will be raised if `store` is not a valid handle + // to an open store. No error is raised if a tuple did not previously + // exist for `key`. + delete: func(store: store, key: string) -> result<_, error>; + + // Return whether a tuple exists for the specified `key` in the specified + // `store`. + // + // `error::invalid-store` will be raised if `store` is not a valid handle + // to an open store. + exists: func(store: store, key: string) -> result; + + // Return a list of all the keys in the specified `store`. + // + // `error::invalid-store` will be raised if `store` is not a valid handle + // to an open store. + get-keys: func(store: store) -> result, error>; + + // Close the specified `store`. + // + // This has no effect if `store` is not a valid handle to an open store. + close: func(store: store); +} diff --git a/wit-2023-10-18/deps/spin@unversioned/llm.wit b/wit-2023-10-18/deps/spin@unversioned/llm.wit new file mode 100644 index 000000000..ffed09ccd --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/llm.wit @@ -0,0 +1,70 @@ +// A WASI interface dedicated to performing inferencing for Large Language Models. +interface llm { + /// A Large Language Model. + type inferencing-model = string; + + /// Inference request parameters + record inferencing-params { + /// The maximum tokens that should be inferred. + /// + /// Note: the backing implementation may return less tokens. + max-tokens: u32, + /// The amount the model should avoid repeating tokens. + repeat-penalty: float32, + /// The number of tokens the model should apply the repeat penalty to. + repeat-penalty-last-n-token-count: u32, + /// The randomness with which the next token is selected. + temperature: float32, + /// The number of possible next tokens the model will choose from. + top-k: u32, + /// The probability total of next tokens the model will choose from. + top-p: float32 + } + + /// The set of errors which may be raised by functions in this interface + variant error { + model-not-supported, + runtime-error(string), + invalid-input(string) + } + + /// An inferencing result + record inferencing-result { + /// The text generated by the model + // TODO: this should be a stream + text: string, + /// Usage information about the inferencing request + usage: inferencing-usage + } + + /// Usage information related to the inferencing result + record inferencing-usage { + /// Number of tokens in the prompt + prompt-token-count: u32, + /// Number of tokens generated by the inferencing operation + generated-token-count: u32 + } + + /// Perform inferencing using the provided model and prompt with the given optional params + infer: func(model: inferencing-model, prompt: string, params: option) -> result; + + /// The model used for generating embeddings + type embedding-model = string; + + /// Generate embeddings for the supplied list of text + generate-embeddings: func(model: embedding-model, text: list) -> result; + + /// Result of generating embeddings + record embeddings-result { + /// The embeddings generated by the request + embeddings: list>, + /// Usage related to the embeddings generation request + usage: embeddings-usage + } + + /// Usage related to an embeddings generation request + record embeddings-usage { + /// Number of tokens in the prompt + prompt-token-count: u32, + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/mysql.wit b/wit-2023-10-18/deps/spin@unversioned/mysql.wit new file mode 100644 index 000000000..dd1b9c3e2 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/mysql.wit @@ -0,0 +1,19 @@ +interface mysql { + use rdbms-types.{parameter-value, row-set}; + + // General purpose error. + variant mysql-error { + success, + connection-failed(string), + bad-parameter(string), + query-failed(string), + value-conversion-failed(string), + other-error(string) + } + + // query the database: select + query: func(address: string, statement: string, params: list) -> result; + + // execute command to the database: insert, update, delete + execute: func(address: string, statement: string, params: list) -> result<_, mysql-error>; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/postgres.wit b/wit-2023-10-18/deps/spin@unversioned/postgres.wit new file mode 100644 index 000000000..e82ef42c9 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/postgres.wit @@ -0,0 +1,19 @@ +interface postgres { + use rdbms-types.{parameter-value, row-set}; + + // General purpose error. + variant pg-error { + success, + connection-failed(string), + bad-parameter(string), + query-failed(string), + value-conversion-failed(string), + other-error(string) + } + + // query the database: select + query: func(address: string, statement: string, params: list) -> result; + + // execute command to the database: insert, update, delete + execute: func(address: string, statement: string, params: list) -> result; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/rdbms-types.wit b/wit-2023-10-18/deps/spin@unversioned/rdbms-types.wit new file mode 100644 index 000000000..7af04209c --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/rdbms-types.wit @@ -0,0 +1,65 @@ +interface rdbms-types { + enum db-data-type { + boolean, + int8, + int16, + int32, + int64, + uint8, + uint16, + uint32, + uint64, + floating32, + floating64, + str, + binary, + other, + } + + variant db-value { + boolean(bool), + int8(s8), + int16(s16), + int32(s32), + int64(s64), + uint8(u8), + uint16(u16), + uint32(u32), + uint64(u64), + floating32(float32), + floating64(float64), + str(string), + binary(list), + db-null, + unsupported, + } + + variant parameter-value { + boolean(bool), + int8(s8), + int16(s16), + int32(s32), + int64(s64), + uint8(u8), + uint16(u16), + uint32(u32), + uint64(u64), + floating32(float32), + floating64(float64), + str(string), + binary(list), + db-null, + } + + record column { + name: string, + data-type: db-data-type, + } + + type row = list; + + record row-set { + columns: list, + rows: list, + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/redis-types.wit b/wit-2023-10-18/deps/spin@unversioned/redis-types.wit new file mode 100644 index 000000000..6970f63ea --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/redis-types.wit @@ -0,0 +1,24 @@ +interface redis-types { + // General purpose error. + enum error { + success, + error, + } + + /// The message payload. + type payload = list; + + /// A parameter type for the general-purpose `execute` function. + variant redis-parameter { + int64(s64), + binary(payload) + } + + /// A return type for the general-purpose `execute` function. + variant redis-result { + nil, + status(string), + int64(s64), + binary(payload) + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/redis.wit b/wit-2023-10-18/deps/spin@unversioned/redis.wit new file mode 100644 index 000000000..1b64906b8 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/redis.wit @@ -0,0 +1,31 @@ +interface redis { + use redis-types.{payload, redis-parameter, redis-result, error}; + + // Publish a Redis message to the specificed channel and return an error, if any. + publish: func(address: string, channel: string, payload: payload) -> result<_, error>; + + // Get the value of a key. + get: func(address: string, key: string) -> result; + + // Set key to value. If key alreads holds a value, it is overwritten. + set: func(address: string, key: string, value: payload) -> result<_, error>; + + // Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. + // An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. + incr: func(address: string, key: string) -> result; + + // Removes the specified keys. A key is ignored if it does not exist. + del: func(address: string, keys: list) -> result; + + // Add the specified `values` to the set named `key`, returning the number of newly-added values. + sadd: func(address: string, key: string, values: list) -> result; + + // Retrieve the contents of the set named `key`. + smembers: func(address: string, key: string) -> result, error>; + + // Remove the specified `values` from the set named `key`, returning the number of newly-removed values. + srem: func(address: string, key: string, values: list) -> result; + + // Execute an arbitrary Redis command and receive the result. + execute: func(address: string, command: string, arguments: list) -> result, error>; +} diff --git a/wit-2023-10-18/deps/spin@unversioned/sqlite.wit b/wit-2023-10-18/deps/spin@unversioned/sqlite.wit new file mode 100644 index 000000000..7e2908f03 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/sqlite.wit @@ -0,0 +1,52 @@ +interface sqlite { + // A handle to an open sqlite instance + type connection = u32; + + // The set of errors which may be raised by functions in this interface + variant error { + // The host does not recognize the database name requested. + no-such-database, + // The requesting component does not have access to the specified database (which may or may not exist). + access-denied, + // The provided connection is not valid + invalid-connection, + // The database has reached its capacity + database-full, + // Some implementation-specific error has occurred (e.g. I/O) + io(string) + } + + // Open a connection to a named database instance. + // + // If `database` is "default", the default instance is opened. + // + // `error::no-such-database` will be raised if the `name` is not recognized. + open: func(database: string) -> result; + + // Execute a statement returning back data if there is any + execute: func(conn: connection, statement: string, parameters: list) -> result; + + // Close the specified `connection`. + close: func(conn: connection); + + // A result of a query + record query-result { + // The names of the columns retrieved in the query + columns: list, + // the row results each containing the values for all the columns for a given row + rows: list, + } + + // A set of values for each of the columns in a query-result + record row-result { + values: list + } + + variant value { + integer(s64), + real(float64), + text(string), + blob(list), + null + } +} diff --git a/wit-2023-10-18/deps/spin@unversioned/world.wit b/wit-2023-10-18/deps/spin@unversioned/world.wit new file mode 100644 index 000000000..603a76028 --- /dev/null +++ b/wit-2023-10-18/deps/spin@unversioned/world.wit @@ -0,0 +1,29 @@ +package fermyon:spin; + +world host { + include platform; + + export inbound-http; + export inbound-redis; +} + +world redis-trigger { + include platform; + export inbound-redis; +} + +world http-trigger { + include platform; + export inbound-http; +} + +world platform { + import config; + import http; + import postgres; + import mysql; + import sqlite; + import redis; + import key-value; + import llm; +} diff --git a/wit-2023-10-18/key-value.wit b/wit-2023-10-18/key-value.wit new file mode 100644 index 000000000..7ba4ed943 --- /dev/null +++ b/wit-2023-10-18/key-value.wit @@ -0,0 +1,47 @@ +interface key-value { + /// An open key-value store + resource store { + /// Open the store with the specified label. + /// + /// `label` must refer to a store allowed in the spin.toml manifest. + /// + /// `error::no-such-store` will be raised if the `label` is not recognized. + open: static func(label: string) -> result; + + /// Get the value associated with the specified `key` + /// + /// Returns `ok(none)` if the key does not exist. + get: func(key: string) -> result>, error>; + + /// Set the `value` associated with the specified `key` overwriting any existing value. + set: func(key: string, value: list) -> result<_, error>; + + /// Delete the tuple with the specified `key` + /// + /// No error is raised if a tuple did not previously exist for `key`. + delete: func(key: string) -> result<_, error>; + + /// Return whether a tuple exists for the specified `key` + exists: func(key: string) -> result; + + /// Return a list of all the keys + get-keys: func() -> result, error>; + } + + /// The set of errors which may be raised by functions in this interface + variant error { + /// Too many stores have been opened simultaneously. Closing one or more + /// stores prior to retrying may address this. + store-table-full, + + /// The host does not recognize the store label requested. + no-such-store, + + /// The requesting component does not have access to the specified store + /// (which may or may not exist). + access-denied, + + /// Some implementation-specific error has occurred (e.g. I/O) + other(string) + } +} diff --git a/wit-2023-10-18/llm.wit b/wit-2023-10-18/llm.wit new file mode 100644 index 000000000..ffed09ccd --- /dev/null +++ b/wit-2023-10-18/llm.wit @@ -0,0 +1,70 @@ +// A WASI interface dedicated to performing inferencing for Large Language Models. +interface llm { + /// A Large Language Model. + type inferencing-model = string; + + /// Inference request parameters + record inferencing-params { + /// The maximum tokens that should be inferred. + /// + /// Note: the backing implementation may return less tokens. + max-tokens: u32, + /// The amount the model should avoid repeating tokens. + repeat-penalty: float32, + /// The number of tokens the model should apply the repeat penalty to. + repeat-penalty-last-n-token-count: u32, + /// The randomness with which the next token is selected. + temperature: float32, + /// The number of possible next tokens the model will choose from. + top-k: u32, + /// The probability total of next tokens the model will choose from. + top-p: float32 + } + + /// The set of errors which may be raised by functions in this interface + variant error { + model-not-supported, + runtime-error(string), + invalid-input(string) + } + + /// An inferencing result + record inferencing-result { + /// The text generated by the model + // TODO: this should be a stream + text: string, + /// Usage information about the inferencing request + usage: inferencing-usage + } + + /// Usage information related to the inferencing result + record inferencing-usage { + /// Number of tokens in the prompt + prompt-token-count: u32, + /// Number of tokens generated by the inferencing operation + generated-token-count: u32 + } + + /// Perform inferencing using the provided model and prompt with the given optional params + infer: func(model: inferencing-model, prompt: string, params: option) -> result; + + /// The model used for generating embeddings + type embedding-model = string; + + /// Generate embeddings for the supplied list of text + generate-embeddings: func(model: embedding-model, text: list) -> result; + + /// Result of generating embeddings + record embeddings-result { + /// The embeddings generated by the request + embeddings: list>, + /// Usage related to the embeddings generation request + usage: embeddings-usage + } + + /// Usage related to an embeddings generation request + record embeddings-usage { + /// Number of tokens in the prompt + prompt-token-count: u32, + } +} diff --git a/wit-2023-10-18/mysql.wit b/wit-2023-10-18/mysql.wit new file mode 100644 index 000000000..446cf89e9 --- /dev/null +++ b/wit-2023-10-18/mysql.wit @@ -0,0 +1,15 @@ +interface mysql { + use rdbms-types.{parameter-value, row-set, error}; + + /// A connection to a MySQL database. + resource connection { + /// Open a connection to the MySQL instance at `address`. + open: static func(address: string) -> result; + + /// query the database: select + query: func(statement: string, params: list) -> result; + + /// execute command to the database: insert, update, delete + execute: func(statement: string, params: list) -> result<_, error>; + } +} diff --git a/wit-2023-10-18/postgres.wit b/wit-2023-10-18/postgres.wit new file mode 100644 index 000000000..ebe1ec6ae --- /dev/null +++ b/wit-2023-10-18/postgres.wit @@ -0,0 +1,15 @@ +interface postgres { + use rdbms-types.{parameter-value, row-set, error}; + + /// A connection to a postgres database. + resource connection { + /// Open a connection to the Postgres instance at `address`. + open: static func(address: string) -> result; + + /// Query the database. + query: func(statement: string, params: list) -> result; + + /// Execute command to the database. + execute: func(statement: string, params: list) -> result; + } +} diff --git a/wit-2023-10-18/rdbms-types.wit b/wit-2023-10-18/rdbms-types.wit new file mode 100644 index 000000000..64f3e59ac --- /dev/null +++ b/wit-2023-10-18/rdbms-types.wit @@ -0,0 +1,80 @@ +interface rdbms-types { + /// Errors related to interacting with a database. + variant error { + connection-failed(string), + bad-parameter(string), + query-failed(string), + value-conversion-failed(string), + other(string) + } + + /// Data types for a database column + enum db-data-type { + boolean, + int8, + int16, + int32, + int64, + uint8, + uint16, + uint32, + uint64, + floating32, + floating64, + str, + binary, + other, + } + + /// Database values + variant db-value { + boolean(bool), + int8(s8), + int16(s16), + int32(s32), + int64(s64), + uint8(u8), + uint16(u16), + uint32(u32), + uint64(u64), + floating32(float32), + floating64(float64), + str(string), + binary(list), + db-null, + unsupported, + } + + /// Values used in parameterized queries + variant parameter-value { + boolean(bool), + int8(s8), + int16(s16), + int32(s32), + int64(s64), + uint8(u8), + uint16(u16), + uint32(u32), + uint64(u64), + floating32(float32), + floating64(float64), + str(string), + binary(list), + db-null, + } + + /// A database column + record column { + name: string, + data-type: db-data-type, + } + + /// A database row + type row = list; + + /// A set of database rows + record row-set { + columns: list, + rows: list, + } +} diff --git a/wit-2023-10-18/redis.wit b/wit-2023-10-18/redis.wit new file mode 100644 index 000000000..27446ebdf --- /dev/null +++ b/wit-2023-10-18/redis.wit @@ -0,0 +1,70 @@ +interface redis { + /// Errors related to interacting with Redis + variant error { + /// An invalid address string + invalid-address, + /// There are too many open connections + too-many-connections, + /// A retrieved value was not of the correct type + type-error, + /// Some other error occurred + other(string), + } + + resource connection { + /// Open a connection to the Redis instance at `address`. + open: static func(address: string) -> result; + + /// Publish a Redis message to the specified channel. + publish: func(channel: string, payload: payload) -> result<_, error>; + + /// Get the value of a key. + get: func(key: string) -> result, error>; + + /// Set key to value. + /// + /// If key already holds a value, it is overwritten. + set: func(key: string, value: payload) -> result<_, error>; + + /// Increments the number stored at key by one. + /// + /// If the key does not exist, it is set to 0 before performing the operation. + /// An `error::type-error` is returned if the key contains a value of the wrong type + /// or contains a string that can not be represented as integer. + incr: func(key: string) -> result; + + /// Removes the specified keys. + /// + /// A key is ignored if it does not exist. Returns the number of keys deleted. + del: func(keys: list) -> result; + + /// Add the specified `values` to the set named `key`, returning the number of newly-added values. + sadd: func(key: string, values: list) -> result; + + /// Retrieve the contents of the set named `key`. + smembers: func(key: string) -> result, error>; + + /// Remove the specified `values` from the set named `key`, returning the number of newly-removed values. + srem: func(key: string, values: list) -> result; + + /// Execute an arbitrary Redis command and receive the result. + execute: func(command: string, arguments: list) -> result, error>; + } + + /// The message payload. + type payload = list; + + /// A parameter type for the general-purpose `execute` function. + variant redis-parameter { + int64(s64), + binary(payload) + } + + /// A return type for the general-purpose `execute` function. + variant redis-result { + nil, + status(string), + int64(s64), + binary(payload) + } +} diff --git a/wit-2023-10-18/sqlite.wit b/wit-2023-10-18/sqlite.wit new file mode 100644 index 000000000..8a5ab2de8 --- /dev/null +++ b/wit-2023-10-18/sqlite.wit @@ -0,0 +1,50 @@ +interface sqlite { + /// A handle to an open sqlite instance + resource connection { + /// Open a connection to a named database instance. + /// + /// If `database` is "default", the default instance is opened. + /// + /// `error::no-such-database` will be raised if the `name` is not recognized. + open: static func(database: string) -> result; + + /// Execute a statement returning back data if there is any + execute: func(statement: string, parameters: list) -> result; + } + + /// The set of errors which may be raised by functions in this interface + variant error { + /// The host does not recognize the database name requested. + no-such-database, + /// The requesting component does not have access to the specified database (which may or may not exist). + access-denied, + /// The provided connection is not valid + invalid-connection, + /// The database has reached its capacity + database-full, + /// Some implementation-specific error has occurred (e.g. I/O) + io(string) + } + + /// A result of a query + record query-result { + /// The names of the columns retrieved in the query + columns: list, + /// the row results each containing the values for all the columns for a given row + rows: list, + } + + /// A set of values for each of the columns in a query-result + record row-result { + values: list + } + + /// A single column's result from a database query + variant value { + integer(s64), + real(float64), + text(string), + blob(list), + null + } +} diff --git a/wit-2023-10-18/variables.wit b/wit-2023-10-18/variables.wit new file mode 100644 index 000000000..6c0511a8b --- /dev/null +++ b/wit-2023-10-18/variables.wit @@ -0,0 +1,18 @@ +interface variables { + /// Get an application variable value for the current component. + /// + /// The name must match one defined in in the component manifest. + get: func(name: string) -> result; + + /// The set of errors which may be raised by functions in this interface. + variant error { + /// The provided variable name is invalid. + invalid-name(string), + /// The provided variable is undefined. + undefined(string), + /// A variables provider specific error has occurred. + provider(string), + /// Some implementation-specific error has occurred. + other(string), + } +} diff --git a/wit/world.wit b/wit-2023-10-18/world.wit similarity index 100% rename from wit/world.wit rename to wit-2023-10-18/world.wit