diff --git a/Cargo.lock b/Cargo.lock index 5f6336376..27d7068fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -796,16 +796,6 @@ dependencies = [ "winx", ] -[[package]] -name = "cap-rand" -version = "3.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8144c22e24bbcf26ade86cb6501a0916c46b7e4787abdb0045a467eb1645a1d" -dependencies = [ - "ambient-authority", - "rand 0.8.6", -] - [[package]] name = "cap-std" version = "3.4.5" @@ -1200,27 +1190,27 @@ dependencies = [ [[package]] name = "cranelift-assembler-x64" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008f1a8d1da5074ad858f398775a6d1989031892e46927df5ed18d3be1ed8717" +checksum = "77c4ebb31662e2051dcc49b7342d222405a99e951720756cc4b93315972abd67" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd76237df1f4e26edb5ad7971d20280ed1e193331fd257f1b4e4dfefd88dda2" +checksum = "106dfc2ec96ec1c3a8a250602e936712e00a381df032f7a8ad175c8f768c03bb" dependencies = [ "cranelift-srcgen", ] [[package]] name = "cranelift-bforest" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380f0bc43e535df6855bbee649efb00bde39c3f33434c47c8e10ac836d21bf47" +checksum = "5694aa8a2eb2571a15b3feee38d16ccaf2712200e7b5c9ae0479069bdfb46949" dependencies = [ "cranelift-entity", "wasmtime-internal-core", @@ -1228,9 +1218,9 @@ dependencies = [ [[package]] name = "cranelift-bitset" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4811e3e4502de04257e90c0a93225b56d9b85e0f9ad10b81446b415511009610" +checksum = "93ab349d30a5fad9699440ee7ccb435374e8a8735dcca26696a4245bcefcc47e" dependencies = [ "serde", "serde_derive", @@ -1239,9 +1229,9 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82ffadb34d497f3e76fb3b4baf764c24ba8a51512976a1b77f78bdbf8f4aa687" +checksum = "3e95970bdb51d145c828a114a1084cb8b63e65569a51600ad398cb49fa78b062" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -1253,7 +1243,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli 0.33.0", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "libm", "log", "pulley-interpreter", @@ -1267,9 +1257,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4f6992eb6faf086ddc7deaaa5f279abfe7f5fd5ae5709bd38253450fc7b945" +checksum = "0e8414b8ecc81f89f8a3f2c5cbc785b9ed690200cd6f9d780e96a92f88879704" dependencies = [ "cranelift-assembler-x64-meta", "cranelift-codegen-shared", @@ -1280,24 +1270,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e1b2aad7d055925a4ea9cdbfa9d1d987f9dfc8ad6b708be28f901ac620a298" +checksum = "631c4e5db42e6a0f9e7a68f18f7faba3692862114870c7c598aee7e0e5677e59" [[package]] name = "cranelift-control" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a355348325e0a63b65c00def3871597b9fcc79d25456397010d16d872b3772" +checksum = "09c6e92c825abfbb739a4beaa5db3988f98a96a68d6ea656f562098efc142976" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f4847d93ce2c80d2bff929aa1004dfb3ce2cf5d881f6ced54b8d654d967ba3" +checksum = "55e57cd185782abada9ab2606bfe88d0abc0d42d83a7d432dcf69991e17fe76e" dependencies = [ "cranelift-bitset", "serde", @@ -1307,9 +1297,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba24e5fe5242cc445e7892ef0a51a4351cf716e3a04ac7a3a05820d056c39818" +checksum = "8a0f17e48d15e29552e2f264d302c31a661a830196d879bbdaf4d7b2bf2f7011" dependencies = [ "cranelift-codegen", "log", @@ -1319,15 +1309,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89bc2035de85c4f04ba7bd57eb5bd3a8b775235bf28852dbf87105115cb8919a" +checksum = "407b80b46934c9dce9a6581f0e80d079b7a69e11372fb03d7dce4c7ba3fee4e3" [[package]] name = "cranelift-native" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea6630c16921ab087792750f239d0c0173411e80179ca7c0ce0710ce9e7646a" +checksum = "3a40e056e421d9a6c757983f2184f765ae1c28a51555d3877e98afc97ce5705b" dependencies = [ "cranelift-codegen", "libc", @@ -1336,9 +1326,9 @@ dependencies = [ [[package]] name = "cranelift-srcgen" -version = "0.131.2" +version = "0.132.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa4bbad54fc28cc0da1f9a5d7f7f826ec8cafda3d503b401b2daaaa93c63ef0" +checksum = "2cdbadda21e49798825a1ec795dab30bcb03235891f662b5ccf23fa45b39682f" [[package]] name = "crc32c" @@ -1903,17 +1893,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" -[[package]] -name = "fd-lock" -version = "4.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" -dependencies = [ - "cfg-if", - "rustix 1.1.4", - "windows-sys 0.52.0", -] - [[package]] name = "fdeflate" version = "0.3.7" @@ -2464,8 +2443,6 @@ dependencies = [ "allocator-api2", "equivalent", "foldhash 0.2.0", - "serde", - "serde_core", ] [[package]] @@ -2475,6 +2452,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "foldhash 0.2.0", + "serde", + "serde_core", ] [[package]] @@ -3356,6 +3335,17 @@ dependencies = [ "libc", ] +[[package]] +name = "macro-string" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a9dbbfc75d2688ed057456ce8a3ee3f48d12eec09229f560f3643b9f275653" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "mappings" version = "0.7.2" @@ -4624,7 +4614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.117", @@ -4650,9 +4640,9 @@ dependencies = [ [[package]] name = "pulley-interpreter" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff0ead8b4616f81b3d3efd41ce41bcf9ea364a5d8df8be8a8a1f98b50104349" +checksum = "dd6ccdd6fc70f6c33eb21cb8fe05a71a5f7ee4cbef7a093a8a87dd8a908697cd" dependencies = [ "cranelift-bitset", "log", @@ -4662,9 +4652,9 @@ dependencies = [ [[package]] name = "pulley-macros" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4389e5820b1b39810ac12a27aa665320cab3caa51913a79637c06f284cfe223" +checksum = "e00101fdb6fcaf9ea98a1994be11861d7e0c910c718c41bae373c44179e3160c" dependencies = [ "proc-macro2", "quote", @@ -4819,24 +4809,13 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "rand" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ - "rand_chacha 0.9.0", + "rand_chacha", "rand_core 0.9.5", ] @@ -4851,16 +4830,6 @@ dependencies = [ "rand_core 0.10.1", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.9.0" @@ -4952,7 +4921,7 @@ dependencies = [ "paste", "profiling", "rand 0.9.4", - "rand_chacha 0.9.0", + "rand_chacha", "simd_helpers", "thiserror 2.0.18", "v_frame", @@ -5795,7 +5764,7 @@ checksum = "dcc7fe48e34d02a97bc8e6253b8b91e5a47fe2c47eaacb5149cefbb69922eaf0" dependencies = [ "ahash", "annotate-snippets", - "base64 0.21.7", + "base64 0.22.1", "encoding_rs_io", "getrandom 0.3.4", "granit-parser", @@ -6349,7 +6318,7 @@ dependencies = [ name = "streamkit-plugin-sdk-wasm" version = "0.1.0" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen 0.58.0", ] [[package]] @@ -6727,22 +6696,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-interface" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4592f674ce18521c2a81483873a49596655b179f71c5e05d10c1fe66c78745" -dependencies = [ - "bitflags 2.11.1", - "cap-fs-ext", - "cap-std", - "fd-lock", - "io-lifetimes", - "rustix 0.38.44", - "windows-sys 0.52.0", - "winx", -] - [[package]] name = "tar" version = "0.4.45" @@ -7809,9 +7762,9 @@ dependencies = [ [[package]] name = "wasm-compose" -version = "0.246.2" +version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05a2b3bad87cc1ce45b63425ec09a854cc4cb369231c9fed1fee31538103efb" +checksum = "96ba953e2b9b4b4b52a31cf4e3ee1c1374c872b6e012cf2138d1c37cba00bfd6" dependencies = [ "anyhow", "heck", @@ -7819,8 +7772,8 @@ dependencies = [ "log", "petgraph", "smallvec", - "wasm-encoder 0.246.2", - "wasmparser 0.246.2", + "wasm-encoder 0.248.0", + "wasmparser 0.248.0", "wat", ] @@ -7836,22 +7789,22 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.246.2" +version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fb705ce81adde29d2a8e99d87995e39a6e927358c91398f374474746070ef7" +checksum = "ac92cf547bc18d27ecc521015c08c353b4f18b84ab388bb6d1b6b682c620d9b6" dependencies = [ "leb128fmt", - "wasmparser 0.246.2", + "wasmparser 0.248.0", ] [[package]] name = "wasm-encoder" -version = "0.248.0" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac92cf547bc18d27ecc521015c08c353b4f18b84ab388bb6d1b6b682c620d9b6" +checksum = "5a879a421bd17c528b74721b2abf4c62e8f1d1889c2ba8c3c50d02deaf2ce395" dependencies = [ "leb128fmt", - "wasmparser 0.248.0", + "wasmparser 0.251.0", ] [[package]] @@ -7866,6 +7819,18 @@ dependencies = [ "wasmparser 0.244.0", ] +[[package]] +name = "wasm-metadata" +version = "0.251.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f998ccc6e012f7b86865eb2a106c8a0422017a1a88977ce01a69f2244be2e57" +dependencies = [ + "anyhow", + "indexmap 2.14.0", + "wasm-encoder 0.251.0", + "wasmparser 0.251.0", +] + [[package]] name = "wasm-streams" version = "0.5.0" @@ -7893,12 +7858,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.246.2" +version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71cde4757396defafd25417cfb36aa3161027d06d865b0c24baaae229aac005d" +checksum = "aa4439c5eee9df71ee0c6efb37f63b1fcb1fec38f85f5142c54e7ed05d33091a" dependencies = [ "bitflags 2.11.1", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "indexmap 2.14.0", "semver", "serde", @@ -7906,36 +7871,38 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.248.0" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4439c5eee9df71ee0c6efb37f63b1fcb1fec38f85f5142c54e7ed05d33091a" +checksum = "437970b35b1a85cfde9c74b2398352d8d653f3bd8e3a3db0c063ea8f5b4b36ff" dependencies = [ "bitflags 2.11.1", + "hashbrown 0.17.1", "indexmap 2.14.0", "semver", ] [[package]] name = "wasmprinter" -version = "0.246.2" +version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e41f7493ba994b8a779430a4c25ff550fd5a40d291693af43a6ef48688f00e3" +checksum = "30b264a5410b008d4d199a92bf536eae703cbd614482fc1ec53831cf19e1c183" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.246.2", + "wasmparser 0.248.0", ] [[package]] name = "wasmtime" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4eccc0728f061979efa8ff4c962cff7041fead4baadb74973f01b9c47158a4" +checksum = "c191891081c3bf9f10cb579819b32b0e81695641dc639eef34b57cf10c59ad81" dependencies = [ "addr2line 0.26.1", "async-trait", "bitflags 2.11.1", "bumpalo", + "bytes", "cc", "cfg-if", "encoding_rs", @@ -7961,8 +7928,8 @@ dependencies = [ "target-lexicon", "tempfile", "wasm-compose", - "wasm-encoder 0.246.2", - "wasmparser 0.246.2", + "wasm-encoder 0.248.0", + "wasmparser 0.248.0", "wasmtime-environ", "wasmtime-internal-cache", "wasmtime-internal-component-macro", @@ -7981,9 +7948,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e84dbe3208c1336a41546beb75927b3b37e2e4fce06653d214b407136fbe295" +checksum = "0f337d68a62d868f3c297517b46d20dc7e293f0da36bbee2f6ec3c30eab938bd" dependencies = [ "anyhow", "cpp_demangle", @@ -7991,7 +7958,7 @@ dependencies = [ "cranelift-bitset", "cranelift-entity", "gimli 0.33.0", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "indexmap 2.14.0", "log", "object 0.39.1", @@ -8003,8 +7970,8 @@ dependencies = [ "sha2 0.10.9", "smallvec", "target-lexicon", - "wasm-encoder 0.246.2", - "wasmparser 0.246.2", + "wasm-encoder 0.248.0", + "wasmparser 0.248.0", "wasmprinter", "wasmtime-internal-component-util", "wasmtime-internal-core", @@ -8012,9 +7979,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-cache" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910b8dcadc0888344b2dea5a087c836b58156d4f455c52b6dac0bdc776a9d029" +checksum = "5f45a4fb2a6a269100b845404f2210d874eaee9ecd9efb6fc6c1e80896fab40f" dependencies = [ "base64 0.22.1", "directories-next", @@ -8032,9 +7999,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-component-macro" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c223bd503db76df8d74d1fcca39e734d25f7a0c1dcaf1509b67f3855d1b0f803" +checksum = "ab1cc8df1940657960571d7bc9bc0eadf869c0eb95cff831a6554409f89b25b0" dependencies = [ "anyhow", "proc-macro2", @@ -8042,32 +8009,32 @@ dependencies = [ "syn 2.0.117", "wasmtime-internal-component-util", "wasmtime-internal-wit-bindgen", - "wit-parser 0.246.2", + "wit-parser 0.248.0", ] [[package]] name = "wasmtime-internal-component-util" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab123ad511483a1b918399789d0cc7dea7c5c6476743df73949007b5b225fc74" +checksum = "f73ccd2e0e6bd91fb0161a17ee5e2d7badbeba6eb7461d0e0e3991492bd3835d" [[package]] name = "wasmtime-internal-core" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4364d345719bba7fc4c435992ea1cb0c118f1e90a88c6e6f22a7a4fc507700c6" +checksum = "110bf85122cd451d3b9ff67f8911d428ec9b729208abe950a0333c3244660e88" dependencies = [ "anyhow", - "hashbrown 0.16.1", + "hashbrown 0.17.1", "libm", "serde", ] [[package]] name = "wasmtime-internal-cranelift" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a3bc28a172037c7864128bb208017a02bba659a59c27acacc048c09e25c1fc" +checksum = "b0236a21553c5b30ee953f413a8dc99729548b747219eef7e70f8288ed313ebe" dependencies = [ "cfg-if", "cranelift-codegen", @@ -8083,7 +8050,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror 2.0.18", - "wasmparser 0.246.2", + "wasmparser 0.248.0", "wasmtime-environ", "wasmtime-internal-core", "wasmtime-internal-unwinder", @@ -8092,9 +8059,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-fiber" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c90a899a47d3da6e384e7b4cad61fdcb27535a395742b32440bdf9980ea83fa" +checksum = "1ccd50931b61ad593ae91e62d41a96b997b26c9308305cae4523cfef9301d9e8" dependencies = [ "cc", "cfg-if", @@ -8107,9 +8074,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-jit-debug" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f364747aa74c686b18925918e5cfd615a73c9613c7a31fc1cd86f42df12fbe" +checksum = "b0a52ca7429272234b44f81fdf80d4793593e5c368b0f960d41fd401b1117bec" dependencies = [ "cc", "object 0.39.1", @@ -8119,9 +8086,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-jit-icache-coherence" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ba98c1492f530833e0d3cc17dbb0c3c57c9f1bb3b078ae44bb55a233e43eba" +checksum = "aa6818a4864719772680694f4e4649a8600bb5efcf71111ebaf7419b266463e8" dependencies = [ "cfg-if", "libc", @@ -8131,9 +8098,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-unwinder" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b8f8a89e8f3660646f820c7d8310a67094156bb866e9d56f1b00892e011206" +checksum = "1fdc6a69c42fbbf13104ccbf0d3c096d0392f00102e2c70b542d9fca402eb162" dependencies = [ "cfg-if", "cranelift-codegen", @@ -8144,9 +8111,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-versioned-export-macros" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a12754f1ffc4a3300d56d324c418b8b32cf029606618da22c7d076213882a3f" +checksum = "fa0bd1cd696ec4b7e6f46357c0479e7739c3858e54afb69a15765402bbc1f9dd" dependencies = [ "proc-macro2", "quote", @@ -8155,16 +8122,16 @@ dependencies = [ [[package]] name = "wasmtime-internal-winch" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b06e4ed07adc579645e5c55c67b3138c49da2e468fad52d3db7b7a098ecc733" +checksum = "5c2ca01234ef55acd10c0fa5a2f96c3fd422eba03b221e2e9572944d19a476a7" dependencies = [ "cranelift-codegen", "gimli 0.33.0", "log", "object 0.39.1", "target-lexicon", - "wasmparser 0.246.2", + "wasmparser 0.248.0", "wasmtime-environ", "wasmtime-internal-cranelift", "winch-codegen", @@ -8172,37 +8139,37 @@ dependencies = [ [[package]] name = "wasmtime-internal-wit-bindgen" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f08787948e3c983799d616ef7dd57463253e9ca8bab6607eef8134f12353f70" +checksum = "708b3d8cfaad2d33a92ec4ed93d69e9836c04f7eb5b8dfe1dde9df47c41f20b7" dependencies = [ "anyhow", "bitflags 2.11.1", "heck", "indexmap 2.14.0", - "wit-parser 0.246.2", + "wit-parser 0.248.0", ] [[package]] name = "wasmtime-wasi" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b2f19834bc6edbc31ac95fdcfd5ddcd7643759265a1d545dec36ac6cc788ca8" +checksum = "79d0c0121dcc5152390d099fb853b9a0d79e7e0a172c12cc668ea8c5d8f883c2" dependencies = [ "async-trait", "bitflags 2.11.1", "bytes", "cap-fs-ext", "cap-net-ext", - "cap-rand", "cap-std", "cap-time-ext", + "cfg-if", "fs-set-times", "futures", "io-extras", "io-lifetimes", + "rand 0.10.1", "rustix 1.1.4", - "system-interface", "thiserror 2.0.18", "tokio", "tracing", @@ -8215,9 +8182,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi-io" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e0c6efdbaf90906016be9ed9ff17b7b58f393876287beebe5bd7fa1de54dbb" +checksum = "02ca2fd53dbd62f5f95b470b43ff1e711933e8f30ebc89d9050351a72f6e5c28" dependencies = [ "async-trait", "bytes", @@ -8556,9 +8523,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b644ab90da80bbca28973192978ac452cbd876955bb209e6ff2cd1955e43a7" +checksum = "a4cd8015611a3bc95e449ad198dfd133b7488759b0dc49b515052101eb954587" dependencies = [ "bitflags 2.11.1", "thiserror 2.0.18", @@ -8570,9 +8537,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521f9d558365357274d960340eb9eb4f4d768fafdc79f381fd2e13a85b925ebc" +checksum = "5c0f655ec3eba7df68408018796911a6acdda3a41e67d6551a3766563495e333" dependencies = [ "heck", "proc-macro2", @@ -8584,9 +8551,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a386e86021363c9f0abd1e189e8f8a729d9b5aab2bb7172a3e40f2ab647a936" +checksum = "7a22f38e7b0f2a3b58bae4dd655dcedd65d56f257916a5eda5f08c40910ee9d4" dependencies = [ "proc-macro2", "quote", @@ -8633,9 +8600,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "44.0.2" +version = "45.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16496e92d2b232f9d195ae74f71a674aabae7b7fa722d39068836723d3b653c" +checksum = "35fdfab04a4d446c558a9ea994ded662d35580a17b15385b862002703aa43245" dependencies = [ "cranelift-assembler-x64", "cranelift-codegen", @@ -8644,7 +8611,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror 2.0.18", - "wasmparser 0.246.2", + "wasmparser 0.248.0", "wasmtime-environ", "wasmtime-internal-core", "wasmtime-internal-cranelift", @@ -9036,7 +9003,7 @@ version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ - "wit-bindgen-rust-macro", + "wit-bindgen-rust-macro 0.51.0", ] [[package]] @@ -9045,6 +9012,16 @@ version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" +[[package]] +name = "wit-bindgen" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a43552cfa071f246cfd99e5dbb23710dfe7336b3259e09339818483359470749" +dependencies = [ + "bitflags 2.11.1", + "wit-bindgen-rust-macro 0.58.0", +] + [[package]] name = "wit-bindgen-core" version = "0.51.0" @@ -9057,12 +9034,14 @@ dependencies = [ ] [[package]] -name = "wit-bindgen-rt" -version = "0.44.0" +name = "wit-bindgen-core" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653c85dd7aee6fe6f4bded0d242406deadae9819029ce6f7d258c920c384358a" +checksum = "4738d1c9a78e97bc7f664bfafd5d8e67d7bb26faa5c41e6d628e8bbdad3ec351" dependencies = [ - "bitflags 2.11.1", + "anyhow", + "heck", + "wit-parser 0.251.0", ] [[package]] @@ -9076,9 +9055,25 @@ dependencies = [ "indexmap 2.14.0", "prettyplease", "syn 2.0.117", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", + "wasm-metadata 0.244.0", + "wit-bindgen-core 0.51.0", + "wit-component 0.244.0", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1130ce1f531bc9f9a75922244aa773bf5e2117fda1ef4a86b9f98d6b8135eb46" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.14.0", + "prettyplease", + "syn 2.0.117", + "wasm-metadata 0.251.0", + "wit-bindgen-core 0.58.0", + "wit-component 0.251.0", ] [[package]] @@ -9092,8 +9087,24 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.117", - "wit-bindgen-core", - "wit-bindgen-rust", + "wit-bindgen-core 0.51.0", + "wit-bindgen-rust 0.51.0", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07296369e4d598e7e79b64eef66f724d83324ea671bcf677d78fc5cf92604ae5" +dependencies = [ + "anyhow", + "macro-string", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core 0.58.0", + "wit-bindgen-rust 0.58.0", ] [[package]] @@ -9110,11 +9121,30 @@ dependencies = [ "serde_derive", "serde_json", "wasm-encoder 0.244.0", - "wasm-metadata", + "wasm-metadata 0.244.0", "wasmparser 0.244.0", "wit-parser 0.244.0", ] +[[package]] +name = "wit-component" +version = "0.251.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a5e60173c413659c689f0581b0cf5d1a2404077568f9ffdce748a9eb2fc913" +dependencies = [ + "anyhow", + "bitflags 2.11.1", + "indexmap 2.14.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder 0.251.0", + "wasm-metadata 0.251.0", + "wasmparser 0.251.0", + "wit-parser 0.251.0", +] + [[package]] name = "wit-parser" version = "0.244.0" @@ -9135,12 +9165,31 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.246.2" +version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd979042b5ff288607ccf3b314145435453f20fc67173195f91062d2289b204d" +checksum = "247ad505da2915a082fe13204c5ba8788425aea1de54f43b284818cf82637856" dependencies = [ "anyhow", - "hashbrown 0.16.1", + "hashbrown 0.17.1", + "id-arena", + "indexmap 2.14.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser 0.248.0", +] + +[[package]] +name = "wit-parser" +version = "0.251.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e960732e824fab95099971a09e638979347c94ca48568d3c854c945729196947" +dependencies = [ + "anyhow", + "hashbrown 0.17.1", "id-arena", "indexmap 2.14.0", "log", @@ -9149,7 +9198,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.246.2", + "wasmparser 0.251.0", ] [[package]] diff --git a/crates/plugin-wasm/Cargo.toml b/crates/plugin-wasm/Cargo.toml index 75c05f079..d41739ef2 100644 --- a/crates/plugin-wasm/Cargo.toml +++ b/crates/plugin-wasm/Cargo.toml @@ -15,8 +15,8 @@ publish = false [dependencies] streamkit-core = { workspace = true } -wasmtime = { version = "44.0.1", features = ["component-model", "async"] } -wasmtime-wasi = "44.0.1" +wasmtime = { version = "45.0.1", features = ["component-model", "component-model-async", "async"] } +wasmtime-wasi = { version = "45.0.1", features = ["p3"] } anyhow = "1.0" tokio = { workspace = true, features = ["macros", "sync"] } @@ -29,7 +29,7 @@ serde-saphyr = { workspace = true } futures = { workspace = true } [build-dependencies] -wasmtime = { version = "44.0.1", features = ["component-model"] } +wasmtime = { version = "45.0.1", features = ["component-model"] } [dev-dependencies] tempfile = "3.27" diff --git a/crates/plugin-wasm/src/lib.rs b/crates/plugin-wasm/src/lib.rs index 109d83d6c..0c48f39eb 100644 --- a/crates/plugin-wasm/src/lib.rs +++ b/crates/plugin-wasm/src/lib.rs @@ -23,11 +23,15 @@ mod bindings { path: "../../wit", world: "plugin", imports: { default: async }, - exports: { default: async }, + exports: { default: async | store }, + with: { + "wasi": wasmtime_wasi::p3::bindings, + }, + require_store_data_send: true, }); } -use bindings::streamkit::plugin::host::Host; +use bindings::streamkit::plugin::host::{Host, HostWithStore}; pub use bindings::streamkit::plugin::types as wit_types; use bindings::Plugin; @@ -73,6 +77,7 @@ impl PluginRuntime { pub fn new(config: PluginRuntimeConfig) -> Result { let mut engine_config = Config::new(); engine_config.wasm_component_model(true); + engine_config.wasm_component_model_async(true); engine_config.wasm_simd(config.enable_simd); if !config.enable_simd { engine_config.wasm_relaxed_simd(false); @@ -82,7 +87,10 @@ impl PluginRuntime { let engine = Engine::new(&engine_config)?; let mut linker = Linker::new(&engine); + // Guests built with current toolchains (e.g. Rust's wasm32-wasip2) still + // import wasi@0.2 interfaces from std, so link both p2 and p3. wasmtime_wasi::p2::add_to_linker_async(&mut linker)?; + wasmtime_wasi::p3::add_to_linker(&mut linker)?; bindings::streamkit::plugin::host::add_to_linker::>( &mut linker, |s| s, @@ -130,12 +138,13 @@ impl PluginRuntime { let mut store = Store::new(&self.engine, host_state); store.limiter(|s| &mut s.limits); - let instance = - futures::executor::block_on(self.linker.instantiate_async(&mut store, component))?; - let plugin = Plugin::new(&mut store, &instance)?; + let metadata = futures::executor::block_on(async { + let instance = self.linker.instantiate_async(&mut store, component).await?; + let plugin = Plugin::new(&mut store, &instance)?; - let node = plugin.streamkit_plugin_node(); - let metadata = futures::executor::block_on(node.call_metadata(&mut store))?; + let node = plugin.streamkit_plugin_node(); + store.run_concurrent(async move |accessor| node.call_metadata(accessor).await).await? + })?; Ok(metadata) } @@ -251,22 +260,31 @@ impl WasiView for HostState { } } -impl Host for HostState { - async fn send_output( - &mut self, +impl HostWithStore for HasSelf { + async fn send_output( + accessor: &wasmtime::component::Accessor, pin_name: String, packet: wit_types::Packet, ) -> Result<(), String> { - if let Some(sender) = &self.output_sender { - let core_packet = streamkit_core::types::Packet::try_from(packet)?; - // Tighten lock scope: acquire lock only for the send operation - sender.lock().await.send(&pin_name, core_packet).await.map_err(|e| e.to_string())?; - Ok(()) - } else { - Err("Output sender not initialized".to_string()) - } + let sender = accessor.with(|mut access| access.get().output_sender.clone()); + send_packet_to_output(sender, &pin_name, packet).await } +} +async fn send_packet_to_output( + sender: Option>>, + pin_name: &str, + packet: wit_types::Packet, +) -> Result<(), String> { + let Some(sender) = sender else { + return Err("Output sender not initialized".to_string()); + }; + let core_packet = streamkit_core::types::Packet::try_from(packet)?; + let mut guard = sender.lock().await; + guard.send(pin_name, core_packet).await.map_err(|e| e.to_string()) +} + +impl Host for HostState { async fn log(&mut self, level: LogLevel, message: String) { match level { LogLevel::Debug => tracing::debug!("[Plugin] {}", message), @@ -640,17 +658,11 @@ mod tests { } #[tokio::test] - async fn host_state_send_output_returns_error_when_no_sender_is_attached() { - // Direct exercise of the Host trait impl: without an output_sender set, - // any send_output call must surface a clear error rather than panicking. - let mut state = HostState { - wasi: wasmtime_wasi::WasiCtx::builder().build(), - resource_table: wasmtime::component::ResourceTable::new(), - output_sender: None, - limits: wasmtime::StoreLimitsBuilder::new().memory_size(1 << 20).build(), - }; + async fn send_packet_to_output_returns_error_when_no_sender_is_attached() { + // Without an output_sender set, any send_output call must surface a + // clear error rather than panicking. let packet = wit_types::Packet::Text("hi".to_string()); - let err = ::send_output(&mut state, "out".to_string(), packet) + let err = send_packet_to_output(None, "out", packet) .await .expect_err("send_output without sender must error"); assert!( diff --git a/crates/plugin-wasm/src/wrapper.rs b/crates/plugin-wasm/src/wrapper.rs index ce9d3a87d..55cb58d70 100644 --- a/crates/plugin-wasm/src/wrapper.rs +++ b/crates/plugin-wasm/src/wrapper.rs @@ -144,11 +144,15 @@ impl ProcessorNode for WasmNodeWrapper { // Access the resource interface for `node-instance` let instance_iface = node.node_instance(); + // Drive all guest calls inside `run_concurrent` so the component-model + // async ABI can multiplex guest tasks while the host loop awaits them. + let loop_result = store + .run_concurrent(async move |accessor| { tracing::debug!(node = %node_id, "Calling plugin constructor"); // Construct a new stateful instance in the plugin with parameters let instance_handle = - match instance_iface.call_constructor(&mut store, initial_params_json.as_deref()).await + match instance_iface.call_constructor(accessor, initial_params_json.clone()).await { Ok(handle) => { tracing::debug!(node = %node_id, "Plugin constructor succeeded"); @@ -198,7 +202,7 @@ impl ProcessorNode for WasmNodeWrapper { }; match instance_iface - .call_update_params(&mut store, instance_handle, params_json.as_deref()) + .call_update_params(accessor, instance_handle, params_json) .await { Ok(Ok(())) => { @@ -255,7 +259,7 @@ impl ProcessorNode for WasmNodeWrapper { let wit_packet: wit_types::Packet = packet.into(); match instance_iface - .call_process(&mut store, instance_handle, &input_pin, &wit_packet) + .call_process(accessor, instance_handle, input_pin, wit_packet) .await { Ok(Ok(())) => {} @@ -310,7 +314,7 @@ impl ProcessorNode for WasmNodeWrapper { } // Clean up - if let Err(e) = instance_iface.call_cleanup(&mut store, instance_handle).await { + if let Err(e) = instance_iface.call_cleanup(accessor, instance_handle).await { tracing::warn!("Plugin cleanup error: {}", e); } @@ -321,6 +325,13 @@ impl ProcessorNode for WasmNodeWrapper { ); Ok(()) + }) + .await; + + match loop_result { + Ok(result) => result, + Err(e) => Err(StreamKitError::Runtime(format!("Plugin execution error: {e}"))), + } } } diff --git a/crates/plugin-wasm/tests/gain_plugin_smoke.rs b/crates/plugin-wasm/tests/gain_plugin_smoke.rs new file mode 100644 index 000000000..515d6755d --- /dev/null +++ b/crates/plugin-wasm/tests/gain_plugin_smoke.rs @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: © 2025 StreamKit Contributors +// +// SPDX-License-Identifier: MPL-2.0 + +//! End-to-end smoke test driving the prebuilt gain example plugin through the +//! WASI 0.3 async host. Ignored by default because it requires the example +//! component to be built first: +//! +//! ```sh +//! cargo build --release --target wasm32-wasip2 \ +//! --manifest-path examples/plugins/gain-wasm-rust/Cargo.toml +//! ``` + +#![allow(clippy::unwrap_used, clippy::expect_used)] + +use std::collections::HashMap; +use std::path::PathBuf; + +use streamkit_core::node::{OutputRouting, OutputSender}; +use streamkit_core::types::{AudioFrame, Packet}; +use streamkit_core::{NodeContext, PipelineMode}; +use streamkit_plugin_wasm::{PluginRuntime, PluginRuntimeConfig}; +use tokio::sync::mpsc; + +fn example_plugin_path(relative: &str) -> PathBuf { + let path = + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../examples/plugins").join(relative); + assert!(path.exists(), "{} not found; build the example first", path.display()); + path +} + +async fn run_gain_plugin(path: PathBuf, expected_kind: &str) { + let runtime = PluginRuntime::new(PluginRuntimeConfig::default()).expect("runtime"); + let plugin = runtime.load_plugin(&path).expect("load plugin"); + assert_eq!(plugin.metadata().kind, expected_kind); + + let node = + plugin.create_node(Some(&serde_json::json!({"gain_db": 6.0206}))).expect("create node"); + + let (input_tx, input_rx) = mpsc::channel(8); + let (state_tx, _state_rx) = mpsc::channel(32); + let (_control_tx, control_rx) = mpsc::channel(8); + let (routed_tx, mut routed_rx) = mpsc::channel(64); + + let mut inputs = HashMap::new(); + inputs.insert("in".to_string(), input_rx); + + let context = NodeContext { + inputs, + input_types: HashMap::new(), + control_rx, + output_sender: OutputSender::new("gain".to_string(), OutputRouting::Routed(routed_tx)), + batch_size: 1, + state_tx, + stats_tx: None, + telemetry_tx: None, + session_id: None, + cancellation_token: None, + pin_management_rx: None, + audio_pool: None, + video_pool: None, + pipeline_mode: PipelineMode::Oneshot, + view_data_tx: None, + engine_control_tx: None, + asset_root: std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")), + }; + + let handle = tokio::spawn(async move { node.run(context).await }); + + input_tx + .send(Packet::Audio(AudioFrame::new(48000, 1, vec![0.5f32; 4]))) + .await + .expect("send input"); + drop(input_tx); + + let (_node, pin, packet) = + tokio::time::timeout(std::time::Duration::from_secs(10), routed_rx.recv()) + .await + .expect("timed out waiting for plugin output") + .expect("output channel closed without packet"); + assert_eq!(&*pin, "out"); + + match packet { + Packet::Audio(frame) => { + for sample in frame.samples.iter() { + assert!((sample - 1.0).abs() < 1e-3, "expected ~2x gain, got {sample}"); + } + }, + other => panic!("unexpected packet: {other:?}"), + } + + handle.await.expect("join").expect("node run"); +} + +#[tokio::test(flavor = "multi_thread")] +#[ignore = "requires the gain example component to be prebuilt"] +async fn rust_gain_plugin_processes_audio_through_async_host() { + run_gain_plugin( + example_plugin_path("gain-wasm-rust/target/wasm32-wasip2/release/gain_plugin.wasm"), + "gain_filter_rust", + ) + .await; +} + +#[tokio::test(flavor = "multi_thread")] +#[ignore = "requires the gain example component to be prebuilt"] +async fn c_gain_plugin_processes_audio_through_async_host() { + run_gain_plugin(example_plugin_path("gain-wasm-c/build/gain_plugin_c.wasm"), "gain_filter_c") + .await; +} diff --git a/docs/src/content/docs/guides/writing-plugins.md b/docs/src/content/docs/guides/writing-plugins.md index 63932d1b1..f96320431 100644 --- a/docs/src/content/docs/guides/writing-plugins.md +++ b/docs/src/content/docs/guides/writing-plugins.md @@ -172,7 +172,7 @@ WASM plugins run in a sandboxed WebAssembly Component Model runtime. ```bash cargo new --lib my-wasm-plugin cd my-wasm-plugin -cargo install cargo-component +rustup target add wasm32-wasip2 ``` ```toml @@ -187,7 +187,7 @@ crate-type = ["cdylib"] [dependencies] streamkit-plugin-sdk-wasm = "0.1.0" -wit-bindgen = "0.44" +wit-bindgen = "0.58" serde_json = "1" ``` @@ -198,11 +198,11 @@ serde_json = "1" ```bash # Build -cargo component build --release +cargo build --release --target wasm32-wasip2 # Upload curl -X POST \ - -F plugin=@target/wasm32-wasip1/release/my_wasm_plugin.wasm \ + -F plugin=@target/wasm32-wasip2/release/my_wasm_plugin.wasm \ http://localhost:4545/api/v1/plugins ``` @@ -212,7 +212,6 @@ For complete, working examples: - `examples/plugins/gain-native` - `examples/plugins/gain-wasm-rust` -- `examples/plugins/gain-wasm-go` - `examples/plugins/gain-wasm-c` ## Next Steps diff --git a/examples/plugins/gain-wasm-c/README.md b/examples/plugins/gain-wasm-c/README.md index bde4bc917..8fff67809 100644 --- a/examples/plugins/gain-wasm-c/README.md +++ b/examples/plugins/gain-wasm-c/README.md @@ -34,7 +34,7 @@ The C plugin is expected to be comparable to or slightly smaller than Rust, with - ❌ Manual memory management (risk of memory leaks/bugs) - ❌ More verbose code (no high-level abstractions) - ❌ Requires manual JSON parsing (no serde equivalent) -- ❌ Less integrated tooling compared to Rust's `cargo component` +- ❌ Less integrated tooling compared to Rust's built-in `wasm32-wasip2` target ## Prerequisites @@ -189,7 +189,7 @@ wasm-tools component new --help - General-purpose plugins (better ergonomics, safety) - Complex state management (borrow checker prevents bugs) - Rich JSON parsing (serde) -- Integrated tooling (`cargo component`) +- Integrated tooling (built-in `wasm32-wasip2` target) **When to use Go instead:** - Familiar to Go developers diff --git a/examples/plugins/gain-wasm-c/gain_plugin.c b/examples/plugins/gain-wasm-c/gain_plugin.c index d83b713b0..415b85a9f 100644 --- a/examples/plugins/gain-wasm-c/gain_plugin.c +++ b/examples/plugins/gain-wasm-c/gain_plugin.c @@ -150,13 +150,34 @@ exports_streamkit_plugin_node_constructor_node_instance(plugin_string_t *maybe_p return exports_streamkit_plugin_node_node_instance_new((exports_streamkit_plugin_node_node_instance_t*)state); } -// Process function -bool exports_streamkit_plugin_node_method_node_instance_process( +// State kept alive across the async send-output subtask. The canonical ABI +// reads `args` lazily (while the subtask is STARTING) and writes `result` +// when it completes, so both must outlive the call. +typedef struct { + streamkit_plugin_host_send_output_args_t args; + streamkit_plugin_host_result_void_string_t result; + plugin_waitable_set_t set; +} pending_send_t; + +static plugin_callback_code_t finish_process(pending_send_t *pending) { + exports_streamkit_plugin_node_result_void_string_t ret = {0}; + if (pending->result.is_err) { + ret.is_err = true; + ret.val.err = pending->result.val.err; + } + free(pending); + exports_streamkit_plugin_node_method_node_instance_process_return(ret); + return PLUGIN_CALLBACK_CODE_EXIT; +} + +// Process function (async export: returns a callback code instead of a bool, +// reporting its result via process_return) +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_process( exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *input_pin, - exports_streamkit_plugin_node_packet_t *packet, - plugin_string_t *err) { + exports_streamkit_plugin_node_packet_t *packet) { + (void)input_pin; gain_state_t *state = (gain_state_t*)(uintptr_t)self; // Debug log @@ -168,8 +189,11 @@ bool exports_streamkit_plugin_node_method_node_instance_process( // Check if packet is audio if (packet->tag != STREAMKIT_PLUGIN_TYPES_PACKET_AUDIO) { - plugin_string_dup(err, "Gain filter only accepts audio packets"); - return false; + exports_streamkit_plugin_node_result_void_string_t ret = {0}; + ret.is_err = true; + plugin_string_dup(&ret.val.err, "Gain filter only accepts audio packets"); + exports_streamkit_plugin_node_method_node_instance_process_return(ret); + return PLUGIN_CALLBACK_CODE_EXIT; } // Apply gain to all samples (in-place modification) @@ -187,37 +211,58 @@ bool exports_streamkit_plugin_node_method_node_instance_process( plugin_string_set(&debug_msg, "[C] samples processed, sending output"); streamkit_plugin_host_log(STREAMKIT_PLUGIN_HOST_LOG_LEVEL_DEBUG, &debug_msg); - // Send output - plugin_string_t out_pin; - plugin_string_set(&out_pin, "out"); + // Send output as an async subtask + pending_send_t *pending = calloc(1, sizeof(pending_send_t)); + if (!pending) { + exports_streamkit_plugin_node_result_void_string_t ret = {0}; + ret.is_err = true; + plugin_string_dup(&ret.val.err, "Out of memory"); + exports_streamkit_plugin_node_method_node_instance_process_return(ret); + return PLUGIN_CALLBACK_CODE_EXIT; + } + plugin_string_set(&pending->args.pin_name, "out"); + pending->args.packet = *packet; - plugin_string_t send_err = {0}; // Initialize to zero - bool send_ok = streamkit_plugin_host_send_output(&out_pin, packet, &send_err); + plugin_subtask_status_t status = + streamkit_plugin_host_send_output(&pending->args, &pending->result); - if (!send_ok) { - plugin_string_set(&debug_msg, "[C] send_output failed"); - streamkit_plugin_host_log(STREAMKIT_PLUGIN_HOST_LOG_LEVEL_ERROR, &debug_msg); - // Forward error from send_output - *err = send_err; - return false; + if (PLUGIN_SUBTASK_STATE(status) == PLUGIN_SUBTASK_RETURNED) { + return finish_process(pending); } - plugin_string_set(&debug_msg, "[C] process() completed successfully"); - streamkit_plugin_host_log(STREAMKIT_PLUGIN_HOST_LOG_LEVEL_DEBUG, &debug_msg); + // The host hasn't completed the send yet: park the subtask in a waitable + // set and resume from the callback when it completes. + pending->set = plugin_waitable_set_new(); + plugin_waitable_join(PLUGIN_SUBTASK_HANDLE(status), pending->set); + plugin_context_set_0(pending); + return PLUGIN_CALLBACK_CODE_WAIT(pending->set); +} + +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_process_callback( + plugin_event_t *event) { + pending_send_t *pending = plugin_context_get_0(); + + if (event->event != PLUGIN_EVENT_SUBTASK || + PLUGIN_SUBTASK_STATE(event->code) != PLUGIN_SUBTASK_RETURNED) { + return PLUGIN_CALLBACK_CODE_WAIT(pending->set); + } - return true; + plugin_subtask_drop(event->waitable); + plugin_waitable_set_drop(pending->set); + return finish_process(pending); } -// Update params function -bool exports_streamkit_plugin_node_method_node_instance_update_params( +// Update params function (async export, but completes synchronously) +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_update_params( exports_streamkit_plugin_node_borrow_node_instance_t self, - plugin_string_t *maybe_params, - plugin_string_t *err) { + plugin_string_t *maybe_params) { gain_state_t *state = (gain_state_t*)(uintptr_t)self; + exports_streamkit_plugin_node_result_void_string_t ok = {0}; if (!maybe_params || !maybe_params->ptr || maybe_params->len == 0) { - return true; + exports_streamkit_plugin_node_method_node_instance_update_params_return(ok); + return PLUGIN_CALLBACK_CODE_EXIT; } float gain_db = parse_gain_db((const char*)maybe_params->ptr, maybe_params->len); @@ -234,7 +279,14 @@ bool exports_streamkit_plugin_node_method_node_instance_update_params( plugin_string_set(&log_msg, log_buffer); streamkit_plugin_host_log(STREAMKIT_PLUGIN_HOST_LOG_LEVEL_INFO, &log_msg); - return true; + exports_streamkit_plugin_node_method_node_instance_update_params_return(ok); + return PLUGIN_CALLBACK_CODE_EXIT; +} + +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_update_params_callback( + plugin_event_t *event) { + (void)event; + return PLUGIN_CALLBACK_CODE_EXIT; } // Cleanup function diff --git a/examples/plugins/gain-wasm-c/plugin.c b/examples/plugins/gain-wasm-c/plugin.c deleted file mode 100644 index c63c16a07..000000000 --- a/examples/plugins/gain-wasm-c/plugin.c +++ /dev/null @@ -1,4819 +0,0 @@ -/* - * SPDX-FileCopyrightText: © 2025 StreamKit Contributors - * - * SPDX-License-Identifier: MPL-2.0 - */ - -// Generated by `wit-bindgen` 0.44.0. DO NOT EDIT! -#include "plugin.h" -#include -#include - -// Imported Functions from `streamkit:plugin/host@0.1.0` - -__attribute__((__import_module__("streamkit:plugin/host@0.1.0"), __import_name__("send-output"))) -extern void __wasm_import_streamkit_plugin_host_send_output(uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("streamkit:plugin/host@0.1.0"), __import_name__("log"))) -extern void __wasm_import_streamkit_plugin_host_log(int32_t, uint8_t *, size_t); - -// Imported Functions from `wasi:cli/environment@0.2.0` - -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-environment"))) -extern void __wasm_import_wasi_cli_environment_get_environment(uint8_t *); - -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-arguments"))) -extern void __wasm_import_wasi_cli_environment_get_arguments(uint8_t *); - -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("initial-cwd"))) -extern void __wasm_import_wasi_cli_environment_initial_cwd(uint8_t *); - -// Imported Functions from `wasi:cli/exit@0.2.0` - -__attribute__((__import_module__("wasi:cli/exit@0.2.0"), __import_name__("exit"))) -extern void __wasm_import_wasi_cli_exit_exit(int32_t); - -// Imported Functions from `wasi:io/error@0.2.0` - -__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[method]error.to-debug-string"))) -extern void __wasm_import_wasi_io_error_method_error_to_debug_string(int32_t, uint8_t *); - -// Imported Functions from `wasi:io/poll@0.2.0` - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.ready"))) -extern int32_t __wasm_import_wasi_io_poll_method_pollable_ready(int32_t); - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.block"))) -extern void __wasm_import_wasi_io_poll_method_pollable_block(int32_t); - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("poll"))) -extern void __wasm_import_wasi_io_poll_poll(uint8_t *, size_t, uint8_t *); - -// Imported Functions from `wasi:io/streams@0.2.0` - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.read"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_read(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-read"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_blocking_read(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.skip"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_skip(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-skip"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_blocking_skip(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.subscribe"))) -extern int32_t __wasm_import_wasi_io_streams_method_input_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.check-write"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_check_write(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_write(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-and-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_write_and_flush(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_flush(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_flush(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.subscribe"))) -extern int32_t __wasm_import_wasi_io_streams_method_output_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write-zeroes"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_write_zeroes(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-zeroes-and-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.splice"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_splice(int32_t, int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-splice"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_splice(int32_t, int32_t, int64_t, uint8_t *); - -// Imported Functions from `wasi:cli/stdin@0.2.0` - -__attribute__((__import_module__("wasi:cli/stdin@0.2.0"), __import_name__("get-stdin"))) -extern int32_t __wasm_import_wasi_cli_stdin_get_stdin(void); - -// Imported Functions from `wasi:cli/stdout@0.2.0` - -__attribute__((__import_module__("wasi:cli/stdout@0.2.0"), __import_name__("get-stdout"))) -extern int32_t __wasm_import_wasi_cli_stdout_get_stdout(void); - -// Imported Functions from `wasi:cli/stderr@0.2.0` - -__attribute__((__import_module__("wasi:cli/stderr@0.2.0"), __import_name__("get-stderr"))) -extern int32_t __wasm_import_wasi_cli_stderr_get_stderr(void); - -// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` - -__attribute__((__import_module__("wasi:cli/terminal-stdin@0.2.0"), __import_name__("get-terminal-stdin"))) -extern void __wasm_import_wasi_cli_terminal_stdin_get_terminal_stdin(uint8_t *); - -// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` - -__attribute__((__import_module__("wasi:cli/terminal-stdout@0.2.0"), __import_name__("get-terminal-stdout"))) -extern void __wasm_import_wasi_cli_terminal_stdout_get_terminal_stdout(uint8_t *); - -// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` - -__attribute__((__import_module__("wasi:cli/terminal-stderr@0.2.0"), __import_name__("get-terminal-stderr"))) -extern void __wasm_import_wasi_cli_terminal_stderr_get_terminal_stderr(uint8_t *); - -// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` - -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("now"))) -extern int64_t __wasm_import_wasi_clocks_monotonic_clock_now(void); - -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("resolution"))) -extern int64_t __wasm_import_wasi_clocks_monotonic_clock_resolution(void); - -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-instant"))) -extern int32_t __wasm_import_wasi_clocks_monotonic_clock_subscribe_instant(int64_t); - -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-duration"))) -extern int32_t __wasm_import_wasi_clocks_monotonic_clock_subscribe_duration(int64_t); - -// Imported Functions from `wasi:clocks/wall-clock@0.2.0` - -__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("now"))) -extern void __wasm_import_wasi_clocks_wall_clock_now(uint8_t *); - -__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("resolution"))) -extern void __wasm_import_wasi_clocks_wall_clock_resolution(uint8_t *); - -// Imported Functions from `wasi:filesystem/types@0.2.0` - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-via-stream"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_read_via_stream(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write-via-stream"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.append-via-stream"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.advise"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync-data"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_sync_data(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-flags"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_get_flags(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-type"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_get_type(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-size"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_read(int32_t, int64_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_write(int32_t, uint8_t *, size_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-directory"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_read_directory(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_sync(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.create-directory-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_stat(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_stat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.link-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_link_at(int32_t, int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.open-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_open_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.readlink-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.remove-directory-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.rename-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_rename_at(int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.symlink-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.unlink-file-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.is-same-object"))) -extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object(int32_t, int32_t); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]directory-entry-stream.read-directory-entry"))) -extern void __wasm_import_wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("filesystem-error-code"))) -extern void __wasm_import_wasi_filesystem_types_filesystem_error_code(int32_t, uint8_t *); - -// Imported Functions from `wasi:filesystem/preopens@0.2.0` - -__attribute__((__import_module__("wasi:filesystem/preopens@0.2.0"), __import_name__("get-directories"))) -extern void __wasm_import_wasi_filesystem_preopens_get_directories(uint8_t *); - -// Imported Functions from `wasi:sockets/instance-network@0.2.0` - -__attribute__((__import_module__("wasi:sockets/instance-network@0.2.0"), __import_name__("instance-network"))) -extern int32_t __wasm_import_wasi_sockets_instance_network_instance_network(void); - -// Imported Functions from `wasi:sockets/udp@0.2.0` - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.start-bind"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.finish-bind"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_finish_bind(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.stream"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_stream(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.local-address"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_local_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.remote-address"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_remote_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.address-family"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_udp_socket_address_family(int32_t); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.unicast-hop-limit"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_unicast_hop_limit(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_receive_buffer_size(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.send-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_send_buffer_size(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-send-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_udp_socket_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.receive"))) -extern void __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_receive(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.check-send"))) -extern void __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_check_send(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.send"))) -extern void __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_send(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(int32_t); - -// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` - -__attribute__((__import_module__("wasi:sockets/udp-create-socket@0.2.0"), __import_name__("create-udp-socket"))) -extern void __wasm_import_wasi_sockets_udp_create_socket_create_udp_socket(int32_t, uint8_t *); - -// Imported Functions from `wasi:sockets/tcp@0.2.0` - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-bind"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-bind"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_bind(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-connect"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-connect"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_connect(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-listen"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_listen(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-listen"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_listen(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.accept"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_accept(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.local-address"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_local_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.remote-address"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_remote_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.is-listening"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_is_listening(int32_t); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.address-family"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_address_family(int32_t); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-enabled"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-idle-time"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-interval"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-count"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_count(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.hop-limit"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_hop_limit(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-hop-limit"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_hop_limit(int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.send-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_send_buffer_size(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.shutdown"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_shutdown(int32_t, int32_t, uint8_t *); - -// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` - -__attribute__((__import_module__("wasi:sockets/tcp-create-socket@0.2.0"), __import_name__("create-tcp-socket"))) -extern void __wasm_import_wasi_sockets_tcp_create_socket_create_tcp_socket(int32_t, uint8_t *); - -// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.resolve-next-address"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("resolve-addresses"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses(int32_t, uint8_t *, size_t, uint8_t *); - -// Imported Functions from `wasi:random/random@0.2.0` - -__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-bytes"))) -extern void __wasm_import_wasi_random_random_get_random_bytes(int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-u64"))) -extern int64_t __wasm_import_wasi_random_random_get_random_u64(void); - -// Imported Functions from `wasi:random/insecure@0.2.0` - -__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-bytes"))) -extern void __wasm_import_wasi_random_insecure_get_insecure_random_bytes(int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-u64"))) -extern int64_t __wasm_import_wasi_random_insecure_get_insecure_random_u64(void); - -// Imported Functions from `wasi:random/insecure-seed@0.2.0` - -__attribute__((__import_module__("wasi:random/insecure-seed@0.2.0"), __import_name__("insecure-seed"))) -extern void __wasm_import_wasi_random_insecure_seed_insecure_seed(uint8_t *); - -// Exported Functions from `streamkit:plugin/node@0.1.0` - -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#metadata"))) -void __wasm_export_exports_streamkit_plugin_node_metadata_post_return(uint8_t * arg0) { - if ((*((size_t*) (arg0 + sizeof(void*)))) > 0) { - free(*((uint8_t **) (arg0 + 0))); - } - size_t len0 = *((size_t*) (arg0 + (3*sizeof(void*)))); - if (len0 > 0) { - uint8_t *ptr1 = *((uint8_t **) (arg0 + (2*sizeof(void*)))); - for (size_t i2 = 0; i2 < len0; i2++) { - uint8_t *base = ptr1 + i2 * (4*sizeof(void*)); - (void) base; - if ((*((size_t*) (base + sizeof(void*)))) > 0) { - free(*((uint8_t **) (base + 0))); - } - size_t len = *((size_t*) (base + (3*sizeof(void*)))); - if (len > 0) { - uint8_t *ptr = *((uint8_t **) (base + (2*sizeof(void*)))); - for (size_t i = 0; i < len; i++) { - uint8_t *base = ptr + i * 12; - (void) base; - } - free(ptr); - } - } - free(ptr1); - } - size_t len3 = *((size_t*) (arg0 + (5*sizeof(void*)))); - if (len3 > 0) { - uint8_t *ptr4 = *((uint8_t **) (arg0 + (4*sizeof(void*)))); - for (size_t i5 = 0; i5 < len3; i5++) { - uint8_t *base = ptr4 + i5 * (8+3*sizeof(void*)); - (void) base; - if ((*((size_t*) (base + sizeof(void*)))) > 0) { - free(*((uint8_t **) (base + 0))); - } - } - free(ptr4); - } - if ((*((size_t*) (arg0 + (7*sizeof(void*))))) > 0) { - free(*((uint8_t **) (arg0 + (6*sizeof(void*))))); - } - size_t len6 = *((size_t*) (arg0 + (9*sizeof(void*)))); - if (len6 > 0) { - uint8_t *ptr7 = *((uint8_t **) (arg0 + (8*sizeof(void*)))); - for (size_t i8 = 0; i8 < len6; i8++) { - uint8_t *base = ptr7 + i8 * (2*sizeof(void*)); - (void) base; - if ((*((size_t*) (base + sizeof(void*)))) > 0) { - free(*((uint8_t **) (base + 0))); - } - } - free(ptr7); - } -} - - -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.process"))) -void __wasm_export_exports_streamkit_plugin_node_method_node_instance_process_post_return(uint8_t * arg0) { - switch ((int32_t) (int32_t) *((uint8_t*) (arg0 + 0))) { - case 0: { - break; - } - case 1: { - if ((*((size_t*) (arg0 + (2*sizeof(void*))))) > 0) { - free(*((uint8_t **) (arg0 + sizeof(void*)))); - } - break; - } - } -} - -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.update-params"))) -void __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params_post_return(uint8_t * arg0) { - switch ((int32_t) (int32_t) *((uint8_t*) (arg0 + 0))) { - case 0: { - break; - } - case 1: { - if ((*((size_t*) (arg0 + (2*sizeof(void*))))) > 0) { - free(*((uint8_t **) (arg0 + sizeof(void*)))); - } - break; - } - } -} - - -// Canonical ABI intrinsics - -__attribute__((__weak__, __export_name__("cabi_realloc"))) -void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { - (void) old_size; - if (new_size == 0) return (void*) align; - void *ret = realloc(ptr, new_size); - if (!ret) abort(); - return ret; -} - -__attribute__((__aligned__(sizeof(void*)))) -static uint8_t RET_AREA[(10*sizeof(void*))]; - -// Helper Functions - -void streamkit_plugin_types_packet_type_free(streamkit_plugin_types_packet_type_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - } -} - -void streamkit_plugin_types_list_packet_type_free(streamkit_plugin_types_list_packet_type_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - streamkit_plugin_types_packet_type_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - streamkit_plugin_types_packet_type_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void streamkit_plugin_types_input_pin_free(streamkit_plugin_types_input_pin_t *ptr) { - plugin_string_free(&ptr->name); - streamkit_plugin_types_list_packet_type_free(&ptr->accepts_types); -} - -void streamkit_plugin_types_output_pin_free(streamkit_plugin_types_output_pin_t *ptr) { - plugin_string_free(&ptr->name); - streamkit_plugin_types_packet_type_free(&ptr->produces_type); -} - -void streamkit_plugin_types_list_input_pin_free(streamkit_plugin_types_list_input_pin_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - streamkit_plugin_types_input_pin_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - streamkit_plugin_types_input_pin_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void streamkit_plugin_types_list_output_pin_free(streamkit_plugin_types_list_output_pin_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - streamkit_plugin_types_output_pin_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - streamkit_plugin_types_output_pin_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void plugin_list_string_free(plugin_list_string_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - plugin_string_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - plugin_string_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void streamkit_plugin_types_node_metadata_free(streamkit_plugin_types_node_metadata_t *ptr) { - plugin_string_free(&ptr->kind); - streamkit_plugin_types_list_input_pin_free(&ptr->inputs); - streamkit_plugin_types_list_output_pin_free(&ptr->outputs); - plugin_string_free(&ptr->param_schema); - plugin_list_string_free(&ptr->categories); -} - -void plugin_list_f32_free(plugin_list_f32_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - float *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } -} - -void streamkit_plugin_types_audio_frame_free(streamkit_plugin_types_audio_frame_t *ptr) { - plugin_list_f32_free(&ptr->samples); -} - -void plugin_list_u8_free(plugin_list_u8_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - uint8_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } -} - -void streamkit_plugin_types_packet_free(streamkit_plugin_types_packet_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - streamkit_plugin_types_audio_frame_free(&ptr->val.audio); - break; - } - case 1: { - plugin_string_free(&ptr->val.text); - break; - } - case 2: { - plugin_list_u8_free(&ptr->val.binary); - break; - } - } -} - -void streamkit_plugin_host_packet_free(streamkit_plugin_host_packet_t *ptr) { - streamkit_plugin_types_packet_free(ptr); -} - -void streamkit_plugin_host_result_void_string_free(streamkit_plugin_host_result_void_string_t *ptr) { - if (!ptr->is_err) { - } else { - plugin_string_free(&ptr->val.err); - } -} - -void plugin_tuple2_string_string_free(plugin_tuple2_string_string_t *ptr) { - plugin_string_free(&ptr->f0); - plugin_string_free(&ptr->f1); -} - -void plugin_list_tuple2_string_string_free(plugin_list_tuple2_string_string_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - plugin_tuple2_string_string_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - plugin_tuple2_string_string_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void plugin_option_string_free(plugin_option_string_t *ptr) { - if (ptr->is_some) { - plugin_string_free(&ptr->val); - } -} - -void wasi_cli_exit_result_void_void_free(wasi_cli_exit_result_void_void_t *ptr) { - if (!ptr->is_err) { - } -} - -__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[resource-drop]error"))) -extern void __wasm_import_wasi_io_error_error_drop(int32_t handle); - -void wasi_io_error_error_drop_own(wasi_io_error_own_error_t handle) { - __wasm_import_wasi_io_error_error_drop(handle.__handle); -} - -void wasi_io_error_error_drop_borrow(wasi_io_error_borrow_error_t handle) { - __wasm_import_wasi_io_error_error_drop(handle.__handle); -} - -wasi_io_error_borrow_error_t wasi_io_error_borrow_error(wasi_io_error_own_error_t arg) { - return (wasi_io_error_borrow_error_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[resource-drop]pollable"))) -extern void __wasm_import_wasi_io_poll_pollable_drop(int32_t handle); - -void wasi_io_poll_pollable_drop_own(wasi_io_poll_own_pollable_t handle) { - __wasm_import_wasi_io_poll_pollable_drop(handle.__handle); -} - -void wasi_io_poll_pollable_drop_borrow(wasi_io_poll_borrow_pollable_t handle) { - __wasm_import_wasi_io_poll_pollable_drop(handle.__handle); -} - -wasi_io_poll_borrow_pollable_t wasi_io_poll_borrow_pollable(wasi_io_poll_own_pollable_t arg) { - return (wasi_io_poll_borrow_pollable_t) { arg.__handle }; -} - -void wasi_io_poll_list_borrow_pollable_free(wasi_io_poll_list_borrow_pollable_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_io_poll_borrow_pollable_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } -} - -void plugin_list_u32_free(plugin_list_u32_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - uint32_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } -} - -void wasi_io_streams_stream_error_free(wasi_io_streams_stream_error_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - } -} - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]input-stream"))) -extern void __wasm_import_wasi_io_streams_input_stream_drop(int32_t handle); - -void wasi_io_streams_input_stream_drop_own(wasi_io_streams_own_input_stream_t handle) { - __wasm_import_wasi_io_streams_input_stream_drop(handle.__handle); -} - -void wasi_io_streams_input_stream_drop_borrow(wasi_io_streams_borrow_input_stream_t handle) { - __wasm_import_wasi_io_streams_input_stream_drop(handle.__handle); -} - -wasi_io_streams_borrow_input_stream_t wasi_io_streams_borrow_input_stream(wasi_io_streams_own_input_stream_t arg) { - return (wasi_io_streams_borrow_input_stream_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]output-stream"))) -extern void __wasm_import_wasi_io_streams_output_stream_drop(int32_t handle); - -void wasi_io_streams_output_stream_drop_own(wasi_io_streams_own_output_stream_t handle) { - __wasm_import_wasi_io_streams_output_stream_drop(handle.__handle); -} - -void wasi_io_streams_output_stream_drop_borrow(wasi_io_streams_borrow_output_stream_t handle) { - __wasm_import_wasi_io_streams_output_stream_drop(handle.__handle); -} - -wasi_io_streams_borrow_output_stream_t wasi_io_streams_borrow_output_stream(wasi_io_streams_own_output_stream_t arg) { - return (wasi_io_streams_borrow_output_stream_t) { arg.__handle }; -} - -void wasi_io_streams_result_list_u8_stream_error_free(wasi_io_streams_result_list_u8_stream_error_t *ptr) { - if (!ptr->is_err) { - } else { - wasi_io_streams_stream_error_free(&ptr->val.err); - } -} - -void wasi_io_streams_result_u64_stream_error_free(wasi_io_streams_result_u64_stream_error_t *ptr) { - if (!ptr->is_err) { - } else { - wasi_io_streams_stream_error_free(&ptr->val.err); - } -} - -void wasi_io_streams_result_void_stream_error_free(wasi_io_streams_result_void_stream_error_t *ptr) { - if (!ptr->is_err) { - } else { - wasi_io_streams_stream_error_free(&ptr->val.err); - } -} - -__attribute__((__import_module__("wasi:cli/terminal-input@0.2.0"), __import_name__("[resource-drop]terminal-input"))) -extern void __wasm_import_wasi_cli_terminal_input_terminal_input_drop(int32_t handle); - -void wasi_cli_terminal_input_terminal_input_drop_own(wasi_cli_terminal_input_own_terminal_input_t handle) { - __wasm_import_wasi_cli_terminal_input_terminal_input_drop(handle.__handle); -} - -void wasi_cli_terminal_input_terminal_input_drop_borrow(wasi_cli_terminal_input_borrow_terminal_input_t handle) { - __wasm_import_wasi_cli_terminal_input_terminal_input_drop(handle.__handle); -} - -wasi_cli_terminal_input_borrow_terminal_input_t wasi_cli_terminal_input_borrow_terminal_input(wasi_cli_terminal_input_own_terminal_input_t arg) { - return (wasi_cli_terminal_input_borrow_terminal_input_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:cli/terminal-output@0.2.0"), __import_name__("[resource-drop]terminal-output"))) -extern void __wasm_import_wasi_cli_terminal_output_terminal_output_drop(int32_t handle); - -void wasi_cli_terminal_output_terminal_output_drop_own(wasi_cli_terminal_output_own_terminal_output_t handle) { - __wasm_import_wasi_cli_terminal_output_terminal_output_drop(handle.__handle); -} - -void wasi_cli_terminal_output_terminal_output_drop_borrow(wasi_cli_terminal_output_borrow_terminal_output_t handle) { - __wasm_import_wasi_cli_terminal_output_terminal_output_drop(handle.__handle); -} - -wasi_cli_terminal_output_borrow_terminal_output_t wasi_cli_terminal_output_borrow_terminal_output(wasi_cli_terminal_output_own_terminal_output_t arg) { - return (wasi_cli_terminal_output_borrow_terminal_output_t) { arg.__handle }; -} - -void wasi_cli_terminal_stdin_option_own_terminal_input_free(wasi_cli_terminal_stdin_option_own_terminal_input_t *ptr) { - if (ptr->is_some) { - } -} - -void wasi_cli_terminal_stdout_option_own_terminal_output_free(wasi_cli_terminal_stdout_option_own_terminal_output_t *ptr) { - if (ptr->is_some) { - } -} - -void wasi_cli_terminal_stderr_option_own_terminal_output_free(wasi_cli_terminal_stderr_option_own_terminal_output_t *ptr) { - if (ptr->is_some) { - } -} - -void wasi_filesystem_types_option_datetime_free(wasi_filesystem_types_option_datetime_t *ptr) { - if (ptr->is_some) { - } -} - -void wasi_filesystem_types_descriptor_stat_free(wasi_filesystem_types_descriptor_stat_t *ptr) { - wasi_filesystem_types_option_datetime_free(&ptr->data_access_timestamp); - wasi_filesystem_types_option_datetime_free(&ptr->data_modification_timestamp); - wasi_filesystem_types_option_datetime_free(&ptr->status_change_timestamp); -} - -void wasi_filesystem_types_new_timestamp_free(wasi_filesystem_types_new_timestamp_t *ptr) { - switch ((int32_t) ptr->tag) { - case 2: { - break; - } - } -} - -void wasi_filesystem_types_directory_entry_free(wasi_filesystem_types_directory_entry_t *ptr) { - plugin_string_free(&ptr->name); -} - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]descriptor"))) -extern void __wasm_import_wasi_filesystem_types_descriptor_drop(int32_t handle); - -void wasi_filesystem_types_descriptor_drop_own(wasi_filesystem_types_own_descriptor_t handle) { - __wasm_import_wasi_filesystem_types_descriptor_drop(handle.__handle); -} - -void wasi_filesystem_types_descriptor_drop_borrow(wasi_filesystem_types_borrow_descriptor_t handle) { - __wasm_import_wasi_filesystem_types_descriptor_drop(handle.__handle); -} - -wasi_filesystem_types_borrow_descriptor_t wasi_filesystem_types_borrow_descriptor(wasi_filesystem_types_own_descriptor_t arg) { - return (wasi_filesystem_types_borrow_descriptor_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]directory-entry-stream"))) -extern void __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(int32_t handle); - -void wasi_filesystem_types_directory_entry_stream_drop_own(wasi_filesystem_types_own_directory_entry_stream_t handle) { - __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(handle.__handle); -} - -void wasi_filesystem_types_directory_entry_stream_drop_borrow(wasi_filesystem_types_borrow_directory_entry_stream_t handle) { - __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(handle.__handle); -} - -wasi_filesystem_types_borrow_directory_entry_stream_t wasi_filesystem_types_borrow_directory_entry_stream(wasi_filesystem_types_own_directory_entry_stream_t arg) { - return (wasi_filesystem_types_borrow_directory_entry_stream_t) { arg.__handle }; -} - -void wasi_filesystem_types_result_own_input_stream_error_code_free(wasi_filesystem_types_result_own_input_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_own_output_stream_error_code_free(wasi_filesystem_types_result_own_output_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_void_error_code_free(wasi_filesystem_types_result_void_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_descriptor_flags_error_code_free(wasi_filesystem_types_result_descriptor_flags_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_descriptor_type_error_code_free(wasi_filesystem_types_result_descriptor_type_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_filesize_error_code_free(wasi_filesystem_types_result_filesize_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_types_result_own_directory_entry_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_descriptor_stat_error_code_free(wasi_filesystem_types_result_descriptor_stat_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_filesystem_types_descriptor_stat_free(&ptr->val.ok); - } else { - } -} - -void wasi_filesystem_types_result_own_descriptor_error_code_free(wasi_filesystem_types_result_own_descriptor_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_string_error_code_free(wasi_filesystem_types_result_string_error_code_t *ptr) { - if (!ptr->is_err) { - plugin_string_free(&ptr->val.ok); - } else { - } -} - -void wasi_filesystem_types_result_metadata_hash_value_error_code_free(wasi_filesystem_types_result_metadata_hash_value_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_option_directory_entry_free(wasi_filesystem_types_option_directory_entry_t *ptr) { - if (ptr->is_some) { - wasi_filesystem_types_directory_entry_free(&ptr->val); - } -} - -void wasi_filesystem_types_result_option_directory_entry_error_code_free(wasi_filesystem_types_result_option_directory_entry_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_filesystem_types_option_directory_entry_free(&ptr->val.ok); - } else { - } -} - -void wasi_filesystem_types_option_error_code_free(wasi_filesystem_types_option_error_code_t *ptr) { - if (ptr->is_some) { - } -} - -void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr) { - plugin_string_free(&ptr->f1); -} - -void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_filesystem_preopens_tuple2_own_descriptor_string_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - wasi_filesystem_preopens_tuple2_own_descriptor_string_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -__attribute__((__import_module__("wasi:sockets/network@0.2.0"), __import_name__("[resource-drop]network"))) -extern void __wasm_import_wasi_sockets_network_network_drop(int32_t handle); - -void wasi_sockets_network_network_drop_own(wasi_sockets_network_own_network_t handle) { - __wasm_import_wasi_sockets_network_network_drop(handle.__handle); -} - -void wasi_sockets_network_network_drop_borrow(wasi_sockets_network_borrow_network_t handle) { - __wasm_import_wasi_sockets_network_network_drop(handle.__handle); -} - -wasi_sockets_network_borrow_network_t wasi_sockets_network_borrow_network(wasi_sockets_network_own_network_t arg) { - return (wasi_sockets_network_borrow_network_t) { arg.__handle }; -} - -void wasi_sockets_network_ip_address_free(wasi_sockets_network_ip_address_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - case 1: { - break; - } - } -} - -void wasi_sockets_network_ip_socket_address_free(wasi_sockets_network_ip_socket_address_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - case 1: { - break; - } - } -} - -void wasi_sockets_udp_ip_socket_address_free(wasi_sockets_udp_ip_socket_address_t *ptr) { - wasi_sockets_network_ip_socket_address_free(ptr); -} - -void wasi_sockets_udp_incoming_datagram_free(wasi_sockets_udp_incoming_datagram_t *ptr) { - wasi_sockets_udp_ip_socket_address_free(&ptr->remote_address); -} - -void wasi_sockets_udp_option_ip_socket_address_free(wasi_sockets_udp_option_ip_socket_address_t *ptr) { - if (ptr->is_some) { - wasi_sockets_udp_ip_socket_address_free(&ptr->val); - } -} - -void wasi_sockets_udp_outgoing_datagram_free(wasi_sockets_udp_outgoing_datagram_t *ptr) { - wasi_sockets_udp_option_ip_socket_address_free(&ptr->remote_address); -} - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]udp-socket"))) -extern void __wasm_import_wasi_sockets_udp_udp_socket_drop(int32_t handle); - -void wasi_sockets_udp_udp_socket_drop_own(wasi_sockets_udp_own_udp_socket_t handle) { - __wasm_import_wasi_sockets_udp_udp_socket_drop(handle.__handle); -} - -void wasi_sockets_udp_udp_socket_drop_borrow(wasi_sockets_udp_borrow_udp_socket_t handle) { - __wasm_import_wasi_sockets_udp_udp_socket_drop(handle.__handle); -} - -wasi_sockets_udp_borrow_udp_socket_t wasi_sockets_udp_borrow_udp_socket(wasi_sockets_udp_own_udp_socket_t arg) { - return (wasi_sockets_udp_borrow_udp_socket_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]incoming-datagram-stream"))) -extern void __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(int32_t handle); - -void wasi_sockets_udp_incoming_datagram_stream_drop_own(wasi_sockets_udp_own_incoming_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(handle.__handle); -} - -void wasi_sockets_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_incoming_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(handle.__handle); -} - -wasi_sockets_udp_borrow_incoming_datagram_stream_t wasi_sockets_udp_borrow_incoming_datagram_stream(wasi_sockets_udp_own_incoming_datagram_stream_t arg) { - return (wasi_sockets_udp_borrow_incoming_datagram_stream_t) { arg.__handle }; -} - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]outgoing-datagram-stream"))) -extern void __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(int32_t handle); - -void wasi_sockets_udp_outgoing_datagram_stream_drop_own(wasi_sockets_udp_own_outgoing_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(handle.__handle); -} - -void wasi_sockets_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_outgoing_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(handle.__handle); -} - -wasi_sockets_udp_borrow_outgoing_datagram_stream_t wasi_sockets_udp_borrow_outgoing_datagram_stream(wasi_sockets_udp_own_outgoing_datagram_stream_t arg) { - return (wasi_sockets_udp_borrow_outgoing_datagram_stream_t) { arg.__handle }; -} - -void wasi_sockets_udp_result_void_error_code_free(wasi_sockets_udp_result_void_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_udp_result_ip_socket_address_error_code_free(wasi_sockets_udp_result_ip_socket_address_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_udp_ip_socket_address_free(&ptr->val.ok); - } else { - } -} - -void wasi_sockets_udp_result_u8_error_code_free(wasi_sockets_udp_result_u8_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_udp_result_u64_error_code_free(wasi_sockets_udp_result_u64_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_udp_list_incoming_datagram_free(wasi_sockets_udp_list_incoming_datagram_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_sockets_udp_incoming_datagram_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - wasi_sockets_udp_incoming_datagram_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void wasi_sockets_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_udp_result_list_incoming_datagram_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_udp_list_incoming_datagram_free(&ptr->val.ok); - } else { - } -} - -void wasi_sockets_udp_list_outgoing_datagram_free(wasi_sockets_udp_list_outgoing_datagram_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_sockets_udp_outgoing_datagram_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - wasi_sockets_udp_outgoing_datagram_free(&list_ptr[i]); - } - free(list_ptr); - } -} - -void wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_ip_socket_address_free(wasi_sockets_tcp_ip_socket_address_t *ptr) { - wasi_sockets_network_ip_socket_address_free(ptr); -} - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[resource-drop]tcp-socket"))) -extern void __wasm_import_wasi_sockets_tcp_tcp_socket_drop(int32_t handle); - -void wasi_sockets_tcp_tcp_socket_drop_own(wasi_sockets_tcp_own_tcp_socket_t handle) { - __wasm_import_wasi_sockets_tcp_tcp_socket_drop(handle.__handle); -} - -void wasi_sockets_tcp_tcp_socket_drop_borrow(wasi_sockets_tcp_borrow_tcp_socket_t handle) { - __wasm_import_wasi_sockets_tcp_tcp_socket_drop(handle.__handle); -} - -wasi_sockets_tcp_borrow_tcp_socket_t wasi_sockets_tcp_borrow_tcp_socket(wasi_sockets_tcp_own_tcp_socket_t arg) { - return (wasi_sockets_tcp_borrow_tcp_socket_t) { arg.__handle }; -} - -void wasi_sockets_tcp_result_void_error_code_free(wasi_sockets_tcp_result_void_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_ip_socket_address_error_code_free(wasi_sockets_tcp_result_ip_socket_address_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_tcp_ip_socket_address_free(&ptr->val.ok); - } else { - } -} - -void wasi_sockets_tcp_result_bool_error_code_free(wasi_sockets_tcp_result_bool_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_duration_error_code_free(wasi_sockets_tcp_result_duration_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_u32_error_code_free(wasi_sockets_tcp_result_u32_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_u8_error_code_free(wasi_sockets_tcp_result_u8_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_result_u64_error_code_free(wasi_sockets_tcp_result_u64_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_ip_name_lookup_ip_address_free(wasi_sockets_ip_name_lookup_ip_address_t *ptr) { - wasi_sockets_network_ip_address_free(ptr); -} - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[resource-drop]resolve-address-stream"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(int32_t handle); - -void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle) { - __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(handle.__handle); -} - -void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t handle) { - __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(handle.__handle); -} - -wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t arg) { - return (wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t) { arg.__handle }; -} - -void wasi_sockets_ip_name_lookup_option_ip_address_free(wasi_sockets_ip_name_lookup_option_ip_address_t *ptr) { - if (ptr->is_some) { - wasi_sockets_ip_name_lookup_ip_address_free(&ptr->val); - } -} - -void wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_ip_name_lookup_option_ip_address_free(&ptr->val.ok); - } else { - } -} - -void wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void exports_streamkit_plugin_node_node_metadata_free(exports_streamkit_plugin_node_node_metadata_t *ptr) { - streamkit_plugin_types_node_metadata_free(ptr); -} - -void exports_streamkit_plugin_node_packet_free(exports_streamkit_plugin_node_packet_t *ptr) { - streamkit_plugin_types_packet_free(ptr); -} - -__attribute__((__import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-drop]node-instance"))) -extern void __wasm_import_exports_streamkit_plugin_node_node_instance_drop(int32_t handle); - -void exports_streamkit_plugin_node_node_instance_drop_own(exports_streamkit_plugin_node_own_node_instance_t handle) { - __wasm_import_exports_streamkit_plugin_node_node_instance_drop(handle.__handle); -} - -__attribute__(( __import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-new]node-instance"))) -extern int32_t __wasm_import_exports_streamkit_plugin_node_node_instance_new(int32_t); - -__attribute__((__import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-rep]node-instance"))) -extern int32_t __wasm_import_exports_streamkit_plugin_node_node_instance_rep(int32_t); - -exports_streamkit_plugin_node_own_node_instance_t exports_streamkit_plugin_node_node_instance_new(exports_streamkit_plugin_node_node_instance_t *rep) { - return (exports_streamkit_plugin_node_own_node_instance_t) { __wasm_import_exports_streamkit_plugin_node_node_instance_new((int32_t) rep) }; -} - -exports_streamkit_plugin_node_node_instance_t* exports_streamkit_plugin_node_node_instance_rep(exports_streamkit_plugin_node_own_node_instance_t handle) { - return (exports_streamkit_plugin_node_node_instance_t*) __wasm_import_exports_streamkit_plugin_node_node_instance_rep(handle.__handle); -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[dtor]node_instance"))) -void __wasm_export_exports_streamkit_plugin_node_node_instance_dtor(exports_streamkit_plugin_node_node_instance_t* arg) { - exports_streamkit_plugin_node_node_instance_destructor(arg); -} - -void exports_streamkit_plugin_node_result_void_string_free(exports_streamkit_plugin_node_result_void_string_t *ptr) { - if (!ptr->is_err) { - } else { - plugin_string_free(&ptr->val.err); - } -} - -void plugin_string_set(plugin_string_t *ret, const char*s) { - ret->ptr = (uint8_t*) s; - ret->len = strlen(s); -} - -void plugin_string_dup(plugin_string_t *ret, const char*s) { - ret->len = strlen(s); - ret->ptr = (uint8_t*) cabi_realloc(NULL, 0, 1, ret->len * 1); - memcpy(ret->ptr, s, ret->len * 1); -} - -void plugin_string_free(plugin_string_t *ret) { - if (ret->len > 0) { - free(ret->ptr); - } - ret->ptr = NULL; - ret->len = 0; -} - -// Component Adapters - -bool streamkit_plugin_host_send_output(plugin_string_t *pin_name, streamkit_plugin_host_packet_t *packet, plugin_string_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - int32_t variant; - uint8_t * variant2; - size_t variant3; - uint8_t * variant4; - size_t variant5; - switch ((int32_t) (*packet).tag) { - case 0: { - const streamkit_plugin_types_audio_frame_t *payload = &(*packet).val.audio; - variant = 0; - variant2 = (uint8_t *) (int32_t) ((*payload).sample_rate); - variant3 = (int32_t) ((*payload).channels); - variant4 = (uint8_t *) ((*payload).samples).ptr; - variant5 = ((*payload).samples).len; - break; - } - case 1: { - const plugin_string_t *payload0 = &(*packet).val.text; - variant = 1; - variant2 = (uint8_t *) (*payload0).ptr; - variant3 = (*payload0).len; - variant4 = 0; - variant5 = 0; - break; - } - case 2: { - const plugin_list_u8_t *payload1 = &(*packet).val.binary; - variant = 2; - variant2 = (uint8_t *) (*payload1).ptr; - variant3 = (*payload1).len; - variant4 = 0; - variant5 = 0; - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_streamkit_plugin_host_send_output((uint8_t *) (*pin_name).ptr, (*pin_name).len, variant, variant2, variant3, variant4, variant5, ptr); - streamkit_plugin_host_result_void_string_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -void streamkit_plugin_host_log(streamkit_plugin_host_log_level_t level, plugin_string_t *message) { - __wasm_import_streamkit_plugin_host_log((int32_t) level, (uint8_t *) (*message).ptr, (*message).len); -} - -void wasi_cli_environment_get_environment(plugin_list_tuple2_string_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_environment_get_environment(ptr); - *ret = (plugin_list_tuple2_string_string_t) { (plugin_tuple2_string_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -void wasi_cli_environment_get_arguments(plugin_list_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_environment_get_arguments(ptr); - *ret = (plugin_list_string_t) { (plugin_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -bool wasi_cli_environment_initial_cwd(plugin_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_environment_initial_cwd(ptr); - plugin_option_string_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - } - *ret = option.val; - return option.is_some; -} - -void wasi_cli_exit_exit(wasi_cli_exit_result_void_void_t *status) { - int32_t result; - if ((*status).is_err) { - result = 1; - } else { - result = 0; - } - __wasm_import_wasi_cli_exit_exit(result); -} - -void wasi_io_error_method_error_to_debug_string(wasi_io_error_borrow_error_t self, plugin_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_error_method_error_to_debug_string((self).__handle, ptr); - *ret = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -bool wasi_io_poll_method_pollable_ready(wasi_io_poll_borrow_pollable_t self) { - int32_t ret = __wasm_import_wasi_io_poll_method_pollable_ready((self).__handle); - return ret; -} - -void wasi_io_poll_method_pollable_block(wasi_io_poll_borrow_pollable_t self) { - __wasm_import_wasi_io_poll_method_pollable_block((self).__handle); -} - -void wasi_io_poll_poll(wasi_io_poll_list_borrow_pollable_t *in, plugin_list_u32_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_poll_poll((uint8_t *) (*in).ptr, (*in).len, ptr); - *ret = (plugin_list_u32_t) { (uint32_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -bool wasi_io_streams_method_input_stream_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_read((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_list_u8_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_input_stream_blocking_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_blocking_read((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_list_u8_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_input_stream_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_skip((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_input_stream_blocking_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_blocking_skip((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_io_streams_own_pollable_t wasi_io_streams_method_input_stream_subscribe(wasi_io_streams_borrow_input_stream_t self) { - int32_t ret = __wasm_import_wasi_io_streams_method_input_stream_subscribe((self).__handle); - return (wasi_io_streams_own_pollable_t) { ret }; -} - -bool wasi_io_streams_method_output_stream_check_write(wasi_io_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_check_write((self).__handle, ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_write(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_write((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_write_and_flush(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_write_and_flush((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_flush((self).__handle, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_flush((self).__handle, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_io_streams_own_pollable_t wasi_io_streams_method_output_stream_subscribe(wasi_io_streams_borrow_output_stream_t self) { - int32_t ret = __wasm_import_wasi_io_streams_method_output_stream_subscribe((self).__handle); - return (wasi_io_streams_own_pollable_t) { ret }; -} - -bool wasi_io_streams_method_output_stream_write_zeroes(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_write_zeroes((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_cli_stdin_own_input_stream_t wasi_cli_stdin_get_stdin(void) { - int32_t ret = __wasm_import_wasi_cli_stdin_get_stdin(); - return (wasi_cli_stdin_own_input_stream_t) { ret }; -} - -wasi_cli_stdout_own_output_stream_t wasi_cli_stdout_get_stdout(void) { - int32_t ret = __wasm_import_wasi_cli_stdout_get_stdout(); - return (wasi_cli_stdout_own_output_stream_t) { ret }; -} - -wasi_cli_stderr_own_output_stream_t wasi_cli_stderr_get_stderr(void) { - int32_t ret = __wasm_import_wasi_cli_stderr_get_stderr(); - return (wasi_cli_stderr_own_output_stream_t) { ret }; -} - -bool wasi_cli_terminal_stdin_get_terminal_stdin(wasi_cli_terminal_stdin_own_terminal_input_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stdin_get_terminal_stdin(ptr); - wasi_cli_terminal_stdin_option_own_terminal_input_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stdin_own_terminal_input_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; -} - -bool wasi_cli_terminal_stdout_get_terminal_stdout(wasi_cli_terminal_stdout_own_terminal_output_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stdout_get_terminal_stdout(ptr); - wasi_cli_terminal_stdout_option_own_terminal_output_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stdout_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; -} - -bool wasi_cli_terminal_stderr_get_terminal_stderr(wasi_cli_terminal_stderr_own_terminal_output_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stderr_get_terminal_stderr(ptr); - wasi_cli_terminal_stderr_option_own_terminal_output_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stderr_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; -} - -wasi_clocks_monotonic_clock_instant_t wasi_clocks_monotonic_clock_now(void) { - int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_now(); - return (uint64_t) (ret); -} - -wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_resolution(void) { - int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_resolution(); - return (uint64_t) (ret); -} - -wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_instant(wasi_clocks_monotonic_clock_instant_t when) { - int32_t ret = __wasm_import_wasi_clocks_monotonic_clock_subscribe_instant((int64_t) (when)); - return (wasi_clocks_monotonic_clock_own_pollable_t) { ret }; -} - -wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_duration(wasi_clocks_monotonic_clock_duration_t when) { - int32_t ret = __wasm_import_wasi_clocks_monotonic_clock_subscribe_duration((int64_t) (when)); - return (wasi_clocks_monotonic_clock_own_pollable_t) { ret }; -} - -void wasi_clocks_wall_clock_now(wasi_clocks_wall_clock_datetime_t *ret) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_clocks_wall_clock_now(ptr); - *ret = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), - }; -} - -void wasi_clocks_wall_clock_resolution(wasi_clocks_wall_clock_datetime_t *ret) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_clocks_wall_clock_resolution(ptr); - *ret = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), - }; -} - -bool wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_input_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read_via_stream((self).__handle, (int64_t) (offset), ptr); - wasi_filesystem_types_result_own_input_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_input_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream((self).__handle, (int64_t) (offset), ptr); - wasi_filesystem_types_result_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream((self).__handle, ptr); - wasi_filesystem_types_result_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_advise((self).__handle, (int64_t) (offset), (int64_t) (length), (int32_t) advice, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_sync_data((self).__handle, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_flags_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_get_flags((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_flags_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_type_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_get_type((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_type_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_size((self).__handle, (int64_t) (size), ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int64_t variant2; - int32_t variant3; - switch ((int32_t) (*data_access_timestamp).tag) { - case 0: { - variant = 0; - variant2 = 0; - variant3 = 0; - break; - } - case 1: { - variant = 1; - variant2 = 0; - variant3 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; - variant = 2; - variant2 = (int64_t) ((*payload1).seconds); - variant3 = (int32_t) ((*payload1).nanoseconds); - break; - } - } - int32_t variant7; - int64_t variant8; - int32_t variant9; - switch ((int32_t) (*data_modification_timestamp).tag) { - case 0: { - variant7 = 0; - variant8 = 0; - variant9 = 0; - break; - } - case 1: { - variant7 = 1; - variant8 = 0; - variant9 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; - variant7 = 2; - variant8 = (int64_t) ((*payload6).seconds); - variant9 = (int32_t) ((*payload6).nanoseconds); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_times((self).__handle, variant, variant2, variant3, variant7, variant8, variant9, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_read(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_filesize_t offset, plugin_tuple2_list_u8_bool_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(4*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read((self).__handle, (int64_t) (length), (int64_t) (offset), ptr); - wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_tuple2_list_u8_bool_t) { - (plugin_list_u8_t) (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, - (bool) (int32_t) *((uint8_t*) (ptr + (3*sizeof(void*)))), - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_write(wasi_filesystem_types_borrow_descriptor_t self, plugin_list_u8_t *buffer, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_write((self).__handle, (uint8_t *) (*buffer).ptr, (*buffer).len, (int64_t) (offset), ptr); - wasi_filesystem_types_result_filesize_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_directory_entry_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read_directory((self).__handle, ptr); - wasi_filesystem_types_result_own_directory_entry_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_directory_entry_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_sync((self).__handle, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[104]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_stat((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_stat_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_datetime_t option; - switch ((int32_t) *((uint8_t*) (ptr + 32))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option0; - switch ((int32_t) *((uint8_t*) (ptr + 56))) { - case 0: { - option0.is_some = false; - break; - } - case 1: { - option0.is_some = true; - option0.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option1; - switch ((int32_t) *((uint8_t*) (ptr + 80))) { - case 0: { - option1.is_some = false; - break; - } - case 1: { - option1.is_some = true; - option1.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), - }; - break; - } - } - - result.val.ok = (wasi_filesystem_types_descriptor_stat_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), - (wasi_filesystem_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), - (wasi_filesystem_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), - (wasi_filesystem_types_option_datetime_t) option, - (wasi_filesystem_types_option_datetime_t) option0, - (wasi_filesystem_types_option_datetime_t) option1, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[104]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_stat_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_descriptor_stat_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_datetime_t option; - switch ((int32_t) *((uint8_t*) (ptr + 32))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option0; - switch ((int32_t) *((uint8_t*) (ptr + 56))) { - case 0: { - option0.is_some = false; - break; - } - case 1: { - option0.is_some = true; - option0.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option1; - switch ((int32_t) *((uint8_t*) (ptr + 80))) { - case 0: { - option1.is_some = false; - break; - } - case 1: { - option1.is_some = true; - option1.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), - }; - break; - } - } - - result.val.ok = (wasi_filesystem_types_descriptor_stat_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), - (wasi_filesystem_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), - (wasi_filesystem_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), - (wasi_filesystem_types_option_datetime_t) option, - (wasi_filesystem_types_option_datetime_t) option0, - (wasi_filesystem_types_option_datetime_t) option1, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int64_t variant2; - int32_t variant3; - switch ((int32_t) (*data_access_timestamp).tag) { - case 0: { - variant = 0; - variant2 = 0; - variant3 = 0; - break; - } - case 1: { - variant = 1; - variant2 = 0; - variant3 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; - variant = 2; - variant2 = (int64_t) ((*payload1).seconds); - variant3 = (int32_t) ((*payload1).nanoseconds); - break; - } - } - int32_t variant7; - int64_t variant8; - int32_t variant9; - switch ((int32_t) (*data_modification_timestamp).tag) { - case 0: { - variant7 = 0; - variant8 = 0; - variant9 = 0; - break; - } - case 1: { - variant7 = 1; - variant8 = 0; - variant9 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; - variant7 = 2; - variant8 = (int64_t) ((*payload6).seconds); - variant9 = (int32_t) ((*payload6).nanoseconds); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, variant, variant2, variant3, variant7, variant8, variant9, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t old_path_flags, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_link_at((self).__handle, old_path_flags, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_open_flags_t open_flags, wasi_filesystem_types_descriptor_flags_t flags, wasi_filesystem_types_own_descriptor_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_open_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, open_flags, flags, ptr); - wasi_filesystem_types_result_own_descriptor_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_descriptor_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, plugin_string_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_string_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_rename_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other) { - int32_t ret = __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object((self).__handle, (other).__handle); - return ret; -} - -bool wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[24]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash((self).__handle, ptr); - wasi_filesystem_types_result_metadata_hash_value_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_metadata_hash_value_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[24]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_metadata_hash_value_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_metadata_hash_value_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_types_borrow_directory_entry_stream_t self, wasi_filesystem_types_option_directory_entry_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(5*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_directory_entry_stream_read_directory_entry((self).__handle, ptr); - wasi_filesystem_types_result_option_directory_entry_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_directory_entry_t option; - switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_filesystem_types_directory_entry_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))), - (plugin_string_t) (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, - }; - break; - } - } - - result.val.ok = option; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_filesystem_error_code(wasi_filesystem_types_borrow_error_t err_, wasi_filesystem_types_error_code_t *ret) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_filesystem_error_code((err_).__handle, ptr); - wasi_filesystem_types_option_error_code_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - *ret = option.val; - return option.is_some; -} - -void wasi_filesystem_preopens_get_directories(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_preopens_get_directories(ptr); - *ret = (wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t) { (wasi_filesystem_preopens_tuple2_own_descriptor_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -wasi_sockets_instance_network_own_network_t wasi_sockets_instance_network_instance_network(void) { - int32_t ret = __wasm_import_wasi_sockets_instance_network_instance_network(); - return (wasi_sockets_instance_network_own_network_t) { ret }; -} - -bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_borrow_network_t network, wasi_sockets_udp_ip_socket_address_t *local_address, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int32_t variant1; - int32_t variant2; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - switch ((int32_t) (*local_address).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; - variant = 0; - variant1 = (int32_t) ((*payload).port); - variant2 = (int32_t) (((*payload).address).f0); - variant3 = (int32_t) (((*payload).address).f1); - variant4 = (int32_t) (((*payload).address).f2); - variant5 = (int32_t) (((*payload).address).f3); - variant6 = 0; - variant7 = 0; - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; - variant = 1; - variant1 = (int32_t) ((*payload0).port); - variant2 = (int32_t) ((*payload0).flow_info); - variant3 = (int32_t) (((*payload0).address).f0); - variant4 = (int32_t) (((*payload0).address).f1); - variant5 = (int32_t) (((*payload0).address).f2); - variant6 = (int32_t) (((*payload0).address).f3); - variant7 = (int32_t) (((*payload0).address).f4); - variant8 = (int32_t) (((*payload0).address).f5); - variant9 = (int32_t) (((*payload0).address).f6); - variant10 = (int32_t) (((*payload0).address).f7); - variant11 = (int32_t) ((*payload0).scope_id); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_finish_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_finish_bind((self).__handle, ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_stream(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - wasi_sockets_udp_option_ip_socket_address_t remote_address; - remote_address.is_some = maybe_remote_address != NULL;if (maybe_remote_address) { - remote_address.val = *maybe_remote_address; - } - int32_t option; - int32_t option14; - int32_t option15; - int32_t option16; - int32_t option17; - int32_t option18; - int32_t option19; - int32_t option20; - int32_t option21; - int32_t option22; - int32_t option23; - int32_t option24; - int32_t option25; - if ((remote_address).is_some) { - const wasi_sockets_udp_ip_socket_address_t *payload0 = &(remote_address).val; - int32_t variant; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - int32_t variant12; - int32_t variant13; - switch ((int32_t) (*payload0).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload1 = &(*payload0).val.ipv4; - variant = 0; - variant3 = (int32_t) ((*payload1).port); - variant4 = (int32_t) (((*payload1).address).f0); - variant5 = (int32_t) (((*payload1).address).f1); - variant6 = (int32_t) (((*payload1).address).f2); - variant7 = (int32_t) (((*payload1).address).f3); - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - variant12 = 0; - variant13 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload2 = &(*payload0).val.ipv6; - variant = 1; - variant3 = (int32_t) ((*payload2).port); - variant4 = (int32_t) ((*payload2).flow_info); - variant5 = (int32_t) (((*payload2).address).f0); - variant6 = (int32_t) (((*payload2).address).f1); - variant7 = (int32_t) (((*payload2).address).f2); - variant8 = (int32_t) (((*payload2).address).f3); - variant9 = (int32_t) (((*payload2).address).f4); - variant10 = (int32_t) (((*payload2).address).f5); - variant11 = (int32_t) (((*payload2).address).f6); - variant12 = (int32_t) (((*payload2).address).f7); - variant13 = (int32_t) ((*payload2).scope_id); - break; - } - } - option = 1; - option14 = variant; - option15 = variant3; - option16 = variant4; - option17 = variant5; - option18 = variant6; - option19 = variant7; - option20 = variant8; - option21 = variant9; - option22 = variant10; - option23 = variant11; - option24 = variant12; - option25 = variant13; - } else { - option = 0; - option14 = 0; - option15 = 0; - option16 = 0; - option17 = 0; - option18 = 0; - option19 = 0; - option20 = 0; - option21 = 0; - option22 = 0; - option23 = 0; - option24 = 0; - option25 = 0; - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_stream((self).__handle, option, option14, option15, option16, option17, option18, option19, option20, option21, option22, option23, option24, option25, ptr); - wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t) { - (wasi_sockets_udp_own_incoming_datagram_stream_t) (wasi_sockets_udp_own_incoming_datagram_stream_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_udp_own_outgoing_datagram_stream_t) (wasi_sockets_udp_own_outgoing_datagram_stream_t) { *((int32_t*) (ptr + 8)) }, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_local_address((self).__handle, ptr); - wasi_sockets_udp_result_ip_socket_address_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; - break; - } - case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; - break; - } - } - - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_remote_address((self).__handle, ptr); - wasi_sockets_udp_result_ip_socket_address_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; - break; - } - case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; - break; - } - } - - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_udp_ip_address_family_t wasi_sockets_udp_method_udp_socket_address_family(wasi_sockets_udp_borrow_udp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_udp_socket_address_family((self).__handle); - return ret; -} - -bool wasi_sockets_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_unicast_hop_limit((self).__handle, ptr); - wasi_sockets_udp_result_u8_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit((self).__handle, (int32_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_receive_buffer_size((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_send_buffer_size((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_udp_socket_subscribe(wasi_sockets_udp_borrow_udp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_udp_socket_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} - -bool wasi_sockets_udp_method_incoming_datagram_stream_receive(wasi_sockets_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_udp_list_incoming_datagram_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_receive((self).__handle, (int64_t) (max_results), ptr); - wasi_sockets_udp_result_list_incoming_datagram_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_udp_list_incoming_datagram_t) { (wasi_sockets_udp_incoming_datagram_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_udp_borrow_incoming_datagram_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} - -bool wasi_sockets_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_check_send((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_send((self).__handle, (uint8_t *) (*datagrams).ptr, (*datagrams).len, ptr); - wasi_sockets_udp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} - -bool wasi_sockets_udp_create_socket_create_udp_socket(wasi_sockets_udp_create_socket_ip_address_family_t address_family, wasi_sockets_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_udp_create_socket_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_create_socket_create_udp_socket((int32_t) address_family, ptr); - wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_udp_create_socket_own_udp_socket_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_start_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *local_address, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int32_t variant1; - int32_t variant2; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - switch ((int32_t) (*local_address).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; - variant = 0; - variant1 = (int32_t) ((*payload).port); - variant2 = (int32_t) (((*payload).address).f0); - variant3 = (int32_t) (((*payload).address).f1); - variant4 = (int32_t) (((*payload).address).f2); - variant5 = (int32_t) (((*payload).address).f3); - variant6 = 0; - variant7 = 0; - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; - variant = 1; - variant1 = (int32_t) ((*payload0).port); - variant2 = (int32_t) ((*payload0).flow_info); - variant3 = (int32_t) (((*payload0).address).f0); - variant4 = (int32_t) (((*payload0).address).f1); - variant5 = (int32_t) (((*payload0).address).f2); - variant6 = (int32_t) (((*payload0).address).f3); - variant7 = (int32_t) (((*payload0).address).f4); - variant8 = (int32_t) (((*payload0).address).f5); - variant9 = (int32_t) (((*payload0).address).f6); - variant10 = (int32_t) (((*payload0).address).f7); - variant11 = (int32_t) ((*payload0).scope_id); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_finish_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_bind((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *remote_address, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int32_t variant1; - int32_t variant2; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - switch ((int32_t) (*remote_address).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*remote_address).val.ipv4; - variant = 0; - variant1 = (int32_t) ((*payload).port); - variant2 = (int32_t) (((*payload).address).f0); - variant3 = (int32_t) (((*payload).address).f1); - variant4 = (int32_t) (((*payload).address).f2); - variant5 = (int32_t) (((*payload).address).f3); - variant6 = 0; - variant7 = 0; - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*remote_address).val.ipv6; - variant = 1; - variant1 = (int32_t) ((*payload0).port); - variant2 = (int32_t) ((*payload0).flow_info); - variant3 = (int32_t) (((*payload0).address).f0); - variant4 = (int32_t) (((*payload0).address).f1); - variant5 = (int32_t) (((*payload0).address).f2); - variant6 = (int32_t) (((*payload0).address).f3); - variant7 = (int32_t) (((*payload0).address).f4); - variant8 = (int32_t) (((*payload0).address).f5); - variant9 = (int32_t) (((*payload0).address).f6); - variant10 = (int32_t) (((*payload0).address).f7); - variant11 = (int32_t) ((*payload0).scope_id); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_connect((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_finish_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_connect((self).__handle, ptr); - wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t) { - (wasi_sockets_tcp_own_input_stream_t) (wasi_sockets_tcp_own_input_stream_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_tcp_own_output_stream_t) (wasi_sockets_tcp_own_output_stream_t) { *((int32_t*) (ptr + 8)) }, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_listen((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_finish_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_listen((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_accept(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_accept((self).__handle, ptr); - wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t) { - (wasi_sockets_tcp_own_tcp_socket_t) (wasi_sockets_tcp_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_tcp_own_input_stream_t) (wasi_sockets_tcp_own_input_stream_t) { *((int32_t*) (ptr + 8)) }, - (wasi_sockets_tcp_own_output_stream_t) (wasi_sockets_tcp_own_output_stream_t) { *((int32_t*) (ptr + 12)) }, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_local_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_local_address((self).__handle, ptr); - wasi_sockets_tcp_result_ip_socket_address_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; - break; - } - case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; - break; - } - } - - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_remote_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_remote_address((self).__handle, ptr); - wasi_sockets_tcp_result_ip_socket_address_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; - break; - } - case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; - break; - } - } - - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_is_listening(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_is_listening((self).__handle); - return ret; -} - -wasi_sockets_tcp_ip_address_family_t wasi_sockets_tcp_method_tcp_socket_address_family(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_address_family((self).__handle); - return ret; -} - -bool wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled((self).__handle, ptr); - wasi_sockets_tcp_result_bool_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled((self).__handle, value, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time((self).__handle, ptr); - wasi_sockets_tcp_result_duration_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_interval((self).__handle, ptr); - wasi_sockets_tcp_result_duration_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_count((self).__handle, ptr); - wasi_sockets_tcp_result_u32_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint32_t) (*((int32_t*) (ptr + 4))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count((self).__handle, (int32_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_hop_limit((self).__handle, ptr); - wasi_sockets_tcp_result_u8_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_hop_limit((self).__handle, (int32_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_receive_buffer_size((self).__handle, ptr); - wasi_sockets_tcp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_send_buffer_size((self).__handle, ptr); - wasi_sockets_tcp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_tcp_own_pollable_t wasi_sockets_tcp_method_tcp_socket_subscribe(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_subscribe((self).__handle); - return (wasi_sockets_tcp_own_pollable_t) { ret }; -} - -bool wasi_sockets_tcp_method_tcp_socket_shutdown(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_shutdown_type_t shutdown_type, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_shutdown((self).__handle, (int32_t) shutdown_type, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_create_socket_create_tcp_socket(wasi_sockets_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_tcp_create_socket_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_create_socket_create_tcp_socket((int32_t) address_family, ptr); - wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_tcp_create_socket_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err) { - __attribute__((__aligned__(2))) - uint8_t ret_area[22]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address((self).__handle, ptr); - wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_sockets_ip_name_lookup_option_ip_address_t option; - switch ((int32_t) *((uint8_t*) (ptr + 2))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - wasi_sockets_network_ip_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 6))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 7))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 8))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 9))), - }; - break; - } - case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 6))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 10))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 12))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 14))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - }; - break; - } - } - - option.val = variant; - break; - } - } - - result.val.ok = option; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 2)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_ip_name_lookup_own_pollable_t wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe((self).__handle); - return (wasi_sockets_ip_name_lookup_own_pollable_t) { ret }; -} - -bool wasi_sockets_ip_name_lookup_resolve_addresses(wasi_sockets_ip_name_lookup_borrow_network_t network, plugin_string_t *name, wasi_sockets_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses((network).__handle, (uint8_t *) (*name).ptr, (*name).len, ptr); - wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_sockets_ip_name_lookup_own_resolve_address_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -void wasi_random_random_get_random_bytes(uint64_t len, plugin_list_u8_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_random_get_random_bytes((int64_t) (len), ptr); - *ret = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -uint64_t wasi_random_random_get_random_u64(void) { - int64_t ret = __wasm_import_wasi_random_random_get_random_u64(); - return (uint64_t) (ret); -} - -void wasi_random_insecure_get_insecure_random_bytes(uint64_t len, plugin_list_u8_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_insecure_get_insecure_random_bytes((int64_t) (len), ptr); - *ret = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -uint64_t wasi_random_insecure_get_insecure_random_u64(void) { - int64_t ret = __wasm_import_wasi_random_insecure_get_insecure_random_u64(); - return (uint64_t) (ret); -} - -void wasi_random_insecure_seed_insecure_seed(plugin_tuple2_u64_u64_t *ret) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_insecure_seed_insecure_seed(ptr); - *ret = (plugin_tuple2_u64_u64_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), - }; -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#metadata"))) -uint8_t * __wasm_export_exports_streamkit_plugin_node_metadata(void) { - exports_streamkit_plugin_node_node_metadata_t ret; - exports_streamkit_plugin_node_metadata(&ret); - uint8_t *ptr = (uint8_t *) &RET_AREA; - *((size_t*)(ptr + sizeof(void*))) = ((ret).kind).len; - *((uint8_t **)(ptr + 0)) = (uint8_t *) ((ret).kind).ptr; - *((size_t*)(ptr + (3*sizeof(void*)))) = ((ret).inputs).len; - *((uint8_t **)(ptr + (2*sizeof(void*)))) = (uint8_t *) ((ret).inputs).ptr; - *((size_t*)(ptr + (5*sizeof(void*)))) = ((ret).outputs).len; - *((uint8_t **)(ptr + (4*sizeof(void*)))) = (uint8_t *) ((ret).outputs).ptr; - *((size_t*)(ptr + (7*sizeof(void*)))) = ((ret).param_schema).len; - *((uint8_t **)(ptr + (6*sizeof(void*)))) = (uint8_t *) ((ret).param_schema).ptr; - *((size_t*)(ptr + (9*sizeof(void*)))) = ((ret).categories).len; - *((uint8_t **)(ptr + (8*sizeof(void*)))) = (uint8_t *) ((ret).categories).ptr; - return ptr; -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[constructor]node-instance"))) -int32_t __wasm_export_exports_streamkit_plugin_node_constructor_node_instance(int32_t arg, uint8_t * arg0, size_t arg1) { - plugin_option_string_t option; - switch (arg) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (plugin_string_t) { (uint8_t*)(arg0), (arg1) }; - break; - } - } - exports_streamkit_plugin_node_own_node_instance_t ret = exports_streamkit_plugin_node_constructor_node_instance(option.is_some ? &(option.val) : NULL); - return (ret).__handle; -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.process"))) -uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_process(uint8_t * arg, uint8_t * arg0, size_t arg1, int32_t arg2, uint8_t * arg3, size_t arg4, uint8_t * arg5, size_t arg6) { - streamkit_plugin_types_packet_t variant; - variant.tag = arg2; - switch ((int32_t) variant.tag) { - case 0: { - variant.val.audio = (streamkit_plugin_types_audio_frame_t) { - (uint32_t) (uint32_t) ((uintptr_t) arg3), - (uint16_t) (uint16_t) (arg4), - (plugin_list_f32_t) (plugin_list_f32_t) { (float*)(arg5), (arg6) }, - }; - break; - } - case 1: { - variant.val.text = (plugin_string_t) { (uint8_t*)(arg3), (arg4) }; - break; - } - case 2: { - variant.val.binary = (plugin_list_u8_t) { (uint8_t*)(arg3), (arg4) }; - break; - } - } - plugin_string_t arg7 = (plugin_string_t) { (uint8_t*)(arg0), (arg1) }; - exports_streamkit_plugin_node_packet_t arg8 = variant; - exports_streamkit_plugin_node_result_void_string_t ret; - plugin_string_t err; - ret.is_err = !exports_streamkit_plugin_node_method_node_instance_process(((exports_streamkit_plugin_node_node_instance_t*) arg), &arg7, &arg8, &err); - if (ret.is_err) { - ret.val.err = err; - } - uint8_t *ptr = (uint8_t *) &RET_AREA; - if ((ret).is_err) { - const plugin_string_t *payload9 = &(ret).val.err;*((int8_t*)(ptr + 0)) = 1; - *((size_t*)(ptr + (2*sizeof(void*)))) = (*payload9).len; - *((uint8_t **)(ptr + sizeof(void*))) = (uint8_t *) (*payload9).ptr; - } else { - *((int8_t*)(ptr + 0)) = 0; - } - return ptr; -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.update-params"))) -uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params(uint8_t * arg, int32_t arg0, uint8_t * arg1, size_t arg2) { - plugin_option_string_t option; - switch (arg0) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (plugin_string_t) { (uint8_t*)(arg1), (arg2) }; - break; - } - } - exports_streamkit_plugin_node_result_void_string_t ret; - plugin_string_t err; - ret.is_err = !exports_streamkit_plugin_node_method_node_instance_update_params(((exports_streamkit_plugin_node_node_instance_t*) arg), option.is_some ? &(option.val) : NULL, &err); - if (ret.is_err) { - ret.val.err = err; - } - uint8_t *ptr = (uint8_t *) &RET_AREA; - if ((ret).is_err) { - const plugin_string_t *payload3 = &(ret).val.err;*((int8_t*)(ptr + 0)) = 1; - *((size_t*)(ptr + (2*sizeof(void*)))) = (*payload3).len; - *((uint8_t **)(ptr + sizeof(void*))) = (uint8_t *) (*payload3).ptr; - } else { - *((int8_t*)(ptr + 0)) = 0; - } - return ptr; -} - -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.cleanup"))) -void __wasm_export_exports_streamkit_plugin_node_method_node_instance_cleanup(uint8_t * arg) { - exports_streamkit_plugin_node_method_node_instance_cleanup(((exports_streamkit_plugin_node_node_instance_t*) arg)); -} - -// Ensure that the *_component_type.o object is linked in - -extern void __component_type_object_force_link_plugin(void); -__attribute__((used)) -void __component_type_object_force_link_plugin_public_use_in_this_compilation_unit(void) { - __component_type_object_force_link_plugin(); -} diff --git a/examples/plugins/gain-wasm-c/plugin.h b/examples/plugins/gain-wasm-c/plugin.h deleted file mode 100644 index 4b8285208..000000000 --- a/examples/plugins/gain-wasm-c/plugin.h +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * SPDX-FileCopyrightText: © 2025 StreamKit Contributors - * - * SPDX-License-Identifier: MPL-2.0 - */ - -// Generated by `wit-bindgen` 0.44.0. DO NOT EDIT! -#ifndef __BINDINGS_PLUGIN_H -#define __BINDINGS_PLUGIN_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -typedef struct plugin_string_t { - uint8_t*ptr; - size_t len; -} plugin_string_t; - -// Sample format for raw audio -typedef uint8_t streamkit_plugin_types_sample_format_t; - -#define STREAMKIT_PLUGIN_TYPES_SAMPLE_FORMAT_FLOAT32 0 -#define STREAMKIT_PLUGIN_TYPES_SAMPLE_FORMAT_S16_LE 1 - -// Audio format specification -typedef struct streamkit_plugin_types_audio_format_t { - uint32_t sample_rate; - uint16_t channels; - streamkit_plugin_types_sample_format_t sample_format; -} streamkit_plugin_types_audio_format_t; - -// Packet types that can flow through the pipeline -typedef struct streamkit_plugin_types_packet_type_t { - uint8_t tag; - union { - streamkit_plugin_types_audio_format_t raw_audio; - } val; -} streamkit_plugin_types_packet_type_t; - -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_RAW_AUDIO 0 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_OPUS_AUDIO 1 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_TEXT 2 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_BINARY 3 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_ANY 4 - -typedef struct { - streamkit_plugin_types_packet_type_t *ptr; - size_t len; -} streamkit_plugin_types_list_packet_type_t; - -// Input pin definition -typedef struct streamkit_plugin_types_input_pin_t { - plugin_string_t name; - streamkit_plugin_types_list_packet_type_t accepts_types; -} streamkit_plugin_types_input_pin_t; - -// Output pin definition -typedef struct streamkit_plugin_types_output_pin_t { - plugin_string_t name; - streamkit_plugin_types_packet_type_t produces_type; -} streamkit_plugin_types_output_pin_t; - -typedef struct { - streamkit_plugin_types_input_pin_t *ptr; - size_t len; -} streamkit_plugin_types_list_input_pin_t; - -typedef struct { - streamkit_plugin_types_output_pin_t *ptr; - size_t len; -} streamkit_plugin_types_list_output_pin_t; - -typedef struct { - plugin_string_t *ptr; - size_t len; -} plugin_list_string_t; - -// Node metadata -typedef struct streamkit_plugin_types_node_metadata_t { - plugin_string_t kind; - streamkit_plugin_types_list_input_pin_t inputs; - streamkit_plugin_types_list_output_pin_t outputs; - plugin_string_t param_schema; - plugin_list_string_t categories; -} streamkit_plugin_types_node_metadata_t; - -typedef struct { - float *ptr; - size_t len; -} plugin_list_f32_t; - -// Audio frame data -typedef struct streamkit_plugin_types_audio_frame_t { - uint32_t sample_rate; - uint16_t channels; - plugin_list_f32_t samples; -} streamkit_plugin_types_audio_frame_t; - -typedef struct { - uint8_t *ptr; - size_t len; -} plugin_list_u8_t; - -// Packet that flows through the pipeline -typedef struct streamkit_plugin_types_packet_t { - uint8_t tag; - union { - streamkit_plugin_types_audio_frame_t audio; - plugin_string_t text; - plugin_list_u8_t binary; - } val; -} streamkit_plugin_types_packet_t; - -#define STREAMKIT_PLUGIN_TYPES_PACKET_AUDIO 0 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TEXT 1 -#define STREAMKIT_PLUGIN_TYPES_PACKET_BINARY 2 - -typedef streamkit_plugin_types_packet_t streamkit_plugin_host_packet_t; - -// Log levels for host logging -typedef uint8_t streamkit_plugin_host_log_level_t; - -#define STREAMKIT_PLUGIN_HOST_LOG_LEVEL_DEBUG 0 -#define STREAMKIT_PLUGIN_HOST_LOG_LEVEL_INFO 1 -#define STREAMKIT_PLUGIN_HOST_LOG_LEVEL_WARN 2 -#define STREAMKIT_PLUGIN_HOST_LOG_LEVEL_ERROR 3 - -typedef struct { - bool is_err; - union { - plugin_string_t err; - } val; -} streamkit_plugin_host_result_void_string_t; - -typedef struct { - plugin_string_t f0; - plugin_string_t f1; -} plugin_tuple2_string_string_t; - -typedef struct { - plugin_tuple2_string_string_t *ptr; - size_t len; -} plugin_list_tuple2_string_string_t; - -typedef struct { - bool is_some; - plugin_string_t val; -} plugin_option_string_t; - -typedef struct { - bool is_err; -} wasi_cli_exit_result_void_void_t; - -typedef struct wasi_io_error_own_error_t { - int32_t __handle; -} wasi_io_error_own_error_t; - -typedef struct wasi_io_error_borrow_error_t { - int32_t __handle; -} wasi_io_error_borrow_error_t; - -typedef struct wasi_io_poll_own_pollable_t { - int32_t __handle; -} wasi_io_poll_own_pollable_t; - -typedef struct wasi_io_poll_borrow_pollable_t { - int32_t __handle; -} wasi_io_poll_borrow_pollable_t; - -typedef struct { - wasi_io_poll_borrow_pollable_t *ptr; - size_t len; -} wasi_io_poll_list_borrow_pollable_t; - -typedef struct { - uint32_t *ptr; - size_t len; -} plugin_list_u32_t; - -typedef wasi_io_error_own_error_t wasi_io_streams_own_error_t; - -typedef struct wasi_io_streams_stream_error_t { - uint8_t tag; - union { - wasi_io_streams_own_error_t last_operation_failed; - } val; -} wasi_io_streams_stream_error_t; - -#define WASI_IO_STREAMS_STREAM_ERROR_LAST_OPERATION_FAILED 0 -#define WASI_IO_STREAMS_STREAM_ERROR_CLOSED 1 - -typedef struct wasi_io_streams_own_input_stream_t { - int32_t __handle; -} wasi_io_streams_own_input_stream_t; - -typedef struct wasi_io_streams_borrow_input_stream_t { - int32_t __handle; -} wasi_io_streams_borrow_input_stream_t; - -typedef struct wasi_io_streams_own_output_stream_t { - int32_t __handle; -} wasi_io_streams_own_output_stream_t; - -typedef struct wasi_io_streams_borrow_output_stream_t { - int32_t __handle; -} wasi_io_streams_borrow_output_stream_t; - -typedef struct { - bool is_err; - union { - plugin_list_u8_t ok; - wasi_io_streams_stream_error_t err; - } val; -} wasi_io_streams_result_list_u8_stream_error_t; - -typedef struct { - bool is_err; - union { - uint64_t ok; - wasi_io_streams_stream_error_t err; - } val; -} wasi_io_streams_result_u64_stream_error_t; - -typedef wasi_io_poll_own_pollable_t wasi_io_streams_own_pollable_t; - -typedef struct { - bool is_err; - union { - wasi_io_streams_stream_error_t err; - } val; -} wasi_io_streams_result_void_stream_error_t; - -typedef wasi_io_streams_own_input_stream_t wasi_cli_stdin_own_input_stream_t; - -typedef wasi_io_streams_own_output_stream_t wasi_cli_stdout_own_output_stream_t; - -typedef wasi_io_streams_own_output_stream_t wasi_cli_stderr_own_output_stream_t; - -typedef struct wasi_cli_terminal_input_own_terminal_input_t { - int32_t __handle; -} wasi_cli_terminal_input_own_terminal_input_t; - -typedef struct wasi_cli_terminal_input_borrow_terminal_input_t { - int32_t __handle; -} wasi_cli_terminal_input_borrow_terminal_input_t; - -typedef struct wasi_cli_terminal_output_own_terminal_output_t { - int32_t __handle; -} wasi_cli_terminal_output_own_terminal_output_t; - -typedef struct wasi_cli_terminal_output_borrow_terminal_output_t { - int32_t __handle; -} wasi_cli_terminal_output_borrow_terminal_output_t; - -typedef wasi_cli_terminal_input_own_terminal_input_t wasi_cli_terminal_stdin_own_terminal_input_t; - -typedef struct { - bool is_some; - wasi_cli_terminal_stdin_own_terminal_input_t val; -} wasi_cli_terminal_stdin_option_own_terminal_input_t; - -typedef wasi_cli_terminal_output_own_terminal_output_t wasi_cli_terminal_stdout_own_terminal_output_t; - -typedef struct { - bool is_some; - wasi_cli_terminal_stdout_own_terminal_output_t val; -} wasi_cli_terminal_stdout_option_own_terminal_output_t; - -typedef wasi_cli_terminal_output_own_terminal_output_t wasi_cli_terminal_stderr_own_terminal_output_t; - -typedef struct { - bool is_some; - wasi_cli_terminal_stderr_own_terminal_output_t val; -} wasi_cli_terminal_stderr_option_own_terminal_output_t; - -typedef uint64_t wasi_clocks_monotonic_clock_instant_t; - -typedef uint64_t wasi_clocks_monotonic_clock_duration_t; - -typedef wasi_io_poll_own_pollable_t wasi_clocks_monotonic_clock_own_pollable_t; - -typedef struct wasi_clocks_wall_clock_datetime_t { - uint64_t seconds; - uint32_t nanoseconds; -} wasi_clocks_wall_clock_datetime_t; - -typedef wasi_clocks_wall_clock_datetime_t wasi_filesystem_types_datetime_t; - -typedef uint64_t wasi_filesystem_types_filesize_t; - -typedef uint8_t wasi_filesystem_types_descriptor_type_t; - -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_UNKNOWN 0 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_BLOCK_DEVICE 1 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_CHARACTER_DEVICE 2 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_DIRECTORY 3 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_FIFO 4 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SYMBOLIC_LINK 5 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_REGULAR_FILE 6 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SOCKET 7 - -typedef uint8_t wasi_filesystem_types_descriptor_flags_t; - -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_READ (1 << 0) -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_WRITE (1 << 1) -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_FILE_INTEGRITY_SYNC (1 << 2) -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_DATA_INTEGRITY_SYNC (1 << 3) -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_REQUESTED_WRITE_SYNC (1 << 4) -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_MUTATE_DIRECTORY (1 << 5) - -typedef uint8_t wasi_filesystem_types_path_flags_t; - -#define WASI_FILESYSTEM_TYPES_PATH_FLAGS_SYMLINK_FOLLOW (1 << 0) - -typedef uint8_t wasi_filesystem_types_open_flags_t; - -#define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_CREATE (1 << 0) -#define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_DIRECTORY (1 << 1) -#define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_EXCLUSIVE (1 << 2) -#define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_TRUNCATE (1 << 3) - -typedef uint64_t wasi_filesystem_types_link_count_t; - -typedef struct { - bool is_some; - wasi_filesystem_types_datetime_t val; -} wasi_filesystem_types_option_datetime_t; - -typedef struct wasi_filesystem_types_descriptor_stat_t { - wasi_filesystem_types_descriptor_type_t type; - wasi_filesystem_types_link_count_t link_count; - wasi_filesystem_types_filesize_t size; - wasi_filesystem_types_option_datetime_t data_access_timestamp; - wasi_filesystem_types_option_datetime_t data_modification_timestamp; - wasi_filesystem_types_option_datetime_t status_change_timestamp; -} wasi_filesystem_types_descriptor_stat_t; - -typedef struct wasi_filesystem_types_new_timestamp_t { - uint8_t tag; - union { - wasi_filesystem_types_datetime_t timestamp; - } val; -} wasi_filesystem_types_new_timestamp_t; - -#define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_NO_CHANGE 0 -#define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_NOW 1 -#define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_TIMESTAMP 2 - -typedef struct wasi_filesystem_types_directory_entry_t { - wasi_filesystem_types_descriptor_type_t type; - plugin_string_t name; -} wasi_filesystem_types_directory_entry_t; - -typedef uint8_t wasi_filesystem_types_error_code_t; - -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ACCESS 0 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_WOULD_BLOCK 1 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ALREADY 2 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BAD_DESCRIPTOR 3 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BUSY 4 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_DEADLOCK 5 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_QUOTA 6 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_EXIST 7 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_FILE_TOO_LARGE 8 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 9 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IN_PROGRESS 10 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INTERRUPTED 11 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID 12 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IO 13 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IS_DIRECTORY 14 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_LOOP 15 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TOO_MANY_LINKS 16 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_MESSAGE_SIZE 17 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NAME_TOO_LONG 18 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_DEVICE 19 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_ENTRY 20 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_LOCK 21 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_MEMORY 22 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_SPACE 23 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_DIRECTORY 24 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_EMPTY 25 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_RECOVERABLE 26 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_UNSUPPORTED 27 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_TTY 28 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_SUCH_DEVICE 29 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_OVERFLOW 30 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_PERMITTED 31 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_PIPE 32 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_READ_ONLY 33 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID_SEEK 34 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TEXT_FILE_BUSY 35 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_CROSS_DEVICE 36 - -typedef uint8_t wasi_filesystem_types_advice_t; - -#define WASI_FILESYSTEM_TYPES_ADVICE_NORMAL 0 -#define WASI_FILESYSTEM_TYPES_ADVICE_SEQUENTIAL 1 -#define WASI_FILESYSTEM_TYPES_ADVICE_RANDOM 2 -#define WASI_FILESYSTEM_TYPES_ADVICE_WILL_NEED 3 -#define WASI_FILESYSTEM_TYPES_ADVICE_DONT_NEED 4 -#define WASI_FILESYSTEM_TYPES_ADVICE_NO_REUSE 5 - -typedef struct wasi_filesystem_types_metadata_hash_value_t { - uint64_t lower; - uint64_t upper; -} wasi_filesystem_types_metadata_hash_value_t; - -typedef struct wasi_filesystem_types_own_descriptor_t { - int32_t __handle; -} wasi_filesystem_types_own_descriptor_t; - -typedef struct wasi_filesystem_types_borrow_descriptor_t { - int32_t __handle; -} wasi_filesystem_types_borrow_descriptor_t; - -typedef struct wasi_filesystem_types_own_directory_entry_stream_t { - int32_t __handle; -} wasi_filesystem_types_own_directory_entry_stream_t; - -typedef struct wasi_filesystem_types_borrow_directory_entry_stream_t { - int32_t __handle; -} wasi_filesystem_types_borrow_directory_entry_stream_t; - -typedef wasi_io_streams_own_input_stream_t wasi_filesystem_types_own_input_stream_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_input_stream_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_input_stream_error_code_t; - -typedef wasi_io_streams_own_output_stream_t wasi_filesystem_types_own_output_stream_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_output_stream_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_output_stream_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_void_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_descriptor_flags_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_descriptor_flags_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_descriptor_type_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_descriptor_type_error_code_t; - -typedef struct { - plugin_list_u8_t f0; - bool f1; -} plugin_tuple2_list_u8_bool_t; - -typedef struct { - bool is_err; - union { - plugin_tuple2_list_u8_bool_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_filesize_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_filesize_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_directory_entry_stream_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_directory_entry_stream_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_descriptor_stat_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_descriptor_stat_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_descriptor_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_descriptor_error_code_t; - -typedef struct { - bool is_err; - union { - plugin_string_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_string_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_metadata_hash_value_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_metadata_hash_value_error_code_t; - -typedef struct { - bool is_some; - wasi_filesystem_types_directory_entry_t val; -} wasi_filesystem_types_option_directory_entry_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_option_directory_entry_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_option_directory_entry_error_code_t; - -typedef wasi_io_error_borrow_error_t wasi_filesystem_types_borrow_error_t; - -typedef struct { - bool is_some; - wasi_filesystem_types_error_code_t val; -} wasi_filesystem_types_option_error_code_t; - -typedef wasi_filesystem_types_own_descriptor_t wasi_filesystem_preopens_own_descriptor_t; - -typedef struct { - wasi_filesystem_preopens_own_descriptor_t f0; - plugin_string_t f1; -} wasi_filesystem_preopens_tuple2_own_descriptor_string_t; - -typedef struct { - wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr; - size_t len; -} wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t; - -typedef struct wasi_sockets_network_own_network_t { - int32_t __handle; -} wasi_sockets_network_own_network_t; - -typedef struct wasi_sockets_network_borrow_network_t { - int32_t __handle; -} wasi_sockets_network_borrow_network_t; - -typedef uint8_t wasi_sockets_network_error_code_t; - -#define WASI_SOCKETS_NETWORK_ERROR_CODE_UNKNOWN 0 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ACCESS_DENIED 1 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NOT_SUPPORTED 2 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_INVALID_ARGUMENT 3 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_OUT_OF_MEMORY 4 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_TIMEOUT 5 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONCURRENCY_CONFLICT 6 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NOT_IN_PROGRESS 7 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_WOULD_BLOCK 8 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_INVALID_STATE 9 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NEW_SOCKET_LIMIT 10 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ADDRESS_NOT_BINDABLE 11 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ADDRESS_IN_USE 12 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_REMOTE_UNREACHABLE 13 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_REFUSED 14 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_RESET 15 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_ABORTED 16 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_DATAGRAM_TOO_LARGE 17 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NAME_UNRESOLVABLE 18 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_TEMPORARY_RESOLVER_FAILURE 19 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_PERMANENT_RESOLVER_FAILURE 20 - -typedef uint8_t wasi_sockets_network_ip_address_family_t; - -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_FAMILY_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_FAMILY_IPV6 1 - -typedef struct wasi_sockets_network_ipv4_address_t { - uint8_t f0; - uint8_t f1; - uint8_t f2; - uint8_t f3; -} wasi_sockets_network_ipv4_address_t; - -typedef struct wasi_sockets_network_ipv6_address_t { - uint16_t f0; - uint16_t f1; - uint16_t f2; - uint16_t f3; - uint16_t f4; - uint16_t f5; - uint16_t f6; - uint16_t f7; -} wasi_sockets_network_ipv6_address_t; - -typedef struct wasi_sockets_network_ip_address_t { - uint8_t tag; - union { - wasi_sockets_network_ipv4_address_t ipv4; - wasi_sockets_network_ipv6_address_t ipv6; - } val; -} wasi_sockets_network_ip_address_t; - -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_IPV6 1 - -typedef struct wasi_sockets_network_ipv4_socket_address_t { - uint16_t port; - wasi_sockets_network_ipv4_address_t address; -} wasi_sockets_network_ipv4_socket_address_t; - -typedef struct wasi_sockets_network_ipv6_socket_address_t { - uint16_t port; - uint32_t flow_info; - wasi_sockets_network_ipv6_address_t address; - uint32_t scope_id; -} wasi_sockets_network_ipv6_socket_address_t; - -typedef struct wasi_sockets_network_ip_socket_address_t { - uint8_t tag; - union { - wasi_sockets_network_ipv4_socket_address_t ipv4; - wasi_sockets_network_ipv6_socket_address_t ipv6; - } val; -} wasi_sockets_network_ip_socket_address_t; - -#define WASI_SOCKETS_NETWORK_IP_SOCKET_ADDRESS_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_SOCKET_ADDRESS_IPV6 1 - -typedef wasi_sockets_network_own_network_t wasi_sockets_instance_network_own_network_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_udp_error_code_t; - -typedef wasi_sockets_network_ip_socket_address_t wasi_sockets_udp_ip_socket_address_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_udp_ip_address_family_t; - -typedef struct wasi_sockets_udp_incoming_datagram_t { - plugin_list_u8_t data; - wasi_sockets_udp_ip_socket_address_t remote_address; -} wasi_sockets_udp_incoming_datagram_t; - -typedef struct { - bool is_some; - wasi_sockets_udp_ip_socket_address_t val; -} wasi_sockets_udp_option_ip_socket_address_t; - -typedef struct wasi_sockets_udp_outgoing_datagram_t { - plugin_list_u8_t data; - wasi_sockets_udp_option_ip_socket_address_t remote_address; -} wasi_sockets_udp_outgoing_datagram_t; - -typedef struct wasi_sockets_udp_own_udp_socket_t { - int32_t __handle; -} wasi_sockets_udp_own_udp_socket_t; - -typedef struct wasi_sockets_udp_borrow_udp_socket_t { - int32_t __handle; -} wasi_sockets_udp_borrow_udp_socket_t; - -typedef struct wasi_sockets_udp_own_incoming_datagram_stream_t { - int32_t __handle; -} wasi_sockets_udp_own_incoming_datagram_stream_t; - -typedef struct wasi_sockets_udp_borrow_incoming_datagram_stream_t { - int32_t __handle; -} wasi_sockets_udp_borrow_incoming_datagram_stream_t; - -typedef struct wasi_sockets_udp_own_outgoing_datagram_stream_t { - int32_t __handle; -} wasi_sockets_udp_own_outgoing_datagram_stream_t; - -typedef struct wasi_sockets_udp_borrow_outgoing_datagram_stream_t { - int32_t __handle; -} wasi_sockets_udp_borrow_outgoing_datagram_stream_t; - -typedef wasi_sockets_network_borrow_network_t wasi_sockets_udp_borrow_network_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_void_error_code_t; - -typedef struct { - wasi_sockets_udp_own_incoming_datagram_stream_t f0; - wasi_sockets_udp_own_outgoing_datagram_stream_t f1; -} wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_ip_socket_address_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_ip_socket_address_error_code_t; - -typedef struct { - bool is_err; - union { - uint8_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_u8_error_code_t; - -typedef struct { - bool is_err; - union { - uint64_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_u64_error_code_t; - -typedef wasi_io_poll_own_pollable_t wasi_sockets_udp_own_pollable_t; - -typedef struct { - wasi_sockets_udp_incoming_datagram_t *ptr; - size_t len; -} wasi_sockets_udp_list_incoming_datagram_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_list_incoming_datagram_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_list_incoming_datagram_error_code_t; - -typedef struct { - wasi_sockets_udp_outgoing_datagram_t *ptr; - size_t len; -} wasi_sockets_udp_list_outgoing_datagram_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_udp_create_socket_error_code_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_udp_create_socket_ip_address_family_t; - -typedef wasi_sockets_udp_own_udp_socket_t wasi_sockets_udp_create_socket_own_udp_socket_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_create_socket_own_udp_socket_t ok; - wasi_sockets_udp_create_socket_error_code_t err; - } val; -} wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t; - -typedef wasi_clocks_monotonic_clock_duration_t wasi_sockets_tcp_duration_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_tcp_error_code_t; - -typedef wasi_sockets_network_ip_socket_address_t wasi_sockets_tcp_ip_socket_address_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_tcp_ip_address_family_t; - -typedef uint8_t wasi_sockets_tcp_shutdown_type_t; - -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_RECEIVE 0 -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_SEND 1 -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_BOTH 2 - -typedef struct wasi_sockets_tcp_own_tcp_socket_t { - int32_t __handle; -} wasi_sockets_tcp_own_tcp_socket_t; - -typedef struct wasi_sockets_tcp_borrow_tcp_socket_t { - int32_t __handle; -} wasi_sockets_tcp_borrow_tcp_socket_t; - -typedef wasi_sockets_network_borrow_network_t wasi_sockets_tcp_borrow_network_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_void_error_code_t; - -typedef wasi_io_streams_own_input_stream_t wasi_sockets_tcp_own_input_stream_t; - -typedef wasi_io_streams_own_output_stream_t wasi_sockets_tcp_own_output_stream_t; - -typedef struct { - wasi_sockets_tcp_own_input_stream_t f0; - wasi_sockets_tcp_own_output_stream_t f1; -} wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t; - -typedef struct { - wasi_sockets_tcp_own_tcp_socket_t f0; - wasi_sockets_tcp_own_input_stream_t f1; - wasi_sockets_tcp_own_output_stream_t f2; -} wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_ip_socket_address_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_ip_socket_address_error_code_t; - -typedef struct { - bool is_err; - union { - bool ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_bool_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_duration_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_duration_error_code_t; - -typedef struct { - bool is_err; - union { - uint32_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_u32_error_code_t; - -typedef struct { - bool is_err; - union { - uint8_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_u8_error_code_t; - -typedef struct { - bool is_err; - union { - uint64_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_u64_error_code_t; - -typedef wasi_io_poll_own_pollable_t wasi_sockets_tcp_own_pollable_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_tcp_create_socket_error_code_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_tcp_create_socket_ip_address_family_t; - -typedef wasi_sockets_tcp_own_tcp_socket_t wasi_sockets_tcp_create_socket_own_tcp_socket_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_create_socket_own_tcp_socket_t ok; - wasi_sockets_tcp_create_socket_error_code_t err; - } val; -} wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_ip_name_lookup_error_code_t; - -typedef wasi_sockets_network_ip_address_t wasi_sockets_ip_name_lookup_ip_address_t; - -typedef struct wasi_sockets_ip_name_lookup_own_resolve_address_stream_t { - int32_t __handle; -} wasi_sockets_ip_name_lookup_own_resolve_address_stream_t; - -typedef struct wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t { - int32_t __handle; -} wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t; - -typedef struct { - bool is_some; - wasi_sockets_ip_name_lookup_ip_address_t val; -} wasi_sockets_ip_name_lookup_option_ip_address_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_ip_name_lookup_option_ip_address_t ok; - wasi_sockets_ip_name_lookup_error_code_t err; - } val; -} wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t; - -typedef wasi_io_poll_own_pollable_t wasi_sockets_ip_name_lookup_own_pollable_t; - -typedef wasi_sockets_network_borrow_network_t wasi_sockets_ip_name_lookup_borrow_network_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_ip_name_lookup_own_resolve_address_stream_t ok; - wasi_sockets_ip_name_lookup_error_code_t err; - } val; -} wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t; - -typedef struct { - uint64_t f0; - uint64_t f1; -} plugin_tuple2_u64_u64_t; - -typedef streamkit_plugin_types_node_metadata_t exports_streamkit_plugin_node_node_metadata_t; - -typedef streamkit_plugin_types_packet_t exports_streamkit_plugin_node_packet_t; - -typedef struct exports_streamkit_plugin_node_own_node_instance_t { - int32_t __handle; -} exports_streamkit_plugin_node_own_node_instance_t; - -typedef struct exports_streamkit_plugin_node_node_instance_t exports_streamkit_plugin_node_node_instance_t; - -typedef exports_streamkit_plugin_node_node_instance_t* exports_streamkit_plugin_node_borrow_node_instance_t; - -typedef struct { - bool is_err; - union { - plugin_string_t err; - } val; -} exports_streamkit_plugin_node_result_void_string_t; - -// Imported Functions from `streamkit:plugin/host@0.1.0` -// Send a packet to an output pin -extern bool streamkit_plugin_host_send_output(plugin_string_t *pin_name, streamkit_plugin_host_packet_t *packet, plugin_string_t *err); -// Log a message to the host -extern void streamkit_plugin_host_log(streamkit_plugin_host_log_level_t level, plugin_string_t *message); - -// Imported Functions from `wasi:cli/environment@0.2.0` -// Get the POSIX-style environment variables. -// -// Each environment variable is provided as a pair of string variable names -// and string value. -// -// Morally, these are a value import, but until value imports are available -// in the component model, this import function should return the same -// values each time it is called. -extern void wasi_cli_environment_get_environment(plugin_list_tuple2_string_string_t *ret); -// Get the POSIX-style arguments to the program. -extern void wasi_cli_environment_get_arguments(plugin_list_string_t *ret); -// Return a path that programs should use as their initial current working -// directory, interpreting `.` as shorthand for this. -extern bool wasi_cli_environment_initial_cwd(plugin_string_t *ret); - -// Imported Functions from `wasi:cli/exit@0.2.0` -// Exit the current instance and any linked instances. -extern void wasi_cli_exit_exit(wasi_cli_exit_result_void_void_t *status); - -// Imported Functions from `wasi:io/error@0.2.0` -extern void wasi_io_error_method_error_to_debug_string(wasi_io_error_borrow_error_t self, plugin_string_t *ret); - -// Imported Functions from `wasi:io/poll@0.2.0` -extern bool wasi_io_poll_method_pollable_ready(wasi_io_poll_borrow_pollable_t self); -extern void wasi_io_poll_method_pollable_block(wasi_io_poll_borrow_pollable_t self); -extern void wasi_io_poll_poll(wasi_io_poll_list_borrow_pollable_t *in, plugin_list_u32_t *ret); - -// Imported Functions from `wasi:io/streams@0.2.0` -extern bool wasi_io_streams_method_input_stream_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_blocking_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_blocking_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern wasi_io_streams_own_pollable_t wasi_io_streams_method_input_stream_subscribe(wasi_io_streams_borrow_input_stream_t self); -extern bool wasi_io_streams_method_output_stream_check_write(wasi_io_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_write(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_write_and_flush(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err); -extern wasi_io_streams_own_pollable_t wasi_io_streams_method_output_stream_subscribe(wasi_io_streams_borrow_output_stream_t self); -extern bool wasi_io_streams_method_output_stream_write_zeroes(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); - -// Imported Functions from `wasi:cli/stdin@0.2.0` -extern wasi_cli_stdin_own_input_stream_t wasi_cli_stdin_get_stdin(void); - -// Imported Functions from `wasi:cli/stdout@0.2.0` -extern wasi_cli_stdout_own_output_stream_t wasi_cli_stdout_get_stdout(void); - -// Imported Functions from `wasi:cli/stderr@0.2.0` -extern wasi_cli_stderr_own_output_stream_t wasi_cli_stderr_get_stderr(void); - -// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` -// If stdin is connected to a terminal, return a `terminal-input` handle -// allowing further interaction with it. -extern bool wasi_cli_terminal_stdin_get_terminal_stdin(wasi_cli_terminal_stdin_own_terminal_input_t *ret); - -// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` -// If stdout is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -extern bool wasi_cli_terminal_stdout_get_terminal_stdout(wasi_cli_terminal_stdout_own_terminal_output_t *ret); - -// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` -// If stderr is connected to a terminal, return a `terminal-output` handle -// allowing further interaction with it. -extern bool wasi_cli_terminal_stderr_get_terminal_stderr(wasi_cli_terminal_stderr_own_terminal_output_t *ret); - -// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` -extern wasi_clocks_monotonic_clock_instant_t wasi_clocks_monotonic_clock_now(void); -extern wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_resolution(void); -extern wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_instant(wasi_clocks_monotonic_clock_instant_t when); -extern wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_duration(wasi_clocks_monotonic_clock_duration_t when); - -// Imported Functions from `wasi:clocks/wall-clock@0.2.0` -extern void wasi_clocks_wall_clock_now(wasi_clocks_wall_clock_datetime_t *ret); -extern void wasi_clocks_wall_clock_resolution(wasi_clocks_wall_clock_datetime_t *ret); - -// Imported Functions from `wasi:filesystem/types@0.2.0` -extern bool wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_input_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_flags_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_type_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_read(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_filesize_t offset, plugin_tuple2_list_u8_bool_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_write(wasi_filesystem_types_borrow_descriptor_t self, plugin_list_u8_t *buffer, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_directory_entry_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t old_path_flags, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_open_flags_t open_flags, wasi_filesystem_types_descriptor_flags_t flags, wasi_filesystem_types_own_descriptor_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, plugin_string_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other); -extern bool wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_types_borrow_directory_entry_stream_t self, wasi_filesystem_types_option_directory_entry_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_filesystem_error_code(wasi_filesystem_types_borrow_error_t err_, wasi_filesystem_types_error_code_t *ret); - -// Imported Functions from `wasi:filesystem/preopens@0.2.0` -extern void wasi_filesystem_preopens_get_directories(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ret); - -// Imported Functions from `wasi:sockets/instance-network@0.2.0` -extern wasi_sockets_instance_network_own_network_t wasi_sockets_instance_network_instance_network(void); - -// Imported Functions from `wasi:sockets/udp@0.2.0` -extern bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_borrow_network_t network, wasi_sockets_udp_ip_socket_address_t *local_address, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_finish_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_stream(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_ip_address_family_t wasi_sockets_udp_method_udp_socket_address_family(wasi_sockets_udp_borrow_udp_socket_t self); -extern bool wasi_sockets_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_udp_socket_subscribe(wasi_sockets_udp_borrow_udp_socket_t self); -extern bool wasi_sockets_udp_method_incoming_datagram_stream_receive(wasi_sockets_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_udp_list_incoming_datagram_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_udp_borrow_incoming_datagram_stream_t self); -extern bool wasi_sockets_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self); - -// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` -extern bool wasi_sockets_udp_create_socket_create_udp_socket(wasi_sockets_udp_create_socket_ip_address_family_t address_family, wasi_sockets_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_udp_create_socket_error_code_t *err); - -// Imported Functions from `wasi:sockets/tcp@0.2.0` -extern bool wasi_sockets_tcp_method_tcp_socket_start_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *local_address, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *remote_address, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_accept(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_local_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_remote_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_is_listening(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern wasi_sockets_tcp_ip_address_family_t wasi_sockets_tcp_method_tcp_socket_address_family(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern bool wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern wasi_sockets_tcp_own_pollable_t wasi_sockets_tcp_method_tcp_socket_subscribe(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern bool wasi_sockets_tcp_method_tcp_socket_shutdown(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_shutdown_type_t shutdown_type, wasi_sockets_tcp_error_code_t *err); - -// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` -extern bool wasi_sockets_tcp_create_socket_create_tcp_socket(wasi_sockets_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_tcp_create_socket_error_code_t *err); - -// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` -extern bool wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err); -extern wasi_sockets_ip_name_lookup_own_pollable_t wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self); -extern bool wasi_sockets_ip_name_lookup_resolve_addresses(wasi_sockets_ip_name_lookup_borrow_network_t network, plugin_string_t *name, wasi_sockets_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err); - -// Imported Functions from `wasi:random/random@0.2.0` -extern void wasi_random_random_get_random_bytes(uint64_t len, plugin_list_u8_t *ret); -extern uint64_t wasi_random_random_get_random_u64(void); - -// Imported Functions from `wasi:random/insecure@0.2.0` -extern void wasi_random_insecure_get_insecure_random_bytes(uint64_t len, plugin_list_u8_t *ret); -extern uint64_t wasi_random_insecure_get_insecure_random_u64(void); - -// Imported Functions from `wasi:random/insecure-seed@0.2.0` -extern void wasi_random_insecure_seed_insecure_seed(plugin_tuple2_u64_u64_t *ret); - -// Exported Functions from `streamkit:plugin/node@0.1.0` -void exports_streamkit_plugin_node_metadata(exports_streamkit_plugin_node_node_metadata_t *ret); -exports_streamkit_plugin_node_own_node_instance_t exports_streamkit_plugin_node_constructor_node_instance(plugin_string_t *maybe_params); -bool exports_streamkit_plugin_node_method_node_instance_process(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *input_pin, exports_streamkit_plugin_node_packet_t *packet, plugin_string_t *err); -bool exports_streamkit_plugin_node_method_node_instance_update_params(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *maybe_params, plugin_string_t *err); -void exports_streamkit_plugin_node_method_node_instance_cleanup(exports_streamkit_plugin_node_borrow_node_instance_t self); - -// Helper Functions - -void streamkit_plugin_types_packet_type_free(streamkit_plugin_types_packet_type_t *ptr); - -void streamkit_plugin_types_list_packet_type_free(streamkit_plugin_types_list_packet_type_t *ptr); - -void streamkit_plugin_types_input_pin_free(streamkit_plugin_types_input_pin_t *ptr); - -void streamkit_plugin_types_output_pin_free(streamkit_plugin_types_output_pin_t *ptr); - -void streamkit_plugin_types_list_input_pin_free(streamkit_plugin_types_list_input_pin_t *ptr); - -void streamkit_plugin_types_list_output_pin_free(streamkit_plugin_types_list_output_pin_t *ptr); - -void plugin_list_string_free(plugin_list_string_t *ptr); - -void streamkit_plugin_types_node_metadata_free(streamkit_plugin_types_node_metadata_t *ptr); - -void plugin_list_f32_free(plugin_list_f32_t *ptr); - -void streamkit_plugin_types_audio_frame_free(streamkit_plugin_types_audio_frame_t *ptr); - -void plugin_list_u8_free(plugin_list_u8_t *ptr); - -void streamkit_plugin_types_packet_free(streamkit_plugin_types_packet_t *ptr); - -void streamkit_plugin_host_packet_free(streamkit_plugin_host_packet_t *ptr); - -void streamkit_plugin_host_result_void_string_free(streamkit_plugin_host_result_void_string_t *ptr); - -void plugin_tuple2_string_string_free(plugin_tuple2_string_string_t *ptr); - -void plugin_list_tuple2_string_string_free(plugin_list_tuple2_string_string_t *ptr); - -void plugin_option_string_free(plugin_option_string_t *ptr); - -void wasi_cli_exit_result_void_void_free(wasi_cli_exit_result_void_void_t *ptr); - -extern void wasi_io_error_error_drop_own(wasi_io_error_own_error_t handle); - -extern void wasi_io_error_error_drop_borrow(wasi_io_error_borrow_error_t handle); - -extern wasi_io_error_borrow_error_t wasi_io_error_borrow_error(wasi_io_error_own_error_t handle); - -extern void wasi_io_poll_pollable_drop_own(wasi_io_poll_own_pollable_t handle); - -extern void wasi_io_poll_pollable_drop_borrow(wasi_io_poll_borrow_pollable_t handle); - -extern wasi_io_poll_borrow_pollable_t wasi_io_poll_borrow_pollable(wasi_io_poll_own_pollable_t handle); - -void wasi_io_poll_list_borrow_pollable_free(wasi_io_poll_list_borrow_pollable_t *ptr); - -void plugin_list_u32_free(plugin_list_u32_t *ptr); - -void wasi_io_streams_stream_error_free(wasi_io_streams_stream_error_t *ptr); - -extern void wasi_io_streams_input_stream_drop_own(wasi_io_streams_own_input_stream_t handle); - -extern void wasi_io_streams_input_stream_drop_borrow(wasi_io_streams_borrow_input_stream_t handle); - -extern wasi_io_streams_borrow_input_stream_t wasi_io_streams_borrow_input_stream(wasi_io_streams_own_input_stream_t handle); - -extern void wasi_io_streams_output_stream_drop_own(wasi_io_streams_own_output_stream_t handle); - -extern void wasi_io_streams_output_stream_drop_borrow(wasi_io_streams_borrow_output_stream_t handle); - -extern wasi_io_streams_borrow_output_stream_t wasi_io_streams_borrow_output_stream(wasi_io_streams_own_output_stream_t handle); - -void wasi_io_streams_result_list_u8_stream_error_free(wasi_io_streams_result_list_u8_stream_error_t *ptr); - -void wasi_io_streams_result_u64_stream_error_free(wasi_io_streams_result_u64_stream_error_t *ptr); - -void wasi_io_streams_result_void_stream_error_free(wasi_io_streams_result_void_stream_error_t *ptr); - -extern void wasi_cli_terminal_input_terminal_input_drop_own(wasi_cli_terminal_input_own_terminal_input_t handle); - -extern void wasi_cli_terminal_input_terminal_input_drop_borrow(wasi_cli_terminal_input_borrow_terminal_input_t handle); - -extern wasi_cli_terminal_input_borrow_terminal_input_t wasi_cli_terminal_input_borrow_terminal_input(wasi_cli_terminal_input_own_terminal_input_t handle); - -extern void wasi_cli_terminal_output_terminal_output_drop_own(wasi_cli_terminal_output_own_terminal_output_t handle); - -extern void wasi_cli_terminal_output_terminal_output_drop_borrow(wasi_cli_terminal_output_borrow_terminal_output_t handle); - -extern wasi_cli_terminal_output_borrow_terminal_output_t wasi_cli_terminal_output_borrow_terminal_output(wasi_cli_terminal_output_own_terminal_output_t handle); - -void wasi_cli_terminal_stdin_option_own_terminal_input_free(wasi_cli_terminal_stdin_option_own_terminal_input_t *ptr); - -void wasi_cli_terminal_stdout_option_own_terminal_output_free(wasi_cli_terminal_stdout_option_own_terminal_output_t *ptr); - -void wasi_cli_terminal_stderr_option_own_terminal_output_free(wasi_cli_terminal_stderr_option_own_terminal_output_t *ptr); - -void wasi_filesystem_types_option_datetime_free(wasi_filesystem_types_option_datetime_t *ptr); - -void wasi_filesystem_types_descriptor_stat_free(wasi_filesystem_types_descriptor_stat_t *ptr); - -void wasi_filesystem_types_new_timestamp_free(wasi_filesystem_types_new_timestamp_t *ptr); - -void wasi_filesystem_types_directory_entry_free(wasi_filesystem_types_directory_entry_t *ptr); - -extern void wasi_filesystem_types_descriptor_drop_own(wasi_filesystem_types_own_descriptor_t handle); - -extern void wasi_filesystem_types_descriptor_drop_borrow(wasi_filesystem_types_borrow_descriptor_t handle); - -extern wasi_filesystem_types_borrow_descriptor_t wasi_filesystem_types_borrow_descriptor(wasi_filesystem_types_own_descriptor_t handle); - -extern void wasi_filesystem_types_directory_entry_stream_drop_own(wasi_filesystem_types_own_directory_entry_stream_t handle); - -extern void wasi_filesystem_types_directory_entry_stream_drop_borrow(wasi_filesystem_types_borrow_directory_entry_stream_t handle); - -extern wasi_filesystem_types_borrow_directory_entry_stream_t wasi_filesystem_types_borrow_directory_entry_stream(wasi_filesystem_types_own_directory_entry_stream_t handle); - -void wasi_filesystem_types_result_own_input_stream_error_code_free(wasi_filesystem_types_result_own_input_stream_error_code_t *ptr); - -void wasi_filesystem_types_result_own_output_stream_error_code_free(wasi_filesystem_types_result_own_output_stream_error_code_t *ptr); - -void wasi_filesystem_types_result_void_error_code_free(wasi_filesystem_types_result_void_error_code_t *ptr); - -void wasi_filesystem_types_result_descriptor_flags_error_code_free(wasi_filesystem_types_result_descriptor_flags_error_code_t *ptr); - -void wasi_filesystem_types_result_descriptor_type_error_code_free(wasi_filesystem_types_result_descriptor_type_error_code_t *ptr); - -void wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t *ptr); - -void wasi_filesystem_types_result_filesize_error_code_free(wasi_filesystem_types_result_filesize_error_code_t *ptr); - -void wasi_filesystem_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_types_result_own_directory_entry_stream_error_code_t *ptr); - -void wasi_filesystem_types_result_descriptor_stat_error_code_free(wasi_filesystem_types_result_descriptor_stat_error_code_t *ptr); - -void wasi_filesystem_types_result_own_descriptor_error_code_free(wasi_filesystem_types_result_own_descriptor_error_code_t *ptr); - -void wasi_filesystem_types_result_string_error_code_free(wasi_filesystem_types_result_string_error_code_t *ptr); - -void wasi_filesystem_types_result_metadata_hash_value_error_code_free(wasi_filesystem_types_result_metadata_hash_value_error_code_t *ptr); - -void wasi_filesystem_types_option_directory_entry_free(wasi_filesystem_types_option_directory_entry_t *ptr); - -void wasi_filesystem_types_result_option_directory_entry_error_code_free(wasi_filesystem_types_result_option_directory_entry_error_code_t *ptr); - -void wasi_filesystem_types_option_error_code_free(wasi_filesystem_types_option_error_code_t *ptr); - -void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr); - -void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr); - -extern void wasi_sockets_network_network_drop_own(wasi_sockets_network_own_network_t handle); - -extern void wasi_sockets_network_network_drop_borrow(wasi_sockets_network_borrow_network_t handle); - -extern wasi_sockets_network_borrow_network_t wasi_sockets_network_borrow_network(wasi_sockets_network_own_network_t handle); - -void wasi_sockets_network_ip_address_free(wasi_sockets_network_ip_address_t *ptr); - -void wasi_sockets_network_ip_socket_address_free(wasi_sockets_network_ip_socket_address_t *ptr); - -void wasi_sockets_udp_ip_socket_address_free(wasi_sockets_udp_ip_socket_address_t *ptr); - -void wasi_sockets_udp_incoming_datagram_free(wasi_sockets_udp_incoming_datagram_t *ptr); - -void wasi_sockets_udp_option_ip_socket_address_free(wasi_sockets_udp_option_ip_socket_address_t *ptr); - -void wasi_sockets_udp_outgoing_datagram_free(wasi_sockets_udp_outgoing_datagram_t *ptr); - -extern void wasi_sockets_udp_udp_socket_drop_own(wasi_sockets_udp_own_udp_socket_t handle); - -extern void wasi_sockets_udp_udp_socket_drop_borrow(wasi_sockets_udp_borrow_udp_socket_t handle); - -extern wasi_sockets_udp_borrow_udp_socket_t wasi_sockets_udp_borrow_udp_socket(wasi_sockets_udp_own_udp_socket_t handle); - -extern void wasi_sockets_udp_incoming_datagram_stream_drop_own(wasi_sockets_udp_own_incoming_datagram_stream_t handle); - -extern void wasi_sockets_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_incoming_datagram_stream_t handle); - -extern wasi_sockets_udp_borrow_incoming_datagram_stream_t wasi_sockets_udp_borrow_incoming_datagram_stream(wasi_sockets_udp_own_incoming_datagram_stream_t handle); - -extern void wasi_sockets_udp_outgoing_datagram_stream_drop_own(wasi_sockets_udp_own_outgoing_datagram_stream_t handle); - -extern void wasi_sockets_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_outgoing_datagram_stream_t handle); - -extern wasi_sockets_udp_borrow_outgoing_datagram_stream_t wasi_sockets_udp_borrow_outgoing_datagram_stream(wasi_sockets_udp_own_outgoing_datagram_stream_t handle); - -void wasi_sockets_udp_result_void_error_code_free(wasi_sockets_udp_result_void_error_code_t *ptr); - -void wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr); - -void wasi_sockets_udp_result_ip_socket_address_error_code_free(wasi_sockets_udp_result_ip_socket_address_error_code_t *ptr); - -void wasi_sockets_udp_result_u8_error_code_free(wasi_sockets_udp_result_u8_error_code_t *ptr); - -void wasi_sockets_udp_result_u64_error_code_free(wasi_sockets_udp_result_u64_error_code_t *ptr); - -void wasi_sockets_udp_list_incoming_datagram_free(wasi_sockets_udp_list_incoming_datagram_t *ptr); - -void wasi_sockets_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_udp_result_list_incoming_datagram_error_code_t *ptr); - -void wasi_sockets_udp_list_outgoing_datagram_free(wasi_sockets_udp_list_outgoing_datagram_t *ptr); - -void wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t *ptr); - -void wasi_sockets_tcp_ip_socket_address_free(wasi_sockets_tcp_ip_socket_address_t *ptr); - -extern void wasi_sockets_tcp_tcp_socket_drop_own(wasi_sockets_tcp_own_tcp_socket_t handle); - -extern void wasi_sockets_tcp_tcp_socket_drop_borrow(wasi_sockets_tcp_borrow_tcp_socket_t handle); - -extern wasi_sockets_tcp_borrow_tcp_socket_t wasi_sockets_tcp_borrow_tcp_socket(wasi_sockets_tcp_own_tcp_socket_t handle); - -void wasi_sockets_tcp_result_void_error_code_free(wasi_sockets_tcp_result_void_error_code_t *ptr); - -void wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr); - -void wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr); - -void wasi_sockets_tcp_result_ip_socket_address_error_code_free(wasi_sockets_tcp_result_ip_socket_address_error_code_t *ptr); - -void wasi_sockets_tcp_result_bool_error_code_free(wasi_sockets_tcp_result_bool_error_code_t *ptr); - -void wasi_sockets_tcp_result_duration_error_code_free(wasi_sockets_tcp_result_duration_error_code_t *ptr); - -void wasi_sockets_tcp_result_u32_error_code_free(wasi_sockets_tcp_result_u32_error_code_t *ptr); - -void wasi_sockets_tcp_result_u8_error_code_free(wasi_sockets_tcp_result_u8_error_code_t *ptr); - -void wasi_sockets_tcp_result_u64_error_code_free(wasi_sockets_tcp_result_u64_error_code_t *ptr); - -void wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr); - -void wasi_sockets_ip_name_lookup_ip_address_free(wasi_sockets_ip_name_lookup_ip_address_t *ptr); - -extern void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle); - -extern void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t handle); - -extern wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle); - -void wasi_sockets_ip_name_lookup_option_ip_address_free(wasi_sockets_ip_name_lookup_option_ip_address_t *ptr); - -void wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t *ptr); - -void wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr); - -void exports_streamkit_plugin_node_node_metadata_free(exports_streamkit_plugin_node_node_metadata_t *ptr); - -void exports_streamkit_plugin_node_packet_free(exports_streamkit_plugin_node_packet_t *ptr); - -extern void exports_streamkit_plugin_node_node_instance_drop_own(exports_streamkit_plugin_node_own_node_instance_t handle); - -extern exports_streamkit_plugin_node_own_node_instance_t exports_streamkit_plugin_node_node_instance_new(exports_streamkit_plugin_node_node_instance_t *rep); -extern exports_streamkit_plugin_node_node_instance_t* exports_streamkit_plugin_node_node_instance_rep(exports_streamkit_plugin_node_own_node_instance_t handle); -void exports_streamkit_plugin_node_node_instance_destructor(exports_streamkit_plugin_node_node_instance_t *rep); - -void exports_streamkit_plugin_node_result_void_string_free(exports_streamkit_plugin_node_result_void_string_t *ptr); - -// Sets the string `ret` to reference the input string `s` without copying it -void plugin_string_set(plugin_string_t *ret, const char*s); - -// Creates a copy of the input nul-terminated string `s` and -// stores it into the component model string `ret`. -void plugin_string_dup(plugin_string_t *ret, const char*s); - -// Deallocates the string pointed to by `ret`, deallocating -// the memory behind the string. -void plugin_string_free(plugin_string_t *ret); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/examples/plugins/gain-wasm-c/plugin_component_type.o b/examples/plugins/gain-wasm-c/plugin_component_type.o deleted file mode 100644 index c05812e88..000000000 Binary files a/examples/plugins/gain-wasm-c/plugin_component_type.o and /dev/null differ diff --git a/examples/plugins/gain-wasm-go/README.md b/examples/plugins/gain-wasm-go/README.md index 3186f3592..32ad696a1 100644 --- a/examples/plugins/gain-wasm-go/README.md +++ b/examples/plugins/gain-wasm-go/README.md @@ -6,6 +6,13 @@ SPDX-License-Identifier: MPL-2.0 # Go Gain Filter Plugin Example +> ⚠️ **Currently not buildable.** The StreamKit plugin world migrated to +> WASI 0.3 / Component Model native async (`async func` for `process`, +> `update-params`, and `send-output`), and `wit-bindgen-go` cannot parse or +> generate bindings for async WIT yet. This example (and the Go SDK bindings +> in `sdks/plugin-sdk/go/`) still target the previous WASI 0.2 world and will +> be migrated once the Go toolchain gains component-model async support. + This directory contains a Go implementation of the StreamKit gain (volume) filter plugin. It mirrors the Rust example so you can compare language ergonomics when targeting WebAssembly components. diff --git a/examples/plugins/gain-wasm-rust/Cargo.lock b/examples/plugins/gain-wasm-rust/Cargo.lock index a891976aa..5c28b822e 100644 --- a/examples/plugins/gain-wasm-rust/Cargo.lock +++ b/examples/plugins/gain-wasm-rust/Cargo.lock @@ -4,15 +4,15 @@ version = 4 [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" [[package]] name = "equivalent" @@ -22,98 +22,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "foldhash" -version = "0.1.5" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - -[[package]] -name = "futures" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-executor" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-macro" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "gain-plugin" @@ -126,19 +37,13 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "foldhash", ] -[[package]] -name = "hashbrown" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" - [[package]] name = "heck" version = "0.5.0" @@ -147,18 +52,18 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "id-arena" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" [[package]] name = "indexmap" -version = "2.11.4" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown", "serde", "serde_core", ] @@ -182,28 +87,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] -name = "memchr" -version = "2.7.6" +name = "macro-string" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "59a9dbbfc75d2688ed057456ce8a3ee3f48d12eec09229f560f3643b9f275653" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "pin-utils" -version = "0.1.0" +name = "memchr" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "prettyplease" @@ -287,17 +185,11 @@ dependencies = [ "serde_core", ] -[[package]] -name = "slab" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" - [[package]] name = "streamkit-plugin-sdk-wasm" version = "0.1.0" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] @@ -325,9 +217,9 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "wasm-encoder" -version = "0.236.1" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7" +checksum = "5a879a421bd17c528b74721b2abf4c62e8f1d1889c2ba8c3c50d02deaf2ce395" dependencies = [ "leb128fmt", "wasmparser", @@ -335,9 +227,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.236.1" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c909f94a49a8de3365f3c0344f064818f1e369ff1740c5b04f455f85d454768e" +checksum = "5f998ccc6e012f7b86865eb2a106c8a0422017a1a88977ce01a69f2244be2e57" dependencies = [ "anyhow", "indexmap", @@ -347,53 +239,42 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.236.1" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7" +checksum = "437970b35b1a85cfde9c74b2398352d8d653f3bd8e3a3db0c063ea8f5b4b36ff" dependencies = [ "bitflags", - "hashbrown 0.15.5", + "hashbrown", "indexmap", "semver", ] [[package]] name = "wit-bindgen" -version = "0.44.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bd9ed271234163b18c92783b0d406f08ca32c232e972f207a68c7b324c44bf" +checksum = "a43552cfa071f246cfd99e5dbb23710dfe7336b3259e09339818483359470749" dependencies = [ - "wit-bindgen-rt", + "bitflags", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.44.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4103c7a3e178b75cd8b0b574fa199ed015e8399c9859b003865cc28834b474b" +checksum = "4738d1c9a78e97bc7f664bfafd5d8e67d7bb26faa5c41e6d628e8bbdad3ec351" dependencies = [ "anyhow", "heck", "wit-parser", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653c85dd7aee6fe6f4bded0d242406deadae9819029ce6f7d258c920c384358a" -dependencies = [ - "bitflags", - "futures", - "once_cell", -] - [[package]] name = "wit-bindgen-rust" -version = "0.44.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d164b3b6fbd2b0dd8b639b1012110c0bc256519a0a6def410d4020fa8ae106" +checksum = "1130ce1f531bc9f9a75922244aa773bf5e2117fda1ef4a86b9f98d6b8135eb46" dependencies = [ "anyhow", "heck", @@ -407,11 +288,12 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.44.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9100a5e1ac85e526dcd4ef49c3ff7689e026fa5e56e2a2047fd377fc682e02" +checksum = "07296369e4d598e7e79b64eef66f724d83324ea671bcf677d78fc5cf92604ae5" dependencies = [ "anyhow", + "macro-string", "prettyplease", "proc-macro2", "quote", @@ -422,9 +304,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.236.1" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3622959ed7ed6341c38e5aa35af243632534b0a36226852faa802939ce11e00f" +checksum = "83a5e60173c413659c689f0581b0cf5d1a2404077568f9ffdce748a9eb2fc913" dependencies = [ "anyhow", "bitflags", @@ -441,11 +323,12 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.236.1" +version = "0.251.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e4833a20cd6e85d6abfea0e63a399472d6f88c6262957c17f546879a80ba15" +checksum = "e960732e824fab95099971a09e638979347c94ca48568d3c854c945729196947" dependencies = [ "anyhow", + "hashbrown", "id-arena", "indexmap", "log", diff --git a/examples/plugins/gain-wasm-rust/Cargo.toml b/examples/plugins/gain-wasm-rust/Cargo.toml index 45b4205cf..7caec3146 100644 --- a/examples/plugins/gain-wasm-rust/Cargo.toml +++ b/examples/plugins/gain-wasm-rust/Cargo.toml @@ -6,7 +6,7 @@ license = "MPL-2.0" [dependencies] streamkit-plugin-sdk-wasm = { path = "../../../sdks/plugin-sdk/wasm/rust" } -wit-bindgen = "0.44" +wit-bindgen = "0.58" serde_json = "1" [lib] diff --git a/examples/plugins/gain-wasm-rust/README.md b/examples/plugins/gain-wasm-rust/README.md index 59d928742..3c157a95f 100644 --- a/examples/plugins/gain-wasm-rust/README.md +++ b/examples/plugins/gain-wasm-rust/README.md @@ -17,22 +17,22 @@ This plugin applies a gain adjustment to audio streams. You can specify the gain ## Building -You need the WebAssembly Component Model toolchain: +You need the `wasm32-wasip2` target, which produces a WebAssembly component +directly: ```bash -cargo install cargo-component -rustup target add wasm32-wasip1 +rustup target add wasm32-wasip2 ``` Then build the plugin: ```bash -cargo component build --release +cargo build --release --target wasm32-wasip2 ``` The compiled plugin will be at: ``` -target/wasm32-wasip1/release/gain_plugin.wasm +target/wasm32-wasip2/release/gain_plugin.wasm ``` ## Using with StreamKit diff --git a/examples/plugins/gain-wasm-rust/src/lib.rs b/examples/plugins/gain-wasm-rust/src/lib.rs index b3e2799e6..915f20702 100644 --- a/examples/plugins/gain-wasm-rust/src/lib.rs +++ b/examples/plugins/gain-wasm-rust/src/lib.rs @@ -16,8 +16,8 @@ wit_bindgen::generate!({ path: "../../../wit", generate_all, with: { - "streamkit:plugin/types@0.1.0": sdk::types, - "streamkit:plugin/host@0.1.0": sdk::host, + "streamkit:plugin/types@0.2.0": sdk::types, + "streamkit:plugin/host@0.2.0": sdk::host, }, }); @@ -94,7 +94,7 @@ impl GuestNodeInstance for GainInstance { } } - fn process(&self, _input_pin: String, packet: Packet) -> Result<(), String> { + async fn process(&self, _input_pin: String, packet: Packet) -> Result<(), String> { match packet { Packet::Audio(mut audio_frame) => { let gain = *self @@ -105,14 +105,14 @@ impl GuestNodeInstance for GainInstance { *sample *= gain; } - sdk::host::send_output("out", &Packet::Audio(audio_frame))?; + sdk::host::send_output("out".to_string(), Packet::Audio(audio_frame)).await?; Ok(()) } _ => Err("Gain filter only accepts audio packets".to_string()), } } - fn update_params(&self, params: Option) -> Result<(), String> { + async fn update_params(&self, params: Option) -> Result<(), String> { let Some(params_str) = params else { return Ok(()); }; diff --git a/justfile b/justfile index 87e79456c..78c3c5f07 100644 --- a/justfile +++ b/justfile @@ -41,23 +41,22 @@ gen-types: @cargo run -p streamkit-api --bin generate-ts-types @cargo run -p streamkit-nodes --bin generate-compositor-types --features codegen -# Fetch WIT dependencies (WASI interfaces) +# WASI 0.3 WIT deps are vendored in wit/deps from the snapshot wasmtime's p3 +# host links against (wasmtime-wasi src/p3/wit/deps); no registry fetch yet. fetch-wit-deps: - @echo "Fetching WIT dependencies..." - @wkg wit fetch -d wit + @echo "WIT dependencies are vendored in wit/deps (wasi@0.3.0-rc snapshot); nothing to fetch." -# Generate pre-baked bindings for WASM plugin SDKs (Rust, Go, and C) +# Generate pre-baked bindings for WASM plugin SDKs (Rust and C). +# Go is skipped until wit-bindgen-go supports component-model async. gen-plugin-bindings: fetch-wit-deps @echo "Regenerating StreamKit WASM plugin bindings..." - @wkg wit build --wit-dir wit --output sdks/plugin-sdk/wit/streamkit-plugin.wasm + @wasm-tools component wit --wasm wit -o sdks/plugin-sdk/wit/streamkit-plugin.wasm @rm -rf sdks/plugin-sdk/wasm/rust/src/generated @mkdir -p sdks/plugin-sdk/wasm/rust/src/generated @wit-bindgen rust \ --world plugin \ --generate-all \ --pub-export-macro \ - --runtime-path wit_bindgen_rt \ - --bitflags-path wit_bindgen_rt::bitflags \ --out-dir sdks/plugin-sdk/wasm/rust/src/generated \ wit @printf '%s\n' \ @@ -67,18 +66,12 @@ gen-plugin-bindings: fetch-wit-deps 'pub mod plugin;' \ 'pub use plugin::*;' \ > sdks/plugin-sdk/wasm/rust/src/generated/mod.rs - @rm -rf sdks/plugin-sdk/go/bindings - @(cd sdks/plugin-sdk/go && go tool wit-bindgen-go generate \ - --world plugin \ - --out bindings \ - ../wit/streamkit-plugin.wasm) @rm -rf sdks/plugin-sdk/c/include sdks/plugin-sdk/c/src @mkdir -p sdks/plugin-sdk/c/include sdks/plugin-sdk/c/src - @(cd sdks/plugin-sdk/c && wit-bindgen c ../../wit --world plugin) + @(cd sdks/plugin-sdk/c && wit-bindgen c ../../../wit --world plugin) @mv sdks/plugin-sdk/c/plugin.h sdks/plugin-sdk/c/include/ @mv sdks/plugin-sdk/c/plugin.c sdks/plugin-sdk/c/plugin_component_type.o sdks/plugin-sdk/c/src/ @cargo fmt -p streamkit-plugin-sdk-wasm - @gofmt -w sdks/plugin-sdk/go || true # --- skit --- # Pre-flight: ensure the UI has been built (required by RustEmbed) @@ -550,22 +543,16 @@ dev: install-ui [working-directory: 'examples/plugins/gain-wasm-rust'] build-plugin-wasm-rust: @echo "Building Rust WASM gain plugin..." - @cargo component build --release - @echo "✓ Plugin built: examples/plugins/gain-wasm-rust/target/wasm32-wasip1/release/gain_plugin.wasm" + @cargo build --release --target wasm32-wasip2 + @echo "✓ Plugin built: examples/plugins/gain-wasm-rust/target/wasm32-wasip2/release/gain_plugin.wasm" -# Build Go WASM gain plugin example +# Build Go WASM gain plugin example. +# Blocked on component-model async support in wit-bindgen-go/TinyGo (the +# plugin world now uses async funcs, which wit-bindgen-go cannot parse yet). [working-directory: 'examples/plugins/gain-wasm-go'] build-plugin-wasm-go: - @echo "Building Go WASM gain plugin..." - @mkdir -p build - @tinygo build \ - -target=wasip2 \ - -no-debug \ - --wit-package ../../../sdks/plugin-sdk/wit/streamkit-plugin.wasm \ - --wit-world plugin \ - -o build/gain_plugin_go.wasm \ - . - @echo "✓ Plugin built: examples/plugins/gain-wasm-go/build/gain_plugin_go.wasm" + @echo "The Go SDK does not support the WASI 0.3 async plugin world yet (waiting on wit-bindgen-go async support)." + @exit 1 # Build C WASM gain plugin example (requires wit-bindgen and WASI SDK) [working-directory: 'examples/plugins/gain-wasm-c'] @@ -573,8 +560,8 @@ build-plugin-wasm-c: @echo "Building C WASM gain plugin..." @make -# Build all WASM plugin examples -build-plugins-wasm: build-plugin-wasm-rust build-plugin-wasm-go build-plugin-wasm-c +# Build all WASM plugin examples (Go pending toolchain async support) +build-plugins-wasm: build-plugin-wasm-rust build-plugin-wasm-c ## Native Plugins diff --git a/sdks/plugin-sdk/README.md b/sdks/plugin-sdk/README.md index adec4f92a..ca68f680a 100644 --- a/sdks/plugin-sdk/README.md +++ b/sdks/plugin-sdk/README.md @@ -29,7 +29,8 @@ The `native/` directory contains the SDK for writing high-performance native plu The `wasm/` directory packages WIT-generated bindings for WASM plugins: - `wasm/rust/` exposes the `streamkit-plugin-sdk-wasm` crate with pre-generated component bindings -- `go/` contains generated Go bindings used by `examples/plugins/gain-wasm-go` +- `go/` contains Go bindings for the previous (WASI 0.2) plugin world; regeneration + is paused until `wit-bindgen-go` supports component-model async - `c/` provides generated C bindings used by `examples/plugins/gain-wasm-c` - All bindings are generated from `/wit/plugin.wit` - WASM plugins must be built as WebAssembly *components* (Component Model) @@ -44,11 +45,9 @@ After editing the shared WIT interfaces, regenerate the language bindings and bu just gen-plugin-bindings ``` -The recipe requires `wkg`, `wit-bindgen` (CLI), and the Go toolchain (with -`wit-bindgen-go` installed via `go install`) to be available in `$PATH`. The command -updates: +The recipe requires `wasm-tools` and `wit-bindgen` (CLI) to be available in +`$PATH`. The command updates: - `plugin-sdk/wasm/rust/src/generated/` - Rust WASM SDK bindings -- `plugin-sdk/go/bindings/` - Go bindings - `plugin-sdk/c/include/` and `plugin-sdk/c/src/` - C bindings - `plugin-sdk/wit/streamkit-plugin.wasm` - Binary WIT package diff --git a/sdks/plugin-sdk/c/include/plugin.h b/sdks/plugin-sdk/c/include/plugin.h index 4b8285208..3b584df29 100644 --- a/sdks/plugin-sdk/c/include/plugin.h +++ b/sdks/plugin-sdk/c/include/plugin.h @@ -1,10 +1,4 @@ -/* - * SPDX-FileCopyrightText: © 2025 StreamKit Contributors - * - * SPDX-License-Identifier: MPL-2.0 - */ - -// Generated by `wit-bindgen` 0.44.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.58.0. DO NOT EDIT! #ifndef __BINDINGS_PLUGIN_H #define __BINDINGS_PLUGIN_H #ifdef __cplusplus @@ -20,6 +14,73 @@ typedef struct plugin_string_t { size_t len; } plugin_string_t; +// Async Helper Functions + +typedef uint32_t plugin_subtask_status_t; +typedef uint32_t plugin_subtask_t; +#define PLUGIN_SUBTASK_STATE(status) ((plugin_subtask_state_t) ((status) & 0xf)) +#define PLUGIN_SUBTASK_HANDLE(status) ((plugin_subtask_t) ((status) >> 4)) + +typedef enum plugin_subtask_state { + PLUGIN_SUBTASK_STARTING, + PLUGIN_SUBTASK_STARTED, + PLUGIN_SUBTASK_RETURNED, + PLUGIN_SUBTASK_STARTED_CANCELLED, + PLUGIN_SUBTASK_RETURNED_CANCELLED, +} plugin_subtask_state_t; + +plugin_subtask_status_t plugin_subtask_cancel(plugin_subtask_t subtask); +void plugin_subtask_drop(plugin_subtask_t subtask); + +typedef uint32_t plugin_callback_code_t; +#define PLUGIN_CALLBACK_CODE_EXIT 0 +#define PLUGIN_CALLBACK_CODE_YIELD 1 +#define PLUGIN_CALLBACK_CODE_WAIT(set) (2 | (set << 4)) + +typedef enum plugin_event_code { + PLUGIN_EVENT_NONE, + PLUGIN_EVENT_SUBTASK, + PLUGIN_EVENT_STREAM_READ, + PLUGIN_EVENT_STREAM_WRITE, + PLUGIN_EVENT_FUTURE_READ, + PLUGIN_EVENT_FUTURE_WRITE, + PLUGIN_EVENT_CANCEL, +} plugin_event_code_t; + +typedef struct plugin_event { + plugin_event_code_t event; + uint32_t waitable; + uint32_t code; +} plugin_event_t; + +typedef uint32_t plugin_waitable_set_t; +plugin_waitable_set_t plugin_waitable_set_new(void); +void plugin_waitable_join(uint32_t waitable, plugin_waitable_set_t set); +void plugin_waitable_set_drop(plugin_waitable_set_t set); +void plugin_waitable_set_wait(plugin_waitable_set_t set, plugin_event_t *event); +void plugin_waitable_set_poll(plugin_waitable_set_t set, plugin_event_t *event); + +void plugin_task_cancel(void); + +typedef uint32_t plugin_waitable_status_t; +#define PLUGIN_WAITABLE_STATE(status) ((plugin_waitable_state_t) ((status) & 0xf)) +#define PLUGIN_WAITABLE_COUNT(status) ((uint32_t) ((status) >> 4)) +#define PLUGIN_WAITABLE_STATUS_BLOCKED ((plugin_waitable_status_t) -1) + +typedef enum plugin_waitable_state { + PLUGIN_WAITABLE_COMPLETED, + PLUGIN_WAITABLE_DROPPED, + PLUGIN_WAITABLE_CANCELLED, +} plugin_waitable_state_t; + +void plugin_backpressure_inc(void); +void plugin_backpressure_dec(void); +void* plugin_context_get_0(void); +void plugin_context_set_0(void* value); +void plugin_thread_yield(void); + + + // Sample format for raw audio typedef uint8_t streamkit_plugin_types_sample_format_t; @@ -38,6 +99,7 @@ typedef struct streamkit_plugin_types_packet_type_t { uint8_t tag; union { streamkit_plugin_types_audio_format_t raw_audio; + plugin_string_t custom; } val; } streamkit_plugin_types_packet_type_t; @@ -45,7 +107,25 @@ typedef struct streamkit_plugin_types_packet_type_t { #define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_OPUS_AUDIO 1 #define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_TEXT 2 #define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_BINARY 3 -#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_ANY 4 +// Extensible structured packet type, identified by a namespaced, versioned id. +// +// Example: `plugin::native::vad/vad-event@1` +#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_CUSTOM 4 +#define STREAMKIT_PLUGIN_TYPES_PACKET_TYPE_ANY 5 + +// Encoding for custom packets. +typedef uint8_t streamkit_plugin_types_custom_encoding_t; + +#define STREAMKIT_PLUGIN_TYPES_CUSTOM_ENCODING_JSON 0 + +// Extensible structured packet payload. +// +// For now, payloads are UTF-8 JSON text for debuggability. +typedef struct streamkit_plugin_types_custom_packet_t { + plugin_string_t type_id; + streamkit_plugin_types_custom_encoding_t encoding; + plugin_string_t data; +} streamkit_plugin_types_custom_packet_t; typedef struct { streamkit_plugin_types_packet_type_t *ptr; @@ -112,12 +192,14 @@ typedef struct streamkit_plugin_types_packet_t { streamkit_plugin_types_audio_frame_t audio; plugin_string_t text; plugin_list_u8_t binary; + streamkit_plugin_types_custom_packet_t custom; } val; } streamkit_plugin_types_packet_t; #define STREAMKIT_PLUGIN_TYPES_PACKET_AUDIO 0 #define STREAMKIT_PLUGIN_TYPES_PACKET_TEXT 1 #define STREAMKIT_PLUGIN_TYPES_PACKET_BINARY 2 +#define STREAMKIT_PLUGIN_TYPES_PACKET_CUSTOM 3 typedef streamkit_plugin_types_packet_t streamkit_plugin_host_packet_t; @@ -135,6 +217,10 @@ typedef struct { plugin_string_t err; } val; } streamkit_plugin_host_result_void_string_t; +typedef struct streamkit_plugin_host_send_output_args { + plugin_string_t pin_name; + streamkit_plugin_host_packet_t packet; +} streamkit_plugin_host_send_output_args_t; typedef struct { plugin_string_t f0; @@ -155,90 +241,54 @@ typedef struct { bool is_err; } wasi_cli_exit_result_void_void_t; -typedef struct wasi_io_error_own_error_t { - int32_t __handle; -} wasi_io_error_own_error_t; +typedef uint8_t wasi_cli_types_error_code_t; -typedef struct wasi_io_error_borrow_error_t { - int32_t __handle; -} wasi_io_error_borrow_error_t; +// Input/output error +#define WASI_CLI_TYPES_ERROR_CODE_IO 0 +// Invalid or incomplete multibyte or wide character +#define WASI_CLI_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 1 +// Broken pipe +#define WASI_CLI_TYPES_ERROR_CODE_PIPE 2 -typedef struct wasi_io_poll_own_pollable_t { - int32_t __handle; -} wasi_io_poll_own_pollable_t; - -typedef struct wasi_io_poll_borrow_pollable_t { - int32_t __handle; -} wasi_io_poll_borrow_pollable_t; +typedef wasi_cli_types_error_code_t wasi_cli_stdin_error_code_t; -typedef struct { - wasi_io_poll_borrow_pollable_t *ptr; - size_t len; -} wasi_io_poll_list_borrow_pollable_t; +typedef uint32_t wasi_cli_stdin_stream_u8_t; typedef struct { - uint32_t *ptr; - size_t len; -} plugin_list_u32_t; - -typedef wasi_io_error_own_error_t wasi_io_streams_own_error_t; - -typedef struct wasi_io_streams_stream_error_t { - uint8_t tag; + bool is_err; union { - wasi_io_streams_own_error_t last_operation_failed; + wasi_cli_stdin_error_code_t err; } val; -} wasi_io_streams_stream_error_t; +} wasi_cli_stdin_result_void_error_code_t; -#define WASI_IO_STREAMS_STREAM_ERROR_LAST_OPERATION_FAILED 0 -#define WASI_IO_STREAMS_STREAM_ERROR_CLOSED 1 +typedef uint32_t wasi_cli_stdin_future_result_void_error_code_t; -typedef struct wasi_io_streams_own_input_stream_t { - int32_t __handle; -} wasi_io_streams_own_input_stream_t; - -typedef struct wasi_io_streams_borrow_input_stream_t { - int32_t __handle; -} wasi_io_streams_borrow_input_stream_t; - -typedef struct wasi_io_streams_own_output_stream_t { - int32_t __handle; -} wasi_io_streams_own_output_stream_t; +typedef struct { + wasi_cli_stdin_stream_u8_t f0; + wasi_cli_stdin_future_result_void_error_code_t f1; +} wasi_cli_stdin_tuple2_stream_u8_future_result_void_error_code_t; -typedef struct wasi_io_streams_borrow_output_stream_t { - int32_t __handle; -} wasi_io_streams_borrow_output_stream_t; +typedef wasi_cli_types_error_code_t wasi_cli_stdout_error_code_t; typedef struct { bool is_err; union { - plugin_list_u8_t ok; - wasi_io_streams_stream_error_t err; + wasi_cli_stdout_error_code_t err; } val; -} wasi_io_streams_result_list_u8_stream_error_t; +} wasi_cli_stdout_result_void_error_code_t; -typedef struct { - bool is_err; - union { - uint64_t ok; - wasi_io_streams_stream_error_t err; - } val; -} wasi_io_streams_result_u64_stream_error_t; +typedef uint32_t wasi_cli_stdout_future_result_void_error_code_t; -typedef wasi_io_poll_own_pollable_t wasi_io_streams_own_pollable_t; +typedef wasi_cli_types_error_code_t wasi_cli_stderr_error_code_t; typedef struct { bool is_err; union { - wasi_io_streams_stream_error_t err; + wasi_cli_stderr_error_code_t err; } val; -} wasi_io_streams_result_void_stream_error_t; - -typedef wasi_io_streams_own_input_stream_t wasi_cli_stdin_own_input_stream_t; - -typedef wasi_io_streams_own_output_stream_t wasi_cli_stdout_own_output_stream_t; +} wasi_cli_stderr_result_void_error_code_t; -typedef wasi_io_streams_own_output_stream_t wasi_cli_stderr_own_output_stream_t; +typedef uint32_t wasi_cli_stderr_future_result_void_error_code_t; typedef struct wasi_cli_terminal_input_own_terminal_input_t { int32_t __handle; @@ -277,135 +327,310 @@ typedef struct { wasi_cli_terminal_stderr_own_terminal_output_t val; } wasi_cli_terminal_stderr_option_own_terminal_output_t; -typedef uint64_t wasi_clocks_monotonic_clock_instant_t; +// A duration of time, in nanoseconds. +typedef uint64_t wasi_clocks_types_duration_t; -typedef uint64_t wasi_clocks_monotonic_clock_duration_t; +typedef wasi_clocks_types_duration_t wasi_clocks_monotonic_clock_duration_t; -typedef wasi_io_poll_own_pollable_t wasi_clocks_monotonic_clock_own_pollable_t; +// A mark on a monotonic clock is a number of nanoseconds since an +// unspecified initial value, and can only be compared to instances from +// the same monotonic-clock. +typedef uint64_t wasi_clocks_monotonic_clock_mark_t; -typedef struct wasi_clocks_wall_clock_datetime_t { - uint64_t seconds; +typedef wasi_clocks_types_duration_t wasi_clocks_system_clock_duration_t; + +// An "instant", or "exact time", is a point in time without regard to any +// time zone: just the time since a particular external reference point, +// often called an "epoch". +// +// Here, the epoch is 1970-01-01T00:00:00Z, also known as +// [POSIX's Seconds Since the Epoch], also known as [Unix Time]. +// +// Note that even if the seconds field is negative, incrementing +// nanoseconds always represents moving forwards in time. +// For example, `{ -1 seconds, 999999999 nanoseconds }` represents the +// instant one nanosecond before the epoch. +// For more on various different ways to represent time, see +// https://tc39.es/proposal-temporal/docs/timezone.html +// +// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 +// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time +typedef struct wasi_clocks_system_clock_instant_t { + int64_t seconds; uint32_t nanoseconds; -} wasi_clocks_wall_clock_datetime_t; +} wasi_clocks_system_clock_instant_t; -typedef wasi_clocks_wall_clock_datetime_t wasi_filesystem_types_datetime_t; +typedef wasi_clocks_system_clock_instant_t wasi_filesystem_types_instant_t; +// File size or length of a region within a file. typedef uint64_t wasi_filesystem_types_filesize_t; -typedef uint8_t wasi_filesystem_types_descriptor_type_t; - -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_UNKNOWN 0 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_BLOCK_DEVICE 1 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_CHARACTER_DEVICE 2 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_DIRECTORY 3 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_FIFO 4 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SYMBOLIC_LINK 5 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_REGULAR_FILE 6 -#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SOCKET 7 - +// The type of a filesystem object referenced by a descriptor. +// +// Note: This was called `filetype` in earlier versions of WASI. +typedef struct wasi_filesystem_types_descriptor_type_t { + uint8_t tag; + union { + plugin_option_string_t other; + } val; +} wasi_filesystem_types_descriptor_type_t; + +// The descriptor refers to a block device inode. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_BLOCK_DEVICE 0 +// The descriptor refers to a character device inode. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_CHARACTER_DEVICE 1 +// The descriptor refers to a directory inode. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_DIRECTORY 2 +// The descriptor refers to a named pipe. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_FIFO 3 +// The file refers to a symbolic link inode. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SYMBOLIC_LINK 4 +// The descriptor refers to a regular file inode. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_REGULAR_FILE 5 +// The descriptor refers to a socket. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_SOCKET 6 +// The type of the descriptor or file is different from any of the +// other types specified. +#define WASI_FILESYSTEM_TYPES_DESCRIPTOR_TYPE_OTHER 7 + +// Descriptor flags. +// +// Note: This was called `fdflags` in earlier versions of WASI. typedef uint8_t wasi_filesystem_types_descriptor_flags_t; +// Read mode: Data can be read. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_READ (1 << 0) +// Write mode: Data can be written to. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_WRITE (1 << 1) +// Request that writes be performed according to synchronized I/O file +// integrity completion. The data stored in the file and the file's +// metadata are synchronized. This is similar to `O_SYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_FILE_INTEGRITY_SYNC (1 << 2) +// Request that writes be performed according to synchronized I/O data +// integrity completion. Only the data stored in the file is +// synchronized. This is similar to `O_DSYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_DATA_INTEGRITY_SYNC (1 << 3) +// Requests that reads be performed at the same level of integrity +// requested for writes. This is similar to `O_RSYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_REQUESTED_WRITE_SYNC (1 << 4) +// Mutating directories mode: Directory contents may be mutated. +// +// When this flag is unset on a descriptor, operations using the +// descriptor which would create, rename, delete, modify the data or +// metadata of filesystem objects, or obtain another handle which +// would permit any of those, shall fail with `error-code::read-only` if +// they would otherwise succeed. +// +// This may only be set on directories. #define WASI_FILESYSTEM_TYPES_DESCRIPTOR_FLAGS_MUTATE_DIRECTORY (1 << 5) +// Flags determining the method of how paths are resolved. typedef uint8_t wasi_filesystem_types_path_flags_t; +// As long as the resolved path corresponds to a symbolic link, it is +// expanded. #define WASI_FILESYSTEM_TYPES_PATH_FLAGS_SYMLINK_FOLLOW (1 << 0) +// Open flags used by `open-at`. typedef uint8_t wasi_filesystem_types_open_flags_t; +// Create file if it does not exist, similar to `O_CREAT` in POSIX. #define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_CREATE (1 << 0) +// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. #define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_DIRECTORY (1 << 1) +// Fail if file already exists, similar to `O_EXCL` in POSIX. #define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_EXCLUSIVE (1 << 2) +// Truncate file to size 0, similar to `O_TRUNC` in POSIX. #define WASI_FILESYSTEM_TYPES_OPEN_FLAGS_TRUNCATE (1 << 3) +// Number of hard links to an inode. typedef uint64_t wasi_filesystem_types_link_count_t; typedef struct { bool is_some; - wasi_filesystem_types_datetime_t val; -} wasi_filesystem_types_option_datetime_t; + wasi_filesystem_types_instant_t val; +} wasi_filesystem_types_option_instant_t; +// File attributes. +// +// Note: This was called `filestat` in earlier versions of WASI. typedef struct wasi_filesystem_types_descriptor_stat_t { + // File type. wasi_filesystem_types_descriptor_type_t type; + // Number of hard links to the file. wasi_filesystem_types_link_count_t link_count; + // For regular files, the file size in bytes. For symbolic links, the + // length in bytes of the pathname contained in the symbolic link. wasi_filesystem_types_filesize_t size; - wasi_filesystem_types_option_datetime_t data_access_timestamp; - wasi_filesystem_types_option_datetime_t data_modification_timestamp; - wasi_filesystem_types_option_datetime_t status_change_timestamp; + // Last data access timestamp. + // + // If the `option` is none, the platform doesn't maintain an access + // timestamp for this file. + wasi_filesystem_types_option_instant_t data_access_timestamp; + // Last data modification timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // modification timestamp for this file. + wasi_filesystem_types_option_instant_t data_modification_timestamp; + // Last file status-change timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // status-change timestamp for this file. + wasi_filesystem_types_option_instant_t status_change_timestamp; } wasi_filesystem_types_descriptor_stat_t; +// When setting a timestamp, this gives the value to set it to. typedef struct wasi_filesystem_types_new_timestamp_t { uint8_t tag; union { - wasi_filesystem_types_datetime_t timestamp; + wasi_filesystem_types_instant_t timestamp; } val; } wasi_filesystem_types_new_timestamp_t; +// Leave the timestamp set to its previous value. #define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_NO_CHANGE 0 +// Set the timestamp to the current time of the system clock associated +// with the filesystem. #define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_NOW 1 +// Set the timestamp to the given value. #define WASI_FILESYSTEM_TYPES_NEW_TIMESTAMP_TIMESTAMP 2 +// A directory entry. typedef struct wasi_filesystem_types_directory_entry_t { + // The type of the file referred to by this directory entry. wasi_filesystem_types_descriptor_type_t type; + // The name of the object. plugin_string_t name; } wasi_filesystem_types_directory_entry_t; -typedef uint8_t wasi_filesystem_types_error_code_t; +// Error codes returned by functions, similar to `errno` in POSIX. +// Not all of these error codes are returned by the functions provided by this +// API; some are used in higher-level library layers, and others are provided +// merely for alignment with POSIX. +typedef struct wasi_filesystem_types_error_code_t { + uint8_t tag; + union { + plugin_option_string_t other; + } val; +} wasi_filesystem_types_error_code_t; +// Permission denied, similar to `EACCES` in POSIX. #define WASI_FILESYSTEM_TYPES_ERROR_CODE_ACCESS 0 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_WOULD_BLOCK 1 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ALREADY 2 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BAD_DESCRIPTOR 3 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BUSY 4 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_DEADLOCK 5 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_QUOTA 6 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_EXIST 7 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_FILE_TOO_LARGE 8 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 9 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IN_PROGRESS 10 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INTERRUPTED 11 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID 12 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IO 13 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IS_DIRECTORY 14 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_LOOP 15 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TOO_MANY_LINKS 16 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_MESSAGE_SIZE 17 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NAME_TOO_LONG 18 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_DEVICE 19 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_ENTRY 20 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_LOCK 21 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_MEMORY 22 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_SPACE 23 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_DIRECTORY 24 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_EMPTY 25 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_RECOVERABLE 26 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_UNSUPPORTED 27 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_TTY 28 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_SUCH_DEVICE 29 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_OVERFLOW 30 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_PERMITTED 31 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_PIPE 32 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_READ_ONLY 33 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID_SEEK 34 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TEXT_FILE_BUSY 35 -#define WASI_FILESYSTEM_TYPES_ERROR_CODE_CROSS_DEVICE 36 - +// Connection already in progress, similar to `EALREADY` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ALREADY 1 +// Bad descriptor, similar to `EBADF` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BAD_DESCRIPTOR 2 +// Device or resource busy, similar to `EBUSY` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_BUSY 3 +// Resource deadlock would occur, similar to `EDEADLK` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_DEADLOCK 4 +// Storage quota exceeded, similar to `EDQUOT` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_QUOTA 5 +// File exists, similar to `EEXIST` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_EXIST 6 +// File too large, similar to `EFBIG` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_FILE_TOO_LARGE 7 +// Illegal byte sequence, similar to `EILSEQ` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 8 +// Operation in progress, similar to `EINPROGRESS` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IN_PROGRESS 9 +// Interrupted function, similar to `EINTR` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INTERRUPTED 10 +// Invalid argument, similar to `EINVAL` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID 11 +// I/O error, similar to `EIO` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IO 12 +// Is a directory, similar to `EISDIR` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_IS_DIRECTORY 13 +// Too many levels of symbolic links, similar to `ELOOP` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_LOOP 14 +// Too many links, similar to `EMLINK` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TOO_MANY_LINKS 15 +// Message too large, similar to `EMSGSIZE` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_MESSAGE_SIZE 16 +// Filename too long, similar to `ENAMETOOLONG` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NAME_TOO_LONG 17 +// No such device, similar to `ENODEV` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_DEVICE 18 +// No such file or directory, similar to `ENOENT` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_ENTRY 19 +// No locks available, similar to `ENOLCK` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_LOCK 20 +// Not enough space, similar to `ENOMEM` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_MEMORY 21 +// No space left on device, similar to `ENOSPC` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INSUFFICIENT_SPACE 22 +// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_DIRECTORY 23 +// Directory not empty, similar to `ENOTEMPTY` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_EMPTY 24 +// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_RECOVERABLE 25 +// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_UNSUPPORTED 26 +// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_TTY 27 +// No such device or address, similar to `ENXIO` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NO_SUCH_DEVICE 28 +// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_OVERFLOW 29 +// Operation not permitted, similar to `EPERM` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_NOT_PERMITTED 30 +// Broken pipe, similar to `EPIPE` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_PIPE 31 +// Read-only file system, similar to `EROFS` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_READ_ONLY 32 +// Invalid seek, similar to `ESPIPE` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_INVALID_SEEK 33 +// Text file busy, similar to `ETXTBSY` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_TEXT_FILE_BUSY 34 +// Cross-device link, similar to `EXDEV` in POSIX. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_CROSS_DEVICE 35 +// A catch-all for errors not captured by the existing variants. +// Implementations can use this to extend the error type without +// breaking existing code. +#define WASI_FILESYSTEM_TYPES_ERROR_CODE_OTHER 36 + +// File or memory access pattern advisory information. typedef uint8_t wasi_filesystem_types_advice_t; +// The application has no advice to give on its behavior with respect +// to the specified data. #define WASI_FILESYSTEM_TYPES_ADVICE_NORMAL 0 +// The application expects to access the specified data sequentially +// from lower offsets to higher offsets. #define WASI_FILESYSTEM_TYPES_ADVICE_SEQUENTIAL 1 +// The application expects to access the specified data in a random +// order. #define WASI_FILESYSTEM_TYPES_ADVICE_RANDOM 2 +// The application expects to access the specified data in the near +// future. #define WASI_FILESYSTEM_TYPES_ADVICE_WILL_NEED 3 +// The application expects that it will not access the specified data +// in the near future. #define WASI_FILESYSTEM_TYPES_ADVICE_DONT_NEED 4 +// The application expects to access the specified data once and then +// not reuse it thereafter. #define WASI_FILESYSTEM_TYPES_ADVICE_NO_REUSE 5 +// A 128-bit hash value, split into parts because wasm doesn't have a +// 128-bit integer type. typedef struct wasi_filesystem_types_metadata_hash_value_t { + // 64 bits of a 128-bit hash value. uint64_t lower; + // Another 64 bits of a 128-bit hash value. uint64_t upper; } wasi_filesystem_types_metadata_hash_value_t; @@ -417,40 +642,21 @@ typedef struct wasi_filesystem_types_borrow_descriptor_t { int32_t __handle; } wasi_filesystem_types_borrow_descriptor_t; -typedef struct wasi_filesystem_types_own_directory_entry_stream_t { - int32_t __handle; -} wasi_filesystem_types_own_directory_entry_stream_t; - -typedef struct wasi_filesystem_types_borrow_directory_entry_stream_t { - int32_t __handle; -} wasi_filesystem_types_borrow_directory_entry_stream_t; - -typedef wasi_io_streams_own_input_stream_t wasi_filesystem_types_own_input_stream_t; +typedef uint32_t wasi_filesystem_types_stream_u8_t; typedef struct { bool is_err; union { - wasi_filesystem_types_own_input_stream_t ok; wasi_filesystem_types_error_code_t err; } val; -} wasi_filesystem_types_result_own_input_stream_error_code_t; - -typedef wasi_io_streams_own_output_stream_t wasi_filesystem_types_own_output_stream_t; +} wasi_filesystem_types_result_void_error_code_t; -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_output_stream_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_output_stream_error_code_t; +typedef uint32_t wasi_filesystem_types_future_result_void_error_code_t; typedef struct { - bool is_err; - union { - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_void_error_code_t; + wasi_filesystem_types_stream_u8_t f0; + wasi_filesystem_types_future_result_void_error_code_t f1; +} wasi_filesystem_types_tuple2_stream_u8_future_result_void_error_code_t; typedef struct { bool is_err; @@ -468,34 +674,12 @@ typedef struct { } val; } wasi_filesystem_types_result_descriptor_type_error_code_t; -typedef struct { - plugin_list_u8_t f0; - bool f1; -} plugin_tuple2_list_u8_bool_t; - -typedef struct { - bool is_err; - union { - plugin_tuple2_list_u8_bool_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t; +typedef uint32_t wasi_filesystem_types_stream_directory_entry_t; typedef struct { - bool is_err; - union { - wasi_filesystem_types_filesize_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_filesize_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_own_directory_entry_stream_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_own_directory_entry_stream_error_code_t; + wasi_filesystem_types_stream_directory_entry_t f0; + wasi_filesystem_types_future_result_void_error_code_t f1; +} wasi_filesystem_types_tuple2_stream_directory_entry_future_result_void_error_code_t; typedef struct { bool is_err; @@ -528,26 +712,43 @@ typedef struct { wasi_filesystem_types_error_code_t err; } val; } wasi_filesystem_types_result_metadata_hash_value_error_code_t; - -typedef struct { - bool is_some; - wasi_filesystem_types_directory_entry_t val; -} wasi_filesystem_types_option_directory_entry_t; - -typedef struct { - bool is_err; - union { - wasi_filesystem_types_option_directory_entry_t ok; - wasi_filesystem_types_error_code_t err; - } val; -} wasi_filesystem_types_result_option_directory_entry_error_code_t; - -typedef wasi_io_error_borrow_error_t wasi_filesystem_types_borrow_error_t; - -typedef struct { - bool is_some; - wasi_filesystem_types_error_code_t val; -} wasi_filesystem_types_option_error_code_t; +typedef struct wasi_filesystem_types_method_descriptor_set_times_args { + wasi_filesystem_types_borrow_descriptor_t self; + wasi_filesystem_types_new_timestamp_t data_access_timestamp; + wasi_filesystem_types_new_timestamp_t data_modification_timestamp; +} wasi_filesystem_types_method_descriptor_set_times_args_t; +typedef struct wasi_filesystem_types_method_descriptor_set_times_at_args { + wasi_filesystem_types_borrow_descriptor_t self; + wasi_filesystem_types_path_flags_t path_flags; + plugin_string_t path; + wasi_filesystem_types_new_timestamp_t data_access_timestamp; + wasi_filesystem_types_new_timestamp_t data_modification_timestamp; +} wasi_filesystem_types_method_descriptor_set_times_at_args_t; +typedef struct wasi_filesystem_types_method_descriptor_link_at_args { + wasi_filesystem_types_borrow_descriptor_t self; + wasi_filesystem_types_path_flags_t old_path_flags; + plugin_string_t old_path; + wasi_filesystem_types_borrow_descriptor_t new_descriptor; + plugin_string_t new_path; +} wasi_filesystem_types_method_descriptor_link_at_args_t; +typedef struct wasi_filesystem_types_method_descriptor_open_at_args { + wasi_filesystem_types_borrow_descriptor_t self; + wasi_filesystem_types_path_flags_t path_flags; + plugin_string_t path; + wasi_filesystem_types_open_flags_t open_flags; + wasi_filesystem_types_descriptor_flags_t flags; +} wasi_filesystem_types_method_descriptor_open_at_args_t; +typedef struct wasi_filesystem_types_method_descriptor_rename_at_args { + wasi_filesystem_types_borrow_descriptor_t self; + plugin_string_t old_path; + wasi_filesystem_types_borrow_descriptor_t new_descriptor; + plugin_string_t new_path; +} wasi_filesystem_types_method_descriptor_rename_at_args_t; +typedef struct wasi_filesystem_types_method_descriptor_symlink_at_args { + wasi_filesystem_types_borrow_descriptor_t self; + plugin_string_t old_path; + plugin_string_t new_path; +} wasi_filesystem_types_method_descriptor_symlink_at_args_t; typedef wasi_filesystem_types_own_descriptor_t wasi_filesystem_preopens_own_descriptor_t; @@ -561,51 +762,102 @@ typedef struct { size_t len; } wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t; -typedef struct wasi_sockets_network_own_network_t { - int32_t __handle; -} wasi_sockets_network_own_network_t; +typedef wasi_clocks_types_duration_t wasi_sockets_types_duration_t; -typedef struct wasi_sockets_network_borrow_network_t { - int32_t __handle; -} wasi_sockets_network_borrow_network_t; - -typedef uint8_t wasi_sockets_network_error_code_t; - -#define WASI_SOCKETS_NETWORK_ERROR_CODE_UNKNOWN 0 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ACCESS_DENIED 1 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NOT_SUPPORTED 2 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_INVALID_ARGUMENT 3 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_OUT_OF_MEMORY 4 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_TIMEOUT 5 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONCURRENCY_CONFLICT 6 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NOT_IN_PROGRESS 7 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_WOULD_BLOCK 8 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_INVALID_STATE 9 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NEW_SOCKET_LIMIT 10 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ADDRESS_NOT_BINDABLE 11 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_ADDRESS_IN_USE 12 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_REMOTE_UNREACHABLE 13 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_REFUSED 14 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_RESET 15 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_CONNECTION_ABORTED 16 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_DATAGRAM_TOO_LARGE 17 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_NAME_UNRESOLVABLE 18 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_TEMPORARY_RESOLVER_FAILURE 19 -#define WASI_SOCKETS_NETWORK_ERROR_CODE_PERMANENT_RESOLVER_FAILURE 20 - -typedef uint8_t wasi_sockets_network_ip_address_family_t; - -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_FAMILY_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_FAMILY_IPV6 1 - -typedef struct wasi_sockets_network_ipv4_address_t { +// Error codes. +// +// In theory, every API can return any error code. +// In practice, API's typically only return the errors documented per API +// combined with a couple of errors that are always possible: +// - `other` +// - `access-denied` +// - `not-supported` +// - `out-of-memory` +// +// See each individual API for what the POSIX equivalents are. They sometimes differ per API. +typedef struct wasi_sockets_types_error_code_t { + uint8_t tag; + union { + plugin_option_string_t other; + } val; +} wasi_sockets_types_error_code_t; + +// Access denied. +// +// POSIX equivalent: EACCES, EPERM +#define WASI_SOCKETS_TYPES_ERROR_CODE_ACCESS_DENIED 0 +// The operation is not supported. +// +// POSIX equivalent: EOPNOTSUPP, ENOPROTOOPT, EPFNOSUPPORT, EPROTONOSUPPORT, ESOCKTNOSUPPORT +#define WASI_SOCKETS_TYPES_ERROR_CODE_NOT_SUPPORTED 1 +// One of the arguments is invalid. +// +// POSIX equivalent: EINVAL, EDESTADDRREQ, EAFNOSUPPORT +#define WASI_SOCKETS_TYPES_ERROR_CODE_INVALID_ARGUMENT 2 +// Not enough memory to complete the operation. +// +// POSIX equivalent: ENOMEM, ENOBUFS +#define WASI_SOCKETS_TYPES_ERROR_CODE_OUT_OF_MEMORY 3 +// The operation timed out before it could finish completely. +// +// POSIX equivalent: ETIMEDOUT +#define WASI_SOCKETS_TYPES_ERROR_CODE_TIMEOUT 4 +// The operation is not valid in the socket's current state. +#define WASI_SOCKETS_TYPES_ERROR_CODE_INVALID_STATE 5 +// The local address is not available. +// +// POSIX equivalent: EADDRNOTAVAIL +#define WASI_SOCKETS_TYPES_ERROR_CODE_ADDRESS_NOT_BINDABLE 6 +// A bind operation failed because the provided address is already in +// use or because there are no ephemeral ports available. +// +// POSIX equivalent: EADDRINUSE +#define WASI_SOCKETS_TYPES_ERROR_CODE_ADDRESS_IN_USE 7 +// The remote address is not reachable. +// +// POSIX equivalent: EHOSTUNREACH, EHOSTDOWN, ENETDOWN, ENETUNREACH, ENONET +#define WASI_SOCKETS_TYPES_ERROR_CODE_REMOTE_UNREACHABLE 8 +// The connection was forcefully rejected. +// +// POSIX equivalent: ECONNREFUSED +#define WASI_SOCKETS_TYPES_ERROR_CODE_CONNECTION_REFUSED 9 +// A write failed because the connection was broken. +// +// POSIX equivalent: EPIPE +#define WASI_SOCKETS_TYPES_ERROR_CODE_CONNECTION_BROKEN 10 +// The connection was reset. +// +// POSIX equivalent: ECONNRESET +#define WASI_SOCKETS_TYPES_ERROR_CODE_CONNECTION_RESET 11 +// The connection was aborted. +// +// POSIX equivalent: ECONNABORTED +#define WASI_SOCKETS_TYPES_ERROR_CODE_CONNECTION_ABORTED 12 +// The size of a datagram sent to a UDP socket exceeded the maximum +// supported size. +// +// POSIX equivalent: EMSGSIZE +#define WASI_SOCKETS_TYPES_ERROR_CODE_DATAGRAM_TOO_LARGE 13 +// A catch-all for errors not captured by the existing variants. +// Implementations can use this to extend the error type without +// breaking existing code. +#define WASI_SOCKETS_TYPES_ERROR_CODE_OTHER 14 + +typedef uint8_t wasi_sockets_types_ip_address_family_t; + +// Similar to `AF_INET` in POSIX. +#define WASI_SOCKETS_TYPES_IP_ADDRESS_FAMILY_IPV4 0 +// Similar to `AF_INET6` in POSIX. +#define WASI_SOCKETS_TYPES_IP_ADDRESS_FAMILY_IPV6 1 + +typedef struct wasi_sockets_types_ipv4_address_t { uint8_t f0; uint8_t f1; uint8_t f2; uint8_t f3; -} wasi_sockets_network_ipv4_address_t; +} wasi_sockets_types_ipv4_address_t; -typedef struct wasi_sockets_network_ipv6_address_t { +typedef struct wasi_sockets_types_ipv6_address_t { uint16_t f0; uint16_t f1; uint16_t f2; @@ -614,331 +866,228 @@ typedef struct wasi_sockets_network_ipv6_address_t { uint16_t f5; uint16_t f6; uint16_t f7; -} wasi_sockets_network_ipv6_address_t; +} wasi_sockets_types_ipv6_address_t; -typedef struct wasi_sockets_network_ip_address_t { +typedef struct wasi_sockets_types_ip_address_t { uint8_t tag; union { - wasi_sockets_network_ipv4_address_t ipv4; - wasi_sockets_network_ipv6_address_t ipv6; + wasi_sockets_types_ipv4_address_t ipv4; + wasi_sockets_types_ipv6_address_t ipv6; } val; -} wasi_sockets_network_ip_address_t; +} wasi_sockets_types_ip_address_t; -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_ADDRESS_IPV6 1 +#define WASI_SOCKETS_TYPES_IP_ADDRESS_IPV4 0 +#define WASI_SOCKETS_TYPES_IP_ADDRESS_IPV6 1 -typedef struct wasi_sockets_network_ipv4_socket_address_t { +typedef struct wasi_sockets_types_ipv4_socket_address_t { + // sin_port uint16_t port; - wasi_sockets_network_ipv4_address_t address; -} wasi_sockets_network_ipv4_socket_address_t; + // sin_addr + wasi_sockets_types_ipv4_address_t address; +} wasi_sockets_types_ipv4_socket_address_t; -typedef struct wasi_sockets_network_ipv6_socket_address_t { +typedef struct wasi_sockets_types_ipv6_socket_address_t { + // sin6_port uint16_t port; + // sin6_flowinfo uint32_t flow_info; - wasi_sockets_network_ipv6_address_t address; + // sin6_addr + wasi_sockets_types_ipv6_address_t address; + // sin6_scope_id uint32_t scope_id; -} wasi_sockets_network_ipv6_socket_address_t; +} wasi_sockets_types_ipv6_socket_address_t; -typedef struct wasi_sockets_network_ip_socket_address_t { +typedef struct wasi_sockets_types_ip_socket_address_t { uint8_t tag; union { - wasi_sockets_network_ipv4_socket_address_t ipv4; - wasi_sockets_network_ipv6_socket_address_t ipv6; + wasi_sockets_types_ipv4_socket_address_t ipv4; + wasi_sockets_types_ipv6_socket_address_t ipv6; } val; -} wasi_sockets_network_ip_socket_address_t; - -#define WASI_SOCKETS_NETWORK_IP_SOCKET_ADDRESS_IPV4 0 -#define WASI_SOCKETS_NETWORK_IP_SOCKET_ADDRESS_IPV6 1 - -typedef wasi_sockets_network_own_network_t wasi_sockets_instance_network_own_network_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_udp_error_code_t; - -typedef wasi_sockets_network_ip_socket_address_t wasi_sockets_udp_ip_socket_address_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_udp_ip_address_family_t; - -typedef struct wasi_sockets_udp_incoming_datagram_t { - plugin_list_u8_t data; - wasi_sockets_udp_ip_socket_address_t remote_address; -} wasi_sockets_udp_incoming_datagram_t; - -typedef struct { - bool is_some; - wasi_sockets_udp_ip_socket_address_t val; -} wasi_sockets_udp_option_ip_socket_address_t; - -typedef struct wasi_sockets_udp_outgoing_datagram_t { - plugin_list_u8_t data; - wasi_sockets_udp_option_ip_socket_address_t remote_address; -} wasi_sockets_udp_outgoing_datagram_t; - -typedef struct wasi_sockets_udp_own_udp_socket_t { - int32_t __handle; -} wasi_sockets_udp_own_udp_socket_t; +} wasi_sockets_types_ip_socket_address_t; -typedef struct wasi_sockets_udp_borrow_udp_socket_t { - int32_t __handle; -} wasi_sockets_udp_borrow_udp_socket_t; +#define WASI_SOCKETS_TYPES_IP_SOCKET_ADDRESS_IPV4 0 +#define WASI_SOCKETS_TYPES_IP_SOCKET_ADDRESS_IPV6 1 -typedef struct wasi_sockets_udp_own_incoming_datagram_stream_t { +typedef struct wasi_sockets_types_own_tcp_socket_t { int32_t __handle; -} wasi_sockets_udp_own_incoming_datagram_stream_t; +} wasi_sockets_types_own_tcp_socket_t; -typedef struct wasi_sockets_udp_borrow_incoming_datagram_stream_t { +typedef struct wasi_sockets_types_borrow_tcp_socket_t { int32_t __handle; -} wasi_sockets_udp_borrow_incoming_datagram_stream_t; +} wasi_sockets_types_borrow_tcp_socket_t; -typedef struct wasi_sockets_udp_own_outgoing_datagram_stream_t { +typedef struct wasi_sockets_types_own_udp_socket_t { int32_t __handle; -} wasi_sockets_udp_own_outgoing_datagram_stream_t; +} wasi_sockets_types_own_udp_socket_t; -typedef struct wasi_sockets_udp_borrow_outgoing_datagram_stream_t { +typedef struct wasi_sockets_types_borrow_udp_socket_t { int32_t __handle; -} wasi_sockets_udp_borrow_outgoing_datagram_stream_t; - -typedef wasi_sockets_network_borrow_network_t wasi_sockets_udp_borrow_network_t; +} wasi_sockets_types_borrow_udp_socket_t; typedef struct { bool is_err; union { - wasi_sockets_udp_error_code_t err; + wasi_sockets_types_own_tcp_socket_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_udp_result_void_error_code_t; - -typedef struct { - wasi_sockets_udp_own_incoming_datagram_stream_t f0; - wasi_sockets_udp_own_outgoing_datagram_stream_t f1; -} wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t; +} wasi_sockets_types_result_own_tcp_socket_error_code_t; typedef struct { bool is_err; union { - wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t ok; - wasi_sockets_udp_error_code_t err; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t; +} wasi_sockets_types_result_void_error_code_t; -typedef struct { - bool is_err; - union { - wasi_sockets_udp_ip_socket_address_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_ip_socket_address_error_code_t; +typedef uint32_t wasi_sockets_types_stream_own_tcp_socket_t; typedef struct { bool is_err; union { - uint8_t ok; - wasi_sockets_udp_error_code_t err; + wasi_sockets_types_stream_own_tcp_socket_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_udp_result_u8_error_code_t; +} wasi_sockets_types_result_stream_own_tcp_socket_error_code_t; -typedef struct { - bool is_err; - union { - uint64_t ok; - wasi_sockets_udp_error_code_t err; - } val; -} wasi_sockets_udp_result_u64_error_code_t; +typedef uint32_t wasi_sockets_types_stream_u8_t; -typedef wasi_io_poll_own_pollable_t wasi_sockets_udp_own_pollable_t; +typedef uint32_t wasi_sockets_types_future_result_void_error_code_t; typedef struct { - wasi_sockets_udp_incoming_datagram_t *ptr; - size_t len; -} wasi_sockets_udp_list_incoming_datagram_t; + wasi_sockets_types_stream_u8_t f0; + wasi_sockets_types_future_result_void_error_code_t f1; +} wasi_sockets_types_tuple2_stream_u8_future_result_void_error_code_t; typedef struct { bool is_err; union { - wasi_sockets_udp_list_incoming_datagram_t ok; - wasi_sockets_udp_error_code_t err; + wasi_sockets_types_ip_socket_address_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_udp_result_list_incoming_datagram_error_code_t; - -typedef struct { - wasi_sockets_udp_outgoing_datagram_t *ptr; - size_t len; -} wasi_sockets_udp_list_outgoing_datagram_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_udp_create_socket_error_code_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_udp_create_socket_ip_address_family_t; - -typedef wasi_sockets_udp_own_udp_socket_t wasi_sockets_udp_create_socket_own_udp_socket_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_udp_create_socket_own_udp_socket_t ok; - wasi_sockets_udp_create_socket_error_code_t err; - } val; -} wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t; - -typedef wasi_clocks_monotonic_clock_duration_t wasi_sockets_tcp_duration_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_tcp_error_code_t; - -typedef wasi_sockets_network_ip_socket_address_t wasi_sockets_tcp_ip_socket_address_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_tcp_ip_address_family_t; - -typedef uint8_t wasi_sockets_tcp_shutdown_type_t; - -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_RECEIVE 0 -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_SEND 1 -#define WASI_SOCKETS_TCP_SHUTDOWN_TYPE_BOTH 2 - -typedef struct wasi_sockets_tcp_own_tcp_socket_t { - int32_t __handle; -} wasi_sockets_tcp_own_tcp_socket_t; - -typedef struct wasi_sockets_tcp_borrow_tcp_socket_t { - int32_t __handle; -} wasi_sockets_tcp_borrow_tcp_socket_t; - -typedef wasi_sockets_network_borrow_network_t wasi_sockets_tcp_borrow_network_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_void_error_code_t; - -typedef wasi_io_streams_own_input_stream_t wasi_sockets_tcp_own_input_stream_t; - -typedef wasi_io_streams_own_output_stream_t wasi_sockets_tcp_own_output_stream_t; - -typedef struct { - wasi_sockets_tcp_own_input_stream_t f0; - wasi_sockets_tcp_own_output_stream_t f1; -} wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t; - -typedef struct { - wasi_sockets_tcp_own_tcp_socket_t f0; - wasi_sockets_tcp_own_input_stream_t f1; - wasi_sockets_tcp_own_output_stream_t f2; -} wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t; - -typedef struct { - bool is_err; - union { - wasi_sockets_tcp_ip_socket_address_t ok; - wasi_sockets_tcp_error_code_t err; - } val; -} wasi_sockets_tcp_result_ip_socket_address_error_code_t; +} wasi_sockets_types_result_ip_socket_address_error_code_t; typedef struct { bool is_err; union { bool ok; - wasi_sockets_tcp_error_code_t err; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_result_bool_error_code_t; +} wasi_sockets_types_result_bool_error_code_t; typedef struct { bool is_err; union { - wasi_sockets_tcp_duration_t ok; - wasi_sockets_tcp_error_code_t err; + wasi_sockets_types_duration_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_result_duration_error_code_t; +} wasi_sockets_types_result_duration_error_code_t; typedef struct { bool is_err; union { uint32_t ok; - wasi_sockets_tcp_error_code_t err; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_result_u32_error_code_t; +} wasi_sockets_types_result_u32_error_code_t; typedef struct { bool is_err; union { uint8_t ok; - wasi_sockets_tcp_error_code_t err; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_result_u8_error_code_t; +} wasi_sockets_types_result_u8_error_code_t; typedef struct { bool is_err; union { uint64_t ok; - wasi_sockets_tcp_error_code_t err; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_result_u64_error_code_t; - -typedef wasi_io_poll_own_pollable_t wasi_sockets_tcp_own_pollable_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_tcp_create_socket_error_code_t; - -typedef wasi_sockets_network_ip_address_family_t wasi_sockets_tcp_create_socket_ip_address_family_t; - -typedef wasi_sockets_tcp_own_tcp_socket_t wasi_sockets_tcp_create_socket_own_tcp_socket_t; +} wasi_sockets_types_result_u64_error_code_t; typedef struct { bool is_err; union { - wasi_sockets_tcp_create_socket_own_tcp_socket_t ok; - wasi_sockets_tcp_create_socket_error_code_t err; + wasi_sockets_types_own_udp_socket_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t; - -typedef wasi_sockets_network_error_code_t wasi_sockets_ip_name_lookup_error_code_t; - -typedef wasi_sockets_network_ip_address_t wasi_sockets_ip_name_lookup_ip_address_t; - -typedef struct wasi_sockets_ip_name_lookup_own_resolve_address_stream_t { - int32_t __handle; -} wasi_sockets_ip_name_lookup_own_resolve_address_stream_t; - -typedef struct wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t { - int32_t __handle; -} wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t; +} wasi_sockets_types_result_own_udp_socket_error_code_t; typedef struct { bool is_some; - wasi_sockets_ip_name_lookup_ip_address_t val; -} wasi_sockets_ip_name_lookup_option_ip_address_t; + wasi_sockets_types_ip_socket_address_t val; +} wasi_sockets_types_option_ip_socket_address_t; + +typedef struct { + plugin_list_u8_t f0; + wasi_sockets_types_ip_socket_address_t f1; +} wasi_sockets_types_tuple2_list_u8_ip_socket_address_t; typedef struct { bool is_err; union { - wasi_sockets_ip_name_lookup_option_ip_address_t ok; - wasi_sockets_ip_name_lookup_error_code_t err; + wasi_sockets_types_tuple2_list_u8_ip_socket_address_t ok; + wasi_sockets_types_error_code_t err; } val; -} wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t; +} wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_t; +typedef struct wasi_sockets_types_method_tcp_socket_connect_args { + wasi_sockets_types_borrow_tcp_socket_t self; + wasi_sockets_types_ip_socket_address_t remote_address; +} wasi_sockets_types_method_tcp_socket_connect_args_t; +typedef struct wasi_sockets_types_method_udp_socket_send_args { + wasi_sockets_types_borrow_udp_socket_t self; + plugin_list_u8_t data; + wasi_sockets_types_option_ip_socket_address_t remote_address; +} wasi_sockets_types_method_udp_socket_send_args_t; + +typedef wasi_sockets_types_ip_address_t wasi_sockets_ip_name_lookup_ip_address_t; + +// Lookup error codes. +typedef struct wasi_sockets_ip_name_lookup_error_code_t { + uint8_t tag; + union { + plugin_option_string_t other; + } val; +} wasi_sockets_ip_name_lookup_error_code_t; -typedef wasi_io_poll_own_pollable_t wasi_sockets_ip_name_lookup_own_pollable_t; +// Access denied. +// +// POSIX equivalent: EACCES, EPERM +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_ACCESS_DENIED 0 +// `name` is a syntactically invalid domain name or IP address. +// +// POSIX equivalent: EINVAL +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_INVALID_ARGUMENT 1 +// Name does not exist or has no suitable associated IP addresses. +// +// POSIX equivalent: EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_NAME_UNRESOLVABLE 2 +// A temporary failure in name resolution occurred. +// +// POSIX equivalent: EAI_AGAIN +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_TEMPORARY_RESOLVER_FAILURE 3 +// A permanent failure in name resolution occurred. +// +// POSIX equivalent: EAI_FAIL +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_PERMANENT_RESOLVER_FAILURE 4 +// A catch-all for errors not captured by the existing variants. +// Implementations can use this to extend the error type without +// breaking existing code. +#define WASI_SOCKETS_IP_NAME_LOOKUP_ERROR_CODE_OTHER 5 -typedef wasi_sockets_network_borrow_network_t wasi_sockets_ip_name_lookup_borrow_network_t; +typedef struct { + wasi_sockets_ip_name_lookup_ip_address_t *ptr; + size_t len; +} wasi_sockets_ip_name_lookup_list_ip_address_t; typedef struct { bool is_err; union { - wasi_sockets_ip_name_lookup_own_resolve_address_stream_t ok; + wasi_sockets_ip_name_lookup_list_ip_address_t ok; wasi_sockets_ip_name_lookup_error_code_t err; } val; -} wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t; +} wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_t; typedef struct { uint64_t f0; @@ -964,13 +1113,13 @@ typedef struct { } val; } exports_streamkit_plugin_node_result_void_string_t; -// Imported Functions from `streamkit:plugin/host@0.1.0` +// Imported Functions from `streamkit:plugin/host@0.2.0` // Send a packet to an output pin -extern bool streamkit_plugin_host_send_output(plugin_string_t *pin_name, streamkit_plugin_host_packet_t *packet, plugin_string_t *err); +extern plugin_subtask_status_t streamkit_plugin_host_send_output(streamkit_plugin_host_send_output_args_t *args, streamkit_plugin_host_result_void_string_t *result); // Log a message to the host extern void streamkit_plugin_host_log(streamkit_plugin_host_log_level_t level, plugin_string_t *message); -// Imported Functions from `wasi:cli/environment@0.2.0` +// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-03-15` // Get the POSIX-style environment variables. // // Each environment variable is provided as a pair of string variable names @@ -984,191 +1133,990 @@ extern void wasi_cli_environment_get_environment(plugin_list_tuple2_string_strin extern void wasi_cli_environment_get_arguments(plugin_list_string_t *ret); // Return a path that programs should use as their initial current working // directory, interpreting `.` as shorthand for this. -extern bool wasi_cli_environment_initial_cwd(plugin_string_t *ret); +extern bool wasi_cli_environment_get_initial_cwd(plugin_string_t *ret); -// Imported Functions from `wasi:cli/exit@0.2.0` +// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-03-15` // Exit the current instance and any linked instances. extern void wasi_cli_exit_exit(wasi_cli_exit_result_void_void_t *status); -// Imported Functions from `wasi:io/error@0.2.0` -extern void wasi_io_error_method_error_to_debug_string(wasi_io_error_borrow_error_t self, plugin_string_t *ret); - -// Imported Functions from `wasi:io/poll@0.2.0` -extern bool wasi_io_poll_method_pollable_ready(wasi_io_poll_borrow_pollable_t self); -extern void wasi_io_poll_method_pollable_block(wasi_io_poll_borrow_pollable_t self); -extern void wasi_io_poll_poll(wasi_io_poll_list_borrow_pollable_t *in, plugin_list_u32_t *ret); - -// Imported Functions from `wasi:io/streams@0.2.0` -extern bool wasi_io_streams_method_input_stream_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_blocking_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_input_stream_blocking_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern wasi_io_streams_own_pollable_t wasi_io_streams_method_input_stream_subscribe(wasi_io_streams_borrow_input_stream_t self); -extern bool wasi_io_streams_method_output_stream_check_write(wasi_io_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_write(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_write_and_flush(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err); -extern wasi_io_streams_own_pollable_t wasi_io_streams_method_output_stream_subscribe(wasi_io_streams_borrow_output_stream_t self); -extern bool wasi_io_streams_method_output_stream_write_zeroes(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); -extern bool wasi_io_streams_method_output_stream_blocking_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err); - -// Imported Functions from `wasi:cli/stdin@0.2.0` -extern wasi_cli_stdin_own_input_stream_t wasi_cli_stdin_get_stdin(void); - -// Imported Functions from `wasi:cli/stdout@0.2.0` -extern wasi_cli_stdout_own_output_stream_t wasi_cli_stdout_get_stdout(void); - -// Imported Functions from `wasi:cli/stderr@0.2.0` -extern wasi_cli_stderr_own_output_stream_t wasi_cli_stderr_get_stderr(void); - -// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` +// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-03-15` +// Return a stream for reading from stdin. +// +// This function returns a stream which provides data read from stdin, +// and a future to signal read results. +// +// If the stream's readable end is dropped the future will resolve to success. +// +// If the stream's writable end is dropped the future will either resolve to +// success if stdin was closed by the writer or to an error-code if reading +// failed for some other reason. +// +// Multiple streams may be active at the same time. The behavior of concurrent +// reads is implementation-specific. +extern void wasi_cli_stdin_read_via_stream(wasi_cli_stdin_tuple2_stream_u8_future_result_void_error_code_t *ret); + +// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-03-15` +// Write the given stream to stdout. +// +// If the stream's writable end is dropped this function will either return +// success once the entire contents of the stream have been written or an +// error-code representing a failure. +// +// Otherwise if there is an error the readable end of the stream will be +// dropped and this function will return an error-code. +extern wasi_cli_stdout_future_result_void_error_code_t wasi_cli_stdout_write_via_stream(wasi_cli_stdin_stream_u8_t data); + +// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-03-15` +// Write the given stream to stderr. +// +// If the stream's writable end is dropped this function will either return +// success once the entire contents of the stream have been written or an +// error-code representing a failure. +// +// Otherwise if there is an error the readable end of the stream will be +// dropped and this function will return an error-code. +extern wasi_cli_stderr_future_result_void_error_code_t wasi_cli_stderr_write_via_stream(wasi_cli_stdin_stream_u8_t data); + +// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15` // If stdin is connected to a terminal, return a `terminal-input` handle // allowing further interaction with it. extern bool wasi_cli_terminal_stdin_get_terminal_stdin(wasi_cli_terminal_stdin_own_terminal_input_t *ret); -// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` +// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15` // If stdout is connected to a terminal, return a `terminal-output` handle // allowing further interaction with it. extern bool wasi_cli_terminal_stdout_get_terminal_stdout(wasi_cli_terminal_stdout_own_terminal_output_t *ret); -// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` +// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-03-15` // If stderr is connected to a terminal, return a `terminal-output` handle // allowing further interaction with it. extern bool wasi_cli_terminal_stderr_get_terminal_stderr(wasi_cli_terminal_stderr_own_terminal_output_t *ret); -// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` -extern wasi_clocks_monotonic_clock_instant_t wasi_clocks_monotonic_clock_now(void); -extern wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_resolution(void); -extern wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_instant(wasi_clocks_monotonic_clock_instant_t when); -extern wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_duration(wasi_clocks_monotonic_clock_duration_t when); - -// Imported Functions from `wasi:clocks/wall-clock@0.2.0` -extern void wasi_clocks_wall_clock_now(wasi_clocks_wall_clock_datetime_t *ret); -extern void wasi_clocks_wall_clock_resolution(wasi_clocks_wall_clock_datetime_t *ret); - -// Imported Functions from `wasi:filesystem/types@0.2.0` -extern bool wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_input_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_flags_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_type_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_read(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_filesize_t offset, plugin_tuple2_list_u8_bool_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_write(wasi_filesystem_types_borrow_descriptor_t self, plugin_list_u8_t *buffer, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_directory_entry_stream_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t old_path_flags, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_open_flags_t open_flags, wasi_filesystem_types_descriptor_flags_t flags, wasi_filesystem_types_own_descriptor_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, plugin_string_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other); -extern bool wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_types_borrow_directory_entry_stream_t self, wasi_filesystem_types_option_directory_entry_t *ret, wasi_filesystem_types_error_code_t *err); -extern bool wasi_filesystem_types_filesystem_error_code(wasi_filesystem_types_borrow_error_t err_, wasi_filesystem_types_error_code_t *ret); - -// Imported Functions from `wasi:filesystem/preopens@0.2.0` +// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15` +// Read the current value of the clock. +// +// The clock is monotonic, therefore calling this function repeatedly will +// produce a sequence of non-decreasing values. +// +// For completeness, this function traps if it's not possible to represent +// the value of the clock in a `mark`. Consequently, implementations +// should ensure that the starting time is low enough to avoid the +// possibility of overflow in practice. +extern wasi_clocks_monotonic_clock_mark_t wasi_clocks_monotonic_clock_now(void); +// Query the resolution of the clock. Returns the duration of time +// corresponding to a clock tick. +extern wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_get_resolution(void); +// Wait until the specified mark has occurred. +extern plugin_subtask_status_t wasi_clocks_monotonic_clock_wait_until(wasi_clocks_monotonic_clock_mark_t when); +// Wait for the specified duration to elapse. +extern plugin_subtask_status_t wasi_clocks_monotonic_clock_wait_for(wasi_clocks_monotonic_clock_duration_t how_long); + +// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-03-15` +// Read the current value of the clock. +// +// This clock is not monotonic, therefore calling this function repeatedly +// will not necessarily produce a sequence of non-decreasing values. +// +// The nanoseconds field of the output is always less than 1000000000. +extern void wasi_clocks_system_clock_now(wasi_clocks_system_clock_instant_t *ret); +// Query the resolution of the clock. Returns the smallest duration of time +// that the implementation permits distinguishing. +extern wasi_clocks_system_clock_duration_t wasi_clocks_system_clock_get_resolution(void); + +// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-03-15` +// Return a stream for reading from a file. +// +// Multiple read, write, and append streams may be active on the same open +// file and they do not interfere with each other. +// +// This function returns a `stream` which provides the data received from the +// file, and a `future` providing additional error information in case an +// error is encountered. +// +// If no error is encountered, `stream.read` on the `stream` will return +// `read-status::closed` with no `error-context` and the future resolves to +// the value `ok`. If an error is encountered, `stream.read` on the +// `stream` returns `read-status::closed` with an `error-context` and the future +// resolves to `err` with an `error-code`. +// +// Note: This is similar to `pread` in POSIX. +extern void wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_tuple2_stream_u8_future_result_void_error_code_t *ret); +// Return a stream for writing to a file, if available. +// +// May fail with an error-code describing why the file cannot be written. +// +// It is valid to write past the end of a file; the file is extended to the +// extent of the write, with bytes between the previous end and the start of +// the write set to zero. +// +// This function returns once either full contents of the stream are +// written or an error is encountered. +// +// Note: This is similar to `pwrite` in POSIX. +extern wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_stream_u8_t data, wasi_filesystem_types_filesize_t offset); +// Return a stream for appending to a file, if available. +// +// May fail with an error-code describing why the file cannot be appended. +// +// This function returns once either full contents of the stream are +// written or an error is encountered. +// +// Note: This is similar to `write` with `O_APPEND` in POSIX. +extern wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_stream_u8_t data); +// Provide file advisory information on a descriptor. +// +// This is similar to `posix_fadvise` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_result_void_error_code_t *result); +// Synchronize the data of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fdatasync` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_void_error_code_t *result); +// Get flags associated with a descriptor. +// +// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. +// +// Note: This returns the value that was the `fs_flags` value returned +// from `fdstat_get` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_flags_error_code_t *result); +// Get the dynamic type of a descriptor. +// +// Note: This returns the same value as the `type` field of the `fd-stat` +// returned by `stat`, `stat-at` and similar. +// +// Note: This returns similar flags to the `st_mode & S_IFMT` value provided +// by `fstat` in POSIX. +// +// Note: This returns the value that was the `fs_filetype` value returned +// from `fdstat_get` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_type_error_code_t *result); +// Adjust the size of an open file. If this increases the file's size, the +// extra bytes are filled with zeros. +// +// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_result_void_error_code_t *result); +// Adjust the timestamps of an open file or directory. +// +// Note: This is similar to `futimens` in POSIX. +// +// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_method_descriptor_set_times_args_t *args, wasi_filesystem_types_result_void_error_code_t *result); +// Read directory entries from a directory. +// +// On filesystems where directories contain entries referring to themselves +// and their parents, often named `.` and `..` respectively, these entries +// are omitted. +// +// This always returns a new stream which starts at the beginning of the +// directory. Multiple streams may be active on the same directory, and they +// do not interfere with each other. +// +// This function returns a future, which will resolve to an error code if +// reading full contents of the directory fails. +extern void wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_tuple2_stream_directory_entry_future_result_void_error_code_t *ret); +// Synchronize the data and metadata of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fsync` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_void_error_code_t *result); +// Create a directory. +// +// Note: This is similar to `mkdirat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result); +// Return the attributes of an open file or directory. +// +// Note: This is similar to `fstat` in POSIX, except that it does not return +// device and inode information. For testing whether two descriptors refer to +// the same underlying filesystem object, use `is-same-object`. To obtain +// additional data that can be used do determine whether a file has been +// modified, use `metadata-hash`. +// +// Note: This was called `fd_filestat_get` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_stat_error_code_t *result); +// Return the attributes of a file or directory. +// +// Note: This is similar to `fstatat` in POSIX, except that it does not +// return device and inode information. See the `stat` description for a +// discussion of alternatives. +// +// Note: This was called `path_filestat_get` in earlier versions of WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t path, wasi_filesystem_types_result_descriptor_stat_error_code_t *result); +// Adjust the timestamps of a file or directory. +// +// Note: This is similar to `utimensat` in POSIX. +// +// Note: This was called `path_filestat_set_times` in earlier versions of +// WASI. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_method_descriptor_set_times_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result); +// Create a hard link. +// +// Fails with `error-code::no-entry` if the old path does not exist, +// with `error-code::exist` if the new path already exists, and +// `error-code::not-permitted` if the old path is not a file. +// +// Note: This is similar to `linkat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_method_descriptor_link_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result); +// Open a file or directory. +// +// If `flags` contains `descriptor-flags::mutate-directory`, and the base +// descriptor doesn't have `descriptor-flags::mutate-directory` set, +// `open-at` fails with `error-code::read-only`. +// +// If `flags` contains `write` or `mutate-directory`, or `open-flags` +// contains `truncate` or `create`, and the base descriptor doesn't have +// `descriptor-flags::mutate-directory` set, `open-at` fails with +// `error-code::read-only`. +// +// Note: This is similar to `openat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_method_descriptor_open_at_args_t *args, wasi_filesystem_types_result_own_descriptor_error_code_t *result); +// Read the contents of a symbolic link. +// +// If the contents contain an absolute or rooted path in the underlying +// filesystem, this function fails with `error-code::not-permitted`. +// +// Note: This is similar to `readlinkat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_string_error_code_t *result); +// Remove a directory. +// +// Return `error-code::not-empty` if the directory is not empty. +// +// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result); +// Rename a filesystem object. +// +// Note: This is similar to `renameat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_method_descriptor_rename_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result); +// Create a symbolic link (also known as a "symlink"). +// +// If `old-path` starts with `/`, the function fails with +// `error-code::not-permitted`. +// +// Note: This is similar to `symlinkat` in POSIX. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_method_descriptor_symlink_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result); +// Unlink a filesystem object that is not a directory. +// +// This is similar to `unlinkat(fd, path, 0)` in POSIX. +// +// Error returns are as specified by POSIX. +// +// If the filesystem object is a directory, `error-code::access` or +// `error-code::is-directory` may be returned instead of the +// POSIX-specified `error-code::not-permitted`. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result); +// Test whether two descriptors refer to the same filesystem object. +// +// In POSIX, this corresponds to testing whether the two descriptors have the +// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. +// wasi-filesystem does not expose device and inode numbers, so this function +// may be used instead. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other, bool *result); +// Return a hash of the metadata associated with a filesystem object referred +// to by a descriptor. +// +// This returns a hash of the last-modification timestamp and file size, and +// may also include the inode number, device number, birth timestamp, and +// other metadata fields that may change when the file is modified or +// replaced. It may also include a secret value chosen by the +// implementation and not otherwise exposed. +// +// Implementations are encouraged to provide the following properties: +// +// - If the file is not modified or replaced, the computed hash value should +// usually not change. +// - If the object is modified or replaced, the computed hash value should +// usually change. +// - The inputs to the hash should not be easily computable from the +// computed hash. +// +// However, none of these is required. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_metadata_hash_value_error_code_t *result); +// Return a hash of the metadata associated with a filesystem object referred +// to by a directory descriptor and a relative path. +// +// This performs the same hash computation as `metadata-hash`. +extern plugin_subtask_status_t wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t path, wasi_filesystem_types_result_metadata_hash_value_error_code_t *result); + +// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-03-15` +// Return the set of preopened directories, and their paths. extern void wasi_filesystem_preopens_get_directories(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ret); -// Imported Functions from `wasi:sockets/instance-network@0.2.0` -extern wasi_sockets_instance_network_own_network_t wasi_sockets_instance_network_instance_network(void); - -// Imported Functions from `wasi:sockets/udp@0.2.0` -extern bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_borrow_network_t network, wasi_sockets_udp_ip_socket_address_t *local_address, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_finish_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_stream(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_ip_address_family_t wasi_sockets_udp_method_udp_socket_address_family(wasi_sockets_udp_borrow_udp_socket_t self); -extern bool wasi_sockets_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_udp_socket_subscribe(wasi_sockets_udp_borrow_udp_socket_t self); -extern bool wasi_sockets_udp_method_incoming_datagram_stream_receive(wasi_sockets_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_udp_list_incoming_datagram_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_udp_borrow_incoming_datagram_stream_t self); -extern bool wasi_sockets_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_udp_error_code_t *err); -extern wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self); - -// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` -extern bool wasi_sockets_udp_create_socket_create_udp_socket(wasi_sockets_udp_create_socket_ip_address_family_t address_family, wasi_sockets_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_udp_create_socket_error_code_t *err); - -// Imported Functions from `wasi:sockets/tcp@0.2.0` -extern bool wasi_sockets_tcp_method_tcp_socket_start_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *local_address, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *remote_address, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_finish_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_accept(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_local_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_remote_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_is_listening(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern wasi_sockets_tcp_ip_address_family_t wasi_sockets_tcp_method_tcp_socket_address_family(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern bool wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err); -extern bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err); -extern wasi_sockets_tcp_own_pollable_t wasi_sockets_tcp_method_tcp_socket_subscribe(wasi_sockets_tcp_borrow_tcp_socket_t self); -extern bool wasi_sockets_tcp_method_tcp_socket_shutdown(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_shutdown_type_t shutdown_type, wasi_sockets_tcp_error_code_t *err); - -// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` -extern bool wasi_sockets_tcp_create_socket_create_tcp_socket(wasi_sockets_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_tcp_create_socket_error_code_t *err); - -// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` -extern bool wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err); -extern wasi_sockets_ip_name_lookup_own_pollable_t wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self); -extern bool wasi_sockets_ip_name_lookup_resolve_addresses(wasi_sockets_ip_name_lookup_borrow_network_t network, plugin_string_t *name, wasi_sockets_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err); - -// Imported Functions from `wasi:random/random@0.2.0` -extern void wasi_random_random_get_random_bytes(uint64_t len, plugin_list_u8_t *ret); +// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-03-15` +// 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. +// +// Unlike POSIX, WASI sockets have no notion of a socket-level +// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's +// async support. +// +// # Typical errors +// - `not-supported`: The `address-family` is not supported. (EAFNOSUPPORT) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_static_tcp_socket_create(wasi_sockets_types_ip_address_family_t address_family, wasi_sockets_types_own_tcp_socket_t *ret, wasi_sockets_types_error_code_t *err); +// Bind the socket to the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is +// left to the implementation to decide which network interface(s) to +// bind to. If the TCP/UDP port is zero, the socket will be bound to a +// random free port. +// +// 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 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. (EINVAL) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `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 can be bound to. (EADDRNOTAVAIL) +// +// # Implementors note +// The 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. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_tcp_socket_bind(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *local_address, wasi_sockets_types_error_code_t *err); +// Connect to a remote endpoint. +// +// On success, the socket is transitioned into the `connected` state +// and the `remote-address` of the socket is updated. +// The `local-address` may be updated as well, based on the best network +// path to `remote-address`. If the socket was not already explicitly +// bound, this function will implicitly bind the socket to a random +// free port. +// +// 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. +// +// # 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. (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-state`: The socket is already in the `connecting` state. (EALREADY) +// - `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) +// +// # References +// - +// - +// - +// - +extern plugin_subtask_status_t wasi_sockets_types_method_tcp_socket_connect(wasi_sockets_types_method_tcp_socket_connect_args_t *args, wasi_sockets_types_result_void_error_code_t *result); +// Start listening and return a stream of new inbound connections. +// +// Transitions the socket into the `listening` state. This can be called +// at most once per socket. +// +// If the socket is not already explicitly bound, this function will +// implicitly bind the socket to a random free port. +// +// Normally, the returned sockets are bound, in the `connected` state +// and immediately ready for I/O. Though, depending on exact timing and +// circumstances, a newly accepted connection may already be `closed` +// by the time the server attempts to perform its first I/O on it. This +// is true regardless of whether the WASI implementation uses +// "synthesized" sockets or not (see Implementors Notes below). +// +// The following properties are inherited from the listener socket: +// - `address-family` +// - `keep-alive-enabled` +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// - `hop-limit` +// - `receive-buffer-size` +// - `send-buffer-size` +// +// # Typical 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) +// +// # Implementors note +// This method returns a single perpetual stream that should only close +// on fatal errors (if any). Yet, the POSIX' `accept` function may also +// return transient errors (e.g. ECONNABORTED). The exact details differ +// per operation system. For example, the Linux manual mentions: +// +// > Linux accept() passes already-pending network errors on the new +// > socket as an error code from accept(). This behavior differs from +// > other BSD socket implementations. For reliable operation the +// > application should detect the network errors defined for the +// > protocol after accept() and treat them like EAGAIN by retrying. +// > In the case of TCP/IP, these are ENETDOWN, EPROTO, ENOPROTOOPT, +// > EHOSTDOWN, ENONET, EHOSTUNREACH, EOPNOTSUPP, and ENETUNREACH. +// Source: https://man7.org/linux/man-pages/man2/accept.2.html +// +// WASI implementations have two options to handle this: +// - Optionally log it and then skip over non-fatal errors returned by +// `accept`. Guest code never gets to see these failures. Or: +// - Synthesize a `tcp-socket` resource that exposes the error when +// attempting to send or receive on it. Guest code then sees these +// failures as regular I/O errors. +// +// In either case, the stream returned by this `listen` method remains +// operational. +// +// WASI requires `listen` to perform an implicit bind if the socket +// has not already been bound. Not all platforms (notably Windows) +// exhibit this behavior out of the box. On platforms that require it, +// the WASI implementation can emulate this behavior by performing +// the bind itself if the guest hasn't already done so. +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +extern bool wasi_sockets_types_method_tcp_socket_listen(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_stream_own_tcp_socket_t *ret, wasi_sockets_types_error_code_t *err); +// Transmit data to peer. +// +// The caller should close the stream when it has no more data to send +// to the peer. Under normal circumstances this will cause a FIN packet +// to be sent out. Closing the stream is equivalent to calling +// `shutdown(SHUT_WR)` in POSIX. +// +// This function may be called at most once and returns once the full +// contents of the stream are transmitted or an error is encountered. +// +// # Typical errors +// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) +// - `invalid-state`: `send` has already been called on this socket. +// - `connection-broken`: The connection is not writable anymore. (EPIPE, ECONNABORTED on Windows) +// - `connection-reset`: The connection was reset. (ECONNRESET) +// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// +// # References +// - +// - +// - +// - +extern wasi_sockets_types_future_result_void_error_code_t wasi_sockets_types_method_tcp_socket_send(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_stream_u8_t data); +// Read data from peer. +// +// Returns a `stream` of data sent by the peer. The implementation +// drops the stream once no more data is available. At that point, the +// returned `future` resolves to: +// - `ok` after a graceful shutdown from the peer (i.e. a FIN packet), or +// - `err` if the socket was closed abnormally. +// +// `receive` may be called only once per socket. Subsequent calls return +// a closed stream and a future resolved to `err(invalid-state)`. +// +// If the caller is not expecting to receive any more data from the peer, +// they should drop the stream. Any data still in the receive queue +// will be discarded. This is equivalent to calling `shutdown(SHUT_RD)` +// in POSIX. +// +// # Typical errors +// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) +// - `invalid-state`: `receive` has already been called on this socket. +// - `connection-reset`: The connection was reset. (ECONNRESET) +// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// +// # References +// - +// - +// - +// - +extern void wasi_sockets_types_method_tcp_socket_receive(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_tuple2_stream_u8_future_result_void_error_code_t *ret); +// Get the bound local address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `get-local-address` to return +// `invalid-state` when the socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_tcp_socket_get_local_address(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err); +// Get the remote address. +// +// # Typical errors +// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_tcp_socket_get_remote_address(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err); +// Whether the socket is in the `listening` state. +// +// Equivalent to the SO_ACCEPTCONN socket option. +extern bool wasi_sockets_types_method_tcp_socket_get_is_listening(wasi_sockets_types_borrow_tcp_socket_t self); +// Whether this is a IPv4 or IPv6 socket. +// +// This is the value passed to the constructor. +// +// Equivalent to the SO_DOMAIN socket option. +extern wasi_sockets_types_ip_address_family_t wasi_sockets_types_method_tcp_socket_get_address_family(wasi_sockets_types_borrow_tcp_socket_t self); +// Hints the desired listen queue size. Implementations are free to +// ignore this. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently +// clamped and/or rounded. +// +// # 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 in the `connecting` or `connected` state. +extern bool wasi_sockets_types_method_tcp_socket_set_listen_backlog_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err); +// Enables or disables keepalive. +// +// The keepalive behavior can be adjusted using: +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// These properties can be configured while `keep-alive-enabled` is +// false, but only come into effect when `keep-alive-enabled` is true. +// +// Equivalent to the SO_KEEPALIVE socket option. +extern bool wasi_sockets_types_method_tcp_socket_get_keep_alive_enabled(wasi_sockets_types_borrow_tcp_socket_t self, bool *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_types_borrow_tcp_socket_t self, bool value, wasi_sockets_types_error_code_t *err); +// Amount of time the connection has to be idle before TCP starts +// sending keepalive packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// All other values are accepted without error, but may be +// clamped or rounded. As a result, the value read back from +// this setting may differ from the value that was set. +// +// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_types_method_tcp_socket_get_keep_alive_idle_time(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t value, wasi_sockets_types_error_code_t *err); +// The time between keepalive packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// All other values are accepted without error, but may be +// clamped or rounded. As a result, the value read back from +// this setting may differ from the value that was set. +// +// Equivalent to the TCP_KEEPINTVL socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_types_method_tcp_socket_get_keep_alive_interval(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_keep_alive_interval(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t value, wasi_sockets_types_error_code_t *err); +// The maximum amount of keepalive packets TCP should send before +// aborting the connection. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// All other values are accepted without error, but may be +// clamped or rounded. As a result, the value read back from +// this setting may differ from the value that was set. +// +// Equivalent to the TCP_KEEPCNT socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_types_method_tcp_socket_get_keep_alive_count(wasi_sockets_types_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_keep_alive_count(wasi_sockets_types_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_types_error_code_t *err); +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +extern bool wasi_sockets_types_method_tcp_socket_get_hop_limit(wasi_sockets_types_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_hop_limit(wasi_sockets_types_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_types_error_code_t *err); +// Kernel buffer space reserved for sending/receiving on this socket. +// Implementations usually treat this as a cap the buffer can grow to, +// rather than allocating the full amount immediately. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// All other values are accepted without error, but may be +// clamped or rounded. As a result, the value read back from +// this setting may differ from the value that was set. +// +// This is only a performance hint. The implementation may ignore it or +// tweak it based on real traffic patterns. +// Linux and macOS appear to behave differently depending on whether a +// buffer size was explicitly set. When set, they tend to honor it; when +// not set, they dynamically adjust the buffer size as the connection +// progresses. This is especially noticeable when comparing the values +// from before and after connection establishment. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_types_method_tcp_socket_get_receive_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_receive_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_get_send_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_tcp_socket_set_send_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err); +// 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. +// +// Unlike POSIX, WASI sockets have no notion of a socket-level +// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's +// async support. +// +// # References: +// - +// - +// - +// - +extern bool wasi_sockets_types_static_udp_socket_create(wasi_sockets_types_ip_address_family_t address_family, wasi_sockets_types_own_udp_socket_t *ret, wasi_sockets_types_error_code_t *err); +// Bind the socket to the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is +// left to the implementation to decide which network interface(s) to +// bind to. If the port is zero, the socket will be bound to a random +// free port. +// +// # Typical errors +// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `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 can be bound to. (EADDRNOTAVAIL) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_udp_socket_bind(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *local_address, wasi_sockets_types_error_code_t *err); +// Associate this socket with a specific peer address. +// +// On success, the `remote-address` of the socket is updated. +// The `local-address` may be updated as well, based on the best network +// path to `remote-address`. If the socket was not already explicitly +// bound, this function will implicitly bind the socket to a random +// free port. +// +// When a UDP socket is "connected", the `send` and `receive` methods +// are limited to communicating with that peer only: +// - `send` can only be used to send to this destination. +// - `receive` will only return datagrams sent from the provided `remote-address`. +// +// The name "connect" was kept to align with the existing POSIX +// terminology. Other than that, this function only changes the local +// socket configuration and does not generate any network traffic. +// The peer is not aware of this "connection". +// +// This method may be called multiple times on the same socket to change +// its association, but only the most recent one will be effective. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) +// - `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) +// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) +// +// # Implementors note +// If the socket is already connected, some platforms (e.g. Linux) +// require a disconnect before connecting to a different peer address. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_udp_socket_connect(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *remote_address, wasi_sockets_types_error_code_t *err); +// Dissociate this socket from its peer address. +// +// After calling this method, `send` & `receive` are free to communicate +// with any remote address again. +// +// The POSIX equivalent of this is calling `connect` with an `AF_UNSPEC` address. +// +// # Typical errors +// - `invalid-state`: The socket is not connected. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_udp_socket_disconnect(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_error_code_t *err); +// Send a message on the socket to a particular peer. +// +// If the socket is connected, the peer address may be left empty. In +// that case this is equivalent to `send` in POSIX. Otherwise it is +// equivalent to `sendto`. +// +// Additionally, if the socket is connected, a `remote-address` argument +// _may_ be provided but then it must be identical to the address +// passed to `connect`. +// +// If the socket has not been explicitly bound, it will be +// implicitly bound to a random free port. +// +// Implementations may trap if the `data` length exceeds 64 KiB. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) +// - `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 `connect`. (EISCONN) +// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) +// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) +// +// # Implementors note +// WASI requires `send` to perform an implicit bind if the socket +// has not been bound. Not all platforms (notably Windows) exhibit +// this behavior natively. On such platforms, the WASI implementation +// should emulate it by performing the bind if the guest has not +// already done so. +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +extern plugin_subtask_status_t wasi_sockets_types_method_udp_socket_send(wasi_sockets_types_method_udp_socket_send_args_t *args, wasi_sockets_types_result_void_error_code_t *result); +// Receive a message on the socket. +// +// On success, the return value contains a tuple of the received data +// and the address of the sender. Theoretical maximum length of the +// data is 64 KiB. Though in practice, it will typically be less than +// 1500 bytes. +// +// If the socket is connected, the sender address is guaranteed to +// match the remote address passed to `connect`. +// +// # Typical errors +// - `invalid-state`: The socket has not been bound yet. +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// +// # References +// - +// - +// - +// - +// - +// - +// - +extern plugin_subtask_status_t wasi_sockets_types_method_udp_socket_receive(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_t *result); +// Get the current bound address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `get-local-address` to return +// `invalid-state` when the socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_udp_socket_get_local_address(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err); +// Get the address the socket is currently "connected" to. +// +// # Typical errors +// - `invalid-state`: The socket is not "connected" to a specific remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_types_method_udp_socket_get_remote_address(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err); +// Whether this is a IPv4 or IPv6 socket. +// +// This is the value passed to the constructor. +// +// Equivalent to the SO_DOMAIN socket option. +extern wasi_sockets_types_ip_address_family_t wasi_sockets_types_method_udp_socket_get_address_family(wasi_sockets_types_borrow_udp_socket_t self); +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +extern bool wasi_sockets_types_method_udp_socket_get_unicast_hop_limit(wasi_sockets_types_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_udp_socket_set_unicast_hop_limit(wasi_sockets_types_borrow_udp_socket_t self, uint8_t value, wasi_sockets_types_error_code_t *err); +// Kernel buffer space reserved for sending/receiving on this socket. +// Implementations usually treat this as a cap the buffer can grow to, +// rather than allocating the full amount immediately. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// All other values are accepted without error, but may be +// clamped or rounded. As a result, the value read back from +// this setting may differ from the value that was set. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_types_method_udp_socket_get_receive_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_udp_socket_set_receive_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_udp_socket_get_send_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err); +extern bool wasi_sockets_types_method_udp_socket_set_send_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err); + +// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15` +// Resolve an internet host name to a list of IP addresses. +// +// Unicode domain names are automatically converted to ASCII using IDNA +// encoding. If the input is an IP address string, the address is parsed +// and returned as-is without making any external requests. +// +// See the wasi-socket proposal README.md for a comparison with getaddrinfo. +// +// The results are returned in connection order preference. +// +// This function never succeeds with 0 results. It either fails or succeeds +// with at least one address. Additionally, this function never returns +// IPv4-mapped IPv6 addresses. +// +// # References: +// - +// - +// - +// - +extern plugin_subtask_status_t wasi_sockets_ip_name_lookup_resolve_addresses(plugin_string_t name, wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_t *result); + +// Imported Functions from `wasi:random/random@0.3.0-rc-2026-03-15` +// Return up to `max-len` cryptographically-secure random or pseudo-random +// bytes. +// +// This function must produce data at least as cryptographically secure and +// fast as an adequately seeded cryptographically-secure pseudo-random +// number generator (CSPRNG). It must not block, from the perspective of +// the calling program, under any circumstances, including on the first +// request and on requests for numbers of bytes. The returned data must +// always be unpredictable. +// +// Implementations MAY return fewer bytes than requested (a short read). +// Callers that require exactly `max-len` bytes MUST call this function in +// a loop until the desired number of bytes has been accumulated. +// Implementations MUST return at least 1 byte when `max-len` is greater +// than zero. When `max-len` is zero, implementations MUST return an empty +// list without trapping. +// +// This function must always return fresh data. Deterministic environments +// must omit this function, rather than implementing it with deterministic +// data. +extern void wasi_random_random_get_random_bytes(uint64_t max_len, plugin_list_u8_t *ret); +// Return a cryptographically-secure random or pseudo-random `u64` value. +// +// This function returns the same type of data as `get-random-bytes`, +// represented as a `u64`. extern uint64_t wasi_random_random_get_random_u64(void); -// Imported Functions from `wasi:random/insecure@0.2.0` -extern void wasi_random_insecure_get_insecure_random_bytes(uint64_t len, plugin_list_u8_t *ret); +// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-03-15` +// Return up to `max-len` insecure pseudo-random bytes. +// +// This function is not cryptographically secure. Do not use it for +// anything related to security. +// +// There are no requirements on the values of the returned bytes, however +// implementations are encouraged to return evenly distributed values with +// a long period. +// +// Implementations MAY return fewer bytes than requested (a short read). +// Callers that require exactly `max-len` bytes MUST call this function in +// a loop until the desired number of bytes has been accumulated. +// Implementations MUST return at least 1 byte when `max-len` is greater +// than zero. When `max-len` is zero, implementations MUST return an empty +// list without trapping. +extern void wasi_random_insecure_get_insecure_random_bytes(uint64_t max_len, plugin_list_u8_t *ret); +// Return an insecure pseudo-random `u64` value. +// +// This function returns the same type of pseudo-random data as +// `get-insecure-random-bytes`, represented as a `u64`. extern uint64_t wasi_random_insecure_get_insecure_random_u64(void); -// Imported Functions from `wasi:random/insecure-seed@0.2.0` -extern void wasi_random_insecure_seed_insecure_seed(plugin_tuple2_u64_u64_t *ret); +// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-03-15` +// Return a 128-bit value that may contain a pseudo-random value. +// +// The returned value is not required to be computed from a CSPRNG, and may +// even be entirely deterministic. Host implementations are encouraged to +// provide pseudo-random values to any program exposed to +// attacker-controlled content, to enable DoS protection built into many +// languages' hash-map implementations. +// +// This function is intended to only be called once, by a source language +// to initialize Denial Of Service (DoS) protection in its hash-map +// implementation. +// +// # Expected future evolution +// +// This will likely be changed to a value import, to prevent it from being +// called multiple times and potentially used for purposes other than DoS +// protection. +extern void wasi_random_insecure_seed_get_insecure_seed(plugin_tuple2_u64_u64_t *ret); -// Exported Functions from `streamkit:plugin/node@0.1.0` +// Exported Functions from `streamkit:plugin/node@0.2.0` void exports_streamkit_plugin_node_metadata(exports_streamkit_plugin_node_node_metadata_t *ret); exports_streamkit_plugin_node_own_node_instance_t exports_streamkit_plugin_node_constructor_node_instance(plugin_string_t *maybe_params); -bool exports_streamkit_plugin_node_method_node_instance_process(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *input_pin, exports_streamkit_plugin_node_packet_t *packet, plugin_string_t *err); -bool exports_streamkit_plugin_node_method_node_instance_update_params(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *maybe_params, plugin_string_t *err); +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_process(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *input_pin, exports_streamkit_plugin_node_packet_t *packet); +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_process_callback(plugin_event_t *event); +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_update_params(exports_streamkit_plugin_node_borrow_node_instance_t self, plugin_string_t *maybe_params); +plugin_callback_code_t exports_streamkit_plugin_node_method_node_instance_update_params_callback(plugin_event_t *event); void exports_streamkit_plugin_node_method_node_instance_cleanup(exports_streamkit_plugin_node_borrow_node_instance_t self); // Helper Functions void streamkit_plugin_types_packet_type_free(streamkit_plugin_types_packet_type_t *ptr); +void streamkit_plugin_types_custom_packet_free(streamkit_plugin_types_custom_packet_t *ptr); + void streamkit_plugin_types_list_packet_type_free(streamkit_plugin_types_list_packet_type_t *ptr); void streamkit_plugin_types_input_pin_free(streamkit_plugin_types_input_pin_t *ptr); @@ -1203,41 +2151,55 @@ void plugin_option_string_free(plugin_option_string_t *ptr); void wasi_cli_exit_result_void_void_free(wasi_cli_exit_result_void_void_t *ptr); -extern void wasi_io_error_error_drop_own(wasi_io_error_own_error_t handle); - -extern void wasi_io_error_error_drop_borrow(wasi_io_error_borrow_error_t handle); - -extern wasi_io_error_borrow_error_t wasi_io_error_borrow_error(wasi_io_error_own_error_t handle); - -extern void wasi_io_poll_pollable_drop_own(wasi_io_poll_own_pollable_t handle); +void wasi_cli_stdin_result_void_error_code_free(wasi_cli_stdin_result_void_error_code_t *ptr); -extern void wasi_io_poll_pollable_drop_borrow(wasi_io_poll_borrow_pollable_t handle); +typedef uint32_t wasi_cli_stdin_stream_u8_writer_t; -extern wasi_io_poll_borrow_pollable_t wasi_io_poll_borrow_pollable(wasi_io_poll_own_pollable_t handle); +wasi_cli_stdin_stream_u8_t wasi_cli_stdin_stream_u8_new(wasi_cli_stdin_stream_u8_writer_t *writer); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_read(wasi_cli_stdin_stream_u8_t reader, uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_write(wasi_cli_stdin_stream_u8_writer_t writer, const uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_cancel_read(wasi_cli_stdin_stream_u8_t reader); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_cancel_write(wasi_cli_stdin_stream_u8_writer_t writer); +void wasi_cli_stdin_stream_u8_drop_readable(wasi_cli_stdin_stream_u8_t reader); +void wasi_cli_stdin_stream_u8_drop_writable(wasi_cli_stdin_stream_u8_writer_t writer); -void wasi_io_poll_list_borrow_pollable_free(wasi_io_poll_list_borrow_pollable_t *ptr); -void plugin_list_u32_free(plugin_list_u32_t *ptr); +typedef uint32_t wasi_cli_stdin_future_result_void_error_code_writer_t; -void wasi_io_streams_stream_error_free(wasi_io_streams_stream_error_t *ptr); +wasi_cli_stdin_future_result_void_error_code_t wasi_cli_stdin_future_result_void_error_code_new(wasi_cli_stdin_future_result_void_error_code_writer_t *writer); +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_read(wasi_cli_stdin_future_result_void_error_code_t reader, wasi_cli_stdin_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_write(wasi_cli_stdin_future_result_void_error_code_writer_t writer, const wasi_cli_stdin_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_cancel_read(wasi_cli_stdin_future_result_void_error_code_t reader); +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_cancel_write(wasi_cli_stdin_future_result_void_error_code_writer_t writer); +void wasi_cli_stdin_future_result_void_error_code_drop_readable(wasi_cli_stdin_future_result_void_error_code_t reader); +void wasi_cli_stdin_future_result_void_error_code_drop_writable(wasi_cli_stdin_future_result_void_error_code_writer_t writer); -extern void wasi_io_streams_input_stream_drop_own(wasi_io_streams_own_input_stream_t handle); -extern void wasi_io_streams_input_stream_drop_borrow(wasi_io_streams_borrow_input_stream_t handle); +void wasi_cli_stdout_result_void_error_code_free(wasi_cli_stdout_result_void_error_code_t *ptr); -extern wasi_io_streams_borrow_input_stream_t wasi_io_streams_borrow_input_stream(wasi_io_streams_own_input_stream_t handle); +typedef uint32_t wasi_cli_stdout_future_result_void_error_code_writer_t; -extern void wasi_io_streams_output_stream_drop_own(wasi_io_streams_own_output_stream_t handle); +wasi_cli_stdout_future_result_void_error_code_t wasi_cli_stdout_future_result_void_error_code_new(wasi_cli_stdout_future_result_void_error_code_writer_t *writer); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_read(wasi_cli_stdout_future_result_void_error_code_t reader, wasi_cli_stdout_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_write(wasi_cli_stdout_future_result_void_error_code_writer_t writer, const wasi_cli_stdout_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_cancel_read(wasi_cli_stdout_future_result_void_error_code_t reader); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_cancel_write(wasi_cli_stdout_future_result_void_error_code_writer_t writer); +void wasi_cli_stdout_future_result_void_error_code_drop_readable(wasi_cli_stdout_future_result_void_error_code_t reader); +void wasi_cli_stdout_future_result_void_error_code_drop_writable(wasi_cli_stdout_future_result_void_error_code_writer_t writer); -extern void wasi_io_streams_output_stream_drop_borrow(wasi_io_streams_borrow_output_stream_t handle); -extern wasi_io_streams_borrow_output_stream_t wasi_io_streams_borrow_output_stream(wasi_io_streams_own_output_stream_t handle); +void wasi_cli_stderr_result_void_error_code_free(wasi_cli_stderr_result_void_error_code_t *ptr); -void wasi_io_streams_result_list_u8_stream_error_free(wasi_io_streams_result_list_u8_stream_error_t *ptr); +typedef uint32_t wasi_cli_stderr_future_result_void_error_code_writer_t; -void wasi_io_streams_result_u64_stream_error_free(wasi_io_streams_result_u64_stream_error_t *ptr); +wasi_cli_stderr_future_result_void_error_code_t wasi_cli_stderr_future_result_void_error_code_new(wasi_cli_stderr_future_result_void_error_code_writer_t *writer); +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_read(wasi_cli_stderr_future_result_void_error_code_t reader, wasi_cli_stderr_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_write(wasi_cli_stderr_future_result_void_error_code_writer_t writer, const wasi_cli_stderr_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_cancel_read(wasi_cli_stderr_future_result_void_error_code_t reader); +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_cancel_write(wasi_cli_stderr_future_result_void_error_code_writer_t writer); +void wasi_cli_stderr_future_result_void_error_code_drop_readable(wasi_cli_stderr_future_result_void_error_code_t reader); +void wasi_cli_stderr_future_result_void_error_code_drop_writable(wasi_cli_stderr_future_result_void_error_code_writer_t writer); -void wasi_io_streams_result_void_stream_error_free(wasi_io_streams_result_void_stream_error_t *ptr); extern void wasi_cli_terminal_input_terminal_input_drop_own(wasi_cli_terminal_input_own_terminal_input_t handle); @@ -1257,7 +2219,9 @@ void wasi_cli_terminal_stdout_option_own_terminal_output_free(wasi_cli_terminal_ void wasi_cli_terminal_stderr_option_own_terminal_output_free(wasi_cli_terminal_stderr_option_own_terminal_output_t *ptr); -void wasi_filesystem_types_option_datetime_free(wasi_filesystem_types_option_datetime_t *ptr); +void wasi_filesystem_types_descriptor_type_free(wasi_filesystem_types_descriptor_type_t *ptr); + +void wasi_filesystem_types_option_instant_free(wasi_filesystem_types_option_instant_t *ptr); void wasi_filesystem_types_descriptor_stat_free(wasi_filesystem_types_descriptor_stat_t *ptr); @@ -1265,34 +2229,20 @@ void wasi_filesystem_types_new_timestamp_free(wasi_filesystem_types_new_timestam void wasi_filesystem_types_directory_entry_free(wasi_filesystem_types_directory_entry_t *ptr); +void wasi_filesystem_types_error_code_free(wasi_filesystem_types_error_code_t *ptr); + extern void wasi_filesystem_types_descriptor_drop_own(wasi_filesystem_types_own_descriptor_t handle); extern void wasi_filesystem_types_descriptor_drop_borrow(wasi_filesystem_types_borrow_descriptor_t handle); extern wasi_filesystem_types_borrow_descriptor_t wasi_filesystem_types_borrow_descriptor(wasi_filesystem_types_own_descriptor_t handle); -extern void wasi_filesystem_types_directory_entry_stream_drop_own(wasi_filesystem_types_own_directory_entry_stream_t handle); - -extern void wasi_filesystem_types_directory_entry_stream_drop_borrow(wasi_filesystem_types_borrow_directory_entry_stream_t handle); - -extern wasi_filesystem_types_borrow_directory_entry_stream_t wasi_filesystem_types_borrow_directory_entry_stream(wasi_filesystem_types_own_directory_entry_stream_t handle); - -void wasi_filesystem_types_result_own_input_stream_error_code_free(wasi_filesystem_types_result_own_input_stream_error_code_t *ptr); - -void wasi_filesystem_types_result_own_output_stream_error_code_free(wasi_filesystem_types_result_own_output_stream_error_code_t *ptr); - void wasi_filesystem_types_result_void_error_code_free(wasi_filesystem_types_result_void_error_code_t *ptr); void wasi_filesystem_types_result_descriptor_flags_error_code_free(wasi_filesystem_types_result_descriptor_flags_error_code_t *ptr); void wasi_filesystem_types_result_descriptor_type_error_code_free(wasi_filesystem_types_result_descriptor_type_error_code_t *ptr); -void wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t *ptr); - -void wasi_filesystem_types_result_filesize_error_code_free(wasi_filesystem_types_result_filesize_error_code_t *ptr); - -void wasi_filesystem_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_types_result_own_directory_entry_stream_error_code_t *ptr); - void wasi_filesystem_types_result_descriptor_stat_error_code_free(wasi_filesystem_types_result_descriptor_stat_error_code_t *ptr); void wasi_filesystem_types_result_own_descriptor_error_code_free(wasi_filesystem_types_result_own_descriptor_error_code_t *ptr); @@ -1301,111 +2251,127 @@ void wasi_filesystem_types_result_string_error_code_free(wasi_filesystem_types_r void wasi_filesystem_types_result_metadata_hash_value_error_code_free(wasi_filesystem_types_result_metadata_hash_value_error_code_t *ptr); -void wasi_filesystem_types_option_directory_entry_free(wasi_filesystem_types_option_directory_entry_t *ptr); +typedef uint32_t wasi_filesystem_types_stream_u8_writer_t; -void wasi_filesystem_types_result_option_directory_entry_error_code_free(wasi_filesystem_types_result_option_directory_entry_error_code_t *ptr); +wasi_filesystem_types_stream_u8_t wasi_filesystem_types_stream_u8_new(wasi_filesystem_types_stream_u8_writer_t *writer); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_read(wasi_filesystem_types_stream_u8_t reader, uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_write(wasi_filesystem_types_stream_u8_writer_t writer, const uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_cancel_read(wasi_filesystem_types_stream_u8_t reader); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_cancel_write(wasi_filesystem_types_stream_u8_writer_t writer); +void wasi_filesystem_types_stream_u8_drop_readable(wasi_filesystem_types_stream_u8_t reader); +void wasi_filesystem_types_stream_u8_drop_writable(wasi_filesystem_types_stream_u8_writer_t writer); -void wasi_filesystem_types_option_error_code_free(wasi_filesystem_types_option_error_code_t *ptr); -void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr); - -void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr); - -extern void wasi_sockets_network_network_drop_own(wasi_sockets_network_own_network_t handle); +typedef uint32_t wasi_filesystem_types_future_result_void_error_code_writer_t; -extern void wasi_sockets_network_network_drop_borrow(wasi_sockets_network_borrow_network_t handle); +wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_future_result_void_error_code_new(wasi_filesystem_types_future_result_void_error_code_writer_t *writer); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_read(wasi_filesystem_types_future_result_void_error_code_t reader, wasi_filesystem_types_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_write(wasi_filesystem_types_future_result_void_error_code_writer_t writer, const wasi_filesystem_types_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_cancel_read(wasi_filesystem_types_future_result_void_error_code_t reader); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_cancel_write(wasi_filesystem_types_future_result_void_error_code_writer_t writer); +void wasi_filesystem_types_future_result_void_error_code_drop_readable(wasi_filesystem_types_future_result_void_error_code_t reader); +void wasi_filesystem_types_future_result_void_error_code_drop_writable(wasi_filesystem_types_future_result_void_error_code_writer_t writer); -extern wasi_sockets_network_borrow_network_t wasi_sockets_network_borrow_network(wasi_sockets_network_own_network_t handle); -void wasi_sockets_network_ip_address_free(wasi_sockets_network_ip_address_t *ptr); +typedef uint32_t wasi_filesystem_types_stream_directory_entry_writer_t; -void wasi_sockets_network_ip_socket_address_free(wasi_sockets_network_ip_socket_address_t *ptr); +wasi_filesystem_types_stream_directory_entry_t wasi_filesystem_types_stream_directory_entry_new(wasi_filesystem_types_stream_directory_entry_writer_t *writer); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_read(wasi_filesystem_types_stream_directory_entry_t reader, wasi_filesystem_types_directory_entry_t *buf, size_t amt); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_write(wasi_filesystem_types_stream_directory_entry_writer_t writer, const wasi_filesystem_types_directory_entry_t *buf, size_t amt); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_cancel_read(wasi_filesystem_types_stream_directory_entry_t reader); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_cancel_write(wasi_filesystem_types_stream_directory_entry_writer_t writer); +void wasi_filesystem_types_stream_directory_entry_drop_readable(wasi_filesystem_types_stream_directory_entry_t reader); +void wasi_filesystem_types_stream_directory_entry_drop_writable(wasi_filesystem_types_stream_directory_entry_writer_t writer); -void wasi_sockets_udp_ip_socket_address_free(wasi_sockets_udp_ip_socket_address_t *ptr); -void wasi_sockets_udp_incoming_datagram_free(wasi_sockets_udp_incoming_datagram_t *ptr); - -void wasi_sockets_udp_option_ip_socket_address_free(wasi_sockets_udp_option_ip_socket_address_t *ptr); - -void wasi_sockets_udp_outgoing_datagram_free(wasi_sockets_udp_outgoing_datagram_t *ptr); +void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr); -extern void wasi_sockets_udp_udp_socket_drop_own(wasi_sockets_udp_own_udp_socket_t handle); +void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr); -extern void wasi_sockets_udp_udp_socket_drop_borrow(wasi_sockets_udp_borrow_udp_socket_t handle); +void wasi_sockets_types_error_code_free(wasi_sockets_types_error_code_t *ptr); -extern wasi_sockets_udp_borrow_udp_socket_t wasi_sockets_udp_borrow_udp_socket(wasi_sockets_udp_own_udp_socket_t handle); +void wasi_sockets_types_ip_address_free(wasi_sockets_types_ip_address_t *ptr); -extern void wasi_sockets_udp_incoming_datagram_stream_drop_own(wasi_sockets_udp_own_incoming_datagram_stream_t handle); +void wasi_sockets_types_ip_socket_address_free(wasi_sockets_types_ip_socket_address_t *ptr); -extern void wasi_sockets_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_incoming_datagram_stream_t handle); +extern void wasi_sockets_types_tcp_socket_drop_own(wasi_sockets_types_own_tcp_socket_t handle); -extern wasi_sockets_udp_borrow_incoming_datagram_stream_t wasi_sockets_udp_borrow_incoming_datagram_stream(wasi_sockets_udp_own_incoming_datagram_stream_t handle); +extern void wasi_sockets_types_tcp_socket_drop_borrow(wasi_sockets_types_borrow_tcp_socket_t handle); -extern void wasi_sockets_udp_outgoing_datagram_stream_drop_own(wasi_sockets_udp_own_outgoing_datagram_stream_t handle); +extern wasi_sockets_types_borrow_tcp_socket_t wasi_sockets_types_borrow_tcp_socket(wasi_sockets_types_own_tcp_socket_t handle); -extern void wasi_sockets_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_outgoing_datagram_stream_t handle); +extern void wasi_sockets_types_udp_socket_drop_own(wasi_sockets_types_own_udp_socket_t handle); -extern wasi_sockets_udp_borrow_outgoing_datagram_stream_t wasi_sockets_udp_borrow_outgoing_datagram_stream(wasi_sockets_udp_own_outgoing_datagram_stream_t handle); +extern void wasi_sockets_types_udp_socket_drop_borrow(wasi_sockets_types_borrow_udp_socket_t handle); -void wasi_sockets_udp_result_void_error_code_free(wasi_sockets_udp_result_void_error_code_t *ptr); +extern wasi_sockets_types_borrow_udp_socket_t wasi_sockets_types_borrow_udp_socket(wasi_sockets_types_own_udp_socket_t handle); -void wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr); +void wasi_sockets_types_result_own_tcp_socket_error_code_free(wasi_sockets_types_result_own_tcp_socket_error_code_t *ptr); -void wasi_sockets_udp_result_ip_socket_address_error_code_free(wasi_sockets_udp_result_ip_socket_address_error_code_t *ptr); +void wasi_sockets_types_result_void_error_code_free(wasi_sockets_types_result_void_error_code_t *ptr); -void wasi_sockets_udp_result_u8_error_code_free(wasi_sockets_udp_result_u8_error_code_t *ptr); +void wasi_sockets_types_result_stream_own_tcp_socket_error_code_free(wasi_sockets_types_result_stream_own_tcp_socket_error_code_t *ptr); -void wasi_sockets_udp_result_u64_error_code_free(wasi_sockets_udp_result_u64_error_code_t *ptr); +void wasi_sockets_types_result_ip_socket_address_error_code_free(wasi_sockets_types_result_ip_socket_address_error_code_t *ptr); -void wasi_sockets_udp_list_incoming_datagram_free(wasi_sockets_udp_list_incoming_datagram_t *ptr); +void wasi_sockets_types_result_bool_error_code_free(wasi_sockets_types_result_bool_error_code_t *ptr); -void wasi_sockets_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_udp_result_list_incoming_datagram_error_code_t *ptr); +void wasi_sockets_types_result_duration_error_code_free(wasi_sockets_types_result_duration_error_code_t *ptr); -void wasi_sockets_udp_list_outgoing_datagram_free(wasi_sockets_udp_list_outgoing_datagram_t *ptr); +void wasi_sockets_types_result_u32_error_code_free(wasi_sockets_types_result_u32_error_code_t *ptr); -void wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t *ptr); +void wasi_sockets_types_result_u8_error_code_free(wasi_sockets_types_result_u8_error_code_t *ptr); -void wasi_sockets_tcp_ip_socket_address_free(wasi_sockets_tcp_ip_socket_address_t *ptr); +void wasi_sockets_types_result_u64_error_code_free(wasi_sockets_types_result_u64_error_code_t *ptr); -extern void wasi_sockets_tcp_tcp_socket_drop_own(wasi_sockets_tcp_own_tcp_socket_t handle); +void wasi_sockets_types_result_own_udp_socket_error_code_free(wasi_sockets_types_result_own_udp_socket_error_code_t *ptr); -extern void wasi_sockets_tcp_tcp_socket_drop_borrow(wasi_sockets_tcp_borrow_tcp_socket_t handle); +void wasi_sockets_types_option_ip_socket_address_free(wasi_sockets_types_option_ip_socket_address_t *ptr); -extern wasi_sockets_tcp_borrow_tcp_socket_t wasi_sockets_tcp_borrow_tcp_socket(wasi_sockets_tcp_own_tcp_socket_t handle); +void wasi_sockets_types_tuple2_list_u8_ip_socket_address_free(wasi_sockets_types_tuple2_list_u8_ip_socket_address_t *ptr); -void wasi_sockets_tcp_result_void_error_code_free(wasi_sockets_tcp_result_void_error_code_t *ptr); +void wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_free(wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_t *ptr); -void wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr); +typedef uint32_t wasi_sockets_types_stream_own_tcp_socket_writer_t; -void wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr); +wasi_sockets_types_stream_own_tcp_socket_t wasi_sockets_types_stream_own_tcp_socket_new(wasi_sockets_types_stream_own_tcp_socket_writer_t *writer); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_read(wasi_sockets_types_stream_own_tcp_socket_t reader, wasi_sockets_types_own_tcp_socket_t *buf, size_t amt); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_write(wasi_sockets_types_stream_own_tcp_socket_writer_t writer, const wasi_sockets_types_own_tcp_socket_t *buf, size_t amt); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_cancel_read(wasi_sockets_types_stream_own_tcp_socket_t reader); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_cancel_write(wasi_sockets_types_stream_own_tcp_socket_writer_t writer); +void wasi_sockets_types_stream_own_tcp_socket_drop_readable(wasi_sockets_types_stream_own_tcp_socket_t reader); +void wasi_sockets_types_stream_own_tcp_socket_drop_writable(wasi_sockets_types_stream_own_tcp_socket_writer_t writer); -void wasi_sockets_tcp_result_ip_socket_address_error_code_free(wasi_sockets_tcp_result_ip_socket_address_error_code_t *ptr); -void wasi_sockets_tcp_result_bool_error_code_free(wasi_sockets_tcp_result_bool_error_code_t *ptr); +typedef uint32_t wasi_sockets_types_stream_u8_writer_t; -void wasi_sockets_tcp_result_duration_error_code_free(wasi_sockets_tcp_result_duration_error_code_t *ptr); +wasi_sockets_types_stream_u8_t wasi_sockets_types_stream_u8_new(wasi_sockets_types_stream_u8_writer_t *writer); +plugin_waitable_status_t wasi_sockets_types_stream_u8_read(wasi_sockets_types_stream_u8_t reader, uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_sockets_types_stream_u8_write(wasi_sockets_types_stream_u8_writer_t writer, const uint8_t *buf, size_t amt); +plugin_waitable_status_t wasi_sockets_types_stream_u8_cancel_read(wasi_sockets_types_stream_u8_t reader); +plugin_waitable_status_t wasi_sockets_types_stream_u8_cancel_write(wasi_sockets_types_stream_u8_writer_t writer); +void wasi_sockets_types_stream_u8_drop_readable(wasi_sockets_types_stream_u8_t reader); +void wasi_sockets_types_stream_u8_drop_writable(wasi_sockets_types_stream_u8_writer_t writer); -void wasi_sockets_tcp_result_u32_error_code_free(wasi_sockets_tcp_result_u32_error_code_t *ptr); -void wasi_sockets_tcp_result_u8_error_code_free(wasi_sockets_tcp_result_u8_error_code_t *ptr); +typedef uint32_t wasi_sockets_types_future_result_void_error_code_writer_t; -void wasi_sockets_tcp_result_u64_error_code_free(wasi_sockets_tcp_result_u64_error_code_t *ptr); +wasi_sockets_types_future_result_void_error_code_t wasi_sockets_types_future_result_void_error_code_new(wasi_sockets_types_future_result_void_error_code_writer_t *writer); +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_read(wasi_sockets_types_future_result_void_error_code_t reader, wasi_sockets_types_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_write(wasi_sockets_types_future_result_void_error_code_writer_t writer, const wasi_sockets_types_result_void_error_code_t *buf); +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_cancel_read(wasi_sockets_types_future_result_void_error_code_t reader); +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_cancel_write(wasi_sockets_types_future_result_void_error_code_writer_t writer); +void wasi_sockets_types_future_result_void_error_code_drop_readable(wasi_sockets_types_future_result_void_error_code_t reader); +void wasi_sockets_types_future_result_void_error_code_drop_writable(wasi_sockets_types_future_result_void_error_code_writer_t writer); -void wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr); void wasi_sockets_ip_name_lookup_ip_address_free(wasi_sockets_ip_name_lookup_ip_address_t *ptr); -extern void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle); - -extern void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t handle); - -extern wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle); +void wasi_sockets_ip_name_lookup_error_code_free(wasi_sockets_ip_name_lookup_error_code_t *ptr); -void wasi_sockets_ip_name_lookup_option_ip_address_free(wasi_sockets_ip_name_lookup_option_ip_address_t *ptr); +void wasi_sockets_ip_name_lookup_list_ip_address_free(wasi_sockets_ip_name_lookup_list_ip_address_t *ptr); -void wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t *ptr); - -void wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr); +void wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_t *ptr); void exports_streamkit_plugin_node_node_metadata_free(exports_streamkit_plugin_node_node_metadata_t *ptr); @@ -1418,6 +2384,8 @@ extern exports_streamkit_plugin_node_node_instance_t* exports_streamkit_plugin_n void exports_streamkit_plugin_node_node_instance_destructor(exports_streamkit_plugin_node_node_instance_t *rep); void exports_streamkit_plugin_node_result_void_string_free(exports_streamkit_plugin_node_result_void_string_t *ptr); +void exports_streamkit_plugin_node_method_node_instance_process_return(exports_streamkit_plugin_node_result_void_string_t ret); +void exports_streamkit_plugin_node_method_node_instance_update_params_return(exports_streamkit_plugin_node_result_void_string_t ret); // Sets the string `ret` to reference the input string `s` without copying it void plugin_string_set(plugin_string_t *ret, const char*s); @@ -1426,6 +2394,11 @@ void plugin_string_set(plugin_string_t *ret, const char*s); // stores it into the component model string `ret`. void plugin_string_dup(plugin_string_t *ret, const char*s); +// Creates a copy of the input string `s` with length `len` and +// stores it into the component model string `ret`. +// The length is specified in code units (bytes for UTF-8, 16-bit values for UTF-16). +void plugin_string_dup_n(plugin_string_t *ret, const char*s, size_t len); + // Deallocates the string pointed to by `ret`, deallocating // the memory behind the string. void plugin_string_free(plugin_string_t *ret); diff --git a/sdks/plugin-sdk/c/src/plugin.c b/sdks/plugin-sdk/c/src/plugin.c index c63c16a07..b46a8087b 100644 --- a/sdks/plugin-sdk/c/src/plugin.c +++ b/sdks/plugin-sdk/c/src/plugin.c @@ -1,439 +1,317 @@ -/* - * SPDX-FileCopyrightText: © 2025 StreamKit Contributors - * - * SPDX-License-Identifier: MPL-2.0 - */ - -// Generated by `wit-bindgen` 0.44.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.58.0. DO NOT EDIT! #include "plugin.h" #include #include -// Imported Functions from `streamkit:plugin/host@0.1.0` +// Imported Functions from `streamkit:plugin/host@0.2.0` -__attribute__((__import_module__("streamkit:plugin/host@0.1.0"), __import_name__("send-output"))) -extern void __wasm_import_streamkit_plugin_host_send_output(uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("streamkit:plugin/host@0.2.0"), __import_name__("[async-lower]send-output"))) +extern int32_t __wasm_import_streamkit_plugin_host_send_output(uint8_t *, uint8_t *); -__attribute__((__import_module__("streamkit:plugin/host@0.1.0"), __import_name__("log"))) +__attribute__((__import_module__("streamkit:plugin/host@0.2.0"), __import_name__("log"))) extern void __wasm_import_streamkit_plugin_host_log(int32_t, uint8_t *, size_t); -// Imported Functions from `wasi:cli/environment@0.2.0` +// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-environment"))) +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-03-15"), __import_name__("get-environment"))) extern void __wasm_import_wasi_cli_environment_get_environment(uint8_t *); -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-arguments"))) +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-03-15"), __import_name__("get-arguments"))) extern void __wasm_import_wasi_cli_environment_get_arguments(uint8_t *); -__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("initial-cwd"))) -extern void __wasm_import_wasi_cli_environment_initial_cwd(uint8_t *); +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-03-15"), __import_name__("get-initial-cwd"))) +extern void __wasm_import_wasi_cli_environment_get_initial_cwd(uint8_t *); -// Imported Functions from `wasi:cli/exit@0.2.0` +// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:cli/exit@0.2.0"), __import_name__("exit"))) +__attribute__((__import_module__("wasi:cli/exit@0.3.0-rc-2026-03-15"), __import_name__("exit"))) extern void __wasm_import_wasi_cli_exit_exit(int32_t); -// Imported Functions from `wasi:io/error@0.2.0` - -__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[method]error.to-debug-string"))) -extern void __wasm_import_wasi_io_error_method_error_to_debug_string(int32_t, uint8_t *); - -// Imported Functions from `wasi:io/poll@0.2.0` - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.ready"))) -extern int32_t __wasm_import_wasi_io_poll_method_pollable_ready(int32_t); - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.block"))) -extern void __wasm_import_wasi_io_poll_method_pollable_block(int32_t); - -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("poll"))) -extern void __wasm_import_wasi_io_poll_poll(uint8_t *, size_t, uint8_t *); - -// Imported Functions from `wasi:io/streams@0.2.0` - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.read"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_read(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-read"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_blocking_read(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.skip"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_skip(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-skip"))) -extern void __wasm_import_wasi_io_streams_method_input_stream_blocking_skip(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.subscribe"))) -extern int32_t __wasm_import_wasi_io_streams_method_input_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.check-write"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_check_write(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_write(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-and-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_write_and_flush(int32_t, uint8_t *, size_t, uint8_t *); - -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_flush(int32_t, uint8_t *); +// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_flush(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("read-via-stream"))) +extern void __wasm_import_wasi_cli_stdin_read_via_stream(uint8_t *); -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.subscribe"))) -extern int32_t __wasm_import_wasi_io_streams_method_output_stream_subscribe(int32_t); +// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write-zeroes"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_write_zeroes(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("write-via-stream"))) +extern int32_t __wasm_import_wasi_cli_stdout_write_via_stream(int32_t); -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-zeroes-and-flush"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(int32_t, int64_t, uint8_t *); +// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.splice"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_splice(int32_t, int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("write-via-stream"))) +extern int32_t __wasm_import_wasi_cli_stderr_write_via_stream(int32_t); -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-splice"))) -extern void __wasm_import_wasi_io_streams_method_output_stream_blocking_splice(int32_t, int32_t, int64_t, uint8_t *); +// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15` -// Imported Functions from `wasi:cli/stdin@0.2.0` - -__attribute__((__import_module__("wasi:cli/stdin@0.2.0"), __import_name__("get-stdin"))) -extern int32_t __wasm_import_wasi_cli_stdin_get_stdin(void); - -// Imported Functions from `wasi:cli/stdout@0.2.0` - -__attribute__((__import_module__("wasi:cli/stdout@0.2.0"), __import_name__("get-stdout"))) -extern int32_t __wasm_import_wasi_cli_stdout_get_stdout(void); - -// Imported Functions from `wasi:cli/stderr@0.2.0` - -__attribute__((__import_module__("wasi:cli/stderr@0.2.0"), __import_name__("get-stderr"))) -extern int32_t __wasm_import_wasi_cli_stderr_get_stderr(void); - -// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` - -__attribute__((__import_module__("wasi:cli/terminal-stdin@0.2.0"), __import_name__("get-terminal-stdin"))) +__attribute__((__import_module__("wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15"), __import_name__("get-terminal-stdin"))) extern void __wasm_import_wasi_cli_terminal_stdin_get_terminal_stdin(uint8_t *); -// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` +// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:cli/terminal-stdout@0.2.0"), __import_name__("get-terminal-stdout"))) +__attribute__((__import_module__("wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15"), __import_name__("get-terminal-stdout"))) extern void __wasm_import_wasi_cli_terminal_stdout_get_terminal_stdout(uint8_t *); -// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` +// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:cli/terminal-stderr@0.2.0"), __import_name__("get-terminal-stderr"))) +__attribute__((__import_module__("wasi:cli/terminal-stderr@0.3.0-rc-2026-03-15"), __import_name__("get-terminal-stderr"))) extern void __wasm_import_wasi_cli_terminal_stderr_get_terminal_stderr(uint8_t *); -// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` +// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("now"))) +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15"), __import_name__("now"))) extern int64_t __wasm_import_wasi_clocks_monotonic_clock_now(void); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("resolution"))) -extern int64_t __wasm_import_wasi_clocks_monotonic_clock_resolution(void); +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15"), __import_name__("get-resolution"))) +extern int64_t __wasm_import_wasi_clocks_monotonic_clock_get_resolution(void); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-instant"))) -extern int32_t __wasm_import_wasi_clocks_monotonic_clock_subscribe_instant(int64_t); +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15"), __import_name__("[async-lower]wait-until"))) +extern int32_t __wasm_import_wasi_clocks_monotonic_clock_wait_until(int64_t); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-duration"))) -extern int32_t __wasm_import_wasi_clocks_monotonic_clock_subscribe_duration(int64_t); +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15"), __import_name__("[async-lower]wait-for"))) +extern int32_t __wasm_import_wasi_clocks_monotonic_clock_wait_for(int64_t); -// Imported Functions from `wasi:clocks/wall-clock@0.2.0` +// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("now"))) -extern void __wasm_import_wasi_clocks_wall_clock_now(uint8_t *); +__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-03-15"), __import_name__("now"))) +extern void __wasm_import_wasi_clocks_system_clock_now(uint8_t *); -__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("resolution"))) -extern void __wasm_import_wasi_clocks_wall_clock_resolution(uint8_t *); +__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-03-15"), __import_name__("get-resolution"))) +extern int64_t __wasm_import_wasi_clocks_system_clock_get_resolution(void); -// Imported Functions from `wasi:filesystem/types@0.2.0` +// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[method]descriptor.read-via-stream"))) extern void __wasm_import_wasi_filesystem_types_method_descriptor_read_via_stream(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write-via-stream"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.append-via-stream"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[method]descriptor.write-via-stream"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream(int32_t, int32_t, int64_t); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.advise"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[method]descriptor.append-via-stream"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream(int32_t, int32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync-data"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_sync_data(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.advise"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-flags"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_get_flags(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.sync-data"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_sync_data(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-type"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_get_type(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.get-flags"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_get_flags(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-size"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_size(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.get-type"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_get_type(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.set-size"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_set_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_read(int32_t, int64_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.set-times"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_set_times(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_write(int32_t, uint8_t *, size_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[method]descriptor.read-directory"))) extern void __wasm_import_wasi_filesystem_types_method_descriptor_read_directory(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_sync(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.create-directory-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at(int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.sync"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_sync(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_stat(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.create-directory-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_stat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.stat"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_stat(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.stat-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_stat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.link-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_link_at(int32_t, int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.set-times-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.open-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_open_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.link-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_link_at(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.readlink-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at(int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.open-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_open_at(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.remove-directory-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.readlink-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.rename-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_rename_at(int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.remove-directory-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.symlink-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.rename-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_rename_at(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.unlink-file-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.symlink-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.is-same-object"))) -extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object(int32_t, int32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.unlink-file-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.is-same-object"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash-at"))) -extern void __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.metadata-hash"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]directory-entry-stream.read-directory-entry"))) -extern void __wasm_import_wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]descriptor.metadata-hash-at"))) +extern int32_t __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("filesystem-error-code"))) -extern void __wasm_import_wasi_filesystem_types_filesystem_error_code(int32_t, uint8_t *); +// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-03-15` -// Imported Functions from `wasi:filesystem/preopens@0.2.0` - -__attribute__((__import_module__("wasi:filesystem/preopens@0.2.0"), __import_name__("get-directories"))) +__attribute__((__import_module__("wasi:filesystem/preopens@0.3.0-rc-2026-03-15"), __import_name__("get-directories"))) extern void __wasm_import_wasi_filesystem_preopens_get_directories(uint8_t *); -// Imported Functions from `wasi:sockets/instance-network@0.2.0` - -__attribute__((__import_module__("wasi:sockets/instance-network@0.2.0"), __import_name__("instance-network"))) -extern int32_t __wasm_import_wasi_sockets_instance_network_instance_network(void); - -// Imported Functions from `wasi:sockets/udp@0.2.0` - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.start-bind"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.finish-bind"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_finish_bind(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.stream"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_stream(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.local-address"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_local_address(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[static]tcp-socket.create"))) +extern void __wasm_import_wasi_sockets_types_static_tcp_socket_create(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.remote-address"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_remote_address(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.bind"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.address-family"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_udp_socket_address_family(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]tcp-socket.connect"))) +extern int32_t __wasm_import_wasi_sockets_types_method_tcp_socket_connect(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.unicast-hop-limit"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_unicast_hop_limit(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.listen"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_listen(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.send"))) +extern int32_t __wasm_import_wasi_sockets_types_method_tcp_socket_send(int32_t, int32_t); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_receive_buffer_size(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.receive"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_receive(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-local-address"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_local_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.send-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_send_buffer_size(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-remote-address"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_remote_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-send-buffer-size"))) -extern void __wasm_import_wasi_sockets_udp_method_udp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-is-listening"))) +extern int32_t __wasm_import_wasi_sockets_types_method_tcp_socket_get_is_listening(int32_t); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_udp_socket_subscribe(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-address-family"))) +extern int32_t __wasm_import_wasi_sockets_types_method_tcp_socket_get_address_family(int32_t); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.receive"))) -extern void __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_receive(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_subscribe(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-keep-alive-enabled"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_enabled(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.check-send"))) -extern void __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_check_send(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.send"))) -extern void __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_send(int32_t, uint8_t *, size_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-keep-alive-idle-time"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_idle_time(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, uint8_t *); -// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-keep-alive-interval"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_interval(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/udp-create-socket@0.2.0"), __import_name__("create-udp-socket"))) -extern void __wasm_import_wasi_sockets_udp_create_socket_create_udp_socket(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, uint8_t *); -// Imported Functions from `wasi:sockets/tcp@0.2.0` +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-keep-alive-count"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_count(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-bind"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-bind"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_bind(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-hop-limit"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_hop_limit(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-connect"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-hop-limit"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_hop_limit(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-connect"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_connect(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_receive_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-listen"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_listen(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-listen"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_listen(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.get-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_get_send_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.accept"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_accept(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.local-address"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_local_address(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[static]udp-socket.create"))) +extern void __wasm_import_wasi_sockets_types_static_udp_socket_create(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.remote-address"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_remote_address(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.bind"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.is-listening"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_is_listening(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.connect"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.address-family"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_address_family(int32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.disconnect"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_disconnect(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]udp-socket.send"))) +extern int32_t __wasm_import_wasi_sockets_types_method_udp_socket_send(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-enabled"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][method]udp-socket.receive"))) +extern int32_t __wasm_import_wasi_sockets_types_method_udp_socket_receive(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-local-address"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_get_local_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-idle-time"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-remote-address"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_get_remote_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-address-family"))) +extern int32_t __wasm_import_wasi_sockets_types_method_udp_socket_get_address_family(int32_t); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-interval"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-unicast-hop-limit"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_get_unicast_hop_limit(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-count"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_count(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_get_receive_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.hop-limit"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_hop_limit(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.get-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_get_send_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-hop-limit"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_hop_limit(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[method]udp-socket.set-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_types_method_udp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(int32_t, uint8_t *); +// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15"), __import_name__("[async-lower]resolve-addresses"))) +extern int32_t __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses(uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.send-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_send_buffer_size(int32_t, uint8_t *); +// Imported Functions from `wasi:random/random@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_tcp_method_tcp_socket_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.shutdown"))) -extern void __wasm_import_wasi_sockets_tcp_method_tcp_socket_shutdown(int32_t, int32_t, uint8_t *); - -// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` - -__attribute__((__import_module__("wasi:sockets/tcp-create-socket@0.2.0"), __import_name__("create-tcp-socket"))) -extern void __wasm_import_wasi_sockets_tcp_create_socket_create_tcp_socket(int32_t, uint8_t *); - -// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.resolve-next-address"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(int32_t, uint8_t *); - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.subscribe"))) -extern int32_t __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(int32_t); - -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("resolve-addresses"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses(int32_t, uint8_t *, size_t, uint8_t *); - -// Imported Functions from `wasi:random/random@0.2.0` - -__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-bytes"))) +__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-03-15"), __import_name__("get-random-bytes"))) extern void __wasm_import_wasi_random_random_get_random_bytes(int64_t, uint8_t *); -__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-u64"))) +__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-03-15"), __import_name__("get-random-u64"))) extern int64_t __wasm_import_wasi_random_random_get_random_u64(void); -// Imported Functions from `wasi:random/insecure@0.2.0` +// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-bytes"))) +__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-03-15"), __import_name__("get-insecure-random-bytes"))) extern void __wasm_import_wasi_random_insecure_get_insecure_random_bytes(int64_t, uint8_t *); -__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-u64"))) +__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-03-15"), __import_name__("get-insecure-random-u64"))) extern int64_t __wasm_import_wasi_random_insecure_get_insecure_random_u64(void); -// Imported Functions from `wasi:random/insecure-seed@0.2.0` +// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-03-15` -__attribute__((__import_module__("wasi:random/insecure-seed@0.2.0"), __import_name__("insecure-seed"))) -extern void __wasm_import_wasi_random_insecure_seed_insecure_seed(uint8_t *); +__attribute__((__import_module__("wasi:random/insecure-seed@0.3.0-rc-2026-03-15"), __import_name__("get-insecure-seed"))) +extern void __wasm_import_wasi_random_insecure_seed_get_insecure_seed(uint8_t *); -// Exported Functions from `streamkit:plugin/node@0.1.0` +// Exported Functions from `streamkit:plugin/node@0.2.0` -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#metadata"))) +__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.2.0#metadata"))) void __wasm_export_exports_streamkit_plugin_node_metadata_post_return(uint8_t * arg0) { if ((*((size_t*) (arg0 + sizeof(void*)))) > 0) { free(*((uint8_t **) (arg0 + 0))); @@ -451,8 +329,31 @@ void __wasm_export_exports_streamkit_plugin_node_metadata_post_return(uint8_t * if (len > 0) { uint8_t *ptr = *((uint8_t **) (base + (2*sizeof(void*)))); for (size_t i = 0; i < len; i++) { - uint8_t *base = ptr + i * 12; + uint8_t *base = ptr + i * (3*sizeof(void*)); (void) base; + switch ((int32_t) (int32_t) *((uint8_t*) (base + 0))) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + if ((*((size_t*) (base + (2*sizeof(void*))))) > 0) { + free(*((uint8_t **) (base + sizeof(void*)))); + } + break; + } + case 5: { + break; + } + } } free(ptr); } @@ -463,11 +364,34 @@ void __wasm_export_exports_streamkit_plugin_node_metadata_post_return(uint8_t * if (len3 > 0) { uint8_t *ptr4 = *((uint8_t **) (arg0 + (4*sizeof(void*)))); for (size_t i5 = 0; i5 < len3; i5++) { - uint8_t *base = ptr4 + i5 * (8+3*sizeof(void*)); + uint8_t *base = ptr4 + i5 * (5*sizeof(void*)); (void) base; if ((*((size_t*) (base + sizeof(void*)))) > 0) { free(*((uint8_t **) (base + 0))); } + switch ((int32_t) (int32_t) *((uint8_t*) (base + (2*sizeof(void*))))) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + if ((*((size_t*) (base + (4*sizeof(void*))))) > 0) { + free(*((uint8_t **) (base + (3*sizeof(void*))))); + } + break; + } + case 5: { + break; + } + } } free(ptr4); } @@ -489,35 +413,7 @@ void __wasm_export_exports_streamkit_plugin_node_metadata_post_return(uint8_t * } -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.process"))) -void __wasm_export_exports_streamkit_plugin_node_method_node_instance_process_post_return(uint8_t * arg0) { - switch ((int32_t) (int32_t) *((uint8_t*) (arg0 + 0))) { - case 0: { - break; - } - case 1: { - if ((*((size_t*) (arg0 + (2*sizeof(void*))))) > 0) { - free(*((uint8_t **) (arg0 + sizeof(void*)))); - } - break; - } - } -} -__attribute__((__weak__, __export_name__("cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.update-params"))) -void __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params_post_return(uint8_t * arg0) { - switch ((int32_t) (int32_t) *((uint8_t*) (arg0 + 0))) { - case 0: { - break; - } - case 1: { - if ((*((size_t*) (arg0 + (2*sizeof(void*))))) > 0) { - free(*((uint8_t **) (arg0 + sizeof(void*)))); - } - break; - } - } -} // Canonical ABI intrinsics @@ -541,9 +437,18 @@ void streamkit_plugin_types_packet_type_free(streamkit_plugin_types_packet_type_ case 0: { break; } + case 4: { + plugin_string_free(&ptr->val.custom); + break; + } } } +void streamkit_plugin_types_custom_packet_free(streamkit_plugin_types_custom_packet_t *ptr) { + plugin_string_free(&ptr->type_id); + plugin_string_free(&ptr->data); +} + void streamkit_plugin_types_list_packet_type_free(streamkit_plugin_types_list_packet_type_t *ptr) { size_t list_len = ptr->len; if (list_len > 0) { @@ -644,6 +549,10 @@ void streamkit_plugin_types_packet_free(streamkit_plugin_types_packet_t *ptr) { plugin_list_u8_free(&ptr->val.binary); break; } + case 3: { + streamkit_plugin_types_custom_packet_free(&ptr->val.custom); + break; + } } } @@ -685,116 +594,209 @@ void wasi_cli_exit_result_void_void_free(wasi_cli_exit_result_void_void_t *ptr) } } -__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[resource-drop]error"))) -extern void __wasm_import_wasi_io_error_error_drop(int32_t handle); +void wasi_cli_stdin_result_void_error_code_free(wasi_cli_stdin_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[stream-new-0]read-via-stream"))) +extern uint64_t wasi_cli_stdin_stream_u8__new(void); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-read-0]read-via-stream"))) +extern uint32_t wasi_cli_stdin_stream_u8__read(uint32_t, uint8_t*, size_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-write-0]read-via-stream"))) +extern uint32_t wasi_cli_stdin_stream_u8__write(uint32_t, const uint8_t*, size_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-read-0]read-via-stream"))) +extern uint32_t wasi_cli_stdin_stream_u8__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-write-0]read-via-stream"))) +extern uint32_t wasi_cli_stdin_stream_u8__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-readable-0]read-via-stream"))) +extern void wasi_cli_stdin_stream_u8__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-writable-0]read-via-stream"))) +extern void wasi_cli_stdin_stream_u8__drop_writable(uint32_t); -void wasi_io_error_error_drop_own(wasi_io_error_own_error_t handle) { - __wasm_import_wasi_io_error_error_drop(handle.__handle); +wasi_cli_stdin_stream_u8_t wasi_cli_stdin_stream_u8_new(wasi_cli_stdin_stream_u8_writer_t *writer) { + uint64_t packed = wasi_cli_stdin_stream_u8__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_io_error_error_drop_borrow(wasi_io_error_borrow_error_t handle) { - __wasm_import_wasi_io_error_error_drop(handle.__handle); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_read(wasi_cli_stdin_stream_u8_t reader, uint8_t *buf, size_t amt) { + return wasi_cli_stdin_stream_u8__read(reader, (uint8_t*) buf, amt); } -wasi_io_error_borrow_error_t wasi_io_error_borrow_error(wasi_io_error_own_error_t arg) { - return (wasi_io_error_borrow_error_t) { arg.__handle }; +plugin_waitable_status_t wasi_cli_stdin_stream_u8_write(wasi_cli_stdin_stream_u8_writer_t writer, const uint8_t *buf, size_t amt) { + return wasi_cli_stdin_stream_u8__write(writer, (const uint8_t*) buf, amt); } -__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[resource-drop]pollable"))) -extern void __wasm_import_wasi_io_poll_pollable_drop(int32_t handle); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_cancel_read(wasi_cli_stdin_stream_u8_t reader){ + return wasi_cli_stdin_stream_u8__cancel_read(reader); +} -void wasi_io_poll_pollable_drop_own(wasi_io_poll_own_pollable_t handle) { - __wasm_import_wasi_io_poll_pollable_drop(handle.__handle); +plugin_waitable_status_t wasi_cli_stdin_stream_u8_cancel_write(wasi_cli_stdin_stream_u8_writer_t writer) { + return wasi_cli_stdin_stream_u8__cancel_write(writer); } -void wasi_io_poll_pollable_drop_borrow(wasi_io_poll_borrow_pollable_t handle) { - __wasm_import_wasi_io_poll_pollable_drop(handle.__handle); +void wasi_cli_stdin_stream_u8_drop_readable(wasi_cli_stdin_stream_u8_t reader){ + wasi_cli_stdin_stream_u8__drop_readable(reader); } -wasi_io_poll_borrow_pollable_t wasi_io_poll_borrow_pollable(wasi_io_poll_own_pollable_t arg) { - return (wasi_io_poll_borrow_pollable_t) { arg.__handle }; +void wasi_cli_stdin_stream_u8_drop_writable(wasi_cli_stdin_stream_u8_writer_t writer) { + wasi_cli_stdin_stream_u8__drop_writable(writer); } -void wasi_io_poll_list_borrow_pollable_free(wasi_io_poll_list_borrow_pollable_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_io_poll_borrow_pollable_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } + +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[future-new-1]read-via-stream"))) +extern uint64_t wasi_cli_stdin_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-read-1]read-via-stream"))) +extern uint32_t wasi_cli_stdin_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-write-1]read-via-stream"))) +extern uint32_t wasi_cli_stdin_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-read-1]read-via-stream"))) +extern uint32_t wasi_cli_stdin_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-write-1]read-via-stream"))) +extern uint32_t wasi_cli_stdin_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-readable-1]read-via-stream"))) +extern void wasi_cli_stdin_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-writable-1]read-via-stream"))) +extern void wasi_cli_stdin_future_result_void_error_code__drop_writable(uint32_t); + +wasi_cli_stdin_future_result_void_error_code_t wasi_cli_stdin_future_result_void_error_code_new(wasi_cli_stdin_future_result_void_error_code_writer_t *writer) { + uint64_t packed = wasi_cli_stdin_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void plugin_list_u32_free(plugin_list_u32_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - uint32_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - } - free(list_ptr); - } +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_read(wasi_cli_stdin_future_result_void_error_code_t reader, wasi_cli_stdin_result_void_error_code_t *buf) { + return wasi_cli_stdin_future_result_void_error_code__read(reader, (uint8_t*) buf); } -void wasi_io_streams_stream_error_free(wasi_io_streams_stream_error_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_write(wasi_cli_stdin_future_result_void_error_code_writer_t writer, const wasi_cli_stdin_result_void_error_code_t *buf) { + return wasi_cli_stdin_future_result_void_error_code__write(writer, (const uint8_t*) buf); +} + +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_cancel_read(wasi_cli_stdin_future_result_void_error_code_t reader){ + return wasi_cli_stdin_future_result_void_error_code__cancel_read(reader); +} + +plugin_waitable_status_t wasi_cli_stdin_future_result_void_error_code_cancel_write(wasi_cli_stdin_future_result_void_error_code_writer_t writer) { + return wasi_cli_stdin_future_result_void_error_code__cancel_write(writer); +} + +void wasi_cli_stdin_future_result_void_error_code_drop_readable(wasi_cli_stdin_future_result_void_error_code_t reader){ + wasi_cli_stdin_future_result_void_error_code__drop_readable(reader); +} + +void wasi_cli_stdin_future_result_void_error_code_drop_writable(wasi_cli_stdin_future_result_void_error_code_writer_t writer) { + wasi_cli_stdin_future_result_void_error_code__drop_writable(writer); +} + + +void wasi_cli_stdout_result_void_error_code_free(wasi_cli_stdout_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { } } -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]input-stream"))) -extern void __wasm_import_wasi_io_streams_input_stream_drop(int32_t handle); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[future-new-1]write-via-stream"))) +extern uint64_t wasi_cli_stdout_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-read-1]write-via-stream"))) +extern uint32_t wasi_cli_stdout_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-write-1]write-via-stream"))) +extern uint32_t wasi_cli_stdout_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-read-1]write-via-stream"))) +extern uint32_t wasi_cli_stdout_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-write-1]write-via-stream"))) +extern uint32_t wasi_cli_stdout_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-readable-1]write-via-stream"))) +extern void wasi_cli_stdout_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-writable-1]write-via-stream"))) +extern void wasi_cli_stdout_future_result_void_error_code__drop_writable(uint32_t); -void wasi_io_streams_input_stream_drop_own(wasi_io_streams_own_input_stream_t handle) { - __wasm_import_wasi_io_streams_input_stream_drop(handle.__handle); +wasi_cli_stdout_future_result_void_error_code_t wasi_cli_stdout_future_result_void_error_code_new(wasi_cli_stdout_future_result_void_error_code_writer_t *writer) { + uint64_t packed = wasi_cli_stdout_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_io_streams_input_stream_drop_borrow(wasi_io_streams_borrow_input_stream_t handle) { - __wasm_import_wasi_io_streams_input_stream_drop(handle.__handle); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_read(wasi_cli_stdout_future_result_void_error_code_t reader, wasi_cli_stdout_result_void_error_code_t *buf) { + return wasi_cli_stdout_future_result_void_error_code__read(reader, (uint8_t*) buf); } -wasi_io_streams_borrow_input_stream_t wasi_io_streams_borrow_input_stream(wasi_io_streams_own_input_stream_t arg) { - return (wasi_io_streams_borrow_input_stream_t) { arg.__handle }; +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_write(wasi_cli_stdout_future_result_void_error_code_writer_t writer, const wasi_cli_stdout_result_void_error_code_t *buf) { + return wasi_cli_stdout_future_result_void_error_code__write(writer, (const uint8_t*) buf); } -__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]output-stream"))) -extern void __wasm_import_wasi_io_streams_output_stream_drop(int32_t handle); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_cancel_read(wasi_cli_stdout_future_result_void_error_code_t reader){ + return wasi_cli_stdout_future_result_void_error_code__cancel_read(reader); +} -void wasi_io_streams_output_stream_drop_own(wasi_io_streams_own_output_stream_t handle) { - __wasm_import_wasi_io_streams_output_stream_drop(handle.__handle); +plugin_waitable_status_t wasi_cli_stdout_future_result_void_error_code_cancel_write(wasi_cli_stdout_future_result_void_error_code_writer_t writer) { + return wasi_cli_stdout_future_result_void_error_code__cancel_write(writer); } -void wasi_io_streams_output_stream_drop_borrow(wasi_io_streams_borrow_output_stream_t handle) { - __wasm_import_wasi_io_streams_output_stream_drop(handle.__handle); +void wasi_cli_stdout_future_result_void_error_code_drop_readable(wasi_cli_stdout_future_result_void_error_code_t reader){ + wasi_cli_stdout_future_result_void_error_code__drop_readable(reader); } -wasi_io_streams_borrow_output_stream_t wasi_io_streams_borrow_output_stream(wasi_io_streams_own_output_stream_t arg) { - return (wasi_io_streams_borrow_output_stream_t) { arg.__handle }; +void wasi_cli_stdout_future_result_void_error_code_drop_writable(wasi_cli_stdout_future_result_void_error_code_writer_t writer) { + wasi_cli_stdout_future_result_void_error_code__drop_writable(writer); } -void wasi_io_streams_result_list_u8_stream_error_free(wasi_io_streams_result_list_u8_stream_error_t *ptr) { + +void wasi_cli_stderr_result_void_error_code_free(wasi_cli_stderr_result_void_error_code_t *ptr) { if (!ptr->is_err) { } else { - wasi_io_streams_stream_error_free(&ptr->val.err); } } -void wasi_io_streams_result_u64_stream_error_free(wasi_io_streams_result_u64_stream_error_t *ptr) { - if (!ptr->is_err) { - } else { - wasi_io_streams_stream_error_free(&ptr->val.err); - } +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[future-new-1]write-via-stream"))) +extern uint64_t wasi_cli_stderr_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-read-1]write-via-stream"))) +extern uint32_t wasi_cli_stderr_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-write-1]write-via-stream"))) +extern uint32_t wasi_cli_stderr_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-read-1]write-via-stream"))) +extern uint32_t wasi_cli_stderr_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-write-1]write-via-stream"))) +extern uint32_t wasi_cli_stderr_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-readable-1]write-via-stream"))) +extern void wasi_cli_stderr_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-writable-1]write-via-stream"))) +extern void wasi_cli_stderr_future_result_void_error_code__drop_writable(uint32_t); + +wasi_cli_stderr_future_result_void_error_code_t wasi_cli_stderr_future_result_void_error_code_new(wasi_cli_stderr_future_result_void_error_code_writer_t *writer) { + uint64_t packed = wasi_cli_stderr_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_io_streams_result_void_stream_error_free(wasi_io_streams_result_void_stream_error_t *ptr) { - if (!ptr->is_err) { - } else { - wasi_io_streams_stream_error_free(&ptr->val.err); - } +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_read(wasi_cli_stderr_future_result_void_error_code_t reader, wasi_cli_stderr_result_void_error_code_t *buf) { + return wasi_cli_stderr_future_result_void_error_code__read(reader, (uint8_t*) buf); +} + +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_write(wasi_cli_stderr_future_result_void_error_code_writer_t writer, const wasi_cli_stderr_result_void_error_code_t *buf) { + return wasi_cli_stderr_future_result_void_error_code__write(writer, (const uint8_t*) buf); +} + +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_cancel_read(wasi_cli_stderr_future_result_void_error_code_t reader){ + return wasi_cli_stderr_future_result_void_error_code__cancel_read(reader); +} + +plugin_waitable_status_t wasi_cli_stderr_future_result_void_error_code_cancel_write(wasi_cli_stderr_future_result_void_error_code_writer_t writer) { + return wasi_cli_stderr_future_result_void_error_code__cancel_write(writer); +} + +void wasi_cli_stderr_future_result_void_error_code_drop_readable(wasi_cli_stderr_future_result_void_error_code_t reader){ + wasi_cli_stderr_future_result_void_error_code__drop_readable(reader); +} + +void wasi_cli_stderr_future_result_void_error_code_drop_writable(wasi_cli_stderr_future_result_void_error_code_writer_t writer) { + wasi_cli_stderr_future_result_void_error_code__drop_writable(writer); } -__attribute__((__import_module__("wasi:cli/terminal-input@0.2.0"), __import_name__("[resource-drop]terminal-input"))) + +__attribute__((__import_module__("wasi:cli/terminal-input@0.3.0-rc-2026-03-15"), __import_name__("[resource-drop]terminal-input"))) extern void __wasm_import_wasi_cli_terminal_input_terminal_input_drop(int32_t handle); void wasi_cli_terminal_input_terminal_input_drop_own(wasi_cli_terminal_input_own_terminal_input_t handle) { @@ -809,7 +811,7 @@ wasi_cli_terminal_input_borrow_terminal_input_t wasi_cli_terminal_input_borrow_t return (wasi_cli_terminal_input_borrow_terminal_input_t) { arg.__handle }; } -__attribute__((__import_module__("wasi:cli/terminal-output@0.2.0"), __import_name__("[resource-drop]terminal-output"))) +__attribute__((__import_module__("wasi:cli/terminal-output@0.3.0-rc-2026-03-15"), __import_name__("[resource-drop]terminal-output"))) extern void __wasm_import_wasi_cli_terminal_output_terminal_output_drop(int32_t handle); void wasi_cli_terminal_output_terminal_output_drop_own(wasi_cli_terminal_output_own_terminal_output_t handle) { @@ -839,15 +841,24 @@ void wasi_cli_terminal_stderr_option_own_terminal_output_free(wasi_cli_terminal_ } } -void wasi_filesystem_types_option_datetime_free(wasi_filesystem_types_option_datetime_t *ptr) { +void wasi_filesystem_types_descriptor_type_free(wasi_filesystem_types_descriptor_type_t *ptr) { + switch ((int32_t) ptr->tag) { + case 7: { + break; + } + } +} + +void wasi_filesystem_types_option_instant_free(wasi_filesystem_types_option_instant_t *ptr) { if (ptr->is_some) { } } void wasi_filesystem_types_descriptor_stat_free(wasi_filesystem_types_descriptor_stat_t *ptr) { - wasi_filesystem_types_option_datetime_free(&ptr->data_access_timestamp); - wasi_filesystem_types_option_datetime_free(&ptr->data_modification_timestamp); - wasi_filesystem_types_option_datetime_free(&ptr->status_change_timestamp); + wasi_filesystem_types_descriptor_type_free(&ptr->type); + wasi_filesystem_types_option_instant_free(&ptr->data_access_timestamp); + wasi_filesystem_types_option_instant_free(&ptr->data_modification_timestamp); + wasi_filesystem_types_option_instant_free(&ptr->status_change_timestamp); } void wasi_filesystem_types_new_timestamp_free(wasi_filesystem_types_new_timestamp_t *ptr) { @@ -859,10 +870,19 @@ void wasi_filesystem_types_new_timestamp_free(wasi_filesystem_types_new_timestam } void wasi_filesystem_types_directory_entry_free(wasi_filesystem_types_directory_entry_t *ptr) { + wasi_filesystem_types_descriptor_type_free(&ptr->type); plugin_string_free(&ptr->name); } -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]descriptor"))) +void wasi_filesystem_types_error_code_free(wasi_filesystem_types_error_code_t *ptr) { + switch ((int32_t) ptr->tag) { + case 36: { + break; + } + } +} + +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[resource-drop]descriptor"))) extern void __wasm_import_wasi_filesystem_types_descriptor_drop(int32_t handle); void wasi_filesystem_types_descriptor_drop_own(wasi_filesystem_types_own_descriptor_t handle) { @@ -877,66 +897,25 @@ wasi_filesystem_types_borrow_descriptor_t wasi_filesystem_types_borrow_descripto return (wasi_filesystem_types_borrow_descriptor_t) { arg.__handle }; } -__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]directory-entry-stream"))) -extern void __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(int32_t handle); - -void wasi_filesystem_types_directory_entry_stream_drop_own(wasi_filesystem_types_own_directory_entry_stream_t handle) { - __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(handle.__handle); -} - -void wasi_filesystem_types_directory_entry_stream_drop_borrow(wasi_filesystem_types_borrow_directory_entry_stream_t handle) { - __wasm_import_wasi_filesystem_types_directory_entry_stream_drop(handle.__handle); -} - -wasi_filesystem_types_borrow_directory_entry_stream_t wasi_filesystem_types_borrow_directory_entry_stream(wasi_filesystem_types_own_directory_entry_stream_t arg) { - return (wasi_filesystem_types_borrow_directory_entry_stream_t) { arg.__handle }; -} - -void wasi_filesystem_types_result_own_input_stream_error_code_free(wasi_filesystem_types_result_own_input_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_own_output_stream_error_code_free(wasi_filesystem_types_result_own_output_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - void wasi_filesystem_types_result_void_error_code_free(wasi_filesystem_types_result_void_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } void wasi_filesystem_types_result_descriptor_flags_error_code_free(wasi_filesystem_types_result_descriptor_flags_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } void wasi_filesystem_types_result_descriptor_type_error_code_free(wasi_filesystem_types_result_descriptor_type_error_code_t *ptr) { if (!ptr->is_err) { + wasi_filesystem_types_descriptor_type_free(&ptr->val.ok); } else { - } -} - -void wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_filesize_error_code_free(wasi_filesystem_types_result_filesize_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_filesystem_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_types_result_own_directory_entry_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } @@ -944,12 +923,14 @@ void wasi_filesystem_types_result_descriptor_stat_error_code_free(wasi_filesyste if (!ptr->is_err) { wasi_filesystem_types_descriptor_stat_free(&ptr->val.ok); } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } void wasi_filesystem_types_result_own_descriptor_error_code_free(wasi_filesystem_types_result_own_descriptor_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } @@ -957,329 +938,485 @@ void wasi_filesystem_types_result_string_error_code_free(wasi_filesystem_types_r if (!ptr->is_err) { plugin_string_free(&ptr->val.ok); } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } void wasi_filesystem_types_result_metadata_hash_value_error_code_free(wasi_filesystem_types_result_metadata_hash_value_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_filesystem_types_error_code_free(&ptr->val.err); } } -void wasi_filesystem_types_option_directory_entry_free(wasi_filesystem_types_option_directory_entry_t *ptr) { - if (ptr->is_some) { - wasi_filesystem_types_directory_entry_free(&ptr->val); - } -} +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-new-0][method]descriptor.read-via-stream"))) +extern uint64_t wasi_filesystem_types_stream_u8__new(void); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_stream_u8__read(uint32_t, uint8_t*, size_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_stream_u8__write(uint32_t, const uint8_t*, size_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-read-0][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_stream_u8__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-write-0][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_stream_u8__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-readable-0][method]descriptor.read-via-stream"))) +extern void wasi_filesystem_types_stream_u8__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-writable-0][method]descriptor.read-via-stream"))) +extern void wasi_filesystem_types_stream_u8__drop_writable(uint32_t); -void wasi_filesystem_types_result_option_directory_entry_error_code_free(wasi_filesystem_types_result_option_directory_entry_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_filesystem_types_option_directory_entry_free(&ptr->val.ok); - } else { - } +wasi_filesystem_types_stream_u8_t wasi_filesystem_types_stream_u8_new(wasi_filesystem_types_stream_u8_writer_t *writer) { + uint64_t packed = wasi_filesystem_types_stream_u8__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_filesystem_types_option_error_code_free(wasi_filesystem_types_option_error_code_t *ptr) { - if (ptr->is_some) { - } +plugin_waitable_status_t wasi_filesystem_types_stream_u8_read(wasi_filesystem_types_stream_u8_t reader, uint8_t *buf, size_t amt) { + return wasi_filesystem_types_stream_u8__read(reader, (uint8_t*) buf, amt); } -void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr) { - plugin_string_free(&ptr->f1); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_write(wasi_filesystem_types_stream_u8_writer_t writer, const uint8_t *buf, size_t amt) { + return wasi_filesystem_types_stream_u8__write(writer, (const uint8_t*) buf, amt); } -void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_filesystem_preopens_tuple2_own_descriptor_string_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - wasi_filesystem_preopens_tuple2_own_descriptor_string_free(&list_ptr[i]); - } - free(list_ptr); - } +plugin_waitable_status_t wasi_filesystem_types_stream_u8_cancel_read(wasi_filesystem_types_stream_u8_t reader){ + return wasi_filesystem_types_stream_u8__cancel_read(reader); } -__attribute__((__import_module__("wasi:sockets/network@0.2.0"), __import_name__("[resource-drop]network"))) -extern void __wasm_import_wasi_sockets_network_network_drop(int32_t handle); - -void wasi_sockets_network_network_drop_own(wasi_sockets_network_own_network_t handle) { - __wasm_import_wasi_sockets_network_network_drop(handle.__handle); +plugin_waitable_status_t wasi_filesystem_types_stream_u8_cancel_write(wasi_filesystem_types_stream_u8_writer_t writer) { + return wasi_filesystem_types_stream_u8__cancel_write(writer); } -void wasi_sockets_network_network_drop_borrow(wasi_sockets_network_borrow_network_t handle) { - __wasm_import_wasi_sockets_network_network_drop(handle.__handle); +void wasi_filesystem_types_stream_u8_drop_readable(wasi_filesystem_types_stream_u8_t reader){ + wasi_filesystem_types_stream_u8__drop_readable(reader); } -wasi_sockets_network_borrow_network_t wasi_sockets_network_borrow_network(wasi_sockets_network_own_network_t arg) { - return (wasi_sockets_network_borrow_network_t) { arg.__handle }; +void wasi_filesystem_types_stream_u8_drop_writable(wasi_filesystem_types_stream_u8_writer_t writer) { + wasi_filesystem_types_stream_u8__drop_writable(writer); } -void wasi_sockets_network_ip_address_free(wasi_sockets_network_ip_address_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - case 1: { - break; - } - } -} -void wasi_sockets_network_ip_socket_address_free(wasi_sockets_network_ip_socket_address_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - break; - } - case 1: { - break; - } - } -} +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[future-new-1][method]descriptor.read-via-stream"))) +extern uint64_t wasi_filesystem_types_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-read-1][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-write-1][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-read-1][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-write-1][method]descriptor.read-via-stream"))) +extern uint32_t wasi_filesystem_types_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-readable-1][method]descriptor.read-via-stream"))) +extern void wasi_filesystem_types_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-writable-1][method]descriptor.read-via-stream"))) +extern void wasi_filesystem_types_future_result_void_error_code__drop_writable(uint32_t); -void wasi_sockets_udp_ip_socket_address_free(wasi_sockets_udp_ip_socket_address_t *ptr) { - wasi_sockets_network_ip_socket_address_free(ptr); +wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_future_result_void_error_code_new(wasi_filesystem_types_future_result_void_error_code_writer_t *writer) { + uint64_t packed = wasi_filesystem_types_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_sockets_udp_incoming_datagram_free(wasi_sockets_udp_incoming_datagram_t *ptr) { - wasi_sockets_udp_ip_socket_address_free(&ptr->remote_address); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_read(wasi_filesystem_types_future_result_void_error_code_t reader, wasi_filesystem_types_result_void_error_code_t *buf) { + return wasi_filesystem_types_future_result_void_error_code__read(reader, (uint8_t*) buf); } -void wasi_sockets_udp_option_ip_socket_address_free(wasi_sockets_udp_option_ip_socket_address_t *ptr) { - if (ptr->is_some) { - wasi_sockets_udp_ip_socket_address_free(&ptr->val); - } +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_write(wasi_filesystem_types_future_result_void_error_code_writer_t writer, const wasi_filesystem_types_result_void_error_code_t *buf) { + return wasi_filesystem_types_future_result_void_error_code__write(writer, (const uint8_t*) buf); } -void wasi_sockets_udp_outgoing_datagram_free(wasi_sockets_udp_outgoing_datagram_t *ptr) { - wasi_sockets_udp_option_ip_socket_address_free(&ptr->remote_address); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_cancel_read(wasi_filesystem_types_future_result_void_error_code_t reader){ + return wasi_filesystem_types_future_result_void_error_code__cancel_read(reader); } -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]udp-socket"))) -extern void __wasm_import_wasi_sockets_udp_udp_socket_drop(int32_t handle); - -void wasi_sockets_udp_udp_socket_drop_own(wasi_sockets_udp_own_udp_socket_t handle) { - __wasm_import_wasi_sockets_udp_udp_socket_drop(handle.__handle); +plugin_waitable_status_t wasi_filesystem_types_future_result_void_error_code_cancel_write(wasi_filesystem_types_future_result_void_error_code_writer_t writer) { + return wasi_filesystem_types_future_result_void_error_code__cancel_write(writer); } -void wasi_sockets_udp_udp_socket_drop_borrow(wasi_sockets_udp_borrow_udp_socket_t handle) { - __wasm_import_wasi_sockets_udp_udp_socket_drop(handle.__handle); +void wasi_filesystem_types_future_result_void_error_code_drop_readable(wasi_filesystem_types_future_result_void_error_code_t reader){ + wasi_filesystem_types_future_result_void_error_code__drop_readable(reader); } -wasi_sockets_udp_borrow_udp_socket_t wasi_sockets_udp_borrow_udp_socket(wasi_sockets_udp_own_udp_socket_t arg) { - return (wasi_sockets_udp_borrow_udp_socket_t) { arg.__handle }; +void wasi_filesystem_types_future_result_void_error_code_drop_writable(wasi_filesystem_types_future_result_void_error_code_writer_t writer) { + wasi_filesystem_types_future_result_void_error_code__drop_writable(writer); } -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]incoming-datagram-stream"))) -extern void __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(int32_t handle); -void wasi_sockets_udp_incoming_datagram_stream_drop_own(wasi_sockets_udp_own_incoming_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(handle.__handle); -} +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-new-0][method]descriptor.read-directory"))) +extern uint64_t wasi_filesystem_types_stream_directory_entry__new(void); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-directory"))) +extern uint32_t wasi_filesystem_types_stream_directory_entry__read(uint32_t, uint8_t*, size_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-directory"))) +extern uint32_t wasi_filesystem_types_stream_directory_entry__write(uint32_t, const uint8_t*, size_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-read-0][method]descriptor.read-directory"))) +extern uint32_t wasi_filesystem_types_stream_directory_entry__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-write-0][method]descriptor.read-directory"))) +extern uint32_t wasi_filesystem_types_stream_directory_entry__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-readable-0][method]descriptor.read-directory"))) +extern void wasi_filesystem_types_stream_directory_entry__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-writable-0][method]descriptor.read-directory"))) +extern void wasi_filesystem_types_stream_directory_entry__drop_writable(uint32_t); -void wasi_sockets_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_incoming_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_incoming_datagram_stream_drop(handle.__handle); +wasi_filesystem_types_stream_directory_entry_t wasi_filesystem_types_stream_directory_entry_new(wasi_filesystem_types_stream_directory_entry_writer_t *writer) { + uint64_t packed = wasi_filesystem_types_stream_directory_entry__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -wasi_sockets_udp_borrow_incoming_datagram_stream_t wasi_sockets_udp_borrow_incoming_datagram_stream(wasi_sockets_udp_own_incoming_datagram_stream_t arg) { - return (wasi_sockets_udp_borrow_incoming_datagram_stream_t) { arg.__handle }; +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_read(wasi_filesystem_types_stream_directory_entry_t reader, wasi_filesystem_types_directory_entry_t *buf, size_t amt) { + return wasi_filesystem_types_stream_directory_entry__read(reader, (uint8_t*) buf, amt); } -__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]outgoing-datagram-stream"))) -extern void __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(int32_t handle); - -void wasi_sockets_udp_outgoing_datagram_stream_drop_own(wasi_sockets_udp_own_outgoing_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(handle.__handle); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_write(wasi_filesystem_types_stream_directory_entry_writer_t writer, const wasi_filesystem_types_directory_entry_t *buf, size_t amt) { + return wasi_filesystem_types_stream_directory_entry__write(writer, (const uint8_t*) buf, amt); } -void wasi_sockets_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_udp_borrow_outgoing_datagram_stream_t handle) { - __wasm_import_wasi_sockets_udp_outgoing_datagram_stream_drop(handle.__handle); +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_cancel_read(wasi_filesystem_types_stream_directory_entry_t reader){ + return wasi_filesystem_types_stream_directory_entry__cancel_read(reader); } -wasi_sockets_udp_borrow_outgoing_datagram_stream_t wasi_sockets_udp_borrow_outgoing_datagram_stream(wasi_sockets_udp_own_outgoing_datagram_stream_t arg) { - return (wasi_sockets_udp_borrow_outgoing_datagram_stream_t) { arg.__handle }; +plugin_waitable_status_t wasi_filesystem_types_stream_directory_entry_cancel_write(wasi_filesystem_types_stream_directory_entry_writer_t writer) { + return wasi_filesystem_types_stream_directory_entry__cancel_write(writer); } -void wasi_sockets_udp_result_void_error_code_free(wasi_sockets_udp_result_void_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } +void wasi_filesystem_types_stream_directory_entry_drop_readable(wasi_filesystem_types_stream_directory_entry_t reader){ + wasi_filesystem_types_stream_directory_entry__drop_readable(reader); } -void wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } +void wasi_filesystem_types_stream_directory_entry_drop_writable(wasi_filesystem_types_stream_directory_entry_writer_t writer) { + wasi_filesystem_types_stream_directory_entry__drop_writable(writer); } -void wasi_sockets_udp_result_ip_socket_address_error_code_free(wasi_sockets_udp_result_ip_socket_address_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_udp_ip_socket_address_free(&ptr->val.ok); - } else { - } -} -void wasi_sockets_udp_result_u8_error_code_free(wasi_sockets_udp_result_u8_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } +void wasi_filesystem_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_tuple2_own_descriptor_string_t *ptr) { + plugin_string_free(&ptr->f1); } -void wasi_sockets_udp_result_u64_error_code_free(wasi_sockets_udp_result_u64_error_code_t *ptr) { - if (!ptr->is_err) { - } else { - } -} - -void wasi_sockets_udp_list_incoming_datagram_free(wasi_sockets_udp_list_incoming_datagram_t *ptr) { +void wasi_filesystem_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr) { size_t list_len = ptr->len; if (list_len > 0) { - wasi_sockets_udp_incoming_datagram_t *list_ptr = ptr->ptr; + wasi_filesystem_preopens_tuple2_own_descriptor_string_t *list_ptr = ptr->ptr; for (size_t i = 0; i < list_len; i++) { - wasi_sockets_udp_incoming_datagram_free(&list_ptr[i]); + wasi_filesystem_preopens_tuple2_own_descriptor_string_free(&list_ptr[i]); } free(list_ptr); } } -void wasi_sockets_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_udp_result_list_incoming_datagram_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_udp_list_incoming_datagram_free(&ptr->val.ok); - } else { +void wasi_sockets_types_error_code_free(wasi_sockets_types_error_code_t *ptr) { + switch ((int32_t) ptr->tag) { + case 14: { + break; + } } } -void wasi_sockets_udp_list_outgoing_datagram_free(wasi_sockets_udp_list_outgoing_datagram_t *ptr) { - size_t list_len = ptr->len; - if (list_len > 0) { - wasi_sockets_udp_outgoing_datagram_t *list_ptr = ptr->ptr; - for (size_t i = 0; i < list_len; i++) { - wasi_sockets_udp_outgoing_datagram_free(&list_ptr[i]); +void wasi_sockets_types_ip_address_free(wasi_sockets_types_ip_address_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; } - free(list_ptr); } } -void wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t *ptr) { - if (!ptr->is_err) { - } else { +void wasi_sockets_types_ip_socket_address_free(wasi_sockets_types_ip_socket_address_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } } } -void wasi_sockets_tcp_ip_socket_address_free(wasi_sockets_tcp_ip_socket_address_t *ptr) { - wasi_sockets_network_ip_socket_address_free(ptr); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[resource-drop]tcp-socket"))) +extern void __wasm_import_wasi_sockets_types_tcp_socket_drop(int32_t handle); + +void wasi_sockets_types_tcp_socket_drop_own(wasi_sockets_types_own_tcp_socket_t handle) { + __wasm_import_wasi_sockets_types_tcp_socket_drop(handle.__handle); +} + +void wasi_sockets_types_tcp_socket_drop_borrow(wasi_sockets_types_borrow_tcp_socket_t handle) { + __wasm_import_wasi_sockets_types_tcp_socket_drop(handle.__handle); +} + +wasi_sockets_types_borrow_tcp_socket_t wasi_sockets_types_borrow_tcp_socket(wasi_sockets_types_own_tcp_socket_t arg) { + return (wasi_sockets_types_borrow_tcp_socket_t) { arg.__handle }; } -__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[resource-drop]tcp-socket"))) -extern void __wasm_import_wasi_sockets_tcp_tcp_socket_drop(int32_t handle); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[resource-drop]udp-socket"))) +extern void __wasm_import_wasi_sockets_types_udp_socket_drop(int32_t handle); -void wasi_sockets_tcp_tcp_socket_drop_own(wasi_sockets_tcp_own_tcp_socket_t handle) { - __wasm_import_wasi_sockets_tcp_tcp_socket_drop(handle.__handle); +void wasi_sockets_types_udp_socket_drop_own(wasi_sockets_types_own_udp_socket_t handle) { + __wasm_import_wasi_sockets_types_udp_socket_drop(handle.__handle); } -void wasi_sockets_tcp_tcp_socket_drop_borrow(wasi_sockets_tcp_borrow_tcp_socket_t handle) { - __wasm_import_wasi_sockets_tcp_tcp_socket_drop(handle.__handle); +void wasi_sockets_types_udp_socket_drop_borrow(wasi_sockets_types_borrow_udp_socket_t handle) { + __wasm_import_wasi_sockets_types_udp_socket_drop(handle.__handle); } -wasi_sockets_tcp_borrow_tcp_socket_t wasi_sockets_tcp_borrow_tcp_socket(wasi_sockets_tcp_own_tcp_socket_t arg) { - return (wasi_sockets_tcp_borrow_tcp_socket_t) { arg.__handle }; +wasi_sockets_types_borrow_udp_socket_t wasi_sockets_types_borrow_udp_socket(wasi_sockets_types_own_udp_socket_t arg) { + return (wasi_sockets_types_borrow_udp_socket_t) { arg.__handle }; } -void wasi_sockets_tcp_result_void_error_code_free(wasi_sockets_tcp_result_void_error_code_t *ptr) { +void wasi_sockets_types_result_own_tcp_socket_error_code_free(wasi_sockets_types_result_own_tcp_socket_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr) { +void wasi_sockets_types_result_void_error_code_free(wasi_sockets_types_result_void_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr) { +void wasi_sockets_types_result_stream_own_tcp_socket_error_code_free(wasi_sockets_types_result_stream_own_tcp_socket_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_ip_socket_address_error_code_free(wasi_sockets_tcp_result_ip_socket_address_error_code_t *ptr) { +void wasi_sockets_types_result_ip_socket_address_error_code_free(wasi_sockets_types_result_ip_socket_address_error_code_t *ptr) { if (!ptr->is_err) { - wasi_sockets_tcp_ip_socket_address_free(&ptr->val.ok); + wasi_sockets_types_ip_socket_address_free(&ptr->val.ok); } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_bool_error_code_free(wasi_sockets_tcp_result_bool_error_code_t *ptr) { +void wasi_sockets_types_result_bool_error_code_free(wasi_sockets_types_result_bool_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_duration_error_code_free(wasi_sockets_tcp_result_duration_error_code_t *ptr) { +void wasi_sockets_types_result_duration_error_code_free(wasi_sockets_types_result_duration_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_u32_error_code_free(wasi_sockets_tcp_result_u32_error_code_t *ptr) { +void wasi_sockets_types_result_u32_error_code_free(wasi_sockets_types_result_u32_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_u8_error_code_free(wasi_sockets_tcp_result_u8_error_code_t *ptr) { +void wasi_sockets_types_result_u8_error_code_free(wasi_sockets_types_result_u8_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_result_u64_error_code_free(wasi_sockets_tcp_result_u64_error_code_t *ptr) { +void wasi_sockets_types_result_u64_error_code_free(wasi_sockets_types_result_u64_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr) { +void wasi_sockets_types_result_own_udp_socket_error_code_free(wasi_sockets_types_result_own_udp_socket_error_code_t *ptr) { if (!ptr->is_err) { } else { + wasi_sockets_types_error_code_free(&ptr->val.err); } } -void wasi_sockets_ip_name_lookup_ip_address_free(wasi_sockets_ip_name_lookup_ip_address_t *ptr) { - wasi_sockets_network_ip_address_free(ptr); +void wasi_sockets_types_option_ip_socket_address_free(wasi_sockets_types_option_ip_socket_address_t *ptr) { + if (ptr->is_some) { + wasi_sockets_types_ip_socket_address_free(&ptr->val); + } } -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[resource-drop]resolve-address-stream"))) -extern void __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(int32_t handle); +void wasi_sockets_types_tuple2_list_u8_ip_socket_address_free(wasi_sockets_types_tuple2_list_u8_ip_socket_address_t *ptr) { + wasi_sockets_types_ip_socket_address_free(&ptr->f1); +} + +void wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_free(wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_sockets_types_tuple2_list_u8_ip_socket_address_free(&ptr->val.ok); + } else { + wasi_sockets_types_error_code_free(&ptr->val.err); + } +} -void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t handle) { - __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(handle.__handle); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-new-0][method]tcp-socket.listen"))) +extern uint64_t wasi_sockets_types_stream_own_tcp_socket__new(void); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.listen"))) +extern uint32_t wasi_sockets_types_stream_own_tcp_socket__read(uint32_t, uint8_t*, size_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.listen"))) +extern uint32_t wasi_sockets_types_stream_own_tcp_socket__write(uint32_t, const uint8_t*, size_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-read-0][method]tcp-socket.listen"))) +extern uint32_t wasi_sockets_types_stream_own_tcp_socket__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-write-0][method]tcp-socket.listen"))) +extern uint32_t wasi_sockets_types_stream_own_tcp_socket__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-readable-0][method]tcp-socket.listen"))) +extern void wasi_sockets_types_stream_own_tcp_socket__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-writable-0][method]tcp-socket.listen"))) +extern void wasi_sockets_types_stream_own_tcp_socket__drop_writable(uint32_t); + +wasi_sockets_types_stream_own_tcp_socket_t wasi_sockets_types_stream_own_tcp_socket_new(wasi_sockets_types_stream_own_tcp_socket_writer_t *writer) { + uint64_t packed = wasi_sockets_types_stream_own_tcp_socket__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; } -void wasi_sockets_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t handle) { - __wasm_import_wasi_sockets_ip_name_lookup_resolve_address_stream_drop(handle.__handle); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_read(wasi_sockets_types_stream_own_tcp_socket_t reader, wasi_sockets_types_own_tcp_socket_t *buf, size_t amt) { + return wasi_sockets_types_stream_own_tcp_socket__read(reader, (uint8_t*) buf, amt); } -wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_ip_name_lookup_own_resolve_address_stream_t arg) { - return (wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t) { arg.__handle }; +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_write(wasi_sockets_types_stream_own_tcp_socket_writer_t writer, const wasi_sockets_types_own_tcp_socket_t *buf, size_t amt) { + return wasi_sockets_types_stream_own_tcp_socket__write(writer, (const uint8_t*) buf, amt); } -void wasi_sockets_ip_name_lookup_option_ip_address_free(wasi_sockets_ip_name_lookup_option_ip_address_t *ptr) { - if (ptr->is_some) { - wasi_sockets_ip_name_lookup_ip_address_free(&ptr->val); +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_cancel_read(wasi_sockets_types_stream_own_tcp_socket_t reader){ + return wasi_sockets_types_stream_own_tcp_socket__cancel_read(reader); +} + +plugin_waitable_status_t wasi_sockets_types_stream_own_tcp_socket_cancel_write(wasi_sockets_types_stream_own_tcp_socket_writer_t writer) { + return wasi_sockets_types_stream_own_tcp_socket__cancel_write(writer); +} + +void wasi_sockets_types_stream_own_tcp_socket_drop_readable(wasi_sockets_types_stream_own_tcp_socket_t reader){ + wasi_sockets_types_stream_own_tcp_socket__drop_readable(reader); +} + +void wasi_sockets_types_stream_own_tcp_socket_drop_writable(wasi_sockets_types_stream_own_tcp_socket_writer_t writer) { + wasi_sockets_types_stream_own_tcp_socket__drop_writable(writer); +} + + +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-new-0][method]tcp-socket.send"))) +extern uint64_t wasi_sockets_types_stream_u8__new(void); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_stream_u8__read(uint32_t, uint8_t*, size_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_stream_u8__write(uint32_t, const uint8_t*, size_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-read-0][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_stream_u8__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-cancel-write-0][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_stream_u8__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-readable-0][method]tcp-socket.send"))) +extern void wasi_sockets_types_stream_u8__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[stream-drop-writable-0][method]tcp-socket.send"))) +extern void wasi_sockets_types_stream_u8__drop_writable(uint32_t); + +wasi_sockets_types_stream_u8_t wasi_sockets_types_stream_u8_new(wasi_sockets_types_stream_u8_writer_t *writer) { + uint64_t packed = wasi_sockets_types_stream_u8__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; +} + +plugin_waitable_status_t wasi_sockets_types_stream_u8_read(wasi_sockets_types_stream_u8_t reader, uint8_t *buf, size_t amt) { + return wasi_sockets_types_stream_u8__read(reader, (uint8_t*) buf, amt); +} + +plugin_waitable_status_t wasi_sockets_types_stream_u8_write(wasi_sockets_types_stream_u8_writer_t writer, const uint8_t *buf, size_t amt) { + return wasi_sockets_types_stream_u8__write(writer, (const uint8_t*) buf, amt); +} + +plugin_waitable_status_t wasi_sockets_types_stream_u8_cancel_read(wasi_sockets_types_stream_u8_t reader){ + return wasi_sockets_types_stream_u8__cancel_read(reader); +} + +plugin_waitable_status_t wasi_sockets_types_stream_u8_cancel_write(wasi_sockets_types_stream_u8_writer_t writer) { + return wasi_sockets_types_stream_u8__cancel_write(writer); +} + +void wasi_sockets_types_stream_u8_drop_readable(wasi_sockets_types_stream_u8_t reader){ + wasi_sockets_types_stream_u8__drop_readable(reader); +} + +void wasi_sockets_types_stream_u8_drop_writable(wasi_sockets_types_stream_u8_writer_t writer) { + wasi_sockets_types_stream_u8__drop_writable(writer); +} + + +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[future-new-1][method]tcp-socket.send"))) +extern uint64_t wasi_sockets_types_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-read-1][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[async-lower][future-write-1][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-read-1][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[future-cancel-write-1][method]tcp-socket.send"))) +extern uint32_t wasi_sockets_types_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-readable-1][method]tcp-socket.send"))) +extern void wasi_sockets_types_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-03-15"), __import_name__("[future-drop-writable-1][method]tcp-socket.send"))) +extern void wasi_sockets_types_future_result_void_error_code__drop_writable(uint32_t); + +wasi_sockets_types_future_result_void_error_code_t wasi_sockets_types_future_result_void_error_code_new(wasi_sockets_types_future_result_void_error_code_writer_t *writer) { + uint64_t packed = wasi_sockets_types_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; +} + +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_read(wasi_sockets_types_future_result_void_error_code_t reader, wasi_sockets_types_result_void_error_code_t *buf) { + return wasi_sockets_types_future_result_void_error_code__read(reader, (uint8_t*) buf); +} + +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_write(wasi_sockets_types_future_result_void_error_code_writer_t writer, const wasi_sockets_types_result_void_error_code_t *buf) { + return wasi_sockets_types_future_result_void_error_code__write(writer, (const uint8_t*) buf); +} + +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_cancel_read(wasi_sockets_types_future_result_void_error_code_t reader){ + return wasi_sockets_types_future_result_void_error_code__cancel_read(reader); +} + +plugin_waitable_status_t wasi_sockets_types_future_result_void_error_code_cancel_write(wasi_sockets_types_future_result_void_error_code_writer_t writer) { + return wasi_sockets_types_future_result_void_error_code__cancel_write(writer); +} + +void wasi_sockets_types_future_result_void_error_code_drop_readable(wasi_sockets_types_future_result_void_error_code_t reader){ + wasi_sockets_types_future_result_void_error_code__drop_readable(reader); +} + +void wasi_sockets_types_future_result_void_error_code_drop_writable(wasi_sockets_types_future_result_void_error_code_writer_t writer) { + wasi_sockets_types_future_result_void_error_code__drop_writable(writer); +} + + +void wasi_sockets_ip_name_lookup_ip_address_free(wasi_sockets_ip_name_lookup_ip_address_t *ptr) { + wasi_sockets_types_ip_address_free(ptr); +} + +void wasi_sockets_ip_name_lookup_error_code_free(wasi_sockets_ip_name_lookup_error_code_t *ptr) { + switch ((int32_t) ptr->tag) { + case 5: { + break; + } } } -void wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t *ptr) { - if (!ptr->is_err) { - wasi_sockets_ip_name_lookup_option_ip_address_free(&ptr->val.ok); - } else { +void wasi_sockets_ip_name_lookup_list_ip_address_free(wasi_sockets_ip_name_lookup_list_ip_address_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_sockets_ip_name_lookup_ip_address_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + wasi_sockets_ip_name_lookup_ip_address_free(&list_ptr[i]); + } + free(list_ptr); } } -void wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr) { +void wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_free(wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_t *ptr) { if (!ptr->is_err) { + wasi_sockets_ip_name_lookup_list_ip_address_free(&ptr->val.ok); } else { + wasi_sockets_ip_name_lookup_error_code_free(&ptr->val.err); } } @@ -1291,17 +1428,17 @@ void exports_streamkit_plugin_node_packet_free(exports_streamkit_plugin_node_pac streamkit_plugin_types_packet_free(ptr); } -__attribute__((__import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-drop]node-instance"))) +__attribute__((__import_module__("[export]streamkit:plugin/node@0.2.0"), __import_name__("[resource-drop]node-instance"))) extern void __wasm_import_exports_streamkit_plugin_node_node_instance_drop(int32_t handle); void exports_streamkit_plugin_node_node_instance_drop_own(exports_streamkit_plugin_node_own_node_instance_t handle) { __wasm_import_exports_streamkit_plugin_node_node_instance_drop(handle.__handle); } -__attribute__(( __import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-new]node-instance"))) +__attribute__(( __import_module__("[export]streamkit:plugin/node@0.2.0"), __import_name__("[resource-new]node-instance"))) extern int32_t __wasm_import_exports_streamkit_plugin_node_node_instance_new(int32_t); -__attribute__((__import_module__("[export]streamkit:plugin/node@0.1.0"), __import_name__("[resource-rep]node-instance"))) +__attribute__((__import_module__("[export]streamkit:plugin/node@0.2.0"), __import_name__("[resource-rep]node-instance"))) extern int32_t __wasm_import_exports_streamkit_plugin_node_node_instance_rep(int32_t); exports_streamkit_plugin_node_own_node_instance_t exports_streamkit_plugin_node_node_instance_new(exports_streamkit_plugin_node_node_instance_t *rep) { @@ -1312,7 +1449,7 @@ exports_streamkit_plugin_node_node_instance_t* exports_streamkit_plugin_node_nod return (exports_streamkit_plugin_node_node_instance_t*) __wasm_import_exports_streamkit_plugin_node_node_instance_rep(handle.__handle); } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[dtor]node_instance"))) +__attribute__((__export_name__("streamkit:plugin/node@0.2.0#[dtor]node_instance"))) void __wasm_export_exports_streamkit_plugin_node_node_instance_dtor(exports_streamkit_plugin_node_node_instance_t* arg) { exports_streamkit_plugin_node_node_instance_destructor(arg); } @@ -1324,6 +1461,66 @@ void exports_streamkit_plugin_node_result_void_string_free(exports_streamkit_plu } } +__attribute__((__export_name__("[callback][async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.process"))) +uint32_t __wasm_export_exports_streamkit_plugin_node_method_node_instance_process_callback(uint32_t event_raw, uint32_t waitable, uint32_t code) { + plugin_event_t event; + event.event = (plugin_event_code_t) event_raw; + event.waitable = waitable; + event.code = code; + return exports_streamkit_plugin_node_method_node_instance_process_callback(&event); +} + +__attribute__((__import_module__("[export]streamkit:plugin/node@0.2.0"), __import_name__("[task-return][method]node-instance.process"))) +void __wasm_export_exports_streamkit_plugin_node_method_node_instance_process__task_return(int32_t, uint8_t *, size_t); + +void exports_streamkit_plugin_node_method_node_instance_process_return(exports_streamkit_plugin_node_result_void_string_t ret) { + int32_t result; + uint8_t * result11; + size_t result12; + if ((ret).is_err) { + const plugin_string_t *payload10 = &(ret).val.err;result = 1; + result11 = (uint8_t *) (*payload10).ptr; + result12 = (*payload10).len; + } else { + result = 0; + result11 = 0; + result12 = 0; + } + + __wasm_export_exports_streamkit_plugin_node_method_node_instance_process__task_return(result, result11, result12); +} + + +__attribute__((__export_name__("[callback][async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.update-params"))) +uint32_t __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params_callback(uint32_t event_raw, uint32_t waitable, uint32_t code) { + plugin_event_t event; + event.event = (plugin_event_code_t) event_raw; + event.waitable = waitable; + event.code = code; + return exports_streamkit_plugin_node_method_node_instance_update_params_callback(&event); +} + +__attribute__((__import_module__("[export]streamkit:plugin/node@0.2.0"), __import_name__("[task-return][method]node-instance.update-params"))) +void __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params__task_return(int32_t, uint8_t *, size_t); + +void exports_streamkit_plugin_node_method_node_instance_update_params_return(exports_streamkit_plugin_node_result_void_string_t ret) { + int32_t result; + uint8_t * result4; + size_t result5; + if ((ret).is_err) { + const plugin_string_t *payload3 = &(ret).val.err;result = 1; + result4 = (uint8_t *) (*payload3).ptr; + result5 = (*payload3).len; + } else { + result = 0; + result4 = 0; + result5 = 0; + } + + __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params__task_return(result, result4, result5); +} + + void plugin_string_set(plugin_string_t *ret, const char*s) { ret->ptr = (uint8_t*) s; ret->len = strlen(s); @@ -1335,6 +1532,12 @@ void plugin_string_dup(plugin_string_t *ret, const char*s) { memcpy(ret->ptr, s, ret->len * 1); } +void plugin_string_dup_n(plugin_string_t *ret, const char*s, size_t len) { + ret->len = len; + ret->ptr = (uint8_t*) cabi_realloc(NULL, 0, 1, ret->len * 1); + memcpy(ret->ptr, s, ret->len * 1); +} + void plugin_string_free(plugin_string_t *ret) { if (ret->len > 0) { free(ret->ptr); @@ -1343,65 +1546,105 @@ void plugin_string_free(plugin_string_t *ret) { ret->len = 0; } +// Async Helper Functions + +__attribute__((__import_module__("$root"), __import_name__("[subtask-cancel]"))) +extern uint32_t __subtask_cancel(uint32_t handle); + +plugin_subtask_status_t plugin_subtask_cancel(plugin_subtask_t subtask) { + return __subtask_cancel(subtask); +} + +__attribute__((__import_module__("$root"), __import_name__("[subtask-drop]"))) +extern void __subtask_drop(uint32_t handle); + +void plugin_subtask_drop(plugin_subtask_t subtask) { + __subtask_drop(subtask); +} + +__attribute__((__import_module__("$root"), __import_name__("[waitable-set-new]"))) +extern uint32_t __waitable_set_new(void); + +plugin_waitable_set_t plugin_waitable_set_new(void) { + return __waitable_set_new(); +} + +__attribute__((__import_module__("$root"), __import_name__("[waitable-join]"))) +extern void __waitable_join(uint32_t, uint32_t); + +void plugin_waitable_join(uint32_t waitable, plugin_waitable_set_t set) { + __waitable_join(waitable, set); +} + +__attribute__((__import_module__("$root"), __import_name__("[waitable-set-drop]"))) +extern void __waitable_set_drop(uint32_t); + +void plugin_waitable_set_drop(plugin_waitable_set_t set) { + __waitable_set_drop(set); +} + +__attribute__((__import_module__("$root"), __import_name__("[waitable-set-wait]"))) +extern uint32_t __waitable_set_wait(uint32_t, uint32_t*); +__attribute__((__import_module__("$root"), __import_name__("[waitable-set-poll]"))) +extern uint32_t __waitable_set_poll(uint32_t, uint32_t*); + +void plugin_waitable_set_wait(plugin_waitable_set_t set, plugin_event_t *event) { + event->event = (plugin_event_code_t) __waitable_set_wait(set, &event->waitable); +} + +void plugin_waitable_set_poll(plugin_waitable_set_t set, plugin_event_t *event) { + event->event = (plugin_event_code_t) __waitable_set_poll(set, &event->waitable); +} + +__attribute__((__import_module__("[export]$root"), __import_name__("[task-cancel]"))) +extern void __task_cancel(void); + +void plugin_task_cancel() { + __task_cancel(); +} + +__attribute__((__import_module__("$root"), __import_name__("[backpressure-inc]"))) +extern void __backpressure_inc(void); + +void plugin_backpressure_inc(void) { + __backpressure_inc(); +} + +__attribute__((__import_module__("$root"), __import_name__("[backpressure-dec]"))) +extern void __backpressure_dec(void); + +void plugin_backpressure_dec(void) { + __backpressure_dec(); +} + +__attribute__((__import_module__("$root"), __import_name__("[context-get-0]"))) +extern void* __context_get_0(void); + +void* plugin_context_get_0(void) { + return __context_get_0(); +} + +__attribute__((__import_module__("$root"), __import_name__("[context-set-0]"))) +extern void __context_set_0(void*); + + +void plugin_context_set_0(void *value) { + __context_set_0(value); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-yield]"))) +extern uint32_t __thread_yield(void); + +void plugin_thread_yield(void) { + __thread_yield(); +} + + + // Component Adapters -bool streamkit_plugin_host_send_output(plugin_string_t *pin_name, streamkit_plugin_host_packet_t *packet, plugin_string_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - int32_t variant; - uint8_t * variant2; - size_t variant3; - uint8_t * variant4; - size_t variant5; - switch ((int32_t) (*packet).tag) { - case 0: { - const streamkit_plugin_types_audio_frame_t *payload = &(*packet).val.audio; - variant = 0; - variant2 = (uint8_t *) (int32_t) ((*payload).sample_rate); - variant3 = (int32_t) ((*payload).channels); - variant4 = (uint8_t *) ((*payload).samples).ptr; - variant5 = ((*payload).samples).len; - break; - } - case 1: { - const plugin_string_t *payload0 = &(*packet).val.text; - variant = 1; - variant2 = (uint8_t *) (*payload0).ptr; - variant3 = (*payload0).len; - variant4 = 0; - variant5 = 0; - break; - } - case 2: { - const plugin_list_u8_t *payload1 = &(*packet).val.binary; - variant = 2; - variant2 = (uint8_t *) (*payload1).ptr; - variant3 = (*payload1).len; - variant4 = 0; - variant5 = 0; - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_streamkit_plugin_host_send_output((uint8_t *) (*pin_name).ptr, (*pin_name).len, variant, variant2, variant3, variant4, variant5, ptr); - streamkit_plugin_host_result_void_string_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t streamkit_plugin_host_send_output(streamkit_plugin_host_send_output_args_t *args, streamkit_plugin_host_result_void_string_t *result) { + return __wasm_import_streamkit_plugin_host_send_output((uint8_t*) args, (uint8_t*) result); } void streamkit_plugin_host_log(streamkit_plugin_host_log_level_t level, plugin_string_t *message) { @@ -1424,11 +1667,11 @@ void wasi_cli_environment_get_arguments(plugin_list_string_t *ret) { *ret = (plugin_list_string_t) { (plugin_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; } -bool wasi_cli_environment_initial_cwd(plugin_string_t *ret) { +bool wasi_cli_environment_get_initial_cwd(plugin_string_t *ret) { __attribute__((__aligned__(sizeof(void*)))) uint8_t ret_area[(3*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_environment_initial_cwd(ptr); + __wasm_import_wasi_cli_environment_get_initial_cwd(ptr); plugin_option_string_t option; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { @@ -1455,1581 +1698,326 @@ void wasi_cli_exit_exit(wasi_cli_exit_result_void_void_t *status) { __wasm_import_wasi_cli_exit_exit(result); } -void wasi_io_error_method_error_to_debug_string(wasi_io_error_borrow_error_t self, plugin_string_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; +void wasi_cli_stdin_read_via_stream(wasi_cli_stdin_tuple2_stream_u8_future_result_void_error_code_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_error_method_error_to_debug_string((self).__handle, ptr); - *ret = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -bool wasi_io_poll_method_pollable_ready(wasi_io_poll_borrow_pollable_t self) { - int32_t ret = __wasm_import_wasi_io_poll_method_pollable_ready((self).__handle); - return ret; + __wasm_import_wasi_cli_stdin_read_via_stream(ptr); + *ret = (wasi_cli_stdin_tuple2_stream_u8_future_result_void_error_code_t) { + (wasi_cli_stdin_stream_u8_t) ((uint32_t) *((int32_t*) (ptr + 0))), + (wasi_cli_stdin_future_result_void_error_code_t) ((uint32_t) *((int32_t*) (ptr + 4))), + }; } -void wasi_io_poll_method_pollable_block(wasi_io_poll_borrow_pollable_t self) { - __wasm_import_wasi_io_poll_method_pollable_block((self).__handle); +wasi_cli_stdout_future_result_void_error_code_t wasi_cli_stdout_write_via_stream(wasi_cli_stdin_stream_u8_t data) { + int32_t ret = __wasm_import_wasi_cli_stdout_write_via_stream(((int32_t) data)); + return ((uint32_t) ret); } -void wasi_io_poll_poll(wasi_io_poll_list_borrow_pollable_t *in, plugin_list_u32_t *ret) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_poll_poll((uint8_t *) (*in).ptr, (*in).len, ptr); - *ret = (plugin_list_u32_t) { (uint32_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +wasi_cli_stderr_future_result_void_error_code_t wasi_cli_stderr_write_via_stream(wasi_cli_stdin_stream_u8_t data) { + int32_t ret = __wasm_import_wasi_cli_stderr_write_via_stream(((int32_t) data)); + return ((uint32_t) ret); } -bool wasi_io_streams_method_input_stream_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; +bool wasi_cli_terminal_stdin_get_terminal_stdin(wasi_cli_terminal_stdin_own_terminal_input_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_read((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_list_u8_stream_error_t result; + __wasm_import_wasi_cli_terminal_stdin_get_terminal_stdin(ptr); + wasi_cli_terminal_stdin_option_own_terminal_input_t option; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { - result.is_err = false; - result.val.ok = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + option.is_some = false; break; } case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; + option.is_some = true; + option.val = (wasi_cli_terminal_stdin_own_terminal_input_t) { *((int32_t*) (ptr + 4)) }; break; } } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } + *ret = option.val; + return option.is_some; } -bool wasi_io_streams_method_input_stream_blocking_read(wasi_io_streams_borrow_input_stream_t self, uint64_t len, plugin_list_u8_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; +bool wasi_cli_terminal_stdout_get_terminal_stdout(wasi_cli_terminal_stdout_own_terminal_output_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_blocking_read((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_list_u8_stream_error_t result; + __wasm_import_wasi_cli_terminal_stdout_get_terminal_stdout(ptr); + wasi_cli_terminal_stdout_option_own_terminal_output_t option; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { - result.is_err = false; - result.val.ok = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + option.is_some = false; break; } case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; + option.is_some = true; + option.val = (wasi_cli_terminal_stdout_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; break; } } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } + *ret = option.val; + return option.is_some; } -bool wasi_io_streams_method_input_stream_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +bool wasi_cli_terminal_stderr_get_terminal_stderr(wasi_cli_terminal_stderr_own_terminal_output_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_skip((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; + __wasm_import_wasi_cli_terminal_stderr_get_terminal_stderr(ptr); + wasi_cli_terminal_stderr_option_own_terminal_output_t option; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + option.is_some = false; break; } case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; + option.is_some = true; + option.val = (wasi_cli_terminal_stderr_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; break; } } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } + *ret = option.val; + return option.is_some; } -bool wasi_io_streams_method_input_stream_blocking_skip(wasi_io_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_input_stream_blocking_skip((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } +wasi_clocks_monotonic_clock_mark_t wasi_clocks_monotonic_clock_now(void) { + int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_now(); + return (uint64_t) (ret); +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_get_resolution(void) { + int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_get_resolution(); + return (uint64_t) (ret); +} + +plugin_subtask_status_t wasi_clocks_monotonic_clock_wait_until(wasi_clocks_monotonic_clock_mark_t when) { + return __wasm_import_wasi_clocks_monotonic_clock_wait_until((int64_t) (when)); } -wasi_io_streams_own_pollable_t wasi_io_streams_method_input_stream_subscribe(wasi_io_streams_borrow_input_stream_t self) { - int32_t ret = __wasm_import_wasi_io_streams_method_input_stream_subscribe((self).__handle); - return (wasi_io_streams_own_pollable_t) { ret }; +plugin_subtask_status_t wasi_clocks_monotonic_clock_wait_for(wasi_clocks_monotonic_clock_duration_t how_long) { + return __wasm_import_wasi_clocks_monotonic_clock_wait_for((int64_t) (how_long)); } -bool wasi_io_streams_method_output_stream_check_write(wasi_io_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_streams_stream_error_t *err) { +void wasi_clocks_system_clock_now(wasi_clocks_system_clock_instant_t *ret) { __attribute__((__aligned__(8))) uint8_t ret_area[16]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_check_write((self).__handle, ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } + __wasm_import_wasi_clocks_system_clock_now(ptr); + *ret = (wasi_clocks_system_clock_instant_t) { + (int64_t) *((int64_t*) (ptr + 0)), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), + }; +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +wasi_clocks_system_clock_duration_t wasi_clocks_system_clock_get_resolution(void) { + int64_t ret = __wasm_import_wasi_clocks_system_clock_get_resolution(); + return (uint64_t) (ret); } -bool wasi_io_streams_method_output_stream_write(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err) { +void wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_tuple2_stream_u8_future_result_void_error_code_t *ret) { __attribute__((__aligned__(4))) - uint8_t ret_area[12]; + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_write((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } + __wasm_import_wasi_filesystem_types_method_descriptor_read_via_stream((self).__handle, (int64_t) (offset), ptr); + *ret = (wasi_filesystem_types_tuple2_stream_u8_future_result_void_error_code_t) { + (wasi_filesystem_types_stream_u8_t) ((uint32_t) *((int32_t*) (ptr + 0))), + (wasi_filesystem_types_future_result_void_error_code_t) ((uint32_t) *((int32_t*) (ptr + 4))), + }; +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_stream_u8_t data, wasi_filesystem_types_filesize_t offset) { + int32_t ret = __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream((self).__handle, ((int32_t) data), (int64_t) (offset)); + return ((uint32_t) ret); } -bool wasi_io_streams_method_output_stream_blocking_write_and_flush(wasi_io_streams_borrow_output_stream_t self, plugin_list_u8_t *contents, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_write_and_flush((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } +wasi_filesystem_types_future_result_void_error_code_t wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_stream_u8_t data) { + int32_t ret = __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream((self).__handle, ((int32_t) data)); + return ((uint32_t) ret); +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_advise((self).__handle, (int64_t) (offset), (int64_t) (length), (int32_t) advice, (uint8_t*) result); } -bool wasi_io_streams_method_output_stream_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_flush((self).__handle, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_sync_data((self).__handle, (uint8_t*) result); +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_flags_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_get_flags((self).__handle, (uint8_t*) result); } -bool wasi_io_streams_method_output_stream_blocking_flush(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_flush((self).__handle, ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_type_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_get_type((self).__handle, (uint8_t*) result); +} - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_set_size((self).__handle, (int64_t) (size), (uint8_t*) result); } -wasi_io_streams_own_pollable_t wasi_io_streams_method_output_stream_subscribe(wasi_io_streams_borrow_output_stream_t self) { - int32_t ret = __wasm_import_wasi_io_streams_method_output_stream_subscribe((self).__handle); - return (wasi_io_streams_own_pollable_t) { ret }; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_method_descriptor_set_times_args_t *args, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_set_times((uint8_t*) args, (uint8_t*) result); } -bool wasi_io_streams_method_output_stream_write_zeroes(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err) { +void wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_tuple2_stream_directory_entry_future_result_void_error_code_t *ret) { __attribute__((__aligned__(4))) - uint8_t ret_area[12]; + uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_write_zeroes((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_streams_borrow_output_stream_t self, uint64_t len, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_write_zeroes_and_flush((self).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_void_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_io_streams_method_output_stream_blocking_splice(wasi_io_streams_borrow_output_stream_t self, wasi_io_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_streams_stream_error_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_io_streams_method_output_stream_blocking_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); - wasi_io_streams_result_u64_stream_error_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - wasi_io_streams_stream_error_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.last_operation_failed = (wasi_io_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; - break; - } - case 1: { - break; - } - } - - result.val.err = variant; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_cli_stdin_own_input_stream_t wasi_cli_stdin_get_stdin(void) { - int32_t ret = __wasm_import_wasi_cli_stdin_get_stdin(); - return (wasi_cli_stdin_own_input_stream_t) { ret }; -} - -wasi_cli_stdout_own_output_stream_t wasi_cli_stdout_get_stdout(void) { - int32_t ret = __wasm_import_wasi_cli_stdout_get_stdout(); - return (wasi_cli_stdout_own_output_stream_t) { ret }; -} - -wasi_cli_stderr_own_output_stream_t wasi_cli_stderr_get_stderr(void) { - int32_t ret = __wasm_import_wasi_cli_stderr_get_stderr(); - return (wasi_cli_stderr_own_output_stream_t) { ret }; -} - -bool wasi_cli_terminal_stdin_get_terminal_stdin(wasi_cli_terminal_stdin_own_terminal_input_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stdin_get_terminal_stdin(ptr); - wasi_cli_terminal_stdin_option_own_terminal_input_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stdin_own_terminal_input_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; + __wasm_import_wasi_filesystem_types_method_descriptor_read_directory((self).__handle, ptr); + *ret = (wasi_filesystem_types_tuple2_stream_directory_entry_future_result_void_error_code_t) { + (wasi_filesystem_types_stream_directory_entry_t) ((uint32_t) *((int32_t*) (ptr + 0))), + (wasi_filesystem_types_future_result_void_error_code_t) ((uint32_t) *((int32_t*) (ptr + 4))), + }; } -bool wasi_cli_terminal_stdout_get_terminal_stdout(wasi_cli_terminal_stdout_own_terminal_output_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stdout_get_terminal_stdout(ptr); - wasi_cli_terminal_stdout_option_own_terminal_output_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stdout_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_sync((self).__handle, (uint8_t*) result); } -bool wasi_cli_terminal_stderr_get_terminal_stderr(wasi_cli_terminal_stderr_own_terminal_output_t *ret) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_cli_terminal_stderr_get_terminal_stderr(ptr); - wasi_cli_terminal_stderr_option_own_terminal_output_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_cli_terminal_stderr_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; - break; - } - } - *ret = option.val; - return option.is_some; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at((self).__handle, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -wasi_clocks_monotonic_clock_instant_t wasi_clocks_monotonic_clock_now(void) { - int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_now(); - return (uint64_t) (ret); +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_descriptor_stat_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_stat((self).__handle, (uint8_t*) result); } -wasi_clocks_monotonic_clock_duration_t wasi_clocks_monotonic_clock_resolution(void) { - int64_t ret = __wasm_import_wasi_clocks_monotonic_clock_resolution(); - return (uint64_t) (ret); +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t path, wasi_filesystem_types_result_descriptor_stat_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_stat_at((self).__handle, path_flags, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_instant(wasi_clocks_monotonic_clock_instant_t when) { - int32_t ret = __wasm_import_wasi_clocks_monotonic_clock_subscribe_instant((int64_t) (when)); - return (wasi_clocks_monotonic_clock_own_pollable_t) { ret }; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_method_descriptor_set_times_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at((uint8_t*) args, (uint8_t*) result); } -wasi_clocks_monotonic_clock_own_pollable_t wasi_clocks_monotonic_clock_subscribe_duration(wasi_clocks_monotonic_clock_duration_t when) { - int32_t ret = __wasm_import_wasi_clocks_monotonic_clock_subscribe_duration((int64_t) (when)); - return (wasi_clocks_monotonic_clock_own_pollable_t) { ret }; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_method_descriptor_link_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_link_at((uint8_t*) args, (uint8_t*) result); } -void wasi_clocks_wall_clock_now(wasi_clocks_wall_clock_datetime_t *ret) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_clocks_wall_clock_now(ptr); - *ret = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), - }; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_method_descriptor_open_at_args_t *args, wasi_filesystem_types_result_own_descriptor_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_open_at((uint8_t*) args, (uint8_t*) result); } -void wasi_clocks_wall_clock_resolution(wasi_clocks_wall_clock_datetime_t *ret) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_clocks_wall_clock_resolution(ptr); - *ret = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), - }; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_string_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at((self).__handle, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_read_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_input_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read_via_stream((self).__handle, (int64_t) (offset), ptr); - wasi_filesystem_types_result_own_input_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_input_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at((self).__handle, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_write_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_write_via_stream((self).__handle, (int64_t) (offset), ptr); - wasi_filesystem_types_result_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_method_descriptor_rename_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_rename_at((uint8_t*) args, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_append_via_stream(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_output_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_append_via_stream((self).__handle, ptr); - wasi_filesystem_types_result_own_output_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_method_descriptor_symlink_at_args_t *args, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at((uint8_t*) args, (uint8_t*) result); } - -bool wasi_filesystem_types_method_descriptor_advise(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_advice_t advice, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_advise((self).__handle, (int64_t) (offset), (int64_t) (length), (int32_t) advice, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_sync_data(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_sync_data((self).__handle, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_get_flags(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_flags_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_get_flags((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_flags_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_get_type(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_type_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_get_type((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_type_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_size(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t size, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_size((self).__handle, (int64_t) (size), ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_times(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int64_t variant2; - int32_t variant3; - switch ((int32_t) (*data_access_timestamp).tag) { - case 0: { - variant = 0; - variant2 = 0; - variant3 = 0; - break; - } - case 1: { - variant = 1; - variant2 = 0; - variant3 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; - variant = 2; - variant2 = (int64_t) ((*payload1).seconds); - variant3 = (int32_t) ((*payload1).nanoseconds); - break; - } - } - int32_t variant7; - int64_t variant8; - int32_t variant9; - switch ((int32_t) (*data_modification_timestamp).tag) { - case 0: { - variant7 = 0; - variant8 = 0; - variant9 = 0; - break; - } - case 1: { - variant7 = 1; - variant8 = 0; - variant9 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; - variant7 = 2; - variant8 = (int64_t) ((*payload6).seconds); - variant9 = (int32_t) ((*payload6).nanoseconds); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_times((self).__handle, variant, variant2, variant3, variant7, variant8, variant9, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_read(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_filesize_t length, wasi_filesystem_types_filesize_t offset, plugin_tuple2_list_u8_bool_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(4*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read((self).__handle, (int64_t) (length), (int64_t) (offset), ptr); - wasi_filesystem_types_result_tuple2_list_u8_bool_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_tuple2_list_u8_bool_t) { - (plugin_list_u8_t) (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, - (bool) (int32_t) *((uint8_t*) (ptr + (3*sizeof(void*)))), - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_write(wasi_filesystem_types_borrow_descriptor_t self, plugin_list_u8_t *buffer, wasi_filesystem_types_filesize_t offset, wasi_filesystem_types_filesize_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_write((self).__handle, (uint8_t *) (*buffer).ptr, (*buffer).len, (int64_t) (offset), ptr); - wasi_filesystem_types_result_filesize_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_read_directory(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_own_directory_entry_stream_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_read_directory((self).__handle, ptr); - wasi_filesystem_types_result_own_directory_entry_stream_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_directory_entry_stream_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_sync(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_sync((self).__handle, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_create_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_create_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_stat(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[104]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_stat((self).__handle, ptr); - wasi_filesystem_types_result_descriptor_stat_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_datetime_t option; - switch ((int32_t) *((uint8_t*) (ptr + 32))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option0; - switch ((int32_t) *((uint8_t*) (ptr + 56))) { - case 0: { - option0.is_some = false; - break; - } - case 1: { - option0.is_some = true; - option0.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option1; - switch ((int32_t) *((uint8_t*) (ptr + 80))) { - case 0: { - option1.is_some = false; - break; - } - case 1: { - option1.is_some = true; - option1.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), - }; - break; - } - } - - result.val.ok = (wasi_filesystem_types_descriptor_stat_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), - (wasi_filesystem_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), - (wasi_filesystem_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), - (wasi_filesystem_types_option_datetime_t) option, - (wasi_filesystem_types_option_datetime_t) option0, - (wasi_filesystem_types_option_datetime_t) option1, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_stat_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_descriptor_stat_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[104]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_stat_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_descriptor_stat_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_datetime_t option; - switch ((int32_t) *((uint8_t*) (ptr + 32))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option0; - switch ((int32_t) *((uint8_t*) (ptr + 56))) { - case 0: { - option0.is_some = false; - break; - } - case 1: { - option0.is_some = true; - option0.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), - }; - break; - } - } - wasi_filesystem_types_option_datetime_t option1; - switch ((int32_t) *((uint8_t*) (ptr + 80))) { - case 0: { - option1.is_some = false; - break; - } - case 1: { - option1.is_some = true; - option1.val = (wasi_clocks_wall_clock_datetime_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), - }; - break; - } - } - - result.val.ok = (wasi_filesystem_types_descriptor_stat_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), - (wasi_filesystem_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), - (wasi_filesystem_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), - (wasi_filesystem_types_option_datetime_t) option, - (wasi_filesystem_types_option_datetime_t) option0, - (wasi_filesystem_types_option_datetime_t) option1, - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_set_times_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int64_t variant2; - int32_t variant3; - switch ((int32_t) (*data_access_timestamp).tag) { - case 0: { - variant = 0; - variant2 = 0; - variant3 = 0; - break; - } - case 1: { - variant = 1; - variant2 = 0; - variant3 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; - variant = 2; - variant2 = (int64_t) ((*payload1).seconds); - variant3 = (int32_t) ((*payload1).nanoseconds); - break; - } - } - int32_t variant7; - int64_t variant8; - int32_t variant9; - switch ((int32_t) (*data_modification_timestamp).tag) { - case 0: { - variant7 = 0; - variant8 = 0; - variant9 = 0; - break; - } - case 1: { - variant7 = 1; - variant8 = 0; - variant9 = 0; - break; - } - case 2: { - const wasi_filesystem_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; - variant7 = 2; - variant8 = (int64_t) ((*payload6).seconds); - variant9 = (int32_t) ((*payload6).nanoseconds); - break; - } - } - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_set_times_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, variant, variant2, variant3, variant7, variant8, variant9, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_link_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t old_path_flags, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_link_at((self).__handle, old_path_flags, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_open_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_open_flags_t open_flags, wasi_filesystem_types_descriptor_flags_t flags, wasi_filesystem_types_own_descriptor_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_open_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, open_flags, flags, ptr); - wasi_filesystem_types_result_own_descriptor_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_own_descriptor_t) { *((int32_t*) (ptr + 4)) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_readlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, plugin_string_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_readlink_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_string_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_remove_directory_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_remove_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_descriptor_rename_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, wasi_filesystem_types_borrow_descriptor_t new_descriptor, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_rename_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } + +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t path, wasi_filesystem_types_result_void_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at((self).__handle, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_symlink_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *old_path, plugin_string_t *new_path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_symlink_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other, bool *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object((self).__handle, (other).__handle, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_unlink_file_at(wasi_filesystem_types_borrow_descriptor_t self, plugin_string_t *path, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_unlink_file_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_result_metadata_hash_value_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash((self).__handle, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_is_same_object(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_borrow_descriptor_t other) { - int32_t ret = __wasm_import_wasi_filesystem_types_method_descriptor_is_same_object((self).__handle, (other).__handle); - return ret; +plugin_subtask_status_t wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t path, wasi_filesystem_types_result_metadata_hash_value_error_code_t *result) { + return __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at((self).__handle, path_flags, (uint8_t *) (path).ptr, (path).len, (uint8_t*) result); } -bool wasi_filesystem_types_method_descriptor_metadata_hash(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[24]; +void wasi_filesystem_preopens_get_directories(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash((self).__handle, ptr); - wasi_filesystem_types_result_metadata_hash_value_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (wasi_filesystem_types_metadata_hash_value_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), - }; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } + __wasm_import_wasi_filesystem_preopens_get_directories(ptr); + *ret = (wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t) { (wasi_filesystem_preopens_tuple2_own_descriptor_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; } -bool wasi_filesystem_types_method_descriptor_metadata_hash_at(wasi_filesystem_types_borrow_descriptor_t self, wasi_filesystem_types_path_flags_t path_flags, plugin_string_t *path, wasi_filesystem_types_metadata_hash_value_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[24]; +bool wasi_sockets_types_static_tcp_socket_create(wasi_sockets_types_ip_address_family_t address_family, wasi_sockets_types_own_tcp_socket_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_descriptor_metadata_hash_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); - wasi_filesystem_types_result_metadata_hash_value_error_code_t result; + __wasm_import_wasi_sockets_types_static_tcp_socket_create((int32_t) address_family, ptr); + wasi_sockets_types_result_own_tcp_socket_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_filesystem_types_metadata_hash_value_t) { - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), - (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), - }; + result.val.ok = (wasi_sockets_types_own_tcp_socket_t) { *((int32_t*) (ptr + sizeof(void*))) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_types_borrow_directory_entry_stream_t self, wasi_filesystem_types_option_directory_entry_t *ret, wasi_filesystem_types_error_code_t *err) { - __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(5*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_method_directory_entry_stream_read_directory_entry((self).__handle, ptr); - wasi_filesystem_types_result_option_directory_entry_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - wasi_filesystem_types_option_directory_entry_t option; - switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { case 0: { - option.is_some = false; break; } case 1: { - option.is_some = true; - option.val = (wasi_filesystem_types_directory_entry_t) { - (wasi_filesystem_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))), - (plugin_string_t) (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, - }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; break; } } - result.val.ok = option; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + result.val.err = variant; break; } } @@ -3042,43 +2030,9 @@ bool wasi_filesystem_types_method_directory_entry_stream_read_directory_entry(wa } } -bool wasi_filesystem_types_filesystem_error_code(wasi_filesystem_types_borrow_error_t err_, wasi_filesystem_types_error_code_t *ret) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_types_filesystem_error_code((err_).__handle, ptr); - wasi_filesystem_types_option_error_code_t option; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - *ret = option.val; - return option.is_some; -} - -void wasi_filesystem_preopens_get_directories(wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t *ret) { +bool wasi_sockets_types_method_tcp_socket_bind(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *local_address, wasi_sockets_types_error_code_t *err) { __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(2*sizeof(void*))]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_filesystem_preopens_get_directories(ptr); - *ret = (wasi_filesystem_preopens_list_tuple2_own_descriptor_string_t) { (wasi_filesystem_preopens_tuple2_own_descriptor_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; -} - -wasi_sockets_instance_network_own_network_t wasi_sockets_instance_network_instance_network(void) { - int32_t ret = __wasm_import_wasi_sockets_instance_network_instance_network(); - return (wasi_sockets_instance_network_own_network_t) { ret }; -} - -bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_borrow_network_t network, wasi_sockets_udp_ip_socket_address_t *local_address, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; + uint8_t ret_area[(5*sizeof(void*))]; int32_t variant; int32_t variant1; int32_t variant2; @@ -3093,7 +2047,7 @@ bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_s int32_t variant11; switch ((int32_t) (*local_address).tag) { case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; + const wasi_sockets_types_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; variant = 0; variant1 = (int32_t) ((*payload).port); variant2 = (int32_t) (((*payload).address).f0); @@ -3109,7 +2063,7 @@ bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_s break; } case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; + const wasi_sockets_types_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; variant = 1; variant1 = (int32_t) ((*payload0).port); variant2 = (int32_t) ((*payload0).flow_info); @@ -3126,8 +2080,8 @@ bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_s } } uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_udp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_bind((self).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -3135,7 +2089,70 @@ bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_s } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant12; + variant12.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant12.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant12.val.other = option; + break; + } + } + + result.val.err = variant12; break; } } @@ -3147,142 +2164,88 @@ bool wasi_sockets_udp_method_udp_socket_start_bind(wasi_sockets_udp_borrow_udp_s } } -bool wasi_sockets_udp_method_udp_socket_finish_bind(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_finish_bind((self).__handle, ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_sockets_types_method_tcp_socket_connect(wasi_sockets_types_method_tcp_socket_connect_args_t *args, wasi_sockets_types_result_void_error_code_t *result) { + return __wasm_import_wasi_sockets_types_method_tcp_socket_connect((uint8_t*) args, (uint8_t*) result); } -bool wasi_sockets_udp_method_udp_socket_stream(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; - wasi_sockets_udp_option_ip_socket_address_t remote_address; - remote_address.is_some = maybe_remote_address != NULL;if (maybe_remote_address) { - remote_address.val = *maybe_remote_address; - } - int32_t option; - int32_t option14; - int32_t option15; - int32_t option16; - int32_t option17; - int32_t option18; - int32_t option19; - int32_t option20; - int32_t option21; - int32_t option22; - int32_t option23; - int32_t option24; - int32_t option25; - if ((remote_address).is_some) { - const wasi_sockets_udp_ip_socket_address_t *payload0 = &(remote_address).val; - int32_t variant; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - int32_t variant12; - int32_t variant13; - switch ((int32_t) (*payload0).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload1 = &(*payload0).val.ipv4; - variant = 0; - variant3 = (int32_t) ((*payload1).port); - variant4 = (int32_t) (((*payload1).address).f0); - variant5 = (int32_t) (((*payload1).address).f1); - variant6 = (int32_t) (((*payload1).address).f2); - variant7 = (int32_t) (((*payload1).address).f3); - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - variant12 = 0; - variant13 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload2 = &(*payload0).val.ipv6; - variant = 1; - variant3 = (int32_t) ((*payload2).port); - variant4 = (int32_t) ((*payload2).flow_info); - variant5 = (int32_t) (((*payload2).address).f0); - variant6 = (int32_t) (((*payload2).address).f1); - variant7 = (int32_t) (((*payload2).address).f2); - variant8 = (int32_t) (((*payload2).address).f3); - variant9 = (int32_t) (((*payload2).address).f4); - variant10 = (int32_t) (((*payload2).address).f5); - variant11 = (int32_t) (((*payload2).address).f6); - variant12 = (int32_t) (((*payload2).address).f7); - variant13 = (int32_t) ((*payload2).scope_id); - break; - } - } - option = 1; - option14 = variant; - option15 = variant3; - option16 = variant4; - option17 = variant5; - option18 = variant6; - option19 = variant7; - option20 = variant8; - option21 = variant9; - option22 = variant10; - option23 = variant11; - option24 = variant12; - option25 = variant13; - } else { - option = 0; - option14 = 0; - option15 = 0; - option16 = 0; - option17 = 0; - option18 = 0; - option19 = 0; - option20 = 0; - option21 = 0; - option22 = 0; - option23 = 0; - option24 = 0; - option25 = 0; - } +bool wasi_sockets_types_method_tcp_socket_listen(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_stream_own_tcp_socket_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_stream((self).__handle, option, option14, option15, option16, option17, option18, option19, option20, option21, option22, option23, option24, option25, ptr); - wasi_sockets_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_listen((self).__handle, ptr); + wasi_sockets_types_result_stream_own_tcp_socket_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t) { - (wasi_sockets_udp_own_incoming_datagram_stream_t) (wasi_sockets_udp_own_incoming_datagram_stream_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_udp_own_outgoing_datagram_stream_t) (wasi_sockets_udp_own_outgoing_datagram_stream_t) { *((int32_t*) (ptr + 8)) }, - }; + result.val.ok = ((uint32_t) *((int32_t*) (ptr + sizeof(void*)))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -3295,45 +2258,61 @@ bool wasi_sockets_udp_method_udp_socket_stream(wasi_sockets_udp_borrow_udp_socke } } -bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err) { +wasi_sockets_types_future_result_void_error_code_t wasi_sockets_types_method_tcp_socket_send(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_stream_u8_t data) { + int32_t ret = __wasm_import_wasi_sockets_types_method_tcp_socket_send((self).__handle, ((int32_t) data)); + return ((uint32_t) ret); +} + +void wasi_sockets_types_method_tcp_socket_receive(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_tuple2_stream_u8_future_result_void_error_code_t *ret) { __attribute__((__aligned__(4))) - uint8_t ret_area[36]; + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_types_method_tcp_socket_receive((self).__handle, ptr); + *ret = (wasi_sockets_types_tuple2_stream_u8_future_result_void_error_code_t) { + (wasi_sockets_types_stream_u8_t) ((uint32_t) *((int32_t*) (ptr + 0))), + (wasi_sockets_types_future_result_void_error_code_t) ((uint32_t) *((int32_t*) (ptr + 4))), + }; +} + +bool wasi_sockets_types_method_tcp_socket_get_local_address(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(32+1*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_local_address((self).__handle, ptr); - wasi_sockets_udp_result_ip_socket_address_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_local_address((self).__handle, ptr); + wasi_sockets_types_result_ip_socket_address_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); switch ((int32_t) variant.tag) { case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + variant.val.ipv4 = (wasi_sockets_types_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (wasi_sockets_types_ipv4_address_t) (wasi_sockets_types_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (6+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (7+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (9+1*sizeof(void*))))), }, }; break; } case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + variant.val.ipv6 = (wasi_sockets_types_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (8+1*sizeof(void*))))), + (wasi_sockets_types_ipv6_address_t) (wasi_sockets_types_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (12+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (14+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (16+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (20+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (22+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (24+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (26+1*sizeof(void*))))), }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (28+1*sizeof(void*))))), }; break; } @@ -3344,7 +2323,70 @@ bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_ud } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant0.val.other = option; + break; + } + } + + result.val.err = variant0; break; } } @@ -3357,45 +2399,45 @@ bool wasi_sockets_udp_method_udp_socket_local_address(wasi_sockets_udp_borrow_ud } } -bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_udp_socket_t self, wasi_sockets_udp_ip_socket_address_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; +bool wasi_sockets_types_method_tcp_socket_get_remote_address(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(32+1*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_remote_address((self).__handle, ptr); - wasi_sockets_udp_result_ip_socket_address_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_remote_address((self).__handle, ptr); + wasi_sockets_types_result_ip_socket_address_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); switch ((int32_t) variant.tag) { case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + variant.val.ipv4 = (wasi_sockets_types_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (wasi_sockets_types_ipv4_address_t) (wasi_sockets_types_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (6+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (7+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (9+1*sizeof(void*))))), }, }; break; } case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + variant.val.ipv6 = (wasi_sockets_types_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (8+1*sizeof(void*))))), + (wasi_sockets_types_ipv6_address_t) (wasi_sockets_types_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (12+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (14+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (16+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (20+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (22+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (24+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (26+1*sizeof(void*))))), }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (28+1*sizeof(void*))))), }; break; } @@ -3406,7 +2448,70 @@ bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_u } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant0.val.other = option; + break; + } + } + + result.val.err = variant0; break; } } @@ -3419,104 +2524,93 @@ bool wasi_sockets_udp_method_udp_socket_remote_address(wasi_sockets_udp_borrow_u } } -wasi_sockets_udp_ip_address_family_t wasi_sockets_udp_method_udp_socket_address_family(wasi_sockets_udp_borrow_udp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_udp_socket_address_family((self).__handle); +bool wasi_sockets_types_method_tcp_socket_get_is_listening(wasi_sockets_types_borrow_tcp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_types_method_tcp_socket_get_is_listening((self).__handle); return ret; } -bool wasi_sockets_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_unicast_hop_limit((self).__handle, ptr); - wasi_sockets_udp_result_u8_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_unicast_hop_limit((self).__handle, (int32_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +wasi_sockets_types_ip_address_family_t wasi_sockets_types_method_tcp_socket_get_address_family(wasi_sockets_types_borrow_tcp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_types_method_tcp_socket_get_address_family((self).__handle); + return ret; } -bool wasi_sockets_udp_method_udp_socket_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +bool wasi_sockets_types_method_tcp_socket_set_listen_backlog_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_receive_buffer_size((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_listen_backlog_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } -bool wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + result.val.err = variant; break; } } @@ -3528,51 +2622,89 @@ bool wasi_sockets_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_udp } } -bool wasi_sockets_udp_method_udp_socket_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +bool wasi_sockets_types_method_tcp_socket_get_keep_alive_enabled(wasi_sockets_types_borrow_tcp_socket_t self, bool *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_send_buffer_size((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_enabled((self).__handle, ptr); + wasi_sockets_types_result_bool_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + result.val.ok = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } -bool wasi_sockets_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_udp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_udp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + result.val.err = variant; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3580,63 +2712,87 @@ bool wasi_sockets_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_udp_bo } } -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_udp_socket_subscribe(wasi_sockets_udp_borrow_udp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_udp_socket_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} - -bool wasi_sockets_udp_method_incoming_datagram_stream_receive(wasi_sockets_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_udp_list_incoming_datagram_t *ret, wasi_sockets_udp_error_code_t *err) { +bool wasi_sockets_types_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_types_borrow_tcp_socket_t self, bool value, wasi_sockets_types_error_code_t *err) { __attribute__((__aligned__(sizeof(void*)))) - uint8_t ret_area[(3*sizeof(void*))]; + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_receive((self).__handle, (int64_t) (max_results), ptr); - wasi_sockets_udp_result_list_incoming_datagram_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_enabled((self).__handle, value, ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_udp_list_incoming_datagram_t) { (wasi_sockets_udp_incoming_datagram_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_udp_borrow_incoming_datagram_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_incoming_datagram_stream_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } -bool wasi_sockets_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_check_send((self).__handle, ptr); - wasi_sockets_udp_result_u64_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3644,12 +2800,12 @@ bool wasi_sockets_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_ud } } -bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_udp_error_code_t *err) { +bool wasi_sockets_types_method_tcp_socket_get_keep_alive_idle_time(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t *ret, wasi_sockets_types_error_code_t *err) { __attribute__((__aligned__(8))) - uint8_t ret_area[16]; + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_send((self).__handle, (uint8_t *) (*datagrams).ptr, (*datagrams).len, ptr); - wasi_sockets_udp_result_u64_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_idle_time((self).__handle, ptr); + wasi_sockets_types_result_duration_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -3658,7 +2814,70 @@ bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borr } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -3671,31 +2890,87 @@ bool wasi_sockets_udp_method_outgoing_datagram_stream_send(wasi_sockets_udp_borr } } -wasi_sockets_udp_own_pollable_t wasi_sockets_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_udp_borrow_outgoing_datagram_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_udp_method_outgoing_datagram_stream_subscribe((self).__handle); - return (wasi_sockets_udp_own_pollable_t) { ret }; -} - -bool wasi_sockets_udp_create_socket_create_udp_socket(wasi_sockets_udp_create_socket_ip_address_family_t address_family, wasi_sockets_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_udp_create_socket_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; +bool wasi_sockets_types_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_udp_create_socket_create_udp_socket((int32_t) address_family, ptr); - wasi_sockets_udp_create_socket_result_own_udp_socket_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_idle_time((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_udp_create_socket_own_udp_socket_t) { *((int32_t*) (ptr + 4)) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3703,95 +2978,89 @@ bool wasi_sockets_udp_create_socket_create_udp_socket(wasi_sockets_udp_create_so } } -bool wasi_sockets_tcp_method_tcp_socket_start_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *local_address, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int32_t variant1; - int32_t variant2; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - switch ((int32_t) (*local_address).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; - variant = 0; - variant1 = (int32_t) ((*payload).port); - variant2 = (int32_t) (((*payload).address).f0); - variant3 = (int32_t) (((*payload).address).f1); - variant4 = (int32_t) (((*payload).address).f2); - variant5 = (int32_t) (((*payload).address).f3); - variant6 = 0; - variant7 = 0; - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; - variant = 1; - variant1 = (int32_t) ((*payload0).port); - variant2 = (int32_t) ((*payload0).flow_info); - variant3 = (int32_t) (((*payload0).address).f0); - variant4 = (int32_t) (((*payload0).address).f1); - variant5 = (int32_t) (((*payload0).address).f2); - variant6 = (int32_t) (((*payload0).address).f3); - variant7 = (int32_t) (((*payload0).address).f4); - variant8 = (int32_t) (((*payload0).address).f5); - variant9 = (int32_t) (((*payload0).address).f6); - variant10 = (int32_t) (((*payload0).address).f7); - variant11 = (int32_t) ((*payload0).scope_id); - break; - } - } +bool wasi_sockets_types_method_tcp_socket_get_keep_alive_interval(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_interval((self).__handle, ptr); + wasi_sockets_types_result_duration_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } -bool wasi_sockets_tcp_method_tcp_socket_finish_bind(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_bind((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + result.val.err = variant; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3799,58 +3068,12 @@ bool wasi_sockets_tcp_method_tcp_socket_finish_bind(wasi_sockets_tcp_borrow_tcp_ } } -bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_borrow_network_t network, wasi_sockets_tcp_ip_socket_address_t *remote_address, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - int32_t variant; - int32_t variant1; - int32_t variant2; - int32_t variant3; - int32_t variant4; - int32_t variant5; - int32_t variant6; - int32_t variant7; - int32_t variant8; - int32_t variant9; - int32_t variant10; - int32_t variant11; - switch ((int32_t) (*remote_address).tag) { - case 0: { - const wasi_sockets_network_ipv4_socket_address_t *payload = &(*remote_address).val.ipv4; - variant = 0; - variant1 = (int32_t) ((*payload).port); - variant2 = (int32_t) (((*payload).address).f0); - variant3 = (int32_t) (((*payload).address).f1); - variant4 = (int32_t) (((*payload).address).f2); - variant5 = (int32_t) (((*payload).address).f3); - variant6 = 0; - variant7 = 0; - variant8 = 0; - variant9 = 0; - variant10 = 0; - variant11 = 0; - break; - } - case 1: { - const wasi_sockets_network_ipv6_socket_address_t *payload0 = &(*remote_address).val.ipv6; - variant = 1; - variant1 = (int32_t) ((*payload0).port); - variant2 = (int32_t) ((*payload0).flow_info); - variant3 = (int32_t) (((*payload0).address).f0); - variant4 = (int32_t) (((*payload0).address).f1); - variant5 = (int32_t) (((*payload0).address).f2); - variant6 = (int32_t) (((*payload0).address).f3); - variant7 = (int32_t) (((*payload0).address).f4); - variant8 = (int32_t) (((*payload0).address).f5); - variant9 = (int32_t) (((*payload0).address).f6); - variant10 = (int32_t) (((*payload0).address).f7); - variant11 = (int32_t) ((*payload0).scope_id); - break; - } - } +bool wasi_sockets_types_method_tcp_socket_set_keep_alive_interval(wasi_sockets_types_borrow_tcp_socket_t self, wasi_sockets_types_duration_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_connect((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_interval((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -3858,7 +3081,70 @@ bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tc } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -3870,24 +3156,84 @@ bool wasi_sockets_tcp_method_tcp_socket_start_connect(wasi_sockets_tcp_borrow_tc } } -bool wasi_sockets_tcp_method_tcp_socket_finish_connect(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[12]; +bool wasi_sockets_types_method_tcp_socket_get_keep_alive_count(wasi_sockets_types_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_connect((self).__handle, ptr); - wasi_sockets_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_keep_alive_count((self).__handle, ptr); + wasi_sockets_types_result_u32_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_tcp_tuple2_own_input_stream_own_output_stream_t) { - (wasi_sockets_tcp_own_input_stream_t) (wasi_sockets_tcp_own_input_stream_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_tcp_own_output_stream_t) (wasi_sockets_tcp_own_output_stream_t) { *((int32_t*) (ptr + 8)) }, - }; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + sizeof(void*)))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -3900,12 +3246,12 @@ bool wasi_sockets_tcp_method_tcp_socket_finish_connect(wasi_sockets_tcp_borrow_t } } -bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_tcp_socket_set_keep_alive_count(wasi_sockets_types_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_start_listen((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_keep_alive_count((self).__handle, (int32_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -3913,7 +3259,70 @@ bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -3925,24 +3334,89 @@ bool wasi_sockets_tcp_method_tcp_socket_start_listen(wasi_sockets_tcp_borrow_tcp } } -bool wasi_sockets_tcp_method_tcp_socket_finish_listen(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_tcp_socket_get_hop_limit(wasi_sockets_types_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_finish_listen((self).__handle, ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_hop_limit((self).__handle, ptr); + wasi_sockets_types_result_u8_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; + result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3950,30 +3424,87 @@ bool wasi_sockets_tcp_method_tcp_socket_finish_listen(wasi_sockets_tcp_borrow_tc } } -bool wasi_sockets_tcp_method_tcp_socket_accept(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[16]; +bool wasi_sockets_types_method_tcp_socket_set_hop_limit(wasi_sockets_types_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_accept((self).__handle, ptr); - wasi_sockets_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_hop_limit((self).__handle, (int32_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t) { - (wasi_sockets_tcp_own_tcp_socket_t) (wasi_sockets_tcp_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }, - (wasi_sockets_tcp_own_input_stream_t) (wasi_sockets_tcp_own_input_stream_t) { *((int32_t*) (ptr + 8)) }, - (wasi_sockets_tcp_own_output_stream_t) (wasi_sockets_tcp_own_output_stream_t) { *((int32_t*) (ptr + 12)) }, - }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -3981,56 +3512,84 @@ bool wasi_sockets_tcp_method_tcp_socket_accept(wasi_sockets_tcp_borrow_tcp_socke } } -bool wasi_sockets_tcp_method_tcp_socket_local_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; +bool wasi_sockets_types_method_tcp_socket_get_receive_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_local_address((self).__handle, ptr); - wasi_sockets_tcp_result_ip_socket_address_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_receive_buffer_size((self).__handle, ptr); + wasi_sockets_types_result_u64_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); switch ((int32_t) variant.tag) { case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; break; } case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; break; } } - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + result.val.err = variant; break; } } @@ -4043,61 +3602,87 @@ bool wasi_sockets_tcp_method_tcp_socket_local_address(wasi_sockets_tcp_borrow_tc } } -bool wasi_sockets_tcp_method_tcp_socket_remote_address(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_ip_socket_address_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[36]; +bool wasi_sockets_types_method_tcp_socket_set_receive_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_remote_address((self).__handle, ptr); - wasi_sockets_tcp_result_ip_socket_address_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - wasi_sockets_network_ip_socket_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + case 1: { + result.is_err = true; + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); switch ((int32_t) variant.tag) { case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (wasi_sockets_network_ipv4_address_t) (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), - }, - }; break; } case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_socket_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), - (wasi_sockets_network_ipv6_address_t) (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), - }, - (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), - }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; break; } } - result.val.ok = variant; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4105,34 +3690,89 @@ bool wasi_sockets_tcp_method_tcp_socket_remote_address(wasi_sockets_tcp_borrow_t } } -bool wasi_sockets_tcp_method_tcp_socket_is_listening(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_is_listening((self).__handle); - return ret; -} - -wasi_sockets_tcp_ip_address_family_t wasi_sockets_tcp_method_tcp_socket_address_family(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_address_family((self).__handle); - return ret; -} - -bool wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_tcp_socket_get_send_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_get_send_buffer_size((self).__handle, ptr); + wasi_sockets_types_result_u64_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4140,47 +3780,83 @@ bool wasi_sockets_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_tcp } } -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_tcp_socket_set_send_buffer_size(wasi_sockets_types_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_enabled((self).__handle, ptr); - wasi_sockets_tcp_result_bool_error_code_t result; + __wasm_import_wasi_sockets_types_method_tcp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } -} + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled((self).__handle, value, ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + result.val.err = variant; break; } } @@ -4192,21 +3868,84 @@ bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_tcp_ } } -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +bool wasi_sockets_types_static_udp_socket_create(wasi_sockets_types_ip_address_family_t address_family, wasi_sockets_types_own_udp_socket_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time((self).__handle, ptr); - wasi_sockets_tcp_result_duration_error_code_t result; + __wasm_import_wasi_sockets_types_static_udp_socket_create((int32_t) address_family, ptr); + wasi_sockets_types_result_own_udp_socket_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + result.val.ok = (wasi_sockets_types_own_udp_socket_t) { *((int32_t*) (ptr + sizeof(void*))) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -4219,51 +3958,133 @@ bool wasi_sockets_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_tcp_bo } } -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_idle_time((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { +bool wasi_sockets_types_method_udp_socket_bind(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *local_address, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + int32_t variant; + int32_t variant1; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + switch ((int32_t) (*local_address).tag) { case 0: { - result.is_err = false; + const wasi_sockets_types_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; + variant = 0; + variant1 = (int32_t) ((*payload).port); + variant2 = (int32_t) (((*payload).address).f0); + variant3 = (int32_t) (((*payload).address).f1); + variant4 = (int32_t) (((*payload).address).f2); + variant5 = (int32_t) (((*payload).address).f3); + variant6 = 0; + variant7 = 0; + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; break; } case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + const wasi_sockets_types_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; + variant = 1; + variant1 = (int32_t) ((*payload0).port); + variant2 = (int32_t) ((*payload0).flow_info); + variant3 = (int32_t) (((*payload0).address).f0); + variant4 = (int32_t) (((*payload0).address).f1); + variant5 = (int32_t) (((*payload0).address).f2); + variant6 = (int32_t) (((*payload0).address).f3); + variant7 = (int32_t) (((*payload0).address).f4); + variant8 = (int32_t) (((*payload0).address).f5); + variant9 = (int32_t) (((*payload0).address).f6); + variant10 = (int32_t) (((*payload0).address).f7); + variant11 = (int32_t) ((*payload0).scope_id); break; } } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_interval((self).__handle, ptr); - wasi_sockets_tcp_result_duration_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_bind((self).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + wasi_sockets_types_error_code_t variant12; + variant12.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant12.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant12.val.other = option; + break; + } + } + + result.val.err = variant12; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4271,51 +4092,133 @@ bool wasi_sockets_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_tcp_bor } } -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_duration_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_interval((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { +bool wasi_sockets_types_method_udp_socket_connect(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *remote_address, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + int32_t variant; + int32_t variant1; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + switch ((int32_t) (*remote_address).tag) { case 0: { - result.is_err = false; + const wasi_sockets_types_ipv4_socket_address_t *payload = &(*remote_address).val.ipv4; + variant = 0; + variant1 = (int32_t) ((*payload).port); + variant2 = (int32_t) (((*payload).address).f0); + variant3 = (int32_t) (((*payload).address).f1); + variant4 = (int32_t) (((*payload).address).f2); + variant5 = (int32_t) (((*payload).address).f3); + variant6 = 0; + variant7 = 0; + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; break; } case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + const wasi_sockets_types_ipv6_socket_address_t *payload0 = &(*remote_address).val.ipv6; + variant = 1; + variant1 = (int32_t) ((*payload0).port); + variant2 = (int32_t) ((*payload0).flow_info); + variant3 = (int32_t) (((*payload0).address).f0); + variant4 = (int32_t) (((*payload0).address).f1); + variant5 = (int32_t) (((*payload0).address).f2); + variant6 = (int32_t) (((*payload0).address).f3); + variant7 = (int32_t) (((*payload0).address).f4); + variant8 = (int32_t) (((*payload0).address).f5); + variant9 = (int32_t) (((*payload0).address).f6); + variant10 = (int32_t) (((*payload0).address).f7); + variant11 = (int32_t) ((*payload0).scope_id); break; } } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } -} - -bool wasi_sockets_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_keep_alive_count((self).__handle, ptr); - wasi_sockets_tcp_result_u32_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_connect((self).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint32_t) (*((int32_t*) (ptr + 4))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant12; + variant12.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant12.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant12.val.other = option; + break; + } + } + + result.val.err = variant12; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4323,12 +4226,12 @@ bool wasi_sockets_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_tcp_borrow } } -bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_udp_socket_disconnect(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count((self).__handle, (int32_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_disconnect((self).__handle, ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -4336,7 +4239,70 @@ bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_bo } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -4348,73 +4314,127 @@ bool wasi_sockets_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_tcp_bo } } -bool wasi_sockets_tcp_method_tcp_socket_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_hop_limit((self).__handle, ptr); - wasi_sockets_tcp_result_u8_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_sockets_types_method_udp_socket_send(wasi_sockets_types_method_udp_socket_send_args_t *args, wasi_sockets_types_result_void_error_code_t *result) { + return __wasm_import_wasi_sockets_types_method_udp_socket_send((uint8_t*) args, (uint8_t*) result); } -bool wasi_sockets_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; - uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_hop_limit((self).__handle, (int32_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; - switch ((int32_t) *((uint8_t*) (ptr + 0))) { - case 0: { - result.is_err = false; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); - break; - } - } - if (!result.is_err) { - return 1; - } else { - *err = result.val.err; - return 0; - } +plugin_subtask_status_t wasi_sockets_types_method_udp_socket_receive(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_result_tuple2_list_u8_ip_socket_address_error_code_t *result) { + return __wasm_import_wasi_sockets_types_method_udp_socket_receive((self).__handle, (uint8_t*) result); } -bool wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +bool wasi_sockets_types_method_udp_socket_get_local_address(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(32+1*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_receive_buffer_size((self).__handle, ptr); - wasi_sockets_tcp_result_u64_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_get_local_address((self).__handle, ptr); + wasi_sockets_types_result_ip_socket_address_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + wasi_sockets_types_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_types_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (wasi_sockets_types_ipv4_address_t) (wasi_sockets_types_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (6+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (7+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (9+1*sizeof(void*))))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_types_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (8+1*sizeof(void*))))), + (wasi_sockets_types_ipv6_address_t) (wasi_sockets_types_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (12+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (14+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (16+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (20+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (22+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (24+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (26+1*sizeof(void*))))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (28+1*sizeof(void*))))), + }; + break; + } + } + + result.val.ok = variant; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + wasi_sockets_types_error_code_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant0.val.other = option; + break; + } + } + + result.val.err = variant0; break; } } @@ -4427,24 +4447,124 @@ bool wasi_sockets_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_tcp_bor } } -bool wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_udp_socket_get_remote_address(wasi_sockets_types_borrow_udp_socket_t self, wasi_sockets_types_ip_socket_address_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(32+1*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_get_remote_address((self).__handle, ptr); + wasi_sockets_types_result_ip_socket_address_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; + wasi_sockets_types_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_types_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (wasi_sockets_types_ipv4_address_t) (wasi_sockets_types_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (6+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (7+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + (9+1*sizeof(void*))))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_types_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (4+1*sizeof(void*))))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (8+1*sizeof(void*))))), + (wasi_sockets_types_ipv6_address_t) (wasi_sockets_types_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (12+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (14+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (16+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (20+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (22+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (24+1*sizeof(void*))))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + (26+1*sizeof(void*))))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (28+1*sizeof(void*))))), + }; + break; + } + } + + result.val.ok = variant; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant0.val.other = option; + break; + } + } + + result.val.err = variant0; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4452,21 +4572,89 @@ bool wasi_sockets_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_tcp } } -bool wasi_sockets_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(8))) - uint8_t ret_area[16]; +wasi_sockets_types_ip_address_family_t wasi_sockets_types_method_udp_socket_get_address_family(wasi_sockets_types_borrow_udp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_types_method_udp_socket_get_address_family((self).__handle); + return ret; +} + +bool wasi_sockets_types_method_udp_socket_get_unicast_hop_limit(wasi_sockets_types_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_send_buffer_size((self).__handle, ptr); - wasi_sockets_tcp_result_u64_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_get_unicast_hop_limit((self).__handle, ptr); + wasi_sockets_types_result_u8_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -4479,12 +4667,12 @@ bool wasi_sockets_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_tcp_borrow } } -bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_udp_socket_set_unicast_hop_limit(wasi_sockets_types_borrow_udp_socket_t self, uint8_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_set_unicast_hop_limit((self).__handle, (int32_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; @@ -4492,7 +4680,70 @@ bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_bo } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } @@ -4504,29 +4755,89 @@ bool wasi_sockets_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_tcp_bo } } -wasi_sockets_tcp_own_pollable_t wasi_sockets_tcp_method_tcp_socket_subscribe(wasi_sockets_tcp_borrow_tcp_socket_t self) { - int32_t ret = __wasm_import_wasi_sockets_tcp_method_tcp_socket_subscribe((self).__handle); - return (wasi_sockets_tcp_own_pollable_t) { ret }; -} - -bool wasi_sockets_tcp_method_tcp_socket_shutdown(wasi_sockets_tcp_borrow_tcp_socket_t self, wasi_sockets_tcp_shutdown_type_t shutdown_type, wasi_sockets_tcp_error_code_t *err) { - __attribute__((__aligned__(1))) - uint8_t ret_area[2]; +bool wasi_sockets_types_method_udp_socket_get_receive_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_method_tcp_socket_shutdown((self).__handle, (int32_t) shutdown_type, ptr); - wasi_sockets_tcp_result_void_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_get_receive_buffer_size((self).__handle, ptr); + wasi_sockets_types_result_u64_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { + *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4534,26 +4845,87 @@ bool wasi_sockets_tcp_method_tcp_socket_shutdown(wasi_sockets_tcp_borrow_tcp_soc } } -bool wasi_sockets_tcp_create_socket_create_tcp_socket(wasi_sockets_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_tcp_create_socket_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; +bool wasi_sockets_types_method_udp_socket_set_receive_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_tcp_create_socket_create_tcp_socket((int32_t) address_family, ptr); - wasi_sockets_tcp_create_socket_result_own_tcp_socket_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_tcp_create_socket_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4561,61 +4933,84 @@ bool wasi_sockets_tcp_create_socket_create_tcp_socket(wasi_sockets_tcp_create_so } } -bool wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err) { - __attribute__((__aligned__(2))) - uint8_t ret_area[22]; +bool wasi_sockets_types_method_udp_socket_get_send_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(8+4*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_address((self).__handle, ptr); - wasi_sockets_ip_name_lookup_result_option_ip_address_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_get_send_buffer_size((self).__handle, ptr); + wasi_sockets_types_result_u64_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - wasi_sockets_ip_name_lookup_option_ip_address_t option; - switch ((int32_t) *((uint8_t*) (ptr + 2))) { + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { case 0: { - option.is_some = false; break; } case 1: { - option.is_some = true; - wasi_sockets_network_ip_address_t variant; - variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); - switch ((int32_t) variant.tag) { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*))))) { case 0: { - variant.val.ipv4 = (wasi_sockets_network_ipv4_address_t) { - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 6))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 7))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 8))), - (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 9))), - }; + option.is_some = false; break; } case 1: { - variant.val.ipv6 = (wasi_sockets_network_ipv6_address_t) { - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 6))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 10))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 12))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 14))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), - (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), - }; + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; break; } } - - option.val = variant; + variant.val.other = option; break; } } - result.val.ok = option; - break; - } - case 1: { - result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 2)); + result.val.err = variant; break; } } @@ -4628,31 +5023,87 @@ bool wasi_sockets_ip_name_lookup_method_resolve_address_stream_resolve_next_addr } } -wasi_sockets_ip_name_lookup_own_pollable_t wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_ip_name_lookup_borrow_resolve_address_stream_t self) { - int32_t ret = __wasm_import_wasi_sockets_ip_name_lookup_method_resolve_address_stream_subscribe((self).__handle); - return (wasi_sockets_ip_name_lookup_own_pollable_t) { ret }; -} - -bool wasi_sockets_ip_name_lookup_resolve_addresses(wasi_sockets_ip_name_lookup_borrow_network_t network, plugin_string_t *name, wasi_sockets_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_ip_name_lookup_error_code_t *err) { - __attribute__((__aligned__(4))) - uint8_t ret_area[8]; +bool wasi_sockets_types_method_udp_socket_set_send_buffer_size(wasi_sockets_types_borrow_udp_socket_t self, uint64_t value, wasi_sockets_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses((network).__handle, (uint8_t *) (*name).ptr, (*name).len, ptr); - wasi_sockets_ip_name_lookup_result_own_resolve_address_stream_error_code_t result; + __wasm_import_wasi_sockets_types_method_udp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_types_result_void_error_code_t result; switch ((int32_t) *((uint8_t*) (ptr + 0))) { case 0: { result.is_err = false; - result.val.ok = (wasi_sockets_ip_name_lookup_own_resolve_address_stream_t) { *((int32_t*) (ptr + 4)) }; break; } case 1: { result.is_err = true; - result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + wasi_sockets_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + plugin_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (2*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (plugin_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant.val.other = option; + break; + } + } + + result.val.err = variant; break; } } if (!result.is_err) { - *ret = result.val.ok; return 1; } else { *err = result.val.err; @@ -4660,11 +5111,15 @@ bool wasi_sockets_ip_name_lookup_resolve_addresses(wasi_sockets_ip_name_lookup_b } } -void wasi_random_random_get_random_bytes(uint64_t len, plugin_list_u8_t *ret) { +plugin_subtask_status_t wasi_sockets_ip_name_lookup_resolve_addresses(plugin_string_t name, wasi_sockets_ip_name_lookup_result_list_ip_address_error_code_t *result) { + return __wasm_import_wasi_sockets_ip_name_lookup_resolve_addresses((uint8_t *) (name).ptr, (name).len, (uint8_t*) result); +} + +void wasi_random_random_get_random_bytes(uint64_t max_len, plugin_list_u8_t *ret) { __attribute__((__aligned__(sizeof(void*)))) uint8_t ret_area[(2*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_random_get_random_bytes((int64_t) (len), ptr); + __wasm_import_wasi_random_random_get_random_bytes((int64_t) (max_len), ptr); *ret = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; } @@ -4673,11 +5128,11 @@ uint64_t wasi_random_random_get_random_u64(void) { return (uint64_t) (ret); } -void wasi_random_insecure_get_insecure_random_bytes(uint64_t len, plugin_list_u8_t *ret) { +void wasi_random_insecure_get_insecure_random_bytes(uint64_t max_len, plugin_list_u8_t *ret) { __attribute__((__aligned__(sizeof(void*)))) uint8_t ret_area[(2*sizeof(void*))]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_insecure_get_insecure_random_bytes((int64_t) (len), ptr); + __wasm_import_wasi_random_insecure_get_insecure_random_bytes((int64_t) (max_len), ptr); *ret = (plugin_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; } @@ -4686,18 +5141,18 @@ uint64_t wasi_random_insecure_get_insecure_random_u64(void) { return (uint64_t) (ret); } -void wasi_random_insecure_seed_insecure_seed(plugin_tuple2_u64_u64_t *ret) { +void wasi_random_insecure_seed_get_insecure_seed(plugin_tuple2_u64_u64_t *ret) { __attribute__((__aligned__(8))) uint8_t ret_area[16]; uint8_t *ptr = (uint8_t *) &ret_area; - __wasm_import_wasi_random_insecure_seed_insecure_seed(ptr); + __wasm_import_wasi_random_insecure_seed_get_insecure_seed(ptr); *ret = (plugin_tuple2_u64_u64_t) { (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), }; } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#metadata"))) +__attribute__((__export_name__("streamkit:plugin/node@0.2.0#metadata"))) uint8_t * __wasm_export_exports_streamkit_plugin_node_metadata(void) { exports_streamkit_plugin_node_node_metadata_t ret; exports_streamkit_plugin_node_metadata(&ret); @@ -4715,7 +5170,7 @@ uint8_t * __wasm_export_exports_streamkit_plugin_node_metadata(void) { return ptr; } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[constructor]node-instance"))) +__attribute__((__export_name__("streamkit:plugin/node@0.2.0#[constructor]node-instance"))) int32_t __wasm_export_exports_streamkit_plugin_node_constructor_node_instance(int32_t arg, uint8_t * arg0, size_t arg1) { plugin_option_string_t option; switch (arg) { @@ -4733,8 +5188,8 @@ int32_t __wasm_export_exports_streamkit_plugin_node_constructor_node_instance(in return (ret).__handle; } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.process"))) -uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_process(uint8_t * arg, uint8_t * arg0, size_t arg1, int32_t arg2, uint8_t * arg3, size_t arg4, uint8_t * arg5, size_t arg6) { +__attribute__((__export_name__("[async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.process"))) +int32_t __wasm_export_exports_streamkit_plugin_node_method_node_instance_process(uint8_t * arg, uint8_t * arg0, size_t arg1, int32_t arg2, uint8_t * arg3, size_t arg4, uint8_t * arg5, uint8_t * arg6, size_t arg7) { streamkit_plugin_types_packet_t variant; variant.tag = arg2; switch ((int32_t) variant.tag) { @@ -4742,7 +5197,7 @@ uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_proce variant.val.audio = (streamkit_plugin_types_audio_frame_t) { (uint32_t) (uint32_t) ((uintptr_t) arg3), (uint16_t) (uint16_t) (arg4), - (plugin_list_f32_t) (plugin_list_f32_t) { (float*)(arg5), (arg6) }, + (plugin_list_f32_t) (plugin_list_f32_t) { (float*)(arg5), ((uintptr_t) arg6) }, }; break; } @@ -4754,28 +5209,23 @@ uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_proce variant.val.binary = (plugin_list_u8_t) { (uint8_t*)(arg3), (arg4) }; break; } + case 3: { + variant.val.custom = (streamkit_plugin_types_custom_packet_t) { + (plugin_string_t) (plugin_string_t) { (uint8_t*)(arg3), (arg4) }, + (streamkit_plugin_types_custom_encoding_t) (uintptr_t) arg5, + (plugin_string_t) (plugin_string_t) { (uint8_t*)(arg6), (arg7) }, + }; + break; + } } - plugin_string_t arg7 = (plugin_string_t) { (uint8_t*)(arg0), (arg1) }; - exports_streamkit_plugin_node_packet_t arg8 = variant; - exports_streamkit_plugin_node_result_void_string_t ret; - plugin_string_t err; - ret.is_err = !exports_streamkit_plugin_node_method_node_instance_process(((exports_streamkit_plugin_node_node_instance_t*) arg), &arg7, &arg8, &err); - if (ret.is_err) { - ret.val.err = err; - } - uint8_t *ptr = (uint8_t *) &RET_AREA; - if ((ret).is_err) { - const plugin_string_t *payload9 = &(ret).val.err;*((int8_t*)(ptr + 0)) = 1; - *((size_t*)(ptr + (2*sizeof(void*)))) = (*payload9).len; - *((uint8_t **)(ptr + sizeof(void*))) = (uint8_t *) (*payload9).ptr; - } else { - *((int8_t*)(ptr + 0)) = 0; - } - return ptr; + plugin_string_t arg8 = (plugin_string_t) { (uint8_t*)(arg0), (arg1) }; + exports_streamkit_plugin_node_packet_t arg9 = variant; + plugin_callback_code_t ret = exports_streamkit_plugin_node_method_node_instance_process(((exports_streamkit_plugin_node_node_instance_t*) arg), &arg8, &arg9); + return ret; } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.update-params"))) -uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params(uint8_t * arg, int32_t arg0, uint8_t * arg1, size_t arg2) { +__attribute__((__export_name__("[async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.update-params"))) +int32_t __wasm_export_exports_streamkit_plugin_node_method_node_instance_update_params(uint8_t * arg, int32_t arg0, uint8_t * arg1, size_t arg2) { plugin_option_string_t option; switch (arg0) { case 0: { @@ -4788,24 +5238,11 @@ uint8_t * __wasm_export_exports_streamkit_plugin_node_method_node_instance_updat break; } } - exports_streamkit_plugin_node_result_void_string_t ret; - plugin_string_t err; - ret.is_err = !exports_streamkit_plugin_node_method_node_instance_update_params(((exports_streamkit_plugin_node_node_instance_t*) arg), option.is_some ? &(option.val) : NULL, &err); - if (ret.is_err) { - ret.val.err = err; - } - uint8_t *ptr = (uint8_t *) &RET_AREA; - if ((ret).is_err) { - const plugin_string_t *payload3 = &(ret).val.err;*((int8_t*)(ptr + 0)) = 1; - *((size_t*)(ptr + (2*sizeof(void*)))) = (*payload3).len; - *((uint8_t **)(ptr + sizeof(void*))) = (uint8_t *) (*payload3).ptr; - } else { - *((int8_t*)(ptr + 0)) = 0; - } - return ptr; + plugin_callback_code_t ret = exports_streamkit_plugin_node_method_node_instance_update_params(((exports_streamkit_plugin_node_node_instance_t*) arg), option.is_some ? &(option.val) : NULL); + return ret; } -__attribute__((__export_name__("streamkit:plugin/node@0.1.0#[method]node-instance.cleanup"))) +__attribute__((__export_name__("streamkit:plugin/node@0.2.0#[method]node-instance.cleanup"))) void __wasm_export_exports_streamkit_plugin_node_method_node_instance_cleanup(uint8_t * arg) { exports_streamkit_plugin_node_method_node_instance_cleanup(((exports_streamkit_plugin_node_node_instance_t*) arg)); } diff --git a/sdks/plugin-sdk/c/src/plugin_component_type.o b/sdks/plugin-sdk/c/src/plugin_component_type.o index c05812e88..49201ada7 100644 Binary files a/sdks/plugin-sdk/c/src/plugin_component_type.o and b/sdks/plugin-sdk/c/src/plugin_component_type.o differ diff --git a/sdks/plugin-sdk/wasm/rust/Cargo.toml b/sdks/plugin-sdk/wasm/rust/Cargo.toml index 78d843d02..e5aca1f87 100644 --- a/sdks/plugin-sdk/wasm/rust/Cargo.toml +++ b/sdks/plugin-sdk/wasm/rust/Cargo.toml @@ -13,7 +13,7 @@ categories = ["multimedia", "api-bindings", "wasm"] readme = "README.md" [dependencies] -wit-bindgen-rt = { version = "0.44", features = ["bitflags"] } +wit-bindgen = { version = "0.58", features = ["async"] } [lib] crate-type = ["rlib"] diff --git a/sdks/plugin-sdk/wasm/rust/src/generated/plugin.rs b/sdks/plugin-sdk/wasm/rust/src/generated/plugin.rs index b32df5e9b..df1ed76f7 100644 --- a/sdks/plugin-sdk/wasm/rust/src/generated/plugin.rs +++ b/sdks/plugin-sdk/wasm/rust/src/generated/plugin.rs @@ -1,7 +1,5 @@ -// Generated by `wit-bindgen` 0.44.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.58.0. DO NOT EDIT! // Options used: -// * runtime_path: "wit_bindgen_rt" -// * bitflags_path: "wit_bindgen_rt::bitflags" // * pub-export-macro #[allow(dead_code, clippy::all)] pub mod streamkit { @@ -275,160 +273,341 @@ pub mod streamkit { #[allow(unused_unsafe, clippy::all)] /// Send a packet to an output pin #[allow(async_fn_in_trait)] - pub fn send_output(pin_name: &str, packet: &Packet) -> Result<(), _rt::String> { + pub async fn send_output( + pin_name: _rt::String, + packet: Packet, + ) -> Result<(), _rt::String> { unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 3 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 3 * ::core::mem::size_of::<*const u8>()], - ); - let vec0 = pin_name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - use super::super::super::streamkit::plugin::types::Packet as V8; - let (result9_0, result9_1, result9_2, result9_3, result9_4, result9_5) = - match packet { - V8::Audio(e) => { - let super::super::super::streamkit::plugin::types::AudioFrame { - sample_rate: sample_rate1, - channels: channels1, - samples: samples1, - } = e; - let vec2 = samples1; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - ( - 0i32, - _rt::as_i32(sample_rate1) as *mut u8, - _rt::as_i32(channels1) as usize, - ptr2.cast_mut(), - len2 as *mut u8, - 0usize, + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (_rt::String, Packet); + type Results = Result<(), _rt::String>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (11 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), ) - }, - V8::Text(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); + } + } - ( - 1i32, - ptr3.cast_mut(), - len3, - ::core::ptr::null_mut(), - ::core::ptr::null_mut(), - 0usize, - ) - }, - V8::Binary(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); + fn results_offset(&mut self) -> usize { + (8 * ::core::mem::size_of::<*const u8>()) + } - ( - 2i32, - ptr4.cast_mut(), - len4, - ::core::ptr::null_mut(), - ::core::ptr::null_mut(), - 0usize, - ) - }, - V8::Custom(e) => { - let super::super::super::streamkit::plugin::types::CustomPacket { - type_id: type_id5, - encoding: encoding5, - data: data5, - } = e; - let vec6 = type_id5; - let ptr6 = vec6.as_ptr().cast::(); - let len6 = vec6.len(); - let vec7 = data5; - let ptr7 = vec7.as_ptr().cast::(); - let len7 = vec7.len(); + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "streamkit:plugin/host@0.2.0")] + unsafe extern "C" { + #[link_name = "[async-lower]send-output"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } - ( - 3i32, - ptr6.cast_mut(), - len6, - encoding5.clone() as i32 as *mut u8, - ptr7.cast_mut(), - len7, - ) - }, - }; - let ptr10 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "streamkit:plugin/host@0.1.0")] - unsafe extern "C" { - #[link_name = "send-output"] - fn wit_import11( - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - _: *mut u8, - _: usize, - _: *mut u8, - ); - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import11( - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() - } - wit_import11( - ptr0.cast_mut(), - len0, - result9_0, - result9_1, - result9_2, - result9_3, - result9_4, - result9_5, - ptr10, - ); - let l12 = i32::from(*ptr10.add(0).cast::()); - let result16 = match l12 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l13 = *ptr10 + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params.0.add(0).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = i32::from( + *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(), + ); + match l2 { + 0 => { + let l3 = *_params + .0 + .add(8 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *_params + .0 + .add(8 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); + }, + 1 => { + let l6 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l6, l7, 1); + }, + 2 => { + let l8 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l9 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base10 = l8; + let len10 = l9; + _rt::cabi_dealloc(base10, len10 * 1, 1); + }, + _ => { + let l11 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l12 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l11, l12, 1); + let l13 = *_params + .0 + .add(6 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l14 = *_params + .0 + .add(7 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l13, l14, 1); + }, + } + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params.0.add(0).cast::<*mut u8>(); + let l1 = *_params + .0 .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l14 = *ptr10 - .add(2 * ::core::mem::size_of::<*const u8>()) .cast::(); - let len15 = l14; - let bytes15 = _rt::Vec::from_raw_parts(l13.cast(), len15, len15); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = i32::from( + *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(), + ); + match l2 { + 0 => { + let l3 = *_params + .0 + .add(8 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *_params + .0 + .add(8 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); + }, + 1 => { + let l6 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l6, l7, 1); + }, + 2 => { + let l8 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l9 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base10 = l8; + let len10 = l9; + _rt::cabi_dealloc(base10, len10 * 1, 1); + }, + _ => { + let l11 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l12 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l11, l12, 1); + let l13 = *_params + .0 + .add(6 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l14 = *_params + .0 + .add(7 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l13, l14, 1); + }, + } + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + let vec0 = (_lower0.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = + unsafe { _ptr.add((2 * ::core::mem::size_of::<*const u8>())) }; + unsafe { + use super::super::super::streamkit::plugin::types::Packet as V7; + match _lower1 { + V7::Audio(e) => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + let super::super::super::streamkit::plugin::types::AudioFrame{ sample_rate:sample_rate0, channels:channels0, samples:samples0, } = e; + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = _rt::as_i32(sample_rate0); + *_param_ptr + .add(4 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::() = (_rt::as_i32(channels0)) as u16; + let vec1 = <_ as Into<_rt::Vec<_>>>::into(samples0) + .into_boxed_slice(); + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + ::core::mem::forget(vec1); + *_param_ptr + .add(8 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::() = len1; + *_param_ptr + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr1.cast_mut(); + }, + V7::Text(e) => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *_param_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = len2; + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr2.cast_mut(); + }, + V7::Binary(e) => { + *_param_ptr.add(0).cast::() = (2i32) as u8; + let vec3 = + <_ as Into<_rt::Vec<_>>>::into(e).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *_param_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = len3; + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr3.cast_mut(); + }, + V7::Custom(e) => { + *_param_ptr.add(0).cast::() = (3i32) as u8; + let super::super::super::streamkit::plugin::types::CustomPacket{ type_id:type_id4, encoding:encoding4, data:data4, } = e; + let vec5 = (type_id4.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *_param_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = len5; + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr5.cast_mut(); + *_param_ptr + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::() = (encoding4.clone() as i32) as u8; + let vec6 = (data4.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *_param_ptr + .add(5 * ::core::mem::size_of::<*const u8>()) + .cast::() = len6; + *_param_ptr + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr6.cast_mut(); + }, + } + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l2 = *_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len3 = l2; + let bytes3 = + _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes15) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result16 + _rt::string_lift(bytes3) + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((pin_name, packet)).await } } #[allow(unused_unsafe, clippy::all)] @@ -441,7 +620,7 @@ pub mod streamkit { let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "streamkit:plugin/host@0.1.0")] + #[link(wasm_import_module = "streamkit:plugin/host@0.2.0")] unsafe extern "C" { #[link_name = "log"] fn wit_import1(_: i32, _: *mut u8, _: usize); @@ -492,7 +671,7 @@ pub mod wasi { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + #[link(wasm_import_module = "wasi:cli/environment@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "get-environment"] fn wit_import1(_: *mut u8); @@ -552,7 +731,7 @@ pub mod wasi { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + #[link(wasm_import_module = "wasi:cli/environment@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "get-arguments"] fn wit_import1(_: *mut u8); @@ -593,7 +772,7 @@ pub mod wasi { /// Return a path that programs should use as their initial current working /// directory, interpreting `.` as shorthand for this. #[allow(async_fn_in_trait)] - pub fn initial_cwd() -> Option<_rt::String> { + pub fn get_initial_cwd() -> Option<_rt::String> { unsafe { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] #[cfg_attr(target_pointer_width = "32", repr(align(4)))] @@ -606,9 +785,9 @@ pub mod wasi { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + #[link(wasm_import_module = "wasi:cli/environment@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "initial-cwd"] + #[link_name = "get-initial-cwd"] fn wit_import1(_: *mut u8); } @@ -659,7 +838,7 @@ pub mod wasi { Err(_) => 1i32, }; #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/exit@0.2.0")] + #[link(wasm_import_module = "wasi:cli/exit@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "exit"] fn wit_import1(_: i32); @@ -674,6 +853,53 @@ pub mod wasi { } } + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + + #[repr(u8)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] + pub enum ErrorCode { + /// Input/output error + Io, + /// Invalid or incomplete multibyte or wide character + IllegalByteSequence, + /// Broken pipe + Pipe, + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + ErrorCode::Io => f.debug_tuple("ErrorCode::Io").finish(), + ErrorCode::IllegalByteSequence => { + f.debug_tuple("ErrorCode::IllegalByteSequence").finish() + }, + ErrorCode::Pipe => f.debug_tuple("ErrorCode::Pipe").finish(), + } + } + } + + impl ErrorCode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> ErrorCode { + if !cfg!(debug_assertions) { + return unsafe { ::core::mem::transmute(val) }; + } + + match val { + 0 => ErrorCode::Io, + 1 => ErrorCode::IllegalByteSequence, + 2 => ErrorCode::Pipe, + + _ => panic!("invalid enum discriminant"), + } + } + } + } + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod stdin { #[used] @@ -681,24 +907,48 @@ pub mod wasi { static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; + use super::super::super::_rt; + pub type ErrorCode = super::super::super::wasi::cli::types::ErrorCode; #[allow(unused_unsafe, clippy::all)] + /// Return a stream for reading from stdin. + /// + /// This function returns a stream which provides data read from stdin, + /// and a future to signal read results. + /// + /// If the stream's readable end is dropped the future will resolve to success. + /// + /// If the stream's writable end is dropped the future will either resolve to + /// success if stdin was closed by the writer or to an error-code if reading + /// failed for some other reason. + /// + /// Multiple streams may be active at the same time. The behavior of concurrent + /// reads is implementation-specific. #[allow(async_fn_in_trait)] - pub fn get_stdin() -> InputStream { + pub fn read_via_stream() -> ( + wit_bindgen::rt::async_support::StreamReader, + wit_bindgen::rt::async_support::FutureReader>, + ) { unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stdin@0.2.0")] + #[link(wasm_import_module = "wasi:cli/stdin@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "get-stdin"] - fn wit_import0() -> i32; + #[link_name = "read-via-stream"] + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - let ret = wit_import0(); - super::super::super::wasi::io::streams::InputStream::from_handle(ret as u32) + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(4).cast::(); + let result4 = (wit_bindgen::rt::async_support::StreamReader::new(l2 as u32, &::VTABLE), wit_bindgen::rt::async_support::FutureReader::new(l3 as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE)); + result4 } } } @@ -710,24 +960,34 @@ pub mod wasi { static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type ErrorCode = super::super::super::wasi::cli::types::ErrorCode; #[allow(unused_unsafe, clippy::all)] + /// Write the given stream to stdout. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. #[allow(async_fn_in_trait)] - pub fn get_stdout() -> OutputStream { + pub fn write_via_stream( + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stdout@0.2.0")] + #[link(wasm_import_module = "wasi:cli/stdout@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "get-stdout"] - fn wit_import0() -> i32; + #[link_name = "write-via-stream"] + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import0(); - super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) + let ret = wit_import0((&data).take_handle() as i32); + wit_bindgen::rt::async_support::FutureReader::new(ret as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE) } } } @@ -739,24 +999,34 @@ pub mod wasi { static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type ErrorCode = super::super::super::wasi::cli::types::ErrorCode; #[allow(unused_unsafe, clippy::all)] + /// Write the given stream to stderr. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. #[allow(async_fn_in_trait)] - pub fn get_stderr() -> OutputStream { + pub fn write_via_stream( + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stderr@0.2.0")] + #[link(wasm_import_module = "wasi:cli/stderr@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "get-stderr"] - fn wit_import0() -> i32; + #[link_name = "write-via-stream"] + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import0(); - super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) + let ret = wit_import0((&data).take_handle() as i32); + wit_bindgen::rt::async_support::FutureReader::new(ret as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE) } } } @@ -803,7 +1073,7 @@ pub mod wasi { #[inline] unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/terminal-input@0.2.0")] + #[link(wasm_import_module = "wasi:cli/terminal-input@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[resource-drop]terminal-input"] fn drop(_: i32); @@ -863,7 +1133,7 @@ pub mod wasi { #[inline] unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/terminal-output@0.2.0")] + #[link(wasm_import_module = "wasi:cli/terminal-output@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[resource-drop]terminal-output"] fn drop(_: i32); @@ -903,7 +1173,7 @@ pub mod wasi { let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/terminal-stdin@0.2.0")] + #[link(wasm_import_module = "wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "get-terminal-stdin"] fn wit_import1(_: *mut u8); @@ -955,7 +1225,7 @@ pub mod wasi { let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/terminal-stdout@0.2.0")] + #[link(wasm_import_module = "wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "get-terminal-stdout"] fn wit_import1(_: *mut u8); @@ -1007,7 +1277,7 @@ pub mod wasi { let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/terminal-stderr@0.2.0")] + #[link(wasm_import_module = "wasi:cli/terminal-stderr@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "get-terminal-stderr"] fn wit_import1(_: *mut u8); @@ -1037,7 +1307,26 @@ pub mod wasi { } } pub mod clocks { + /// This interface common types used throughout wasi:clocks. + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + + /// A duration of time, in nanoseconds. + pub type Duration = u64; + } + /// WASI Monotonic Clock is a clock API intended to let users measure elapsed + /// time. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + /// + /// A monotonic clock is a clock which has an unspecified initial value, and + /// successive reads of the clock will produce non-decreasing values. #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod monotonic_clock { #[used] @@ -1046,15 +1335,26 @@ pub mod wasi { super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub type Instant = u64; - pub type Duration = u64; + pub type Duration = super::super::super::wasi::clocks::types::Duration; + /// A mark on a monotonic clock is a number of nanoseconds since an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Mark = u64; #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + /// + /// For completeness, this function traps if it's not possible to represent + /// the value of the clock in a `mark`. Consequently, implementations + /// should ensure that the starting time is low enough to avoid the + /// possibility of overflow in practice. #[allow(async_fn_in_trait)] - pub fn now() -> Instant { + pub fn now() -> Mark { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "now"] fn wit_import0() -> i64; @@ -1069,13 +1369,15 @@ pub mod wasi { } } #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. #[allow(async_fn_in_trait)] - pub fn resolution() -> Duration { + pub fn get_resolution() -> Duration { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "resolution"] + #[link_name = "get-resolution"] fn wit_import0() -> i64; } @@ -1088,76 +1390,209 @@ pub mod wasi { } } #[allow(unused_unsafe, clippy::all)] + /// Wait until the specified mark has occurred. #[allow(async_fn_in_trait)] - pub fn subscribe_instant(when: Instant) -> Pollable { + pub async fn wait_until(when: Mark) -> () { unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - unsafe extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import0(_: i64) -> i32; - } + #[derive(Copy, Clone)] + struct ParamsLower(i64); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (Mark,); + type Results = (); + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { ::core::alloc::Layout::from_size_align_unchecked(0, 1) } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i64) -> i32 { - unreachable!() + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower]wait-until"] + fn call(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i64) -> i32 { + unreachable!() + } + + unsafe { call(_params.0) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower(_rt::as_i64(_lower0)) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results {} } - let ret = wit_import0(_rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + _MySubtask { _unused: core::marker::PhantomData }.call((when,)).await } } #[allow(unused_unsafe, clippy::all)] + /// Wait for the specified duration to elapse. #[allow(async_fn_in_trait)] - pub fn subscribe_duration(when: Duration) -> Pollable { + pub async fn wait_for(how_long: Duration) -> () { unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - unsafe extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import0(_: i64) -> i32; - } + #[derive(Copy, Clone)] + struct ParamsLower(i64); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (Duration,); + type Results = (); + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { ::core::alloc::Layout::from_size_align_unchecked(0, 1) } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i64) -> i32 { - unreachable!() + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower]wait-for"] + fn call(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i64) -> i32 { + unreachable!() + } + + unsafe { call(_params.0) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower(_rt::as_i64(_lower0)) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results {} } - let ret = wit_import0(_rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + _MySubtask { _unused: core::marker::PhantomData }.call((how_long,)).await } } } + /// WASI System Clock is a clock API intended to let users query the current + /// time. The clock is not necessarily monotonic as it may be reset. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + /// + /// External references may be reset, so this clock is not necessarily + /// monotonic, making it unsuitable for measuring elapsed time. + /// + /// It is intended for reporting the current date and time for humans. #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod wall_clock { + pub mod system_clock { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + pub type Duration = super::super::super::wasi::clocks::types::Duration; + /// An "instant", or "exact time", is a point in time without regard to any + /// time zone: just the time since a particular external reference point, + /// often called an "epoch". + /// + /// Here, the epoch is 1970-01-01T00:00:00Z, also known as + /// [POSIX's Seconds Since the Epoch], also known as [Unix Time]. + /// + /// Note that even if the seconds field is negative, incrementing + /// nanoseconds always represents moving forwards in time. + /// For example, `{ -1 seconds, 999999999 nanoseconds }` represents the + /// instant one nanosecond before the epoch. + /// For more on various different ways to represent time, see + /// https://tc39.es/proposal-temporal/docs/timezone.html + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time #[repr(C)] #[derive(Clone, Copy)] - pub struct Datetime { - pub seconds: u64, + pub struct Instant { + pub seconds: i64, pub nanoseconds: u32, } - impl ::core::fmt::Debug for Datetime { + impl ::core::fmt::Debug for Instant { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Datetime") + f.debug_struct("Instant") .field("seconds", &self.seconds) .field("nanoseconds", &self.nanoseconds) .finish() } } #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The nanoseconds field of the output is always less than 1000000000. #[allow(async_fn_in_trait)] - pub fn now() -> Datetime { + pub fn now() -> Instant { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + #[link(wasm_import_module = "wasi:clocks/system-clock@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "now"] fn wit_import1(_: *mut u8); @@ -1170,40 +1605,69 @@ pub mod wasi { wit_import1(ptr0); let l2 = *ptr0.add(0).cast::(); let l3 = *ptr0.add(8).cast::(); - let result4 = Datetime { seconds: l2 as u64, nanoseconds: l3 as u32 }; + let result4 = Instant { seconds: l2, nanoseconds: l3 as u32 }; result4 } } #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the smallest duration of time + /// that the implementation permits distinguishing. #[allow(async_fn_in_trait)] - pub fn resolution() -> Datetime { + pub fn get_resolution() -> Duration { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + #[link(wasm_import_module = "wasi:clocks/system-clock@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "resolution"] - fn wit_import1(_: *mut u8); + #[link_name = "get-resolution"] + fn wit_import0() -> i64; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: *mut u8) { + unsafe extern "C" fn wit_import0() -> i64 { unreachable!() } - wit_import1(ptr0); - let l2 = *ptr0.add(0).cast::(); - let l3 = *ptr0.add(8).cast::(); - let result4 = Datetime { seconds: l2 as u64, nanoseconds: l3 as u32 }; - result4 + let ret = wit_import0(); + ret as u64 } } } } pub mod filesystem { - + /// 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. + /// + /// Paths are passed as interface-type `string`s, meaning they must consist of + /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain + /// paths which are not accessible by this API. + /// + /// The directory separator in WASI is always the forward-slash (`/`). + /// + /// All paths in WASI are relative paths, and are interpreted relative to a + /// `descriptor` referring to a base directory. If a `path` argument to any WASI + /// function starts with `/`, or if any step of resolving a `path`, including + /// `..` and symbolic link steps, reaches a directory outside of the base + /// directory, or reaches a symlink to an absolute or rooted path in the + /// underlying filesystem, the function fails with `error-code::not-permitted`. + /// + /// For more information about WASI path resolution and sandboxing, see + /// [WASI filesystem path resolution]. + /// + /// Though this package presents a portable interface modelled on POSIX, it + /// prioritizes compatibility over portability: allowing users to access their + /// files on their machine is more important than exposing a single semantics + /// across all platforms. Notably, depending on the underlying operating system + /// and file system: + /// * Paths may be case-folded or not. + /// * Deleting (unlinking) a file may fail if there are other file descriptors + /// open. + /// * Durability and atomicity of changes to underlying files when there are + /// concurrent writers. + /// + /// Users that need well-defined, portable semantics should use a key-value + /// store or a database instead. + /// + /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod types { #[used] @@ -1212,29 +1676,35 @@ pub mod wasi { super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type Error = super::super::super::wasi::io::streams::Error; - pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; + pub type Instant = super::super::super::wasi::clocks::system_clock::Instant; + /// File size or length of a region within a file. pub type Filesize = u64; - #[repr(u8)] - #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] + /// The type of a filesystem object referenced by a descriptor. + /// + /// Note: This was called `filetype` in earlier versions of WASI. + #[derive(Clone)] pub enum DescriptorType { - Unknown, + /// The descriptor refers to a block device inode. BlockDevice, + /// The descriptor refers to a character device inode. CharacterDevice, + /// The descriptor refers to a directory inode. Directory, + /// The descriptor refers to a named pipe. Fifo, + /// The file refers to a symbolic link inode. SymbolicLink, + /// The descriptor refers to a regular file inode. RegularFile, + /// The descriptor refers to a socket. Socket, + /// The type of the descriptor or file is different from any of the + /// other types specified. + Other(Option<_rt::String>), } impl ::core::fmt::Debug for DescriptorType { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { - DescriptorType::Unknown => { - f.debug_tuple("DescriptorType::Unknown").finish() - }, DescriptorType::BlockDevice => { f.debug_tuple("DescriptorType::BlockDevice").finish() }, @@ -1252,68 +1722,109 @@ pub mod wasi { f.debug_tuple("DescriptorType::RegularFile").finish() }, DescriptorType::Socket => f.debug_tuple("DescriptorType::Socket").finish(), + DescriptorType::Other(e) => { + f.debug_tuple("DescriptorType::Other").field(e).finish() + }, } } } - - impl DescriptorType { - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> DescriptorType { - if !cfg!(debug_assertions) { - return unsafe { ::core::mem::transmute(val) }; - } - - match val { - 0 => DescriptorType::Unknown, - 1 => DescriptorType::BlockDevice, - 2 => DescriptorType::CharacterDevice, - 3 => DescriptorType::Directory, - 4 => DescriptorType::Fifo, - 5 => DescriptorType::SymbolicLink, - 6 => DescriptorType::RegularFile, - 7 => DescriptorType::Socket, - - _ => panic!("invalid enum discriminant"), - } - } - } - - wit_bindgen_rt::bitflags::bitflags! { + wit_bindgen::rt::bitflags::bitflags! { + /// Descriptor flags. + /// + /// Note: This was called `fdflags` in earlier versions of WASI. #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct DescriptorFlags: u8 { + /// Read mode: Data can be read. const READ = 1 << 0; + /// Write mode: Data can be written to. const WRITE = 1 << 1; + /// Request that writes be performed according to synchronized I/O file + /// integrity completion. The data stored in the file and the file's + /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. const FILE_INTEGRITY_SYNC = 1 << 2; + /// Request that writes be performed according to synchronized I/O data + /// integrity completion. Only the data stored in the file is + /// synchronized. This is similar to `O_DSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. const DATA_INTEGRITY_SYNC = 1 << 3; + /// Requests that reads be performed at the same level of integrity + /// requested for writes. This is similar to `O_RSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. const REQUESTED_WRITE_SYNC = 1 << 4; + /// Mutating directories mode: Directory contents may be mutated. + /// + /// When this flag is unset on a descriptor, operations using the + /// descriptor which would create, rename, delete, modify the data or + /// metadata of filesystem objects, or obtain another handle which + /// would permit any of those, shall fail with `error-code::read-only` if + /// they would otherwise succeed. + /// + /// This may only be set on directories. const MUTATE_DIRECTORY = 1 << 5; } } - wit_bindgen_rt::bitflags::bitflags! { + wit_bindgen::rt::bitflags::bitflags! { + /// Flags determining the method of how paths are resolved. #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct PathFlags: u8 { + /// As long as the resolved path corresponds to a symbolic link, it is + /// expanded. const SYMLINK_FOLLOW = 1 << 0; } } - wit_bindgen_rt::bitflags::bitflags! { + wit_bindgen::rt::bitflags::bitflags! { + /// Open flags used by `open-at`. #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct OpenFlags: u8 { + /// Create file if it does not exist, similar to `O_CREAT` in POSIX. const CREATE = 1 << 0; + /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. const DIRECTORY = 1 << 1; + /// Fail if file already exists, similar to `O_EXCL` in POSIX. const EXCLUSIVE = 1 << 2; + /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. const TRUNCATE = 1 << 3; } } + /// Number of hard links to an inode. pub type LinkCount = u64; - #[repr(C)] - #[derive(Clone, Copy)] + /// File attributes. + /// + /// Note: This was called `filestat` in earlier versions of WASI. + #[derive(Clone)] pub struct DescriptorStat { + /// File type. pub type_: DescriptorType, + /// Number of hard links to the file. pub link_count: LinkCount, + /// For regular files, the file size in bytes. For symbolic links, the + /// length in bytes of the pathname contained in the symbolic link. pub size: Filesize, - pub data_access_timestamp: Option, - pub data_modification_timestamp: Option, - pub status_change_timestamp: Option, + /// Last data access timestamp. + /// + /// If the `option` is none, the platform doesn't maintain an access + /// timestamp for this file. + pub data_access_timestamp: Option, + /// Last data modification timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// modification timestamp for this file. + pub data_modification_timestamp: Option, + /// Last file status-change timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// status-change timestamp for this file. + pub status_change_timestamp: Option, } impl ::core::fmt::Debug for DescriptorStat { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -1327,11 +1838,16 @@ pub mod wasi { .finish() } } + /// When setting a timestamp, this gives the value to set it to. #[derive(Clone, Copy)] pub enum NewTimestamp { + /// Leave the timestamp set to its previous value. NoChange, + /// Set the timestamp to the current time of the system clock associated + /// with the filesystem. Now, - Timestamp(Datetime), + /// Set the timestamp to the given value. + Timestamp(Instant), } impl ::core::fmt::Debug for NewTimestamp { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -1344,9 +1860,12 @@ pub mod wasi { } } } + /// A directory entry. #[derive(Clone)] pub struct DirectoryEntry { + /// The type of the file referred to by this directory entry. pub type_: DescriptorType, + /// The name of the object. pub name: _rt::String, } impl ::core::fmt::Debug for DirectoryEntry { @@ -1357,207 +1876,182 @@ pub mod wasi { .finish() } } - #[repr(u8)] - #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] + /// Error codes returned by functions, similar to `errno` in POSIX. + /// Not all of these error codes are returned by the functions provided by this + /// API; some are used in higher-level library layers, and others are provided + /// merely for alignment with POSIX. + #[derive(Clone)] pub enum ErrorCode { + /// Permission denied, similar to `EACCES` in POSIX. Access, - WouldBlock, + /// Connection already in progress, similar to `EALREADY` in POSIX. Already, + /// Bad descriptor, similar to `EBADF` in POSIX. BadDescriptor, + /// Device or resource busy, similar to `EBUSY` in POSIX. Busy, + /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. Deadlock, + /// Storage quota exceeded, similar to `EDQUOT` in POSIX. Quota, + /// File exists, similar to `EEXIST` in POSIX. Exist, + /// File too large, similar to `EFBIG` in POSIX. FileTooLarge, + /// Illegal byte sequence, similar to `EILSEQ` in POSIX. IllegalByteSequence, + /// Operation in progress, similar to `EINPROGRESS` in POSIX. InProgress, + /// Interrupted function, similar to `EINTR` in POSIX. Interrupted, + /// Invalid argument, similar to `EINVAL` in POSIX. Invalid, + /// I/O error, similar to `EIO` in POSIX. Io, + /// Is a directory, similar to `EISDIR` in POSIX. IsDirectory, + /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. Loop, + /// Too many links, similar to `EMLINK` in POSIX. TooManyLinks, + /// Message too large, similar to `EMSGSIZE` in POSIX. MessageSize, + /// Filename too long, similar to `ENAMETOOLONG` in POSIX. NameTooLong, + /// No such device, similar to `ENODEV` in POSIX. NoDevice, + /// No such file or directory, similar to `ENOENT` in POSIX. NoEntry, + /// No locks available, similar to `ENOLCK` in POSIX. NoLock, + /// Not enough space, similar to `ENOMEM` in POSIX. InsufficientMemory, + /// No space left on device, similar to `ENOSPC` in POSIX. InsufficientSpace, + /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. NotDirectory, + /// Directory not empty, similar to `ENOTEMPTY` in POSIX. NotEmpty, + /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. NotRecoverable, + /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. Unsupported, + /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. NoTty, + /// No such device or address, similar to `ENXIO` in POSIX. NoSuchDevice, + /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. Overflow, + /// Operation not permitted, similar to `EPERM` in POSIX. NotPermitted, + /// Broken pipe, similar to `EPIPE` in POSIX. Pipe, + /// Read-only file system, similar to `EROFS` in POSIX. ReadOnly, + /// Invalid seek, similar to `ESPIPE` in POSIX. InvalidSeek, + /// Text file busy, similar to `ETXTBSY` in POSIX. TextFileBusy, + /// Cross-device link, similar to `EXDEV` in POSIX. CrossDevice, - } - impl ErrorCode { - pub fn name(&self) -> &'static str { - match self { - ErrorCode::Access => "access", - ErrorCode::WouldBlock => "would-block", - ErrorCode::Already => "already", - ErrorCode::BadDescriptor => "bad-descriptor", - ErrorCode::Busy => "busy", - ErrorCode::Deadlock => "deadlock", - ErrorCode::Quota => "quota", - ErrorCode::Exist => "exist", - ErrorCode::FileTooLarge => "file-too-large", - ErrorCode::IllegalByteSequence => "illegal-byte-sequence", - ErrorCode::InProgress => "in-progress", - ErrorCode::Interrupted => "interrupted", - ErrorCode::Invalid => "invalid", - ErrorCode::Io => "io", - ErrorCode::IsDirectory => "is-directory", - ErrorCode::Loop => "loop", - ErrorCode::TooManyLinks => "too-many-links", - ErrorCode::MessageSize => "message-size", - ErrorCode::NameTooLong => "name-too-long", - ErrorCode::NoDevice => "no-device", - ErrorCode::NoEntry => "no-entry", - ErrorCode::NoLock => "no-lock", - ErrorCode::InsufficientMemory => "insufficient-memory", - ErrorCode::InsufficientSpace => "insufficient-space", - ErrorCode::NotDirectory => "not-directory", - ErrorCode::NotEmpty => "not-empty", - ErrorCode::NotRecoverable => "not-recoverable", - ErrorCode::Unsupported => "unsupported", - ErrorCode::NoTty => "no-tty", - ErrorCode::NoSuchDevice => "no-such-device", - ErrorCode::Overflow => "overflow", - ErrorCode::NotPermitted => "not-permitted", - ErrorCode::Pipe => "pipe", - ErrorCode::ReadOnly => "read-only", - ErrorCode::InvalidSeek => "invalid-seek", - ErrorCode::TextFileBusy => "text-file-busy", - ErrorCode::CrossDevice => "cross-device", - } - } - pub fn message(&self) -> &'static str { - match self { - ErrorCode::Access => "", - ErrorCode::WouldBlock => "", - ErrorCode::Already => "", - ErrorCode::BadDescriptor => "", - ErrorCode::Busy => "", - ErrorCode::Deadlock => "", - ErrorCode::Quota => "", - ErrorCode::Exist => "", - ErrorCode::FileTooLarge => "", - ErrorCode::IllegalByteSequence => "", - ErrorCode::InProgress => "", - ErrorCode::Interrupted => "", - ErrorCode::Invalid => "", - ErrorCode::Io => "", - ErrorCode::IsDirectory => "", - ErrorCode::Loop => "", - ErrorCode::TooManyLinks => "", - ErrorCode::MessageSize => "", - ErrorCode::NameTooLong => "", - ErrorCode::NoDevice => "", - ErrorCode::NoEntry => "", - ErrorCode::NoLock => "", - ErrorCode::InsufficientMemory => "", - ErrorCode::InsufficientSpace => "", - ErrorCode::NotDirectory => "", - ErrorCode::NotEmpty => "", - ErrorCode::NotRecoverable => "", - ErrorCode::Unsupported => "", - ErrorCode::NoTty => "", - ErrorCode::NoSuchDevice => "", - ErrorCode::Overflow => "", - ErrorCode::NotPermitted => "", - ErrorCode::Pipe => "", - ErrorCode::ReadOnly => "", - ErrorCode::InvalidSeek => "", - ErrorCode::TextFileBusy => "", - ErrorCode::CrossDevice => "", - } - } + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + Other(Option<_rt::String>), } impl ::core::fmt::Debug for ErrorCode { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() + match self { + ErrorCode::Access => f.debug_tuple("ErrorCode::Access").finish(), + ErrorCode::Already => f.debug_tuple("ErrorCode::Already").finish(), + ErrorCode::BadDescriptor => { + f.debug_tuple("ErrorCode::BadDescriptor").finish() + }, + ErrorCode::Busy => f.debug_tuple("ErrorCode::Busy").finish(), + ErrorCode::Deadlock => f.debug_tuple("ErrorCode::Deadlock").finish(), + ErrorCode::Quota => f.debug_tuple("ErrorCode::Quota").finish(), + ErrorCode::Exist => f.debug_tuple("ErrorCode::Exist").finish(), + ErrorCode::FileTooLarge => { + f.debug_tuple("ErrorCode::FileTooLarge").finish() + }, + ErrorCode::IllegalByteSequence => { + f.debug_tuple("ErrorCode::IllegalByteSequence").finish() + }, + ErrorCode::InProgress => f.debug_tuple("ErrorCode::InProgress").finish(), + ErrorCode::Interrupted => f.debug_tuple("ErrorCode::Interrupted").finish(), + ErrorCode::Invalid => f.debug_tuple("ErrorCode::Invalid").finish(), + ErrorCode::Io => f.debug_tuple("ErrorCode::Io").finish(), + ErrorCode::IsDirectory => f.debug_tuple("ErrorCode::IsDirectory").finish(), + ErrorCode::Loop => f.debug_tuple("ErrorCode::Loop").finish(), + ErrorCode::TooManyLinks => { + f.debug_tuple("ErrorCode::TooManyLinks").finish() + }, + ErrorCode::MessageSize => f.debug_tuple("ErrorCode::MessageSize").finish(), + ErrorCode::NameTooLong => f.debug_tuple("ErrorCode::NameTooLong").finish(), + ErrorCode::NoDevice => f.debug_tuple("ErrorCode::NoDevice").finish(), + ErrorCode::NoEntry => f.debug_tuple("ErrorCode::NoEntry").finish(), + ErrorCode::NoLock => f.debug_tuple("ErrorCode::NoLock").finish(), + ErrorCode::InsufficientMemory => { + f.debug_tuple("ErrorCode::InsufficientMemory").finish() + }, + ErrorCode::InsufficientSpace => { + f.debug_tuple("ErrorCode::InsufficientSpace").finish() + }, + ErrorCode::NotDirectory => { + f.debug_tuple("ErrorCode::NotDirectory").finish() + }, + ErrorCode::NotEmpty => f.debug_tuple("ErrorCode::NotEmpty").finish(), + ErrorCode::NotRecoverable => { + f.debug_tuple("ErrorCode::NotRecoverable").finish() + }, + ErrorCode::Unsupported => f.debug_tuple("ErrorCode::Unsupported").finish(), + ErrorCode::NoTty => f.debug_tuple("ErrorCode::NoTty").finish(), + ErrorCode::NoSuchDevice => { + f.debug_tuple("ErrorCode::NoSuchDevice").finish() + }, + ErrorCode::Overflow => f.debug_tuple("ErrorCode::Overflow").finish(), + ErrorCode::NotPermitted => { + f.debug_tuple("ErrorCode::NotPermitted").finish() + }, + ErrorCode::Pipe => f.debug_tuple("ErrorCode::Pipe").finish(), + ErrorCode::ReadOnly => f.debug_tuple("ErrorCode::ReadOnly").finish(), + ErrorCode::InvalidSeek => f.debug_tuple("ErrorCode::InvalidSeek").finish(), + ErrorCode::TextFileBusy => { + f.debug_tuple("ErrorCode::TextFileBusy").finish() + }, + ErrorCode::CrossDevice => f.debug_tuple("ErrorCode::CrossDevice").finish(), + ErrorCode::Other(e) => f.debug_tuple("ErrorCode::Other").field(e).finish(), + } } } impl ::core::fmt::Display for ErrorCode { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for ErrorCode {} - - impl ErrorCode { - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> ErrorCode { - if !cfg!(debug_assertions) { - return unsafe { ::core::mem::transmute(val) }; - } - - match val { - 0 => ErrorCode::Access, - 1 => ErrorCode::WouldBlock, - 2 => ErrorCode::Already, - 3 => ErrorCode::BadDescriptor, - 4 => ErrorCode::Busy, - 5 => ErrorCode::Deadlock, - 6 => ErrorCode::Quota, - 7 => ErrorCode::Exist, - 8 => ErrorCode::FileTooLarge, - 9 => ErrorCode::IllegalByteSequence, - 10 => ErrorCode::InProgress, - 11 => ErrorCode::Interrupted, - 12 => ErrorCode::Invalid, - 13 => ErrorCode::Io, - 14 => ErrorCode::IsDirectory, - 15 => ErrorCode::Loop, - 16 => ErrorCode::TooManyLinks, - 17 => ErrorCode::MessageSize, - 18 => ErrorCode::NameTooLong, - 19 => ErrorCode::NoDevice, - 20 => ErrorCode::NoEntry, - 21 => ErrorCode::NoLock, - 22 => ErrorCode::InsufficientMemory, - 23 => ErrorCode::InsufficientSpace, - 24 => ErrorCode::NotDirectory, - 25 => ErrorCode::NotEmpty, - 26 => ErrorCode::NotRecoverable, - 27 => ErrorCode::Unsupported, - 28 => ErrorCode::NoTty, - 29 => ErrorCode::NoSuchDevice, - 30 => ErrorCode::Overflow, - 31 => ErrorCode::NotPermitted, - 32 => ErrorCode::Pipe, - 33 => ErrorCode::ReadOnly, - 34 => ErrorCode::InvalidSeek, - 35 => ErrorCode::TextFileBusy, - 36 => ErrorCode::CrossDevice, - - _ => panic!("invalid enum discriminant"), - } + write!(f, "{:?}", self) } } + impl ::core::error::Error for ErrorCode {} + /// File or memory access pattern advisory information. #[repr(u8)] #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum Advice { + /// The application has no advice to give on its behavior with respect + /// to the specified data. Normal, + /// The application expects to access the specified data sequentially + /// from lower offsets to higher offsets. Sequential, + /// The application expects to access the specified data in a random + /// order. Random, + /// The application expects to access the specified data in the near + /// future. WillNeed, + /// The application expects that it will not access the specified data + /// in the near future. DontNeed, + /// The application expects to access the specified data once and then + /// not reuse it thereafter. NoReuse, } impl ::core::fmt::Debug for Advice { @@ -1593,10 +2087,14 @@ pub mod wasi { } } + /// A 128-bit hash value, split into parts because wasm doesn't have a + /// 128-bit integer type. #[repr(C)] #[derive(Clone, Copy)] pub struct MetadataHashValue { + /// 64 bits of a 128-bit hash value. pub lower: u64, + /// Another 64 bits of a 128-bit hash value. pub upper: u64, } impl ::core::fmt::Debug for MetadataHashValue { @@ -1607,6 +2105,9 @@ pub mod wasi { .finish() } } + /// A descriptor is a reference to a filesystem object, which may be a file, + /// directory, named pipe, special file, or other object on which filesystem + /// calls may be made. #[derive(Debug)] #[repr(transparent)] @@ -1635,7 +2136,7 @@ pub mod wasi { #[inline] unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[resource-drop]descriptor"] fn drop(_: i32); @@ -1652,61 +2153,39 @@ pub mod wasi { } } - #[derive(Debug)] - #[repr(transparent)] - pub struct DirectoryEntryStream { - handle: _rt::Resource, - } - - impl DirectoryEntryStream { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for DirectoryEntryStream { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]directory-entry-stream"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return a stream for reading from a file. + /// + /// Multiple read, write, and append streams may be active on the same open + /// file and they do not interfere with each other. + /// + /// This function returns a `stream` which provides the data received from the + /// file, and a `future` providing additional error information in case an + /// error is encountered. + /// + /// If no error is encountered, `stream.read` on the `stream` will return + /// `read-status::closed` with no `error-context` and the future resolves to + /// the value `ok`. If an error is encountered, `stream.read` on the + /// `stream` returns `read-status::closed` with an `error-context` and the future + /// resolves to `err` with an `error-code`. + /// + /// Note: This is similar to `pread` in POSIX. #[allow(async_fn_in_trait)] - pub fn read_via_stream(&self, offset: Filesize) -> Result { + pub fn read_via_stream( + &self, + offset: Filesize, + ) -> ( + wit_bindgen::rt::async_support::StreamReader, + wit_bindgen::rt::async_support::FutureReader>, + ) { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 8]); let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[method]descriptor.read-via-stream"] fn wit_import1(_: i32, _: i64, _: *mut u8); @@ -1717,603 +2196,1332 @@ pub mod wasi { unreachable!() } wit_import1((self).handle() as i32, _rt::as_i64(offset), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::InputStream::from_handle( - l3 as u32, - ) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(4).cast::(); + let result4 = (wit_bindgen::rt::async_support::StreamReader::new(l2 as u32, &::VTABLE), wit_bindgen::rt::async_support::FutureReader::new(l3 as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE)); + result4 } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return a stream for writing to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be written. + /// + /// It is valid to write past the end of a file; the file is extended to the + /// extent of the write, with bytes between the previous end and the start of + /// the write set to zero. + /// + /// This function returns once either full contents of the stream are + /// written or an error is encountered. + /// + /// Note: This is similar to `pwrite` in POSIX. #[allow(async_fn_in_trait)] pub fn write_via_stream( &self, + data: wit_bindgen::rt::async_support::StreamReader, offset: Filesize, - ) -> Result { + ) -> wit_bindgen::rt::async_support::FutureReader> + { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[method]descriptor.write-via-stream"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + fn wit_import0(_: i32, _: i32, _: i64) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import0(_: i32, _: i32, _: i64) -> i32 { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(offset), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l3 as u32) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + let ret = wit_import0( + (self).handle() as i32, + (&data).take_handle() as i32, + _rt::as_i64(offset), + ); + wit_bindgen::rt::async_support::FutureReader::new(ret as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE) } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return a stream for appending to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be appended. + /// + /// This function returns once either full contents of the stream are + /// written or an error is encountered. + /// + /// Note: This is similar to `write` with `O_APPEND` in POSIX. #[allow(async_fn_in_trait)] - pub fn append_via_stream(&self) -> Result { + pub fn append_via_stream( + &self, + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> + { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[method]descriptor.append-via-stream"] - fn wit_import1(_: i32, _: *mut u8); + fn wit_import0(_: i32, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import0(_: i32, _: i32) -> i32 { unreachable!() } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l3 as u32) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + let ret = wit_import0((self).handle() as i32, (&data).take_handle() as i32); + wit_bindgen::rt::async_support::FutureReader::new(ret as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE) } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Provide file advisory information on a descriptor. + /// + /// This is similar to `posix_fadvise` in POSIX. #[allow(async_fn_in_trait)] - pub fn advise( + pub async fn advise( &self, offset: Filesize, length: Filesize, advice: Advice, ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.advise"] - fn wit_import1(_: i32, _: i64, _: i64, _: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, i64, i64, i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1( - _: i32, - _: i64, - _: i64, - _: i32, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1( - (self).handle() as i32, - _rt::as_i64(offset), - _rt::as_i64(length), - advice.clone() as i32, - ptr0, - ); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, Filesize, Filesize, Advice); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l3 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn sync_data(&self) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.sync-data"] - fn wit_import1(_: i32, _: *mut u8); - } + fn results_offset(&mut self) -> usize { + 0 + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.advise"] + fn call(_: i32, _: i64, _: i64, _: i32, _: *mut u8) -> i32; + } - ErrorCode::_lift(l3 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: i64, + _: i64, + _: i32, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { + call(_params.0, _params.1, _params.2, _params.3, _results) + as u32 + } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2, _lower3): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + ParamsLower( + (_lower0).handle() as i32, + _rt::as_i64(_lower1), + _rt::as_i64(_lower2), + _lower3.clone() as i32, + ) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, offset, length, advice)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fdatasync` in POSIX. #[allow(async_fn_in_trait)] - pub fn get_flags(&self) -> Result { + pub async fn sync_data(&self) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.get-flags"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - DescriptorFlags::empty() - | DescriptorFlags::from_bits_retain(((l3 as u8) << 0) as _) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(1).cast::()); + fn results_offset(&mut self) -> usize { + 0 + } - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.sync-data"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Get flags associated with a descriptor. + /// + /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + /// + /// Note: This returns the value that was the `fs_flags` value returned + /// from `fdstat_get` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn get_type(&self) -> Result { + pub async fn get_flags(&self) -> Result { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.get-type"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - DescriptorType::_lift(l3 as u8) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(1).cast::()); + fn results_offset(&mut self) -> usize { + 0 + } - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.get-flags"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + + DescriptorFlags::empty() + | DescriptorFlags::from_bits_retain( + ((l1 as u8) << 0) as _, + ) + }; + Ok(e) + }, + 1 => { + let e = { + let l2 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v7 = match l2 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e7 = { + let l3 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l3 { + 0 => None, + 1 => { + let e = { + let l4 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l5 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e7) + }, + }; + + v7 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Get the dynamic type of a descriptor. + /// + /// Note: This returns the same value as the `type` field of the `fd-stat` + /// returned by `stat`, `stat-at` and similar. + /// + /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided + /// by `fstat` in POSIX. + /// + /// Note: This returns the value that was the `fs_filetype` value returned + /// from `fdstat_get` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn set_size(&self, size: Filesize) -> Result<(), ErrorCode> { + pub async fn get_type(&self) -> Result { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.set-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, _rt::as_i64(size), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l3 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_times( - &self, - data_access_timestamp: NewTimestamp, - data_modification_timestamp: NewTimestamp, - ) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let (result1_0, result1_1, result1_2) = match data_access_timestamp { - NewTimestamp::NoChange => (0i32, 0i64, 0i32), - NewTimestamp::Now => (1i32, 0i64, 0i32), - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: seconds0, - nanoseconds: nanoseconds0, - } = e; + fn results_offset(&mut self) -> usize { + 0 + } - (2i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) - }, - }; - let (result3_0, result3_1, result3_2) = match data_modification_timestamp { - NewTimestamp::NoChange => (0i32, 0i64, 0i32), - NewTimestamp::Now => (1i32, 0i64, 0i32), - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: seconds2, - nanoseconds: nanoseconds2, - } = e; + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.get-type"] + fn call(_: i32, _: *mut u8) -> i32; + } - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) - }, - }; - let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.set-times"] - fn wit_import5( - _: i32, - _: i32, - _: i64, - _: i32, - _: i32, - _: i64, - _: i32, - _: *mut u8, - ); - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import5( - _: i32, - _: i32, - _: i64, - _: i32, - _: i32, - _: i64, - _: i32, - _: *mut u8, - ) { - unreachable!() - } - wit_import5( - (self).handle() as i32, - result1_0, - result1_1, - result1_2, - result3_0, - result3_1, - result3_2, - ptr4, - ); - let l6 = i32::from(*ptr4.add(0).cast::()); - let result8 = match l6 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l7 = i32::from(*ptr4.add(1).cast::()); + unsafe { call(_params.0, _results) as u32 } + } - ErrorCode::_lift(l7 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result8 + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => DescriptorType::BlockDevice, + 1 => DescriptorType::CharacterDevice, + 2 => DescriptorType::Directory, + 3 => DescriptorType::Fifo, + 4 => DescriptorType::SymbolicLink, + 5 => DescriptorType::RegularFile, + 6 => DescriptorType::Socket, + n => { + debug_assert_eq!( + n, 7, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + DescriptorType::Other(e6) + }, + }; + + v6 + }; + Ok(e) + }, + 1 => { + let e = { + let l7 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v12 = match l7 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e12 = { + let l8 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l8 { + 0 => None, + 1 => { + let e = { + let l9 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l10 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len11 = l10; + let bytes11 = _rt::Vec::from_raw_parts(l9.cast(), len11, len11); + + _rt::string_lift(bytes11) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e12) + }, + }; + + v12 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Adjust the size of an open file. If this increases the file's size, the + /// extra bytes are filled with zeros. + /// + /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn read( - &self, - length: Filesize, - offset: Filesize, - ) -> Result<(_rt::Vec, bool), ErrorCode> { + pub async fn set_size(&self, size: Filesize) -> Result<(), ErrorCode> { unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 4 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 4 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.read"] - fn wit_import1(_: i32, _: i64, _: i64, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, i64); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: i64, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1( - (self).handle() as i32, - _rt::as_i64(length), - _rt::as_i64(offset), - ptr0, - ); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result8 = match l2 { - 0 => { - let e = { - let l3 = *ptr0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l4 = *ptr0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let len5 = l4; - let l6 = i32::from( - *ptr0 - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::(), - ); - - ( - _rt::Vec::from_raw_parts(l3.cast(), len5, len5), - _rt::bool_lift(l6 as u8), + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, Filesize); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), ) - }; - Ok(e) - }, - 1 => { - let e = { - let l7 = i32::from( - *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), - ); + } + } - ErrorCode::_lift(l7 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result8 + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.set-size"] + fn call(_: i32, _: i64, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: i64, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + ParamsLower((_lower0).handle() as i32, _rt::as_i64(_lower1)) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, size)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of an open file or directory. + /// + /// Note: This is similar to `futimens` in POSIX. + /// + /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn write( + pub async fn set_times( &self, - buffer: &[u8], - offset: Filesize, - ) -> Result { + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let vec0 = buffer; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.write"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2( - _: i32, - _: *mut u8, - _: usize, - _: i64, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import2( - (self).handle() as i32, - ptr0.cast_mut(), - len0, - _rt::as_i64(offset), - ptr1, - ); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result6 = match l3 { - 0 => { - let e = { - let l4 = *ptr1.add(8).cast::(); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, NewTimestamp, NewTimestamp); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (64 + 4 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } - l4 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr1.add(8).cast::()); + fn results_offset(&mut self) -> usize { + 56 + } - ErrorCode::_lift(l5 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.set-times"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = unsafe { _ptr.add(8) }; + unsafe { + match _lower1 { + NewTimestamp::NoChange => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + }, + NewTimestamp::Now => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + }, + NewTimestamp::Timestamp(e) => { + *_param_ptr.add(0).cast::() = (2i32) as u8; + let super::super::super::wasi::clocks::system_clock::Instant{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + *_param_ptr.add(8).cast::() = + _rt::as_i64(seconds0); + *_param_ptr.add(16).cast::() = + _rt::as_i32(nanoseconds0); + }, + } + } + let _param_ptr = unsafe { _ptr.add(32) }; + unsafe { + match _lower2 { + NewTimestamp::NoChange => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + }, + NewTimestamp::Now => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + }, + NewTimestamp::Timestamp(e) => { + *_param_ptr.add(0).cast::() = (2i32) as u8; + let super::super::super::wasi::clocks::system_clock::Instant{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + *_param_ptr.add(8).cast::() = + _rt::as_i64(seconds0); + *_param_ptr.add(16).cast::() = + _rt::as_i32(nanoseconds0); + }, + } + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, data_access_timestamp, data_modification_timestamp)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Read directory entries from a directory. + /// + /// On filesystems where directories contain entries referring to themselves + /// and their parents, often named `.` and `..` respectively, these entries + /// are omitted. + /// + /// This always returns a new stream which starts at the beginning of the + /// directory. Multiple streams may be active on the same directory, and they + /// do not interfere with each other. + /// + /// This function returns a future, which will resolve to an error code if + /// reading full contents of the directory fails. #[allow(async_fn_in_trait)] - pub fn read_directory(&self) -> Result { + pub fn read_directory( + &self, + ) -> ( + wit_bindgen::rt::async_support::StreamReader, + wit_bindgen::rt::async_support::FutureReader>, + ) { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 8]); let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { #[link_name = "[method]descriptor.read-directory"] fn wit_import1(_: i32, _: *mut u8); @@ -2324,1188 +3532,3459 @@ pub mod wasi { unreachable!() } wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - DirectoryEntryStream::from_handle(l3 as u32) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(4).cast::(); + let result4 = (wit_bindgen::rt::async_support::StreamReader::new(l2 as u32, &::VTABLE), wit_bindgen::rt::async_support::FutureReader::new(l3 as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE)); + result4 } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data and metadata of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fsync` in POSIX. #[allow(async_fn_in_trait)] - pub fn sync(&self) -> Result<(), ErrorCode> { + pub async fn sync(&self) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.sync"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l3 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.sync"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Create a directory. + /// + /// Note: This is similar to `mkdirat` in POSIX. #[allow(async_fn_in_trait)] - pub fn create_directory_at(&self, path: &str) -> Result<(), ErrorCode> { + pub async fn create_directory_at( + &self, + path: _rt::String, + ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.create-directory-at"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result5 = match l3 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, _rt::String); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.create-directory-at"] + fn call(_: i32, _: *mut u8, _: usize, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _params.2, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + ParamsLower((_lower0).handle() as i32, ptr0.cast_mut(), len0) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, path)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of an open file or directory. + /// + /// Note: This is similar to `fstat` in POSIX, except that it does not return + /// device and inode information. For testing whether two descriptors refer to + /// the same underlying filesystem object, use `is-same-object`. To obtain + /// additional data that can be used do determine whether a file has been + /// modified, use `metadata-hash`. + /// + /// Note: This was called `fd_filestat_get` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn stat(&self) -> Result { + pub async fn stat(&self) -> Result { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 104]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.stat"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result16 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let l4 = *ptr0.add(16).cast::(); - let l5 = *ptr0.add(24).cast::(); - let l6 = i32::from(*ptr0.add(32).cast::()); - let l9 = i32::from(*ptr0.add(56).cast::()); - let l12 = i32::from(*ptr0.add(80).cast::()); - - DescriptorStat { - type_: DescriptorType::_lift(l3 as u8), - link_count: l4 as u64, - size: l5 as u64, - data_access_timestamp: match l6 { - 0 => None, - 1 => { - let e = { - let l7 = *ptr0.add(40).cast::(); - let l8 = *ptr0.add(48).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l7 as u64, - nanoseconds: l8 as u32, - } - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l9 { - 0 => None, - 1 => { - let e = { - let l10 = *ptr0.add(64).cast::(); - let l11 = *ptr0.add(72).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l10 as u64, - nanoseconds: l11 as u32, - } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (96 + 4 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } + + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.stat"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = i32::from(*_ptr.add(8).cast::()); + let v6 = match l1 { + 0 => DescriptorType::BlockDevice, + 1 => DescriptorType::CharacterDevice, + 2 => DescriptorType::Directory, + 3 => DescriptorType::Fifo, + 4 => DescriptorType::SymbolicLink, + 5 => DescriptorType::RegularFile, + 6 => DescriptorType::Socket, + n => { + debug_assert_eq!( + n, 7, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + DescriptorType::Other(e6) + }, }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), + let l7 = *_ptr + .add( + 8 + 4 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l8 = *_ptr + .add( + 16 + 4 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); + let l9 = i32::from( + *_ptr + .add( + 24 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *_ptr + .add( + 48 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *_ptr + .add( + 72 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + DescriptorStat { + type_: v6, + link_count: l7 as u64, + size: l8 as u64, + data_access_timestamp: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = *_ptr.add(32+4*::core::mem::size_of::<*const u8>()).cast::(); + let l11 = *_ptr.add(40+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l10, + nanoseconds: l11 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = *_ptr.add(56+4*::core::mem::size_of::<*const u8>()).cast::(); + let l14 = *_ptr.add(64+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l13, + nanoseconds: l14 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *_ptr.add(80+4*::core::mem::size_of::<*const u8>()).cast::(); + let l17 = *_ptr.add(88+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l16, + nanoseconds: l17 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) }, - status_change_timestamp: match l12 { - 0 => None, - 1 => { - let e = { - let l13 = *ptr0.add(88).cast::(); - let l14 = *ptr0.add(96).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l13 as u64, - nanoseconds: l14 as u32, - } + 1 => { + let e = { + let l18 = i32::from(*_ptr.add(8).cast::()); + let v23 = match l18 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e23 = { + let l19 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l21 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts(l20.cast(), len22, len22); + + _rt::string_lift(bytes22) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e23) + }, }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), + + v23 + }; + Err(e) }, + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - }, - 1 => { - let e = { - let l15 = i32::from(*ptr0.add(8).cast::()); - - ErrorCode::_lift(l15 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result16 + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of a file or directory. + /// + /// Note: This is similar to `fstatat` in POSIX, except that it does not + /// return device and inode information. See the `stat` description for a + /// discussion of alternatives. + /// + /// Note: This was called `path_filestat_get` in earlier versions of WASI. #[allow(async_fn_in_trait)] - pub fn stat_at( + pub async fn stat_at( &self, path_flags: PathFlags, - path: &str, + path: _rt::String, ) -> Result { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 104]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.stat-at"] - fn wit_import3(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import3( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import3( - (self).handle() as i32, - (flags0.bits() >> 0) as i32, - ptr1.cast_mut(), - len1, - ptr2, - ); - let l4 = i32::from(*ptr2.add(0).cast::()); - let result18 = match l4 { - 0 => { - let e = { - let l5 = i32::from(*ptr2.add(8).cast::()); - let l6 = *ptr2.add(16).cast::(); - let l7 = *ptr2.add(24).cast::(); - let l8 = i32::from(*ptr2.add(32).cast::()); - let l11 = i32::from(*ptr2.add(56).cast::()); - let l14 = i32::from(*ptr2.add(80).cast::()); - - DescriptorStat { - type_: DescriptorType::_lift(l5 as u8), - link_count: l6 as u64, - size: l7 as u64, - data_access_timestamp: match l8 { - 0 => None, - 1 => { - let e = { - let l9 = *ptr2.add(40).cast::(); - let l10 = *ptr2.add(48).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l9 as u64, - nanoseconds: l10 as u32, - } - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *ptr2.add(64).cast::(); - let l13 = *ptr2.add(72).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l12 as u64, - nanoseconds: l13 as u32, - } - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - }, - status_change_timestamp: match l14 { - 0 => None, - 1 => { - let e = { - let l15 = *ptr2.add(88).cast::(); - let l16 = *ptr2.add(96).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l15 as u64, - nanoseconds: l16 as u32, - } - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Ok(e) - }, - 1 => { - let e = { - let l17 = i32::from(*ptr2.add(8).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, PathFlags, _rt::String); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (96 + 4 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } - ErrorCode::_lift(l17 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result18 + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.stat-at"] + fn call( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { + call(_params.0, _params.1, _params.2, _params.3, _results) + as u32 + } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.2, _params.3, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.2, _params.3, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let flags0 = _lower1; + let vec1 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + ::core::mem::forget(vec1); + ParamsLower( + (_lower0).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + ) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = i32::from(*_ptr.add(8).cast::()); + let v6 = match l1 { + 0 => DescriptorType::BlockDevice, + 1 => DescriptorType::CharacterDevice, + 2 => DescriptorType::Directory, + 3 => DescriptorType::Fifo, + 4 => DescriptorType::SymbolicLink, + 5 => DescriptorType::RegularFile, + 6 => DescriptorType::Socket, + n => { + debug_assert_eq!( + n, 7, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + DescriptorType::Other(e6) + }, + }; + let l7 = *_ptr + .add( + 8 + 4 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l8 = *_ptr + .add( + 16 + 4 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); + let l9 = i32::from( + *_ptr + .add( + 24 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *_ptr + .add( + 48 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *_ptr + .add( + 72 + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + DescriptorStat { + type_: v6, + link_count: l7 as u64, + size: l8 as u64, + data_access_timestamp: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = *_ptr.add(32+4*::core::mem::size_of::<*const u8>()).cast::(); + let l11 = *_ptr.add(40+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l10, + nanoseconds: l11 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = *_ptr.add(56+4*::core::mem::size_of::<*const u8>()).cast::(); + let l14 = *_ptr.add(64+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l13, + nanoseconds: l14 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *_ptr.add(80+4*::core::mem::size_of::<*const u8>()).cast::(); + let l17 = *_ptr.add(88+4*::core::mem::size_of::<*const u8>()).cast::(); + + super::super::super::wasi::clocks::system_clock::Instant{ + seconds: l16, + nanoseconds: l17 as u32, + } + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) + }, + 1 => { + let e = { + let l18 = i32::from(*_ptr.add(8).cast::()); + let v23 = match l18 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e23 = { + let l19 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l21 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts(l20.cast(), len22, len22); + + _rt::string_lift(bytes22) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e23) + }, + }; + + v23 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, path_flags, path)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of a file or directory. + /// + /// Note: This is similar to `utimensat` in POSIX. + /// + /// Note: This was called `path_filestat_set_times` in earlier versions of + /// WASI. #[allow(async_fn_in_trait)] - pub fn set_times_at( + pub async fn set_times_at( &self, path_flags: PathFlags, - path: &str, + path: _rt::String, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let (result3_0, result3_1, result3_2) = match data_access_timestamp { - NewTimestamp::NoChange => (0i32, 0i64, 0i32), - NewTimestamp::Now => (1i32, 0i64, 0i32), - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: seconds2, - nanoseconds: nanoseconds2, - } = e; - - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) - }, - }; - let (result5_0, result5_1, result5_2) = match data_modification_timestamp { - NewTimestamp::NoChange => (0i32, 0i64, 0i32), - NewTimestamp::Now => (1i32, 0i64, 0i32), - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: seconds4, - nanoseconds: nanoseconds4, - } = e; + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - (2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4)) - }, - }; - let ptr6 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.set-times-at"] - fn wit_import7( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: i64, - _: i32, - _: i32, - _: i64, - _: i32, - _: *mut u8, - ); + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = ( + &'a Descriptor, + PathFlags, + _rt::String, + NewTimestamp, + NewTimestamp, + ); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (64 + 6 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import7( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: i64, - _: i32, - _: i32, - _: i64, - _: i32, - _: *mut u8, - ) { - unreachable!() - } - wit_import7( - (self).handle() as i32, - (flags0.bits() >> 0) as i32, - ptr1.cast_mut(), - len1, - result3_0, - result3_1, - result3_2, - result5_0, - result5_1, - result5_2, - ptr6, - ); - let l8 = i32::from(*ptr6.add(0).cast::()); - let result10 = match l8 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l9 = i32::from(*ptr6.add(1).cast::()); + fn results_offset(&mut self) -> usize { + (56 + 2 * ::core::mem::size_of::<*const u8>()) + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.set-times-at"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } - ErrorCode::_lift(l9 as u8) + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2, _lower3, _lower4): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = unsafe { _ptr.add(4) }; + unsafe { + let flags0 = _lower1; + *_param_ptr.add(0).cast::() = + ((flags0.bits() >> 0) as i32) as u8; + } + let _param_ptr = unsafe { _ptr.add(8) }; + unsafe { + let vec0 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = unsafe { + _ptr.add((8 + 2 * ::core::mem::size_of::<*const u8>())) }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result10 + unsafe { + match _lower3 { + NewTimestamp::NoChange => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + }, + NewTimestamp::Now => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + }, + NewTimestamp::Timestamp(e) => { + *_param_ptr.add(0).cast::() = (2i32) as u8; + let super::super::super::wasi::clocks::system_clock::Instant{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + *_param_ptr.add(8).cast::() = + _rt::as_i64(seconds0); + *_param_ptr.add(16).cast::() = + _rt::as_i32(nanoseconds0); + }, + } + } + let _param_ptr = unsafe { + _ptr.add((32 + 2 * ::core::mem::size_of::<*const u8>())) + }; + unsafe { + match _lower4 { + NewTimestamp::NoChange => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + }, + NewTimestamp::Now => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + }, + NewTimestamp::Timestamp(e) => { + *_param_ptr.add(0).cast::() = (2i32) as u8; + let super::super::super::wasi::clocks::system_clock::Instant{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + *_param_ptr.add(8).cast::() = + _rt::as_i64(seconds0); + *_param_ptr.add(16).cast::() = + _rt::as_i32(nanoseconds0); + }, + } + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call(( + self, + path_flags, + path, + data_access_timestamp, + data_modification_timestamp, + )) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Create a hard link. + /// + /// Fails with `error-code::no-entry` if the old path does not exist, + /// with `error-code::exist` if the new path already exists, and + /// `error-code::not-permitted` if the old path is not a file. + /// + /// Note: This is similar to `linkat` in POSIX. #[allow(async_fn_in_trait)] - pub fn link_at( + pub async fn link_at( &self, old_path_flags: PathFlags, - old_path: &str, + old_path: _rt::String, new_descriptor: &Descriptor, - new_path: &str, + new_path: _rt::String, ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let flags0 = old_path_flags; - let vec1 = old_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = new_path; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.link-at"] - fn wit_import4( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ); - } + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import4( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import4( - (self).handle() as i32, - (flags0.bits() >> 0) as i32, - ptr1.cast_mut(), - len1, - (new_descriptor).handle() as i32, - ptr2.cast_mut(), - len2, - ptr3, - ); - let l5 = i32::from(*ptr3.add(0).cast::()); - let result7 = match l5 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l6 = i32::from(*ptr3.add(1).cast::()); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result7 - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn open_at( - &self, - path_flags: PathFlags, - path: &str, - open_flags: OpenFlags, - flags: DescriptorFlags, - ) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let flags2 = open_flags; - let flags3 = flags; - let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.open-at"] - fn wit_import5( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: i32, - _: *mut u8, + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = ( + &'a Descriptor, + PathFlags, + _rt::String, + &'a Descriptor, + _rt::String, ); - } + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (8 + 10 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import5( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: i32, - _: *mut u8, - ) { - unreachable!() - } - wit_import5( - (self).handle() as i32, - (flags0.bits() >> 0) as i32, - ptr1.cast_mut(), - len1, - (flags2.bits() >> 0) as i32, - (flags3.bits() >> 0) as i32, - ptr4, - ); - let l6 = i32::from(*ptr4.add(0).cast::()); - let result9 = match l6 { - 0 => { - let e = { - let l7 = *ptr4.add(4).cast::(); + fn results_offset(&mut self) -> usize { + (8 + 5 * ::core::mem::size_of::<*const u8>()) + } - Descriptor::from_handle(l7 as u32) - }; - Ok(e) - }, - 1 => { - let e = { - let l8 = i32::from(*ptr4.add(4).cast::()); + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.link-at"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } - ErrorCode::_lift(l8 as u8) + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(8 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(8 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(8 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(8 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2, _lower3, _lower4): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = unsafe { _ptr.add(4) }; + unsafe { + let flags0 = _lower1; + *_param_ptr.add(0).cast::() = + ((flags0.bits() >> 0) as i32) as u8; + } + let _param_ptr = unsafe { _ptr.add(8) }; + unsafe { + let vec0 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = unsafe { + _ptr.add((8 + 2 * ::core::mem::size_of::<*const u8>())) }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result9 + unsafe { + *_param_ptr.add(0).cast::() = (_lower3).handle() as i32; + } + let _param_ptr = unsafe { + _ptr.add((8 + 3 * ::core::mem::size_of::<*const u8>())) + }; + unsafe { + let vec0 = (_lower4.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, old_path_flags, old_path, new_descriptor, new_path)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Open a file or directory. + /// + /// If `flags` contains `descriptor-flags::mutate-directory`, and the base + /// descriptor doesn't have `descriptor-flags::mutate-directory` set, + /// `open-at` fails with `error-code::read-only`. + /// + /// If `flags` contains `write` or `mutate-directory`, or `open-flags` + /// contains `truncate` or `create`, and the base descriptor doesn't have + /// `descriptor-flags::mutate-directory` set, `open-at` fails with + /// `error-code::read-only`. + /// + /// Note: This is similar to `openat` in POSIX. #[allow(async_fn_in_trait)] - pub fn readlink_at(&self, path: &str) -> Result<_rt::String, ErrorCode> { + pub async fn open_at( + &self, + path_flags: PathFlags, + path: _rt::String, + open_flags: OpenFlags, + flags: DescriptorFlags, + ) -> Result { unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 3 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 3 * ::core::mem::size_of::<*const u8>()], - ); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.readlink-at"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result8 = match l3 { - 0 => { - let e = { - let l4 = *ptr1 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l5 = *ptr1 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = ( + &'a Descriptor, + PathFlags, + _rt::String, + OpenFlags, + DescriptorFlags, + ); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (8 + 8 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - _rt::string_lift(bytes6) - }; - Ok(e) - }, - 1 => { - let e = { - let l7 = i32::from( - *ptr1.add(::core::mem::size_of::<*const u8>()).cast::(), - ); + fn results_offset(&mut self) -> usize { + (8 + 3 * ::core::mem::size_of::<*const u8>()) + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.open-at"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } - ErrorCode::_lift(l7 as u8) + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params.0.add(8).cast::<*mut u8>(); + let l1 = *_params + .0 + .add(8 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2, _lower3, _lower4): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = unsafe { _ptr.add(4) }; + unsafe { + let flags0 = _lower1; + *_param_ptr.add(0).cast::() = + ((flags0.bits() >> 0) as i32) as u8; + } + let _param_ptr = unsafe { _ptr.add(8) }; + unsafe { + let vec0 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = unsafe { + _ptr.add((8 + 2 * ::core::mem::size_of::<*const u8>())) }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result8 + unsafe { + let flags0 = _lower3; + *_param_ptr.add(0).cast::() = + ((flags0.bits() >> 0) as i32) as u8; + } + let _param_ptr = unsafe { + _ptr.add((9 + 2 * ::core::mem::size_of::<*const u8>())) + }; + unsafe { + let flags0 = _lower4; + *_param_ptr.add(0).cast::() = + ((flags0.bits() >> 0) as i32) as u8; + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + + Descriptor::from_handle(l1 as u32) + }; + Ok(e) + }, + 1 => { + let e = { + let l2 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v7 = match l2 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e7 = { + let l3 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l3 { + 0 => None, + 1 => { + let e = { + let l4 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l5 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e7) + }, + }; + + v7 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, path_flags, path, open_flags, flags)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Read the contents of a symbolic link. + /// + /// If the contents contain an absolute or rooted path in the underlying + /// filesystem, this function fails with `error-code::not-permitted`. + /// + /// Note: This is similar to `readlinkat` in POSIX. #[allow(async_fn_in_trait)] - pub fn remove_directory_at(&self, path: &str) -> Result<(), ErrorCode> { + pub async fn readlink_at( + &self, + path: _rt::String, + ) -> Result<_rt::String, ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.remove-directory-at"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result5 = match l3 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, _rt::String); + type Results = Result<_rt::String, ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.readlink-at"] + fn call(_: i32, _: *mut u8, _: usize, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _params.2, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + ParamsLower((_lower0).handle() as i32, ptr0.cast_mut(), len0) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l2 = *_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len3 = l2; + let bytes3 = + _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + + _rt::string_lift(bytes3) + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e9 = { + let l5 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l7 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, path)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Remove a directory. + /// + /// Return `error-code::not-empty` if the directory is not empty. + /// + /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. #[allow(async_fn_in_trait)] - pub fn rename_at( + pub async fn remove_directory_at( &self, - old_path: &str, - new_descriptor: &Descriptor, - new_path: &str, + path: _rt::String, ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = old_path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = new_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.rename-at"] - fn wit_import3( - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import3( - _: i32, - _: *mut u8, - _: usize, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import3( - (self).handle() as i32, - ptr0.cast_mut(), - len0, - (new_descriptor).handle() as i32, - ptr1.cast_mut(), - len1, - ptr2, - ); - let l4 = i32::from(*ptr2.add(0).cast::()); - let result6 = match l4 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr2.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, _rt::String); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l5 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn symlink_at(&self, old_path: &str, new_path: &str) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = old_path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = new_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.symlink-at"] - fn wit_import3( - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - _: usize, - _: *mut u8, - ); - } + fn results_offset(&mut self) -> usize { + 0 + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import3( - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() - } - wit_import3( - (self).handle() as i32, - ptr0.cast_mut(), - len0, - ptr1.cast_mut(), - len1, - ptr2, - ); - let l4 = i32::from(*ptr2.add(0).cast::()); - let result6 = match l4 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr2.add(1).cast::()); + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.remove-directory-at"] + fn call(_: i32, _: *mut u8, _: usize, _: *mut u8) -> i32; + } - ErrorCode::_lift(l5 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _params.2, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + ParamsLower((_lower0).handle() as i32, ptr0.cast_mut(), len0) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, path)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Rename a filesystem object. + /// + /// Note: This is similar to `renameat` in POSIX. #[allow(async_fn_in_trait)] - pub fn unlink_file_at(&self, path: &str) -> Result<(), ErrorCode> { + pub async fn rename_at( + &self, + old_path: _rt::String, + new_descriptor: &Descriptor, + new_path: _rt::String, + ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.unlink-file-at"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result5 = match l3 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = + (&'a Descriptor, _rt::String, &'a Descriptor, _rt::String); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (11 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - ErrorCode::_lift(l4 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + fn results_offset(&mut self) -> usize { + (6 * ::core::mem::size_of::<*const u8>()) + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.rename-at"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(5 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(5 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2, _lower3): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = + unsafe { _ptr.add(::core::mem::size_of::<*const u8>()) }; + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = + unsafe { _ptr.add((3 * ::core::mem::size_of::<*const u8>())) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower2).handle() as i32; + } + let _param_ptr = + unsafe { _ptr.add((4 * ::core::mem::size_of::<*const u8>())) }; + unsafe { + let vec0 = (_lower3.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, old_path, new_descriptor, new_path)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Create a symbolic link (also known as a "symlink"). + /// + /// If `old-path` starts with `/`, the function fails with + /// `error-code::not-permitted`. + /// + /// Note: This is similar to `symlinkat` in POSIX. #[allow(async_fn_in_trait)] - pub fn is_same_object(&self, other: &Descriptor) -> bool { + pub async fn symlink_at( + &self, + old_path: _rt::String, + new_path: _rt::String, + ) -> Result<(), ErrorCode> { unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.is-same-object"] - fn wit_import0(_: i32, _: i32) -> i32; + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, _rt::String, _rt::String); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (10 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32, _: i32) -> i32 { - unreachable!() + fn results_offset(&mut self) -> usize { + (5 * ::core::mem::size_of::<*const u8>()) + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.symlink-at"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *_params + .0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *_params + .0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = + unsafe { _ptr.add(::core::mem::size_of::<*const u8>()) }; + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = + unsafe { _ptr.add((3 * ::core::mem::size_of::<*const u8>())) }; + unsafe { + let vec0 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } } - let ret = wit_import0((self).handle() as i32, (other).handle() as i32); - _rt::bool_lift(ret as u8) + _MySubtask { _unused: core::marker::PhantomData } + .call((self, old_path, new_path)) + .await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Unlink a filesystem object that is not a directory. + /// + /// This is similar to `unlinkat(fd, path, 0)` in POSIX. + /// + /// Error returns are as specified by POSIX. + /// + /// If the filesystem object is a directory, `error-code::access` or + /// `error-code::is-directory` may be returned instead of the + /// POSIX-specified `error-code::not-permitted`. #[allow(async_fn_in_trait)] - pub fn metadata_hash(&self) -> Result { + pub async fn unlink_file_at(&self, path: _rt::String) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.metadata-hash"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); - let l4 = *ptr0.add(16).cast::(); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, _rt::String); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - MetadataHashValue { lower: l3 as u64, upper: l4 as u64 } - }; - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr0.add(8).cast::()); + fn results_offset(&mut self) -> usize { + 0 + } - ErrorCode::_lift(l5 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.unlink-file-at"] + fn call(_: i32, _: *mut u8, _: usize, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _params.2, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.1, _params.2, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let vec0 = (_lower1.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + ParamsLower((_lower0).handle() as i32, ptr0.cast_mut(), len0) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, path)).await } } } impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Test whether two descriptors refer to the same filesystem object. + /// + /// In POSIX, this corresponds to testing whether the two descriptors have the + /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. + /// wasi-filesystem does not expose device and inode numbers, so this function + /// may be used instead. #[allow(async_fn_in_trait)] - pub fn metadata_hash_at( - &self, - path_flags: PathFlags, - path: &str, - ) -> Result { + pub async fn is_same_object(&self, other: &Descriptor) -> bool { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]descriptor.metadata-hash-at"] - fn wit_import3(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32, i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import3( - _: i32, - _: i32, - _: *mut u8, - _: usize, - _: *mut u8, - ) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import3( - (self).handle() as i32, - (flags0.bits() >> 0) as i32, - ptr1.cast_mut(), - len1, - ptr2, - ); - let l4 = i32::from(*ptr2.add(0).cast::()); - let result8 = match l4 { - 0 => { - let e = { - let l5 = *ptr2.add(8).cast::(); - let l6 = *ptr2.add(16).cast::(); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, &'a Descriptor); + type Results = bool; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { ::core::alloc::Layout::from_size_align_unchecked(1, 1) } + } - MetadataHashValue { lower: l5 as u64, upper: l6 as u64 } - }; - Ok(e) - }, - 1 => { - let e = { - let l7 = i32::from(*ptr2.add(8).cast::()); + fn results_offset(&mut self) -> usize { + 0 + } - ErrorCode::_lift(l7 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result8 + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.is-same-object"] + fn call(_: i32, _: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + ParamsLower( + (_lower0).handle() as i32, + (_lower1).handle() as i32, + ) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + _rt::bool_lift(l0 as u8) + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self, other)).await } } } - impl DirectoryEntryStream { + impl Descriptor { #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a descriptor. + /// + /// This returns a hash of the last-modification timestamp and file size, and + /// may also include the inode number, device number, birth timestamp, and + /// other metadata fields that may change when the file is modified or + /// replaced. It may also include a secret value chosen by the + /// implementation and not otherwise exposed. + /// + /// Implementations are encouraged to provide the following properties: + /// + /// - If the file is not modified or replaced, the computed hash value should + /// usually not change. + /// - If the object is modified or replaced, the computed hash value should + /// usually change. + /// - The inputs to the hash should not be easily computable from the + /// computed hash. + /// + /// However, none of these is required. #[allow(async_fn_in_trait)] - pub fn read_directory_entry(&self) -> Result, ErrorCode> { + pub async fn metadata_hash(&self) -> Result { unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 5 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]directory-entry-stream.read-directory-entry"] - fn wit_import1(_: i32, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result9 = match l2 { - 0 => { - let e = { - let l3 = i32::from( - *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), - ); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor,); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (8 + 4 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } - match l3 { - 0 => None, - 1 => { + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.metadata-hash"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { let e = { - let l4 = i32::from( - *ptr0 - .add( - 2 * ::core::mem::size_of::<*const u8>(), - ) - .cast::(), - ); - let l5 = *ptr0 - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l6 = *ptr0 - .add(4 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let len7 = l6; - let bytes7 = - _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + let l1 = *_ptr.add(8).cast::(); + let l2 = *_ptr.add(16).cast::(); - DirectoryEntry { - type_: DescriptorType::_lift(l4 as u8), - name: _rt::string_lift(bytes7), + MetadataHashValue { + lower: l1 as u64, + upper: l2 as u64, } }; - Some(e) + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from(*_ptr.add(8).cast::()); + let v8 = match l3 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e8 = { + let l4 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l6 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 + }; + Err(e) }, _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - }, - 1 => { - let e = { - let l8 = i32::from( - *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), - ); - - ErrorCode::_lift(l8 as u8) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result9 + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn filesystem_error_code(err: &Error) -> Option { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - unsafe extern "C" { - #[link_name = "filesystem-error-code"] - fn wit_import1(_: i32, _: *mut u8); - } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a directory descriptor and a relative path. + /// + /// This performs the same hash computation as `metadata-hash`. + #[allow(async_fn_in_trait)] + pub async fn metadata_hash_at( + &self, + path_flags: PathFlags, + path: _rt::String, + ) -> Result { + unsafe { + #[derive(Copy, Clone)] + struct ParamsLower(i32, i32, *mut u8, usize); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((err).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a Descriptor, PathFlags, _rt::String); + type Results = Result; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (8 + 4 * ::core::mem::size_of::<*const u8>()), + 8, + ) + } + } - ErrorCode::_lift(l3 as u8) - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 - } - } - } + fn results_offset(&mut self) -> usize { + 0 + } - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod preopens { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]descriptor.metadata-hash-at"] + fn call( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32; + } - use super::super::super::_rt; - pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn get_directories() -> _rt::Vec<(Descriptor, _rt::String)> { - unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 2 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0")] - unsafe extern "C" { + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) -> i32 { + unreachable!() + } + + unsafe { + call(_params.0, _params.1, _params.2, _params.3, _results) + as u32 + } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.2, _params.3, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.2, _params.3, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let flags0 = _lower1; + let vec1 = (_lower2.into_bytes()).into_boxed_slice(); + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + ::core::mem::forget(vec1); + ParamsLower( + (_lower0).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + ) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = *_ptr.add(8).cast::(); + let l2 = *_ptr.add(16).cast::(); + + MetadataHashValue { + lower: l1 as u64, + upper: l2 as u64, + } + }; + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from(*_ptr.add(8).cast::()); + let v8 = match l3 { + 0 => ErrorCode::Access, + 1 => ErrorCode::Already, + 2 => ErrorCode::BadDescriptor, + 3 => ErrorCode::Busy, + 4 => ErrorCode::Deadlock, + 5 => ErrorCode::Quota, + 6 => ErrorCode::Exist, + 7 => ErrorCode::FileTooLarge, + 8 => ErrorCode::IllegalByteSequence, + 9 => ErrorCode::InProgress, + 10 => ErrorCode::Interrupted, + 11 => ErrorCode::Invalid, + 12 => ErrorCode::Io, + 13 => ErrorCode::IsDirectory, + 14 => ErrorCode::Loop, + 15 => ErrorCode::TooManyLinks, + 16 => ErrorCode::MessageSize, + 17 => ErrorCode::NameTooLong, + 18 => ErrorCode::NoDevice, + 19 => ErrorCode::NoEntry, + 20 => ErrorCode::NoLock, + 21 => ErrorCode::InsufficientMemory, + 22 => ErrorCode::InsufficientSpace, + 23 => ErrorCode::NotDirectory, + 24 => ErrorCode::NotEmpty, + 25 => ErrorCode::NotRecoverable, + 26 => ErrorCode::Unsupported, + 27 => ErrorCode::NoTty, + 28 => ErrorCode::NoSuchDevice, + 29 => ErrorCode::Overflow, + 30 => ErrorCode::NotPermitted, + 31 => ErrorCode::Pipe, + 32 => ErrorCode::ReadOnly, + 33 => ErrorCode::InvalidSeek, + 34 => ErrorCode::TextFileBusy, + 35 => ErrorCode::CrossDevice, + n => { + debug_assert_eq!( + n, 36, + "invalid enum discriminant" + ); + let e8 = { + let l4 = i32::from(*_ptr.add(8+1*::core::mem::size_of::<*const u8>()).cast::()); + + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *_ptr.add(8+2*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l6 = *_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, path_flags, path)) + .await + } + } + } + } + + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod preopens { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + + use super::super::super::_rt; + pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; + #[allow(unused_unsafe, clippy::all)] + /// Return the set of preopened directories, and their paths. + #[allow(async_fn_in_trait)] + pub fn get_directories() -> _rt::Vec<(Descriptor, _rt::String)> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 2 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/preopens@0.3.0-rc-2026-03-15")] + unsafe extern "C" { #[link_name = "get-directories"] fn wit_import1(_: *mut u8); } @@ -3546,196 +7025,131 @@ pub mod wasi { } } } - pub mod io { - + pub mod random { + /// WASI Random is a random data API. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod error { + pub mod random { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error { - handle: _rt::Resource, - } - - impl Error { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for Error { - #[inline] - unsafe fn drop(_handle: u32) { + #[allow(unused_unsafe, clippy::all)] + /// Return up to `max-len` cryptographically-secure random or pseudo-random + /// bytes. + /// + /// This function must produce data at least as cryptographically secure and + /// fast as an adequately seeded cryptographically-secure pseudo-random + /// number generator (CSPRNG). It must not block, from the perspective of + /// the calling program, under any circumstances, including on the first + /// request and on requests for numbers of bytes. The returned data must + /// always be unpredictable. + /// + /// Implementations MAY return fewer bytes than requested (a short read). + /// Callers that require exactly `max-len` bytes MUST call this function in + /// a loop until the desired number of bytes has been accumulated. + /// Implementations MUST return at least 1 byte when `max-len` is greater + /// than zero. When `max-len` is zero, implementations MUST return an empty + /// list without trapping. + /// + /// This function must always return fresh data. Deterministic environments + /// must omit this function, rather than implementing it with deterministic + /// data. + #[allow(async_fn_in_trait)] + pub fn get_random_bytes(max_len: u64) -> _rt::Vec { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 2 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] + #[link(wasm_import_module = "wasi:random/random@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: i32); + #[link_name = "get-random-bytes"] + fn wit_import1(_: i64, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { + unsafe extern "C" fn wit_import1(_: i64, _: *mut u8) { unreachable!() } - - unsafe { - drop(_handle as i32); - } + wit_import1(_rt::as_i64(&max_len), ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(); + let len4 = l3; + let result5 = <_ as From<_rt::Vec<_>>>::from(_rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + )); + result5 } } + #[allow(unused_unsafe, clippy::all)] + /// Return a cryptographically-secure random or pseudo-random `u64` value. + /// + /// This function returns the same type of data as `get-random-bytes`, + /// represented as a `u64`. + #[allow(async_fn_in_trait)] + pub fn get_random_u64() -> u64 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/random@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "get-random-u64"] + fn wit_import0() -> i64; + } - impl Error { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn to_debug_string(&self) -> _rt::String { - unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 2 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = *ptr0.add(0).cast::<*mut u8>(); - let l3 = *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - let result5 = _rt::string_lift(bytes4); - result5 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import0() -> i64 { + unreachable!() } + let ret = wit_import0(); + ret as u64 } } } + /// The insecure interface for insecure pseudo-random numbers. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod poll { + pub mod insecure { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable { - handle: _rt::Resource, - } - - impl Pollable { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for Pollable { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn ready(&self) -> bool { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import0(_: i32) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - _rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn block(&self) -> () { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import0(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) { - unreachable!() - } - wit_import0((self).handle() as i32); - } - } - } #[allow(unused_unsafe, clippy::all)] + /// Return up to `max-len` insecure pseudo-random bytes. + /// + /// This function is not cryptographically secure. Do not use it for + /// anything related to security. + /// + /// There are no requirements on the values of the returned bytes, however + /// implementations are encouraged to return evenly distributed values with + /// a long period. + /// + /// Implementations MAY return fewer bytes than requested (a short read). + /// Callers that require exactly `max-len` bytes MUST call this function in + /// a loop until the desired number of bytes has been accumulated. + /// Implementations MUST return at least 1 byte when `max-len` is greater + /// than zero. When `max-len` is zero, implementations MUST return an empty + /// list without trapping. #[allow(async_fn_in_trait)] - pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + pub fn get_insecure_random_bytes(max_len: u64) -> _rt::Vec { unsafe { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] #[cfg_attr(target_pointer_width = "32", repr(align(4)))] @@ -3746,77 +7160,391 @@ pub mod wasi { [::core::mem::MaybeUninit::uninit(); 2 * ::core::mem::size_of::<*const u8>()], ); - let vec0 = in_; - let len0 = vec0.len(); - let layout0 = _rt::alloc::Layout::from_size_align(vec0.len() * 4, 4).unwrap(); - let (result0, _cleanup0) = wit_bindgen_rt::Cleanup::new(layout0); - for (i, e) in vec0.into_iter().enumerate() { - let base = result0.add(i * 4); - { - *base.add(0).cast::() = (e).handle() as i32; - } - } - let ptr1 = ret_area.0.as_mut_ptr().cast::(); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + #[link(wasm_import_module = "wasi:random/insecure@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "poll"] - fn wit_import2(_: *mut u8, _: usize, _: *mut u8); + #[link_name = "get-insecure-random-bytes"] + fn wit_import1(_: i64, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i64, _: *mut u8) { unreachable!() } - wit_import2(result0, len0, ptr1); - let l3 = *ptr1.add(0).cast::<*mut u8>(); - let l4 = *ptr1.add(::core::mem::size_of::<*const u8>()).cast::(); - let len5 = l4; - let result6 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - result6 + wit_import1(_rt::as_i64(&max_len), ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(); + let len4 = l3; + let result5 = <_ as From<_rt::Vec<_>>>::from(_rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + )); + result5 } } - } + #[allow(unused_unsafe, clippy::all)] + /// Return an insecure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-insecure-random-bytes`, represented as a `u64`. + #[allow(async_fn_in_trait)] + pub fn get_insecure_random_u64() -> u64 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/insecure@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "get-insecure-random-u64"] + fn wit_import0() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import0() -> i64 { + unreachable!() + } + let ret = wit_import0(); + ret as u64 + } + } + } + + /// The insecure-seed interface for seeding hash-map DoS resistance. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod insecure_seed { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + + #[allow(unused_unsafe, clippy::all)] + /// Return a 128-bit value that may contain a pseudo-random value. + /// + /// The returned value is not required to be computed from a CSPRNG, and may + /// even be entirely deterministic. Host implementations are encouraged to + /// provide pseudo-random values to any program exposed to + /// attacker-controlled content, to enable DoS protection built into many + /// languages' hash-map implementations. + /// + /// This function is intended to only be called once, by a source language + /// to initialize Denial Of Service (DoS) protection in its hash-map + /// implementation. + /// + /// # Expected future evolution + /// + /// This will likely be changed to a value import, to prevent it from being + /// called multiple times and potentially used for purposes other than DoS + /// protection. + #[allow(async_fn_in_trait)] + pub fn get_insecure_seed() -> (u64, u64) { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/insecure-seed@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "get-insecure-seed"] + fn wit_import1(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: *mut u8) { + unreachable!() + } + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(8).cast::(); + let result4 = (l2 as u64, l3 as u64); + result4 + } + } + } + } + pub mod sockets { #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod streams { + pub mod types { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub enum StreamError { - LastOperationFailed(Error), - Closed, + pub type Duration = super::super::super::wasi::clocks::types::Duration; + /// Error codes. + /// + /// In theory, every API can return any error code. + /// In practice, API's typically only return the errors documented per API + /// combined with a couple of errors that are always possible: + /// - `other` + /// - `access-denied` + /// - `not-supported` + /// - `out-of-memory` + /// + /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + #[derive(Clone)] + pub enum ErrorCode { + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + AccessDenied, + /// The operation is not supported. + /// + /// POSIX equivalent: EOPNOTSUPP, ENOPROTOOPT, EPFNOSUPPORT, EPROTONOSUPPORT, ESOCKTNOSUPPORT + NotSupported, + /// One of the arguments is invalid. + /// + /// POSIX equivalent: EINVAL, EDESTADDRREQ, EAFNOSUPPORT + InvalidArgument, + /// Not enough memory to complete the operation. + /// + /// POSIX equivalent: ENOMEM, ENOBUFS + OutOfMemory, + /// The operation timed out before it could finish completely. + /// + /// POSIX equivalent: ETIMEDOUT + Timeout, + /// The operation is not valid in the socket's current state. + InvalidState, + /// The local address is not available. + /// + /// POSIX equivalent: EADDRNOTAVAIL + AddressNotBindable, + /// A bind operation failed because the provided address is already in + /// use or because there are no ephemeral ports available. + /// + /// POSIX equivalent: EADDRINUSE + AddressInUse, + /// The remote address is not reachable. + /// + /// POSIX equivalent: EHOSTUNREACH, EHOSTDOWN, ENETDOWN, ENETUNREACH, ENONET + RemoteUnreachable, + /// The connection was forcefully rejected. + /// + /// POSIX equivalent: ECONNREFUSED + ConnectionRefused, + /// A write failed because the connection was broken. + /// + /// POSIX equivalent: EPIPE + ConnectionBroken, + /// The connection was reset. + /// + /// POSIX equivalent: ECONNRESET + ConnectionReset, + /// The connection was aborted. + /// + /// POSIX equivalent: ECONNABORTED + ConnectionAborted, + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. + /// + /// POSIX equivalent: EMSGSIZE + DatagramTooLarge, + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + Other(Option<_rt::String>), } - impl ::core::fmt::Debug for StreamError { + impl ::core::fmt::Debug for ErrorCode { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() + ErrorCode::AccessDenied => { + f.debug_tuple("ErrorCode::AccessDenied").finish() + }, + ErrorCode::NotSupported => { + f.debug_tuple("ErrorCode::NotSupported").finish() + }, + ErrorCode::InvalidArgument => { + f.debug_tuple("ErrorCode::InvalidArgument").finish() + }, + ErrorCode::OutOfMemory => f.debug_tuple("ErrorCode::OutOfMemory").finish(), + ErrorCode::Timeout => f.debug_tuple("ErrorCode::Timeout").finish(), + ErrorCode::InvalidState => { + f.debug_tuple("ErrorCode::InvalidState").finish() + }, + ErrorCode::AddressNotBindable => { + f.debug_tuple("ErrorCode::AddressNotBindable").finish() + }, + ErrorCode::AddressInUse => { + f.debug_tuple("ErrorCode::AddressInUse").finish() + }, + ErrorCode::RemoteUnreachable => { + f.debug_tuple("ErrorCode::RemoteUnreachable").finish() + }, + ErrorCode::ConnectionRefused => { + f.debug_tuple("ErrorCode::ConnectionRefused").finish() }, - StreamError::Closed => f.debug_tuple("StreamError::Closed").finish(), + ErrorCode::ConnectionBroken => { + f.debug_tuple("ErrorCode::ConnectionBroken").finish() + }, + ErrorCode::ConnectionReset => { + f.debug_tuple("ErrorCode::ConnectionReset").finish() + }, + ErrorCode::ConnectionAborted => { + f.debug_tuple("ErrorCode::ConnectionAborted").finish() + }, + ErrorCode::DatagramTooLarge => { + f.debug_tuple("ErrorCode::DatagramTooLarge").finish() + }, + ErrorCode::Other(e) => f.debug_tuple("ErrorCode::Other").field(e).finish(), } } } - impl ::core::fmt::Display for StreamError { + impl ::core::fmt::Display for ErrorCode { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for StreamError {} + impl ::core::error::Error for ErrorCode {} + #[repr(u8)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] + pub enum IpAddressFamily { + /// Similar to `AF_INET` in POSIX. + Ipv4, + /// Similar to `AF_INET6` in POSIX. + Ipv6, + } + impl ::core::fmt::Debug for IpAddressFamily { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + IpAddressFamily::Ipv4 => f.debug_tuple("IpAddressFamily::Ipv4").finish(), + IpAddressFamily::Ipv6 => f.debug_tuple("IpAddressFamily::Ipv6").finish(), + } + } + } + + impl IpAddressFamily { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> IpAddressFamily { + if !cfg!(debug_assertions) { + return unsafe { ::core::mem::transmute(val) }; + } + + match val { + 0 => IpAddressFamily::Ipv4, + 1 => IpAddressFamily::Ipv6, + + _ => panic!("invalid enum discriminant"), + } + } + } + + pub type Ipv4Address = (u8, u8, u8, u8); + pub type Ipv6Address = (u16, u16, u16, u16, u16, u16, u16, u16); + #[derive(Clone, Copy)] + pub enum IpAddress { + Ipv4(Ipv4Address), + Ipv6(Ipv6Address), + } + impl ::core::fmt::Debug for IpAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + IpAddress::Ipv4(e) => f.debug_tuple("IpAddress::Ipv4").field(e).finish(), + IpAddress::Ipv6(e) => f.debug_tuple("IpAddress::Ipv6").field(e).finish(), + } + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Ipv4SocketAddress { + /// sin_port + pub port: u16, + /// sin_addr + pub address: Ipv4Address, + } + impl ::core::fmt::Debug for Ipv4SocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ipv4SocketAddress") + .field("port", &self.port) + .field("address", &self.address) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Ipv6SocketAddress { + /// sin6_port + pub port: u16, + /// sin6_flowinfo + pub flow_info: u32, + /// sin6_addr + pub address: Ipv6Address, + /// sin6_scope_id + pub scope_id: u32, + } + impl ::core::fmt::Debug for Ipv6SocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ipv6SocketAddress") + .field("port", &self.port) + .field("flow-info", &self.flow_info) + .field("address", &self.address) + .field("scope-id", &self.scope_id) + .finish() + } + } + #[derive(Clone, Copy)] + pub enum IpSocketAddress { + Ipv4(Ipv4SocketAddress), + Ipv6(Ipv6SocketAddress), + } + impl ::core::fmt::Debug for IpSocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + IpSocketAddress::Ipv4(e) => { + f.debug_tuple("IpSocketAddress::Ipv4").field(e).finish() + }, + IpSocketAddress::Ipv6(e) => { + f.debug_tuple("IpSocketAddress::Ipv6").field(e).finish() + }, + } + } + } + /// A TCP socket resource. + /// + /// The socket can be in one of the following states: + /// - `unbound` + /// - `bound` (See note below) + /// - `listening` + /// - `connecting` + /// - `connected` + /// - `closed` + /// See + /// for 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`, `listening`, `connecting` or `connected`) + /// + /// WASI uses shared ownership semantics: the `tcp-socket` handle and all + /// derived `stream` and `future` values reference a single underlying OS + /// socket: + /// - Send/receive streams remain functional after the original `tcp-socket` + /// handle is dropped. + /// - The stream returned by `listen` behaves similarly. + /// - Client sockets returned by `tcp-socket::listen` are independent and do + /// not keep the listening socket alive. + /// + /// The OS socket is closed only after the last handle is dropped. This + /// model has observable effects; for example, it affects when the local + /// port binding is released. + /// + /// In addition to the general error codes documented on the + /// `types::error-code` type, TCP socket methods may always return + /// `error(invalid-state)` when in the `closed` state. #[derive(Debug)] #[repr(transparent)] - pub struct InputStream { - handle: _rt::Resource, + pub struct TcpSocket { + handle: _rt::Resource, } - impl InputStream { + impl TcpSocket { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { handle: unsafe { _rt::Resource::from_handle(handle) } } @@ -3833,13 +7561,13 @@ pub mod wasi { } } - unsafe impl _rt::WasmResource for InputStream { + unsafe impl _rt::WasmResource for TcpSocket { #[inline] unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[resource-drop]input-stream"] + #[link_name = "[resource-drop]tcp-socket"] fn drop(_: i32); } @@ -3854,13 +7582,15 @@ pub mod wasi { } } + /// A UDP socket handle. + #[derive(Debug)] #[repr(transparent)] - pub struct OutputStream { - handle: _rt::Resource, + pub struct UdpSocket { + handle: _rt::Resource, } - impl OutputStream { + impl UdpSocket { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { handle: unsafe { _rt::Resource::from_handle(handle) } } @@ -3877,13 +7607,13 @@ pub mod wasi { } } - unsafe impl _rt::WasmResource for OutputStream { + unsafe impl _rt::WasmResource for UdpSocket { #[inline] unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[resource-drop]output-stream"] + #[link_name = "[resource-drop]udp-socket"] fn drop(_: i32); } @@ -3898,312 +7628,924 @@ pub mod wasi { } } - impl InputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// 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. + /// + /// Unlike POSIX, WASI sockets have no notion of a socket-level + /// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's + /// async support. + /// + /// # Typical errors + /// - `not-supported`: The `address-family` is not supported. (EAFNOSUPPORT) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + pub fn create(address_family: IpAddressFamily) -> Result { unsafe { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] #[cfg_attr(target_pointer_width = "32", repr(align(4)))] struct RetArea( - [::core::mem::MaybeUninit; 3 * ::core::mem::size_of::<*const u8>()], + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], ); let mut ret_area = RetArea( [::core::mem::MaybeUninit::uninit(); - 3 * ::core::mem::size_of::<*const u8>()], + 5 * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[static]tcp-socket.create"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); + wit_import1(address_family.clone() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result9 = match l2 { + let result10 = match l2 { 0 => { let e = { let l3 = *ptr0 .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l4 = *ptr0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let len5 = l4; + .cast::(); - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) + TcpSocket::from_handle(l3 as u32) }; Ok(e) }, 1 => { let e = { - let l6 = i32::from( + let l4 = i32::from( *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), ); - let v8 = match l6 { - 0 => { - let e8 = { - let l7 = *ptr0 - .add( - 4 + 1 * ::core::mem::size_of::<*const u8>(), - ) - .cast::(); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - super::super::super::wasi::io::error::Error::from_handle(l7 as u32) + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e8) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e9) }, }; - v8 + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result9 + result10 } } } - impl InputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { - unsafe { + /// Bind the socket to the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is + /// left to the implementation to decide which network interface(s) to + /// bind to. If the TCP/UDP port is zero, the socket will be bound to a + /// random free port. + /// + /// 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 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. (EINVAL) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `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 can be bound to. (EADDRNOTAVAIL) + /// + /// # Implementors note + /// The 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. + /// + /// # References + /// - + /// - + /// - + /// - + #[allow(async_fn_in_trait)] + pub fn bind(&self, local_address: IpSocketAddress) -> Result<(), ErrorCode> { + unsafe { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] #[cfg_attr(target_pointer_width = "32", repr(align(4)))] struct RetArea( - [::core::mem::MaybeUninit; 3 * ::core::mem::size_of::<*const u8>()], + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], ); let mut ret_area = RetArea( [::core::mem::MaybeUninit::uninit(); - 3 * ::core::mem::size_of::<*const u8>()], + 5 * ::core::mem::size_of::<*const u8>()], ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + let ( + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ) = match local_address { + IpSocketAddress::Ipv4(e) => { + let Ipv4SocketAddress { port: port0, address: address0 } = e; + let (t1_0, t1_1, t1_2, t1_3) = address0; + + ( + 0i32, + _rt::as_i32(port0), + _rt::as_i32(t1_0), + _rt::as_i32(t1_1), + _rt::as_i32(t1_2), + _rt::as_i32(t1_3), + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + ) + }, + IpSocketAddress::Ipv6(e) => { + let Ipv6SocketAddress { + port: port2, + flow_info: flow_info2, + address: address2, + scope_id: scope_id2, + } = e; + let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; + + ( + 1i32, + _rt::as_i32(port2), + _rt::as_i32(flow_info2), + _rt::as_i32(t3_0), + _rt::as_i32(t3_1), + _rt::as_i32(t3_2), + _rt::as_i32(t3_3), + _rt::as_i32(t3_4), + _rt::as_i32(t3_5), + _rt::as_i32(t3_6), + _rt::as_i32(t3_7), + _rt::as_i32(scope_id2), + ) + }, + }; + let ptr5 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[method]tcp-socket.bind"] + fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result9 = match l2 { + wit_import6( + (self).handle() as i32, + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ptr5, + ); + let l7 = i32::from(*ptr5.add(0).cast::()); + let result14 = match l7 { 0 => { - let e = { - let l3 = *ptr0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l4 = *ptr0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let len5 = l4; - - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) - }; + let e = (); Ok(e) }, 1 => { let e = { - let l6 = i32::from( - *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + let l8 = i32::from( + *ptr5.add(::core::mem::size_of::<*const u8>()).cast::(), ); - let v8 = match l6 { - 0 => { - let e8 = { - let l7 = *ptr0 - .add( - 4 + 1 * ::core::mem::size_of::<*const u8>(), - ) - .cast::(); + let v13 = match l8 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e13 = { + let l9 = i32::from( + *ptr5 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l9 { + 0 => None, + 1 => { + let e = { + let l10 = *ptr5 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l11 = *ptr5 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts( + l10.cast(), + len12, + len12, + ); - super::super::super::wasi::io::error::Error::from_handle(l7 as u32) + _rt::string_lift(bytes12) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e8) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e13) }, }; - v8 + v13 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result9 + result14 } } } - impl InputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Connect to a remote endpoint. + /// + /// On success, the socket is transitioned into the `connected` state + /// and the `remote-address` of the socket is updated. + /// The `local-address` may be updated as well, based on the best network + /// path to `remote-address`. If the socket was not already explicitly + /// bound, this function will implicitly bind the socket to a random + /// free port. + /// + /// 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. + /// + /// # 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. (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-state`: The socket is already in the `connecting` state. (EALREADY) + /// - `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) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn skip(&self, len: u64) -> Result { + pub async fn connect( + &self, + remote_address: IpSocketAddress, + ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a TcpSocket, IpSocketAddress); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (32 + 6 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr0.add(12).cast::(); + fn results_offset(&mut self) -> usize { + (32 + 1 * ::core::mem::size_of::<*const u8>()) + } - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) - }; - StreamError::LastOperationFailed(e6) + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]tcp-socket.connect"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = unsafe { _ptr.add(4) }; + unsafe { + match _lower1 { + IpSocketAddress::Ipv4(e) => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + let Ipv4SocketAddress { + port: port0, + address: address0, + } = e; + *_param_ptr.add(4).cast::() = + (_rt::as_i32(port0)) as u16; + let (t1_0, t1_1, t1_2, t1_3) = address0; + *_param_ptr.add(6).cast::() = + (_rt::as_i32(t1_0)) as u8; + *_param_ptr.add(7).cast::() = + (_rt::as_i32(t1_1)) as u8; + *_param_ptr.add(8).cast::() = + (_rt::as_i32(t1_2)) as u8; + *_param_ptr.add(9).cast::() = + (_rt::as_i32(t1_3)) as u8; }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + IpSocketAddress::Ipv6(e) => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + let Ipv6SocketAddress { + port: port2, + flow_info: flow_info2, + address: address2, + scope_id: scope_id2, + } = e; + *_param_ptr.add(4).cast::() = + (_rt::as_i32(port2)) as u16; + *_param_ptr.add(8).cast::() = + _rt::as_i32(flow_info2); + let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = + address2; + *_param_ptr.add(12).cast::() = + (_rt::as_i32(t3_0)) as u16; + *_param_ptr.add(14).cast::() = + (_rt::as_i32(t3_1)) as u16; + *_param_ptr.add(16).cast::() = + (_rt::as_i32(t3_2)) as u16; + *_param_ptr.add(18).cast::() = + (_rt::as_i32(t3_3)) as u16; + *_param_ptr.add(20).cast::() = + (_rt::as_i32(t3_4)) as u16; + *_param_ptr.add(22).cast::() = + (_rt::as_i32(t3_5)) as u16; + *_param_ptr.add(24).cast::() = + (_rt::as_i32(t3_6)) as u16; + *_param_ptr.add(26).cast::() = + (_rt::as_i32(t3_7)) as u16; + *_param_ptr.add(28).cast::() = + _rt::as_i32(scope_id2); }, - }; + } + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); - v6 - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result7 + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!( + n, 14, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData } + .call((self, remote_address)) + .await } } } - impl InputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Start listening and return a stream of new inbound connections. + /// + /// Transitions the socket into the `listening` state. This can be called + /// at most once per socket. + /// + /// If the socket is not already explicitly bound, this function will + /// implicitly bind the socket to a random free port. + /// + /// Normally, the returned sockets are bound, in the `connected` state + /// and immediately ready for I/O. Though, depending on exact timing and + /// circumstances, a newly accepted connection may already be `closed` + /// by the time the server attempts to perform its first I/O on it. This + /// is true regardless of whether the WASI implementation uses + /// "synthesized" sockets or not (see Implementors Notes below). + /// + /// The following properties are inherited from the listener socket: + /// - `address-family` + /// - `keep-alive-enabled` + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// - `hop-limit` + /// - `receive-buffer-size` + /// - `send-buffer-size` + /// + /// # Typical 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) + /// + /// # Implementors note + /// This method returns a single perpetual stream that should only close + /// on fatal errors (if any). Yet, the POSIX' `accept` function may also + /// return transient errors (e.g. ECONNABORTED). The exact details differ + /// per operation system. For example, the Linux manual mentions: + /// + /// > Linux accept() passes already-pending network errors on the new + /// > socket as an error code from accept(). This behavior differs from + /// > other BSD socket implementations. For reliable operation the + /// > application should detect the network errors defined for the + /// > protocol after accept() and treat them like EAGAIN by retrying. + /// > In the case of TCP/IP, these are ENETDOWN, EPROTO, ENOPROTOOPT, + /// > EHOSTDOWN, ENONET, EHOSTUNREACH, EOPNOTSUPP, and ENETUNREACH. + /// Source: https://man7.org/linux/man-pages/man2/accept.2.html + /// + /// WASI implementations have two options to handle this: + /// - Optionally log it and then skip over non-fatal errors returned by + /// `accept`. Guest code never gets to see these failures. Or: + /// - Synthesize a `tcp-socket` resource that exposes the error when + /// attempting to send or receive on it. Guest code then sees these + /// failures as regular I/O errors. + /// + /// In either case, the stream returned by this `listen` method remains + /// operational. + /// + /// WASI requires `listen` to perform an implicit bind if the socket + /// has not already been bound. Not all platforms (notably Windows) + /// exhibit this behavior out of the box. On platforms that require it, + /// the WASI implementation can emulate this behavior by performing + /// the bind itself if the guest hasn't already done so. + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn blocking_skip(&self, len: u64) -> Result { + pub fn listen( + &self, + ) -> Result, ErrorCode> + { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[method]tcp-socket.listen"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); + wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { + let result10 = match l2 { 0 => { let e = { - let l3 = *ptr0.add(8).cast::(); + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); - l3 as u64 + wit_bindgen::rt::async_support::StreamReader::new(l3 as u32, &::VTABLE) }; Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) - }; - StreamError::LastOperationFailed(e6) - }, + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - }, - }; - - v6 - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), }; - result7 + result10 } } } - impl InputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Transmit data to peer. + /// + /// The caller should close the stream when it has no more data to send + /// to the peer. Under normal circumstances this will cause a FIN packet + /// to be sent out. Closing the stream is equivalent to calling + /// `shutdown(SHUT_WR)` in POSIX. + /// + /// This function may be called at most once and returns once the full + /// contents of the stream are transmitted or an error is encountered. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// - `invalid-state`: `send` has already been called on this socket. + /// - `connection-broken`: The connection is not writable anymore. (EPIPE, ECONNABORTED on Windows) + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { + pub fn send( + &self, + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> + { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import0(_: i32) -> i32; + #[link_name = "[method]tcp-socket.send"] + fn wit_import0(_: i32, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32, _: i32) -> i32 { unreachable!() } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + let ret = wit_import0((self).handle() as i32, (&data).take_handle() as i32); + wit_bindgen::rt::async_support::FutureReader::new(ret as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE) } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Read data from peer. + /// + /// Returns a `stream` of data sent by the peer. The implementation + /// drops the stream once no more data is available. At that point, the + /// returned `future` resolves to: + /// - `ok` after a graceful shutdown from the peer (i.e. a FIN packet), or + /// - `err` if the socket was closed abnormally. + /// + /// `receive` may be called only once per socket. Subsequent calls return + /// a closed stream and a future resolved to `err(invalid-state)`. + /// + /// If the caller is not expecting to receive any more data from the peer, + /// they should drop the stream. Any data still in the receive queue + /// will be discarded. This is equivalent to calling `shutdown(SHUT_RD)` + /// in POSIX. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// - `invalid-state`: `receive` has already been called on this socket. + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn check_write(&self) -> Result { + pub fn receive( + &self, + ) -> ( + wit_bindgen::rt::async_support::StreamReader, + wit_bindgen::rt::async_support::FutureReader>, + ) { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.check-write"] + #[link_name = "[method]tcp-socket.receive"] fn wit_import1(_: i32, _: *mut u8); } @@ -4212,173 +8554,355 @@ pub mod wasi { unreachable!() } wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); - - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) - }; - StreamError::LastOperationFailed(e6) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - }, - }; - - v6 - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result7 + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(4).cast::(); + let result4 = (wit_bindgen::rt::async_support::StreamReader::new(l2 as u32, &::VTABLE), wit_bindgen::rt::async_support::FutureReader::new(l3 as u32, & as super::super::super::wit_future::FuturePayload>::VTABLE)); + result4 } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Get the bound local address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `get-local-address` to return + /// `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { + pub fn get_local_address(&self) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = contents; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); + #[link_name = "[method]tcp-socket.get-local-address"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result7 = match l3 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result27 = match l2 { 0 => { - let e = (); - Ok(e) - }, - 1 => { let e = { - let l4 = i32::from(*ptr1.add(4).cast::()); - let v6 = match l4 { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v20 = match l3 { 0 => { - let e6 = { - let l5 = *ptr1.add(8).cast::(); + let e20 = { + let l4 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l5 = i32::from( + *ptr0 + .add( + 6 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l6 = i32::from( + *ptr0 + .add( + 7 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l7 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l8 = i32::from( + *ptr0 + .add( + 9 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) + Ipv4SocketAddress { + port: l4 as u16, + address: ( + l5 as u8, l6 as u8, l7 as u8, l8 as u8, + ), + } }; - StreamError::LastOperationFailed(e6) + IpSocketAddress::Ipv4(e20) }, n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + let e20 = { + let l9 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l10 = *ptr0 + .add( + 8 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l11 = i32::from( + *ptr0 + .add( + 12 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *ptr0 + .add( + 14 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l13 = i32::from( + *ptr0 + .add( + 16 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l14 = i32::from( + *ptr0 + .add( + 18 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *ptr0 + .add( + 20 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l16 = i32::from( + *ptr0 + .add( + 22 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l17 = i32::from( + *ptr0 + .add( + 24 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l18 = i32::from( + *ptr0 + .add( + 26 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l19 = *ptr0 + .add( + 28 + 1 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); + + Ipv6SocketAddress { + port: l9 as u16, + flow_info: l10 as u32, + address: ( + l11 as u16, l12 as u16, l13 as u16, + l14 as u16, l15 as u16, l16 as u16, + l17 as u16, l18 as u16, + ), + scope_id: l19 as u32, + } + }; + IpSocketAddress::Ipv6(e20) }, }; - v6 + v20 }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result7 - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = contents; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() - } - wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result7 = match l3 { - 0 => { - let e = (); Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr1.add(4).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr1.add(8).cast::(); + let l21 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v26 = match l21 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e26 = { + let l22 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l22 { + 0 => None, + 1 => { + let e = { + let l23 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l24 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts( + l23.cast(), + len25, + len25, + ); - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) + _rt::string_lift(bytes25) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e6) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e26) }, }; - v6 + v26 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result7 + result27 } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Get the remote address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn flush(&self) -> Result<(), StreamError> { + pub fn get_remote_address(&self) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.flush"] + #[link_name = "[method]tcp-socket.get-remote-address"] fn wit_import1(_: i32, _: *mut u8); } @@ -4388,103 +8912,284 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { + let result27 = match l2 { 0 => { - let e = (); - Ok(e) - }, - 1 => { let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v20 = match l3 { + 0 => { + let e20 = { + let l4 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l5 = i32::from( + *ptr0 + .add( + 6 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l6 = i32::from( + *ptr0 + .add( + 7 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l7 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l8 = i32::from( + *ptr0 + .add( + 9 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + + Ipv4SocketAddress { + port: l4 as u16, + address: ( + l5 as u8, l6 as u8, l7 as u8, l8 as u8, + ), + } + }; + IpSocketAddress::Ipv4(e20) }, n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + let e20 = { + let l9 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l10 = *ptr0 + .add( + 8 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l11 = i32::from( + *ptr0 + .add( + 12 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *ptr0 + .add( + 14 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l13 = i32::from( + *ptr0 + .add( + 16 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l14 = i32::from( + *ptr0 + .add( + 18 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *ptr0 + .add( + 20 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l16 = i32::from( + *ptr0 + .add( + 22 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l17 = i32::from( + *ptr0 + .add( + 24 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l18 = i32::from( + *ptr0 + .add( + 26 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l19 = *ptr0 + .add( + 28 + 1 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); + + Ipv6SocketAddress { + port: l9 as u16, + flow_info: l10 as u32, + address: ( + l11 as u16, l12 as u16, l13 as u16, + l14 as u16, l15 as u16, l16 as u16, + l17 as u16, l18 as u16, + ), + scope_id: l19 as u32, + } + }; + IpSocketAddress::Ipv6(e20) }, }; - v5 + v20 }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn blocking_flush(&self) -> Result<(), StreamError> { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { - 0 => { - let e = (); Ok(e) }, 1 => { let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(8).cast::(); + let l21 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v26 = match l21 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e26 = { + let l22 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l22 { + 0 => None, + 1 => { + let e = { + let l23 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l24 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts( + l23.cast(), + len25, + len25, + ); - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + _rt::string_lift(bytes25) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e5) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e26) }, }; - v5 + v26 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result6 + result27 } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Whether the socket is in the `listening` state. + /// + /// Equivalent to the SO_ACCEPTCONN socket option. #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { + pub fn get_is_listening(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.subscribe"] + #[link_name = "[method]tcp-socket.get-is-listening"] fn wit_import0(_: i32) -> i32; } @@ -4493,78 +9198,66 @@ pub mod wasi { unreachable!() } let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + _rt::bool_lift(ret as u8) } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Whether this is a IPv4 or IPv6 socket. + /// + /// This is the value passed to the constructor. + /// + /// Equivalent to the SO_DOMAIN socket option. #[allow(async_fn_in_trait)] - pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + pub fn get_address_family(&self) -> IpAddressFamily { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[method]tcp-socket.get-address-family"] + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - }, - }; - - v5 - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 + let ret = wit_import0((self).handle() as i32); + IpAddressFamily::_lift(ret as u8) } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Hints the desired listen queue size. Implementations are free to + /// ignore this. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently + /// clamped and/or rounded. + /// + /// # 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 in the `connecting` or `connected` state. #[allow(async_fn_in_trait)] - pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + pub fn set_listen_backlog_size(&self, value: u64) -> Result<(), ErrorCode> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + #[link_name = "[method]tcp-socket.set-listen-backlog-size"] fn wit_import1(_: i32, _: i64, _: *mut u8); } @@ -4572,137 +9265,380 @@ pub mod wasi { unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&len), ptr0); + wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { + let result9 = match l2 { 0 => { let e = (); Ok(e) }, 1 => { let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(8).cast::(); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e5) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e8) }, }; - v5 + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result6 + result9 } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] + /// Enables or disables keepalive. + /// + /// The keepalive behavior can be adjusted using: + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// These properties can be configured while `keep-alive-enabled` is + /// false, but only come into effect when `keep-alive-enabled` is true. + /// + /// Equivalent to the SO_KEEPALIVE socket option. #[allow(async_fn_in_trait)] - pub fn splice(&self, src: &InputStream, len: u64) -> Result { + pub fn get_keep_alive_enabled(&self) -> Result { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import1(_: i32, _: i32, _: i64, _: *mut u8); + #[link_name = "[method]tcp-socket.get-keep-alive-enabled"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import1( - (self).handle() as i32, - (src).handle() as i32, - _rt::as_i64(&len), - ptr0, - ); + wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { + let result10 = match l2 { 0 => { let e = { - let l3 = *ptr0.add(8).cast::(); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); - l3 as u64 + _rt::bool_lift(l3 as u8) }; Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) - }; - StreamError::LastOperationFailed(e6) - }, + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) }, }; - v6 + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result7 + result10 } } } - impl OutputStream { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn blocking_splice( - &self, - src: &InputStream, - len: u64, - ) -> Result { + pub fn set_keep_alive_enabled(&self, value: bool) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import1(_: i32, _: i32, _: i64, _: *mut u8); + #[link_name = "[method]tcp-socket.set-keep-alive-enabled"] + fn wit_import1(_: i32, _: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { unreachable!() } wit_import1( (self).handle() as i32, - (src).handle() as i32, - _rt::as_i64(&len), + match &value { + true => 1, + false => 0, + }, ptr0, ); let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { + let result9 = match l2 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result9 + } + } + } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + /// Amount of time the connection has to be idle before TCP starts + /// sending keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + #[allow(async_fn_in_trait)] + pub fn get_keep_alive_idle_time(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.get-keep-alive-idle-time"] + fn wit_import1(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { 0 => { let e = { let l3 = *ptr0.add(8).cast::(); @@ -4714,838 +9650,1179 @@ pub mod wasi { 1 => { let e = { let l4 = i32::from(*ptr0.add(8).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr0.add(12).cast::(); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - super::super::super::wasi::io::error::Error::from_handle(l5 as u32) + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - StreamError::LastOperationFailed(e6) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + ErrorCode::Other(e9) }, }; - v6 + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result7 + result10 } } } - } - } - pub mod random { + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] + pub fn set_keep_alive_idle_time(&self, value: Duration) -> Result<(), ErrorCode> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.set-keep-alive-idle-time"] + fn wit_import1(_: i32, _: i64, _: *mut u8); + } - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod random { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, _rt::as_i64(value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - use super::super::super::_rt; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn get_random_bytes(len: u64) -> _rt::Vec { - unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 2 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/random@0.2.0")] - unsafe extern "C" { - #[link_name = "get-random-bytes"] - fn wit_import1(_: i64, _: *mut u8); - } + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i64, _: *mut u8) { - unreachable!() + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result9 } - wit_import1(_rt::as_i64(&len), ptr0); - let l2 = *ptr0.add(0).cast::<*mut u8>(); - let l3 = *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(); - let len4 = l3; - let result5 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - result5 } } - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn get_random_u64() -> u64 { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/random@0.2.0")] - unsafe extern "C" { - #[link_name = "get-random-u64"] - fn wit_import0() -> i64; - } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + /// The time between keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPINTVL socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + #[allow(async_fn_in_trait)] + pub fn get_keep_alive_interval(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.get-keep-alive-interval"] + fn wit_import1(_: i32, _: *mut u8); + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i64 { - unreachable!() - } - let ret = wit_import0(); - ret as u64 - } - } - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { + 0 => { + let e = { + let l3 = *ptr0.add(8).cast::(); - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod insecure { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + l3 as u64 + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - use super::super::super::_rt; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn get_insecure_random_bytes(len: u64) -> _rt::Vec { - unsafe { - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct RetArea( - [::core::mem::MaybeUninit; 2 * ::core::mem::size_of::<*const u8>()], - ); - let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); - 2 * ::core::mem::size_of::<*const u8>()], - ); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] - unsafe extern "C" { - #[link_name = "get-insecure-random-bytes"] - fn wit_import1(_: i64, _: *mut u8); - } + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i64, _: *mut u8) { - unreachable!() - } - wit_import1(_rt::as_i64(&len), ptr0); - let l2 = *ptr0.add(0).cast::<*mut u8>(); - let l3 = *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(); - let len4 = l3; - let result5 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - result5 - } - } - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn get_insecure_random_u64() -> u64 { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] - unsafe extern "C" { - #[link_name = "get-insecure-random-u64"] - fn wit_import0() -> i64; - } + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i64 { - unreachable!() + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result10 } - let ret = wit_import0(); - ret as u64 } } - } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] + pub fn set_keep_alive_interval(&self, value: Duration) -> Result<(), ErrorCode> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.set-keep-alive-interval"] + fn wit_import1(_: i32, _: i64, _: *mut u8); + } - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod insecure_seed { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, _rt::as_i64(value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn insecure_seed() -> (u64, u64) { - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure-seed@0.2.0")] - unsafe extern "C" { - #[link_name = "insecure-seed"] - fn wit_import1(_: *mut u8); - } + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: *mut u8) { - unreachable!() + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result9 } - wit_import1(ptr0); - let l2 = *ptr0.add(0).cast::(); - let l3 = *ptr0.add(8).cast::(); - let result4 = (l2 as u64, l3 as u64); - result4 } } - } - } - pub mod sockets { - - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod network { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + /// The maximum amount of keepalive packets TCP should send before + /// aborting the connection. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPCNT socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + #[allow(async_fn_in_trait)] + pub fn get_keep_alive_count(&self) -> Result { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.get-keep-alive-count"] + fn wit_import1(_: i32, _: *mut u8); + } - use super::super::super::_rt; + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { + 0 => { + let e = { + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); - #[derive(Debug)] - #[repr(transparent)] - pub struct Network { - handle: _rt::Resource, - } + l3 as u32 + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - impl Network { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result10 + } } } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] + pub fn set_keep_alive_count(&self, value: u32) -> Result<(), ErrorCode> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.set-keep-alive-count"] + fn wit_import1(_: i32, _: i32, _: *mut u8); + } - unsafe impl _rt::WasmResource for Network { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/network@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]network"] - fn drop(_: i32); - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - unsafe { - drop(_handle as i32); - } - } - } + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; - #[repr(u8)] - #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] - pub enum ErrorCode { - Unknown, - AccessDenied, - NotSupported, - InvalidArgument, - OutOfMemory, - Timeout, - ConcurrencyConflict, - NotInProgress, - WouldBlock, - InvalidState, - NewSocketLimit, - AddressNotBindable, - AddressInUse, - RemoteUnreachable, - ConnectionRefused, - ConnectionReset, - ConnectionAborted, - DatagramTooLarge, - NameUnresolvable, - TemporaryResolverFailure, - PermanentResolverFailure, - } - impl ErrorCode { - pub fn name(&self) -> &'static str { - match self { - ErrorCode::Unknown => "unknown", - ErrorCode::AccessDenied => "access-denied", - ErrorCode::NotSupported => "not-supported", - ErrorCode::InvalidArgument => "invalid-argument", - ErrorCode::OutOfMemory => "out-of-memory", - ErrorCode::Timeout => "timeout", - ErrorCode::ConcurrencyConflict => "concurrency-conflict", - ErrorCode::NotInProgress => "not-in-progress", - ErrorCode::WouldBlock => "would-block", - ErrorCode::InvalidState => "invalid-state", - ErrorCode::NewSocketLimit => "new-socket-limit", - ErrorCode::AddressNotBindable => "address-not-bindable", - ErrorCode::AddressInUse => "address-in-use", - ErrorCode::RemoteUnreachable => "remote-unreachable", - ErrorCode::ConnectionRefused => "connection-refused", - ErrorCode::ConnectionReset => "connection-reset", - ErrorCode::ConnectionAborted => "connection-aborted", - ErrorCode::DatagramTooLarge => "datagram-too-large", - ErrorCode::NameUnresolvable => "name-unresolvable", - ErrorCode::TemporaryResolverFailure => "temporary-resolver-failure", - ErrorCode::PermanentResolverFailure => "permanent-resolver-failure", - } - } - pub fn message(&self) -> &'static str { - match self { - ErrorCode::Unknown => "", - ErrorCode::AccessDenied => "", - ErrorCode::NotSupported => "", - ErrorCode::InvalidArgument => "", - ErrorCode::OutOfMemory => "", - ErrorCode::Timeout => "", - ErrorCode::ConcurrencyConflict => "", - ErrorCode::NotInProgress => "", - ErrorCode::WouldBlock => "", - ErrorCode::InvalidState => "", - ErrorCode::NewSocketLimit => "", - ErrorCode::AddressNotBindable => "", - ErrorCode::AddressInUse => "", - ErrorCode::RemoteUnreachable => "", - ErrorCode::ConnectionRefused => "", - ErrorCode::ConnectionReset => "", - ErrorCode::ConnectionAborted => "", - ErrorCode::DatagramTooLarge => "", - ErrorCode::NameUnresolvable => "", - ErrorCode::TemporaryResolverFailure => "", - ErrorCode::PermanentResolverFailure => "", + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result9 } } } - impl ::core::fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + #[allow(async_fn_in_trait)] + pub fn get_hop_limit(&self) -> Result { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.get-hop-limit"] + fn wit_import1(_: i32, _: *mut u8); + } - impl std::error::Error for ErrorCode {} + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { + 0 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); - impl ErrorCode { - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> ErrorCode { - if !cfg!(debug_assertions) { - return unsafe { ::core::mem::transmute(val) }; - } + l3 as u8 + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - match val { - 0 => ErrorCode::Unknown, - 1 => ErrorCode::AccessDenied, - 2 => ErrorCode::NotSupported, - 3 => ErrorCode::InvalidArgument, - 4 => ErrorCode::OutOfMemory, - 5 => ErrorCode::Timeout, - 6 => ErrorCode::ConcurrencyConflict, - 7 => ErrorCode::NotInProgress, - 8 => ErrorCode::WouldBlock, - 9 => ErrorCode::InvalidState, - 10 => ErrorCode::NewSocketLimit, - 11 => ErrorCode::AddressNotBindable, - 12 => ErrorCode::AddressInUse, - 13 => ErrorCode::RemoteUnreachable, - 14 => ErrorCode::ConnectionRefused, - 15 => ErrorCode::ConnectionReset, - 16 => ErrorCode::ConnectionAborted, - 17 => ErrorCode::DatagramTooLarge, - 18 => ErrorCode::NameUnresolvable, - 19 => ErrorCode::TemporaryResolverFailure, - 20 => ErrorCode::PermanentResolverFailure, + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - _ => panic!("invalid enum discriminant"), - } - } - } + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; - #[repr(u8)] - #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] - pub enum IpAddressFamily { - Ipv4, - Ipv6, - } - impl ::core::fmt::Debug for IpAddressFamily { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - IpAddressFamily::Ipv4 => f.debug_tuple("IpAddressFamily::Ipv4").finish(), - IpAddressFamily::Ipv6 => f.debug_tuple("IpAddressFamily::Ipv6").finish(), + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result10 } } } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] + pub fn set_hop_limit(&self, value: u8) -> Result<(), ErrorCode> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.set-hop-limit"] + fn wit_import1(_: i32, _: i32, _: *mut u8); + } - impl IpAddressFamily { - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> IpAddressFamily { - if !cfg!(debug_assertions) { - return unsafe { ::core::mem::transmute(val) }; - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - match val { - 0 => IpAddressFamily::Ipv4, - 1 => IpAddressFamily::Ipv6, + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - _ => panic!("invalid enum discriminant"), - } - } - } + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; - pub type Ipv4Address = (u8, u8, u8, u8); - pub type Ipv6Address = (u16, u16, u16, u16, u16, u16, u16, u16); - #[derive(Clone, Copy)] - pub enum IpAddress { - Ipv4(Ipv4Address), - Ipv6(Ipv6Address), - } - impl ::core::fmt::Debug for IpAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - IpAddress::Ipv4(e) => f.debug_tuple("IpAddress::Ipv4").field(e).finish(), - IpAddress::Ipv6(e) => f.debug_tuple("IpAddress::Ipv6").field(e).finish(), - } - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Ipv4SocketAddress { - pub port: u16, - pub address: Ipv4Address, - } - impl ::core::fmt::Debug for Ipv4SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Ipv4SocketAddress") - .field("port", &self.port) - .field("address", &self.address) - .finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Ipv6SocketAddress { - pub port: u16, - pub flow_info: u32, - pub address: Ipv6Address, - pub scope_id: u32, - } - impl ::core::fmt::Debug for Ipv6SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Ipv6SocketAddress") - .field("port", &self.port) - .field("flow-info", &self.flow_info) - .field("address", &self.address) - .field("scope-id", &self.scope_id) - .finish() - } - } - #[derive(Clone, Copy)] - pub enum IpSocketAddress { - Ipv4(Ipv4SocketAddress), - Ipv6(Ipv6SocketAddress), - } - impl ::core::fmt::Debug for IpSocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - IpSocketAddress::Ipv4(e) => { - f.debug_tuple("IpSocketAddress::Ipv4").field(e).finish() - }, - IpSocketAddress::Ipv6(e) => { - f.debug_tuple("IpSocketAddress::Ipv6").field(e).finish() - }, + v8 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result9 } } } - } + impl TcpSocket { + #[allow(unused_unsafe, clippy::all)] + /// Kernel buffer space reserved for sending/receiving on this socket. + /// Implementations usually treat this as a cap the buffer can grow to, + /// rather than allocating the full amount immediately. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// This is only a performance hint. The implementation may ignore it or + /// tweak it based on real traffic patterns. + /// Linux and macOS appear to behave differently depending on whether a + /// buffer size was explicitly set. When set, they tend to honor it; when + /// not set, they dynamically adjust the buffer size as the connection + /// progresses. This is especially noticeable when comparing the values + /// from before and after connection establishment. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + #[allow(async_fn_in_trait)] + pub fn get_receive_buffer_size(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]tcp-socket.get-receive-buffer-size"] + fn wit_import1(_: i32, _: *mut u8); + } - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod instance_network { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unreachable!() + } + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { + 0 => { + let e = { + let l3 = *ptr0.add(8).cast::(); - pub type Network = super::super::super::wasi::sockets::network::Network; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn instance_network() -> Network { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/instance-network@0.2.0")] - unsafe extern "C" { - #[link_name = "instance-network"] - fn wit_import0() -> i32; - } + l3 as u64 + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0() -> i32 { - unreachable!() - } - let ret = wit_import0(); - super::super::super::wasi::sockets::network::Network::from_handle(ret as u32) - } - } - } + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod udp { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; - use super::super::super::_rt; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub type Network = super::super::super::wasi::sockets::network::Network; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpSocketAddress = super::super::super::wasi::sockets::network::IpSocketAddress; - pub type IpAddressFamily = super::super::super::wasi::sockets::network::IpAddressFamily; - #[derive(Clone)] - pub struct IncomingDatagram { - pub data: _rt::Vec, - pub remote_address: IpSocketAddress, - } - impl ::core::fmt::Debug for IncomingDatagram { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("IncomingDatagram") - .field("data", &self.data) - .field("remote-address", &self.remote_address) - .finish() + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result10 + } } } - #[derive(Clone)] - pub struct OutgoingDatagram { - pub data: _rt::Vec, - pub remote_address: Option, - } - impl ::core::fmt::Debug for OutgoingDatagram { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("OutgoingDatagram") - .field("data", &self.data) - .field("remote-address", &self.remote_address) - .finish() - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct UdpSocket { - handle: _rt::Resource, - } - - impl UdpSocket { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for UdpSocket { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]udp-socket"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingDatagramStream { - handle: _rt::Resource, - } - - impl IncomingDatagramStream { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for IncomingDatagramStream { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]incoming-datagram-stream"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingDatagramStream { - handle: _rt::Resource, - } - - impl OutgoingDatagramStream { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for OutgoingDatagramStream { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]outgoing-datagram-stream"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - impl UdpSocket { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn start_bind( - &self, - network: &Network, - local_address: IpSocketAddress, - ) -> Result<(), ErrorCode> { + pub fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - use super::super::super::wasi::sockets::network::IpSocketAddress as V4; - let ( - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ) = match local_address { - V4::Ipv4(e) => { - let super::super::super::wasi::sockets::network::Ipv4SocketAddress{ port:port0, address:address0, } = e; - let (t1_0, t1_1, t1_2, t1_3) = address0; - - ( - 0i32, - _rt::as_i32(port0), - _rt::as_i32(t1_0), - _rt::as_i32(t1_1), - _rt::as_i32(t1_2), - _rt::as_i32(t1_3), - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - ) - }, - V4::Ipv6(e) => { - let super::super::super::wasi::sockets::network::Ipv6SocketAddress{ port:port2, flow_info:flow_info2, address:address2, scope_id:scope_id2, } = e; - let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; - - ( - 1i32, - _rt::as_i32(port2), - _rt::as_i32(flow_info2), - _rt::as_i32(t3_0), - _rt::as_i32(t3_1), - _rt::as_i32(t3_2), - _rt::as_i32(t3_3), - _rt::as_i32(t3_4), - _rt::as_i32(t3_5), - _rt::as_i32(t3_6), - _rt::as_i32(t3_7), - _rt::as_i32(scope_id2), - ) - }, - }; - let ptr6 = ret_area.0.as_mut_ptr().cast::(); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.start-bind"] - fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ); + #[link_name = "[method]tcp-socket.set-receive-buffer-size"] + fn wit_import1(_: i32, _: i64, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ) { + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { unreachable!() } - wit_import7( - (self).handle() as i32, - (network).handle() as i32, - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ptr6, - ); - let l8 = i32::from(*ptr6.add(0).cast::()); - let result10 = match l8 { + wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { let e = (); Ok(e) }, 1 => { let e = { - let l9 = i32::from(*ptr6.add(1).cast::()); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l9 as u8, - ) + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result10 + result9 } } } - impl UdpSocket { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn finish_bind(&self) -> Result<(), ErrorCode> { + pub fn get_send_buffer_size(&self) -> Result { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.finish-bind"] + #[link_name = "[method]tcp-socket.get-send-buffer-size"] fn wit_import1(_: i32, _: *mut u8); } @@ -5555,315 +10832,240 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 - } - } - } - impl UdpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn stream( - &self, - remote_address: Option, - ) -> Result<(IncomingDatagramStream, OutgoingDatagramStream), ErrorCode> - { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ( - result6_0, - result6_1, - result6_2, - result6_3, - result6_4, - result6_5, - result6_6, - result6_7, - result6_8, - result6_9, - result6_10, - result6_11, - result6_12, - ) = match remote_address { - Some(e) => { - use super::super::super::wasi::sockets::network::IpSocketAddress as V4; - let ( - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ) = match e { - V4::Ipv4(e) => { - let super::super::super::wasi::sockets::network::Ipv4SocketAddress{ port:port0, address:address0, } = e; - let (t1_0, t1_1, t1_2, t1_3) = address0; - - ( - 0i32, - _rt::as_i32(port0), - _rt::as_i32(t1_0), - _rt::as_i32(t1_1), - _rt::as_i32(t1_2), - _rt::as_i32(t1_3), - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - ) - }, - V4::Ipv6(e) => { - let super::super::super::wasi::sockets::network::Ipv6SocketAddress{ port:port2, flow_info:flow_info2, address:address2, scope_id:scope_id2, } = e; - let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = - address2; - - ( - 1i32, - _rt::as_i32(port2), - _rt::as_i32(flow_info2), - _rt::as_i32(t3_0), - _rt::as_i32(t3_1), - _rt::as_i32(t3_2), - _rt::as_i32(t3_3), - _rt::as_i32(t3_4), - _rt::as_i32(t3_5), - _rt::as_i32(t3_6), - _rt::as_i32(t3_7), - _rt::as_i32(scope_id2), - ) - }, - }; - - ( - 1i32, result5_0, result5_1, result5_2, result5_3, result5_4, - result5_5, result5_6, result5_7, result5_8, result5_9, - result5_10, result5_11, - ) - }, - None => ( - 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32, - 0i32, 0i32, - ), - }; - let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]udp-socket.stream"] - fn wit_import8( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import8( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ) { - unreachable!() - } - wit_import8( - (self).handle() as i32, - result6_0, - result6_1, - result6_2, - result6_3, - result6_4, - result6_5, - result6_6, - result6_7, - result6_8, - result6_9, - result6_10, - result6_11, - result6_12, - ptr7, - ); - let l9 = i32::from(*ptr7.add(0).cast::()); - let result13 = match l9 { + let result10 = match l2 { 0 => { let e = { - let l10 = *ptr7.add(4).cast::(); - let l11 = *ptr7.add(8).cast::(); + let l3 = *ptr0.add(8).cast::(); - ( - IncomingDatagramStream::from_handle(l10 as u32), - OutgoingDatagramStream::from_handle(l11 as u32), - ) + l3 as u64 }; Ok(e) }, 1 => { let e = { - let l12 = i32::from(*ptr7.add(4).cast::()); + let l4 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l12 as u8, - ) + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result13 + result10 } } } - impl UdpSocket { + impl TcpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn local_address(&self) -> Result { + pub fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 36]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 36]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.local-address"] - fn wit_import1(_: i32, _: *mut u8); + #[link_name = "[method]tcp-socket.set-send-buffer-size"] + fn wit_import1(_: i32, _: i64, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, ptr0); + wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result22 = match l2 { + let result9 = match l2 { 0 => { + let e = (); + Ok(e) + }, + 1 => { let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - use super::super::super::wasi::sockets::network::IpSocketAddress as V20; - let v20 = match l3 { - 0 => { - let e20 = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let l5 = i32::from(*ptr0.add(10).cast::()); - let l6 = i32::from(*ptr0.add(11).cast::()); - let l7 = i32::from(*ptr0.add(12).cast::()); - let l8 = i32::from(*ptr0.add(13).cast::()); - - super::super::super::wasi::sockets::network::Ipv4SocketAddress{ - port: l4 as u16, - address: (l5 as u8, l6 as u8, l7 as u8, l8 as u8), - } - }; - V20::Ipv4(e20) - }, + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e20 = { - let l9 = i32::from(*ptr0.add(8).cast::()); - let l10 = *ptr0.add(12).cast::(); - let l11 = i32::from(*ptr0.add(16).cast::()); - let l12 = i32::from(*ptr0.add(18).cast::()); - let l13 = i32::from(*ptr0.add(20).cast::()); - let l14 = i32::from(*ptr0.add(22).cast::()); - let l15 = i32::from(*ptr0.add(24).cast::()); - let l16 = i32::from(*ptr0.add(26).cast::()); - let l17 = i32::from(*ptr0.add(28).cast::()); - let l18 = i32::from(*ptr0.add(30).cast::()); - let l19 = *ptr0.add(32).cast::(); - - super::super::super::wasi::sockets::network::Ipv6SocketAddress{ - port: l9 as u16, - flow_info: l10 as u32, - address: (l11 as u16, l12 as u16, l13 as u16, l14 as u16, l15 as u16, l16 as u16, l17 as u16, l18 as u16), - scope_id: l19 as u32, - } + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } }; - V20::Ipv6(e20) + ErrorCode::Other(e8) }, }; - v20 - }; - Ok(e) - }, - 1 => { - let e = { - let l21 = i32::from(*ptr0.add(4).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l21 as u8, - ) + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result22 + result9 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// 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. + /// + /// Unlike POSIX, WASI sockets have no notion of a socket-level + /// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's + /// async support. + /// + /// # References: + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn remote_address(&self) -> Result { + pub fn create(address_family: IpAddressFamily) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 36]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 36]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.remote-address"] + #[link_name = "[static]udp-socket.create"] fn wit_import1(_: i32, _: *mut u8); } @@ -5871,201 +11073,617 @@ pub mod wasi { unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, ptr0); + wit_import1(address_family.clone() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result22 = match l2 { + let result10 = match l2 { 0 => { let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - use super::super::super::wasi::sockets::network::IpSocketAddress as V20; - let v20 = match l3 { - 0 => { - let e20 = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let l5 = i32::from(*ptr0.add(10).cast::()); - let l6 = i32::from(*ptr0.add(11).cast::()); - let l7 = i32::from(*ptr0.add(12).cast::()); - let l8 = i32::from(*ptr0.add(13).cast::()); - - super::super::super::wasi::sockets::network::Ipv4SocketAddress{ - port: l4 as u16, - address: (l5 as u8, l6 as u8, l7 as u8, l8 as u8), - } - }; - V20::Ipv4(e20) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e20 = { - let l9 = i32::from(*ptr0.add(8).cast::()); - let l10 = *ptr0.add(12).cast::(); - let l11 = i32::from(*ptr0.add(16).cast::()); - let l12 = i32::from(*ptr0.add(18).cast::()); - let l13 = i32::from(*ptr0.add(20).cast::()); - let l14 = i32::from(*ptr0.add(22).cast::()); - let l15 = i32::from(*ptr0.add(24).cast::()); - let l16 = i32::from(*ptr0.add(26).cast::()); - let l17 = i32::from(*ptr0.add(28).cast::()); - let l18 = i32::from(*ptr0.add(30).cast::()); - let l19 = *ptr0.add(32).cast::(); - - super::super::super::wasi::sockets::network::Ipv6SocketAddress{ - port: l9 as u16, - flow_info: l10 as u32, - address: (l11 as u16, l12 as u16, l13 as u16, l14 as u16, l15 as u16, l16 as u16, l17 as u16, l18 as u16), - scope_id: l19 as u32, - } - }; - V20::Ipv6(e20) - }, - }; + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); - v20 + UdpSocket::from_handle(l3 as u32) }; Ok(e) }, 1 => { let e = { - let l21 = i32::from(*ptr0.add(4).cast::()); + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l21 as u8, - ) + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result22 + result10 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Bind the socket to the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is + /// left to the implementation to decide which network interface(s) to + /// bind to. If the port is zero, the socket will be bound to a random + /// free port. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `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 can be bound to. (EADDRNOTAVAIL) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn address_family(&self) -> IpAddressFamily { + pub fn bind(&self, local_address: IpSocketAddress) -> Result<(), ErrorCode> { unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]udp-socket.address-family"] - fn wit_import0(_: i32) -> i32; - } + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ( + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ) = match local_address { + IpSocketAddress::Ipv4(e) => { + let Ipv4SocketAddress { port: port0, address: address0 } = e; + let (t1_0, t1_1, t1_2, t1_3) = address0; - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::sockets::network::IpAddressFamily::_lift( - ret as u8, - ) - } - } - } - impl UdpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn unicast_hop_limit(&self) -> Result { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + ( + 0i32, + _rt::as_i32(port0), + _rt::as_i32(t1_0), + _rt::as_i32(t1_1), + _rt::as_i32(t1_2), + _rt::as_i32(t1_3), + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + ) + }, + IpSocketAddress::Ipv6(e) => { + let Ipv6SocketAddress { + port: port2, + flow_info: flow_info2, + address: address2, + scope_id: scope_id2, + } = e; + let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; + + ( + 1i32, + _rt::as_i32(port2), + _rt::as_i32(flow_info2), + _rt::as_i32(t3_0), + _rt::as_i32(t3_1), + _rt::as_i32(t3_2), + _rt::as_i32(t3_3), + _rt::as_i32(t3_4), + _rt::as_i32(t3_5), + _rt::as_i32(t3_6), + _rt::as_i32(t3_7), + _rt::as_i32(scope_id2), + ) + }, + }; + let ptr5 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.unicast-hop-limit"] - fn wit_import1(_: i32, _: *mut u8); + #[link_name = "[method]udp-socket.bind"] + fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ) { unreachable!() } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { + wit_import6( + (self).handle() as i32, + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ptr5, + ); + let l7 = i32::from(*ptr5.add(0).cast::()); + let result14 = match l7 { 0 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - l3 as u8 - }; + let e = (); Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr0.add(1).cast::()); + let l8 = i32::from( + *ptr5.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v13 = match l8 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e13 = { + let l9 = i32::from( + *ptr5 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) + match l9 { + 0 => None, + 1 => { + let e = { + let l10 = *ptr5 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l11 = *ptr5 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts( + l10.cast(), + len12, + len12, + ); + + _rt::string_lift(bytes12) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e13) + }, + }; + + v13 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result5 + result14 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Associate this socket with a specific peer address. + /// + /// On success, the `remote-address` of the socket is updated. + /// The `local-address` may be updated as well, based on the best network + /// path to `remote-address`. If the socket was not already explicitly + /// bound, this function will implicitly bind the socket to a random + /// free port. + /// + /// When a UDP socket is "connected", the `send` and `receive` methods + /// are limited to communicating with that peer only: + /// - `send` can only be used to send to this destination. + /// - `receive` will only return datagrams sent from the provided `remote-address`. + /// + /// The name "connect" was kept to align with the existing POSIX + /// terminology. Other than that, this function only changes the local + /// socket configuration and does not generate any network traffic. + /// The peer is not aware of this "connection". + /// + /// This method may be called multiple times on the same socket to change + /// its association, but only the most recent one will be effective. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `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) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// + /// # Implementors note + /// If the socket is already connected, some platforms (e.g. Linux) + /// require a disconnect before connecting to a different peer address. + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn set_unicast_hop_limit(&self, value: u8) -> Result<(), ErrorCode> { + pub fn connect(&self, remote_address: IpSocketAddress) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ( + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ) = match remote_address { + IpSocketAddress::Ipv4(e) => { + let Ipv4SocketAddress { port: port0, address: address0 } = e; + let (t1_0, t1_1, t1_2, t1_3) = address0; + + ( + 0i32, + _rt::as_i32(port0), + _rt::as_i32(t1_0), + _rt::as_i32(t1_1), + _rt::as_i32(t1_2), + _rt::as_i32(t1_3), + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + 0i32, + ) + }, + IpSocketAddress::Ipv6(e) => { + let Ipv6SocketAddress { + port: port2, + flow_info: flow_info2, + address: address2, + scope_id: scope_id2, + } = e; + let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; + + ( + 1i32, + _rt::as_i32(port2), + _rt::as_i32(flow_info2), + _rt::as_i32(t3_0), + _rt::as_i32(t3_1), + _rt::as_i32(t3_2), + _rt::as_i32(t3_3), + _rt::as_i32(t3_4), + _rt::as_i32(t3_5), + _rt::as_i32(t3_6), + _rt::as_i32(t3_7), + _rt::as_i32(scope_id2), + ) + }, + }; + let ptr5 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.set-unicast-hop-limit"] - fn wit_import1(_: i32, _: i32, _: *mut u8); + #[link_name = "[method]udp-socket.connect"] + fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { + unsafe extern "C" fn wit_import6( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: *mut u8, + ) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { + wit_import6( + (self).handle() as i32, + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + result4_7, + result4_8, + result4_9, + result4_10, + result4_11, + ptr5, + ); + let l7 = i32::from(*ptr5.add(0).cast::()); + let result14 = match l7 { 0 => { let e = (); Ok(e) }, 1 => { let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + let l8 = i32::from( + *ptr5.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v13 = match l8 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e13 = { + let l9 = i32::from( + *ptr5 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) + match l9 { + 0 => None, + 1 => { + let e = { + let l10 = *ptr5 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l11 = *ptr5 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts( + l10.cast(), + len12, + len12, + ); + + _rt::string_lift(bytes12) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e13) + }, + }; + + v13 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result4 + result14 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Dissociate this socket from its peer address. + /// + /// After calling this method, `send` & `receive` are free to communicate + /// with any remote address again. + /// + /// The POSIX equivalent of this is calling `connect` with an `AF_UNSPEC` address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected. + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn receive_buffer_size(&self) -> Result { + pub fn disconnect(&self) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.receive-buffer-size"] + #[link_name = "[method]udp-socket.disconnect"] fn wit_import1(_: i32, _: *mut u8); } @@ -6075,87 +11693,709 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { + let result9 = match l2 { 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); - - l3 as u64 - }; + let e = (); Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result5 + result9 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Send a message on the socket to a particular peer. + /// + /// If the socket is connected, the peer address may be left empty. In + /// that case this is equivalent to `send` in POSIX. Otherwise it is + /// equivalent to `sendto`. + /// + /// Additionally, if the socket is connected, a `remote-address` argument + /// _may_ be provided but then it must be identical to the address + /// passed to `connect`. + /// + /// If the socket has not been explicitly bound, it will be + /// implicitly bound to a random free port. + /// + /// Implementations may trap if the `data` length exceeds 64 KiB. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `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 `connect`. (EISCONN) + /// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) + /// + /// # Implementors note + /// WASI requires `send` to perform an implicit bind if the socket + /// has not been bound. Not all platforms (notably Windows) exhibit + /// this behavior natively. On such platforms, the WASI implementation + /// should emulate it by performing the bind if the guest has not + /// already done so. + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { + pub async fn send( + &self, + data: _rt::Vec, + remote_address: Option, + ) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]udp-socket.set-receive-buffer-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a UdpSocket, _rt::Vec, Option); + type Results = Result<(), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (32 + 9 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() + fn results_offset(&mut self) -> usize { + (32 + 4 * ::core::mem::size_of::<*const u8>()) + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]udp-socket.send"] + fn call(_: *mut u8, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 1, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + let l0 = *_params + .0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l1 = *_params + .0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 1, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0, _lower1, _lower2): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + let _param_ptr = unsafe { _ptr.add(0) }; + unsafe { + *_param_ptr.add(0).cast::() = (_lower0).handle() as i32; + } + let _param_ptr = + unsafe { _ptr.add(::core::mem::size_of::<*const u8>()) }; + unsafe { + let vec0 = + <_ as Into<_rt::Vec<_>>>::into(_lower1).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *_param_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *_param_ptr.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + let _param_ptr = + unsafe { _ptr.add((3 * ::core::mem::size_of::<*const u8>())) }; + unsafe { + match _lower2 { + Some(e) => { + *_param_ptr.add(0).cast::() = (1i32) as u8; + match e { + IpSocketAddress::Ipv4(e) => { + *_param_ptr.add(4).cast::() = (0i32) as u8; + let Ipv4SocketAddress { + port: port0, + address: address0, + } = e; + *_param_ptr.add(8).cast::() = + (_rt::as_i32(port0)) as u16; + let (t1_0, t1_1, t1_2, t1_3) = address0; + *_param_ptr.add(10).cast::() = + (_rt::as_i32(t1_0)) as u8; + *_param_ptr.add(11).cast::() = + (_rt::as_i32(t1_1)) as u8; + *_param_ptr.add(12).cast::() = + (_rt::as_i32(t1_2)) as u8; + *_param_ptr.add(13).cast::() = + (_rt::as_i32(t1_3)) as u8; + }, + IpSocketAddress::Ipv6(e) => { + *_param_ptr.add(4).cast::() = (1i32) as u8; + let Ipv6SocketAddress { + port: port2, + flow_info: flow_info2, + address: address2, + scope_id: scope_id2, + } = e; + *_param_ptr.add(8).cast::() = + (_rt::as_i32(port2)) as u16; + *_param_ptr.add(12).cast::() = + _rt::as_i32(flow_info2); + let ( + t3_0, + t3_1, + t3_2, + t3_3, + t3_4, + t3_5, + t3_6, + t3_7, + ) = address2; + *_param_ptr.add(16).cast::() = + (_rt::as_i32(t3_0)) as u16; + *_param_ptr.add(18).cast::() = + (_rt::as_i32(t3_1)) as u16; + *_param_ptr.add(20).cast::() = + (_rt::as_i32(t3_2)) as u16; + *_param_ptr.add(22).cast::() = + (_rt::as_i32(t3_3)) as u16; + *_param_ptr.add(24).cast::() = + (_rt::as_i32(t3_4)) as u16; + *_param_ptr.add(26).cast::() = + (_rt::as_i32(t3_5)) as u16; + *_param_ptr.add(28).cast::() = + (_rt::as_i32(t3_6)) as u16; + *_param_ptr.add(30).cast::() = + (_rt::as_i32(t3_7)) as u16; + *_param_ptr.add(32).cast::() = + _rt::as_i32(scope_id2); + }, + } + }, + None => { + *_param_ptr.add(0).cast::() = (0i32) as u8; + }, + }; + } + ParamsLower(_ptr) + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v6 = match l1 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!( + n, 14, + "invalid enum discriminant" + ); + let e6 = { + let l2 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e6) + }, + }; + + v6 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } } - wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + _MySubtask { _unused: core::marker::PhantomData } + .call((self, data, remote_address)) + .await + } + } + } + impl UdpSocket { + #[allow(unused_unsafe, clippy::all)] + /// Receive a message on the socket. + /// + /// On success, the return value contains a tuple of the received data + /// and the address of the sender. Theoretical maximum length of the + /// data is 64 KiB. Though in practice, it will typically be less than + /// 1500 bytes. + /// + /// If the socket is connected, the sender address is guaranteed to + /// match the remote address passed to `connect`. + /// + /// # Typical errors + /// - `invalid-state`: The socket has not been bound yet. + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + #[allow(async_fn_in_trait)] + pub async fn receive(&self) -> Result<(_rt::Vec, IpSocketAddress), ErrorCode> { + unsafe { + #[derive(Copy, Clone)] + struct ParamsLower(i32); + unsafe impl Send for ParamsLower {} - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (&'a UdpSocket,); + type Results = Result<(_rt::Vec, IpSocketAddress), ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (32 + 3 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + } + } + + fn results_offset(&mut self) -> usize { + 0 + } + + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower][method]udp-socket.receive"] + fn call(_: i32, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: i32, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _results) as u32 } + } + + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe {} + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe {} + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { ParamsLower((_lower0).handle() as i32) } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = { + let l1 = *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l2 = *_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len3 = l2; + let l4 = i32::from( + *_ptr + .add( + 3 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + let v21 = match l4 { + 0 => { + let e21 = { + let l5 = i32::from(*_ptr.add(4+3*::core::mem::size_of::<*const u8>()).cast::()); + let l6 = i32::from(*_ptr.add(6+3*::core::mem::size_of::<*const u8>()).cast::()); + let l7 = i32::from(*_ptr.add(7+3*::core::mem::size_of::<*const u8>()).cast::()); + let l8 = i32::from(*_ptr.add(8+3*::core::mem::size_of::<*const u8>()).cast::()); + let l9 = i32::from(*_ptr.add(9+3*::core::mem::size_of::<*const u8>()).cast::()); + + Ipv4SocketAddress { + port: l5 as u16, + address: ( + l6 as u8, l7 as u8, l8 as u8, + l9 as u8, + ), + } + }; + IpSocketAddress::Ipv4(e21) + }, + n => { + debug_assert_eq!( + n, 1, + "invalid enum discriminant" + ); + let e21 = { + let l10 = i32::from(*_ptr.add(4+3*::core::mem::size_of::<*const u8>()).cast::()); + let l11 = *_ptr + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let l12 = i32::from(*_ptr.add(12+3*::core::mem::size_of::<*const u8>()).cast::()); + let l13 = i32::from(*_ptr.add(14+3*::core::mem::size_of::<*const u8>()).cast::()); + let l14 = i32::from(*_ptr.add(16+3*::core::mem::size_of::<*const u8>()).cast::()); + let l15 = i32::from(*_ptr.add(18+3*::core::mem::size_of::<*const u8>()).cast::()); + let l16 = i32::from(*_ptr.add(20+3*::core::mem::size_of::<*const u8>()).cast::()); + let l17 = i32::from(*_ptr.add(22+3*::core::mem::size_of::<*const u8>()).cast::()); + let l18 = i32::from(*_ptr.add(24+3*::core::mem::size_of::<*const u8>()).cast::()); + let l19 = i32::from(*_ptr.add(26+3*::core::mem::size_of::<*const u8>()).cast::()); + let l20 = *_ptr + .add( + 28 + 3 + * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + + Ipv6SocketAddress { + port: l10 as u16, + flow_info: l11 as u32, + address: ( + l12 as u16, l13 as u16, + l14 as u16, l15 as u16, + l16 as u16, l17 as u16, + l18 as u16, l19 as u16, + ), + scope_id: l20 as u32, + } + }; + IpSocketAddress::Ipv6(e21) + }, + }; + + ( + <_ as From<_rt::Vec<_>>>::from( + _rt::Vec::from_raw_parts( + l1.cast(), + len3, + len3, + ), + ), + v21, + ) + }; + Ok(e) + }, + 1 => { + let e = { + let l22 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v27 = match l22 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!( + n, 14, + "invalid enum discriminant" + ); + let e27 = { + let l23 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + + match l23 { + 0 => None, + 1 => { + let e = { + let l24 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l25 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len26 = l25; + let bytes26 = _rt::Vec::from_raw_parts(l24.cast(), len26, len26); + + _rt::string_lift(bytes26) + }; + Some(e) + }, + _ => { + _rt::invalid_enum_discriminant() + }, + } + }; + ErrorCode::Other(e27) + }, + }; + + v27 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + _MySubtask { _unused: core::marker::PhantomData }.call((self,)).await } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Get the current bound address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `get-local-address` to return + /// `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn send_buffer_size(&self) -> Result { + pub fn get_local_address(&self) -> Result { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 32 + 1 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]udp-socket.send-buffer-size"] + #[link_name = "[method]udp-socket.get-local-address"] fn wit_import1(_: i32, _: *mut u8); } @@ -6165,395 +12405,591 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { + let result27 = match l2 { 0 => { let e = { - let l3 = *ptr0.add(8).cast::(); - - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v20 = match l3 { + 0 => { + let e20 = { + let l4 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l5 = i32::from( + *ptr0 + .add( + 6 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l6 = i32::from( + *ptr0 + .add( + 7 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l7 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l8 = i32::from( + *ptr0 + .add( + 9 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 - } - } - } - impl UdpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]udp-socket.set-send-buffer-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } + Ipv4SocketAddress { + port: l4 as u16, + address: ( + l5 as u8, l6 as u8, l7 as u8, l8 as u8, + ), + } + }; + IpSocketAddress::Ipv4(e20) + }, + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + let e20 = { + let l9 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l10 = *ptr0 + .add( + 8 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l11 = i32::from( + *ptr0 + .add( + 12 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *ptr0 + .add( + 14 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l13 = i32::from( + *ptr0 + .add( + 16 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l14 = i32::from( + *ptr0 + .add( + 18 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *ptr0 + .add( + 20 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l16 = i32::from( + *ptr0 + .add( + 22 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l17 = i32::from( + *ptr0 + .add( + 24 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l18 = i32::from( + *ptr0 + .add( + 26 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l19 = *ptr0 + .add( + 28 + 1 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); + Ipv6SocketAddress { + port: l9 as u16, + flow_info: l10 as u32, + address: ( + l11 as u16, l12 as u16, l13 as u16, + l14 as u16, l15 as u16, l16 as u16, + l17 as u16, l18 as u16, + ), + scope_id: l19 as u32, + } + }; + IpSocketAddress::Ipv6(e20) + }, + }; + + v20 + }; Ok(e) }, 1 => { let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + let l21 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v26 = match l21 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e26 = { + let l22 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) + match l22 { + 0 => None, + 1 => { + let e = { + let l23 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l24 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts( + l23.cast(), + len25, + len25, + ); + + _rt::string_lift(bytes25) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e26) + }, + }; + + v26 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result4 + result27 } } } impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Get the address the socket is currently "connected" to. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not "connected" to a specific remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]udp-socket.subscribe"] - fn wit_import0(_: i32) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl IncomingDatagramStream { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn receive( - &self, - max_results: u64, - ) -> Result<_rt::Vec, ErrorCode> { + pub fn get_remote_address(&self) -> Result { unsafe { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] #[cfg_attr(target_pointer_width = "32", repr(align(4)))] struct RetArea( - [::core::mem::MaybeUninit; 3 * ::core::mem::size_of::<*const u8>()], + [::core::mem::MaybeUninit; + 32 + 1 * ::core::mem::size_of::<*const u8>()], ); let mut ret_area = RetArea( [::core::mem::MaybeUninit::uninit(); - 3 * ::core::mem::size_of::<*const u8>()], + 32 + 1 * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]incoming-datagram-stream.receive"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[method]udp-socket.get-remote-address"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&max_results), ptr0); + wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result28 = match l2 { + let result27 = match l2 { 0 => { let e = { - let l3 = *ptr0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l4 = *ptr0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let base26 = l3; - let len26 = l4; - let mut result26 = _rt::Vec::with_capacity(len26); - for i in 0..len26 { - let base = base26.add( - i * (32 + 2 * ::core::mem::size_of::<*const u8>()), - ); - let e26 = { - let l5 = *base.add(0).cast::<*mut u8>(); - let l6 = *base - .add(::core::mem::size_of::<*const u8>()) - .cast::(); - let len7 = l6; - let l8 = i32::from( - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(), - ); - use super::super::super::wasi::sockets::network::IpSocketAddress as V25; - let v25 = match l8 { - 0 => { - let e25 = { - let l9 = i32::from( - *base - .add( - 4 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l10 = i32::from( - *base - .add( - 6 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l11 = i32::from( - *base - .add( - 7 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l12 = i32::from( - *base - .add( - 8 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l13 = i32::from( - *base - .add( - 9 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - - super::super::super::wasi::sockets::network::Ipv4SocketAddress{ - port: l9 as u16, - address: (l10 as u8, l11 as u8, l12 as u8, l13 as u8), - } - }; - V25::Ipv4(e25) - }, - n => { - debug_assert_eq!( - n, 1, - "invalid enum discriminant" - ); - let e25 = { - let l14 = i32::from( - *base - .add( - 4 + 2 * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l15 = *base - .add( - 8 + 2 * ::core::mem::size_of::< - *const u8, - >( + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v20 = match l3 { + 0 => { + let e20 = { + let l4 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( ), - ) - .cast::(); - let l16 = i32::from( - *base - .add( - 12 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l17 = i32::from( - *base - .add( - 14 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l18 = i32::from( - *base - .add( - 16 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l19 = i32::from( - *base - .add( - 18 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l20 = i32::from( - *base - .add( - 20 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l21 = i32::from( - *base - .add( - 22 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l22 = i32::from( - *base - .add( - 24 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l23 = i32::from( - *base - .add( - 26 + 2 - * ::core::mem::size_of::< - *const u8, - >( - ), - ) - .cast::(), - ); - let l24 = *base - .add( - 28 + 2 * ::core::mem::size_of::< - *const u8, - >( + ) + .cast::(), + ); + let l5 = i32::from( + *ptr0 + .add( + 6 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l6 = i32::from( + *ptr0 + .add( + 7 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l7 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l8 = i32::from( + *ptr0 + .add( + 9 + 1 + * ::core::mem::size_of::<*const u8>( ), - ) - .cast::(); + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::Ipv6SocketAddress{ - port: l14 as u16, - flow_info: l15 as u32, - address: (l16 as u16, l17 as u16, l18 as u16, l19 as u16, l20 as u16, l21 as u16, l22 as u16, l23 as u16), - scope_id: l24 as u32, - } - }; - V25::Ipv6(e25) - }, + Ipv4SocketAddress { + port: l4 as u16, + address: ( + l5 as u8, l6 as u8, l7 as u8, l8 as u8, + ), + } }; + IpSocketAddress::Ipv4(e20) + }, + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + let e20 = { + let l9 = i32::from( + *ptr0 + .add( + 4 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); + let l10 = *ptr0 + .add( + 8 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(); + let l11 = i32::from( + *ptr0 + .add( + 12 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l12 = i32::from( + *ptr0 + .add( + 14 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l13 = i32::from( + *ptr0 + .add( + 16 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l14 = i32::from( + *ptr0 + .add( + 18 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l15 = i32::from( + *ptr0 + .add( + 20 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l16 = i32::from( + *ptr0 + .add( + 22 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l17 = i32::from( + *ptr0 + .add( + 24 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l18 = i32::from( + *ptr0 + .add( + 26 + 1 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); + let l19 = *ptr0 + .add( + 28 + 1 * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(); - IncomingDatagram { - data: _rt::Vec::from_raw_parts( - l5.cast(), - len7, - len7, - ), - remote_address: v25, - } - }; - result26.push(e26); - } - _rt::cabi_dealloc( - base26, - len26 * (32 + 2 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); + Ipv6SocketAddress { + port: l9 as u16, + flow_info: l10 as u32, + address: ( + l11 as u16, l12 as u16, l13 as u16, + l14 as u16, l15 as u16, l16 as u16, + l17 as u16, l18 as u16, + ), + scope_id: l19 as u32, + } + }; + IpSocketAddress::Ipv6(e20) + }, + }; - result26 + v20 }; Ok(e) }, 1 => { let e = { - let l27 = i32::from( + let l21 = i32::from( *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), ); + let v26 = match l21 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e26 = { + let l22 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l27 as u8, - ) + match l22 { + 0 => None, + 1 => { + let e = { + let l23 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l24 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts( + l23.cast(), + len25, + len25, + ); + + _rt::string_lift(bytes25) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e26) + }, + }; + + v26 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result28 + result27 } } } - impl IncomingDatagramStream { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Whether this is a IPv4 or IPv6 socket. + /// + /// This is the value passed to the constructor. + /// + /// Equivalent to the SO_DOMAIN socket option. #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { + pub fn get_address_family(&self) -> IpAddressFamily { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]incoming-datagram-stream.subscribe"] + #[link_name = "[method]udp-socket.get-address-family"] fn wit_import0(_: i32) -> i32; } @@ -6562,23 +12998,35 @@ pub mod wasi { unreachable!() } let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + IpAddressFamily::_lift(ret as u8) } } } - impl OutgoingDatagramStream { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. #[allow(async_fn_in_trait)] - pub fn check_send(&self) -> Result { + pub fn get_unicast_hop_limit(&self) -> Result { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]outgoing-datagram-stream.check-send"] + #[link_name = "[method]udp-socket.get-unicast-hop-limit"] fn wit_import1(_: i32, _: *mut u8); } @@ -6588,579 +13036,468 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { + let result10 = match l2 { 0 => { let e = { - let l3 = *ptr0.add(8).cast::(); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); - l3 as u64 + l3 as u8 }; Ok(e) }, 1 => { let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); + let l4 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result5 + result10 } } } - impl OutgoingDatagramStream { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn send(&self, datagrams: &[OutgoingDatagram]) -> Result { + pub fn set_unicast_hop_limit(&self, value: u8) -> Result<(), ErrorCode> { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let vec7 = datagrams; - let len7 = vec7.len(); - let layout7 = _rt::alloc::Layout::from_size_align( - vec7.len() * (32 + 3 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ) - .unwrap(); - let (result7, _cleanup7) = wit_bindgen_rt::Cleanup::new(layout7); - for (i, e) in vec7.into_iter().enumerate() { - let base = - result7.add(i * (32 + 3 * ::core::mem::size_of::<*const u8>())); - { - let OutgoingDatagram { - data: data0, - remote_address: remote_address0, - } = e; - let vec1 = data0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - *base.add(::core::mem::size_of::<*const u8>()).cast::() = - len1; - *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); - match remote_address0 { - Some(e) => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (1i32) as u8; - use super::super::super::wasi::sockets::network::IpSocketAddress as V6; - match e { - V6::Ipv4(e) => { - *base - .add( - 4 + 2 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = (0i32) as u8; - let super::super::super::wasi::sockets::network::Ipv4SocketAddress{ port:port2, address:address2, } = e; - *base - .add( - 8 + 2 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = (_rt::as_i32(port2)) as u16; - let (t3_0, t3_1, t3_2, t3_3) = address2; - *base - .add( - 10 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t3_0)) as u8; - *base - .add( - 11 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t3_1)) as u8; - *base - .add( - 12 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t3_2)) as u8; - *base - .add( - 13 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t3_3)) as u8; - }, - V6::Ipv6(e) => { - *base - .add( - 4 + 2 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = (1i32) as u8; - let super::super::super::wasi::sockets::network::Ipv6SocketAddress{ port:port4, flow_info:flow_info4, address:address4, scope_id:scope_id4, } = e; - *base - .add( - 8 + 2 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = (_rt::as_i32(port4)) as u16; - *base - .add( - 12 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = _rt::as_i32(flow_info4); - let ( - t5_0, - t5_1, - t5_2, - t5_3, - t5_4, - t5_5, - t5_6, - t5_7, - ) = address4; - *base - .add( - 16 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_0)) as u16; - *base - .add( - 18 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_1)) as u16; - *base - .add( - 20 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_2)) as u16; - *base - .add( - 22 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_3)) as u16; - *base - .add( - 24 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_4)) as u16; - *base - .add( - 26 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_5)) as u16; - *base - .add( - 28 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_6)) as u16; - *base - .add( - 30 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = (_rt::as_i32(t5_7)) as u16; - *base - .add( - 32 + 2 * ::core::mem::size_of::<*const u8>( - ), - ) - .cast::() = _rt::as_i32(scope_id4); - }, - } - }, - None => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (0i32) as u8; - }, - }; - } - } - let ptr8 = ret_area.0.as_mut_ptr().cast::(); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]outgoing-datagram-stream.send"] - fn wit_import9(_: i32, _: *mut u8, _: usize, _: *mut u8); + #[link_name = "[method]udp-socket.set-unicast-hop-limit"] + fn wit_import1(_: i32, _: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import9(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { unreachable!() } - wit_import9((self).handle() as i32, result7, len7, ptr8); - let l10 = i32::from(*ptr8.add(0).cast::()); - let result13 = match l10 { + wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { - let e = { - let l11 = *ptr8.add(8).cast::(); - - l11 as u64 - }; + let e = (); Ok(e) }, 1 => { let e = { - let l12 = i32::from(*ptr8.add(8).cast::()); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l12 as u8, - ) + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result13 + result9 } } } - impl OutgoingDatagramStream { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] + /// Kernel buffer space reserved for sending/receiving on this socket. + /// Implementations usually treat this as a cap the buffer can grow to, + /// rather than allocating the full amount immediately. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { + pub fn get_receive_buffer_size(&self) -> Result { unsafe { + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]outgoing-datagram-stream.subscribe"] - fn wit_import0(_: i32) -> i32; + #[link_name = "[method]udp-socket.get-receive-buffer-size"] + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - } - - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod udp_create_socket { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; - - use super::super::super::_rt; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpAddressFamily = super::super::super::wasi::sockets::network::IpAddressFamily; - pub type UdpSocket = super::super::super::wasi::sockets::udp::UdpSocket; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn create_udp_socket( - address_family: IpAddressFamily, - ) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/udp-create-socket@0.2.0")] - unsafe extern "C" { - #[link_name = "create-udp-socket"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1(address_family.clone() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { + 0 => { + let e = { + let l3 = *ptr0.add(8).cast::(); - super::super::super::wasi::sockets::udp::UdpSocket::from_handle( - l3 as u32, - ) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); + l3 as u64 + }; + Ok(e) + }, + 1 => { + let e = { + let l4 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 - } - } - } + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod tcp { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; - use super::super::super::_rt; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - pub type Network = super::super::super::wasi::sockets::network::Network; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpSocketAddress = super::super::super::wasi::sockets::network::IpSocketAddress; - pub type IpAddressFamily = super::super::super::wasi::sockets::network::IpAddressFamily; - #[repr(u8)] - #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] - pub enum ShutdownType { - Receive, - Send, - Both, - } - impl ::core::fmt::Debug for ShutdownType { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - ShutdownType::Receive => f.debug_tuple("ShutdownType::Receive").finish(), - ShutdownType::Send => f.debug_tuple("ShutdownType::Send").finish(), - ShutdownType::Both => f.debug_tuple("ShutdownType::Both").finish(), + v9 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + }; + result10 } } } - - impl ShutdownType { - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> ShutdownType { - if !cfg!(debug_assertions) { - return unsafe { ::core::mem::transmute(val) }; - } - - match val { - 0 => ShutdownType::Receive, - 1 => ShutdownType::Send, - 2 => ShutdownType::Both, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct TcpSocket { - handle: _rt::Resource, - } - - impl TcpSocket { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } - - unsafe impl _rt::WasmResource for TcpSocket { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]tcp-socket"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn start_bind( - &self, - network: &Network, - local_address: IpSocketAddress, - ) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - use super::super::super::wasi::sockets::network::IpSocketAddress as V4; - let ( - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ) = match local_address { - V4::Ipv4(e) => { - let super::super::super::wasi::sockets::network::Ipv4SocketAddress{ port:port0, address:address0, } = e; - let (t1_0, t1_1, t1_2, t1_3) = address0; - - ( - 0i32, - _rt::as_i32(port0), - _rt::as_i32(t1_0), - _rt::as_i32(t1_1), - _rt::as_i32(t1_2), - _rt::as_i32(t1_3), - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - ) - }, - V4::Ipv6(e) => { - let super::super::super::wasi::sockets::network::Ipv6SocketAddress{ port:port2, flow_info:flow_info2, address:address2, scope_id:scope_id2, } = e; - let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; - - ( - 1i32, - _rt::as_i32(port2), - _rt::as_i32(flow_info2), - _rt::as_i32(t3_0), - _rt::as_i32(t3_1), - _rt::as_i32(t3_2), - _rt::as_i32(t3_3), - _rt::as_i32(t3_4), - _rt::as_i32(t3_5), - _rt::as_i32(t3_6), - _rt::as_i32(t3_7), - _rt::as_i32(scope_id2), - ) - }, - }; - let ptr6 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.start-bind"] - fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ); - } + impl UdpSocket { + #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] + pub fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { + unsafe { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]udp-socket.set-receive-buffer-size"] + fn wit_import1(_: i32, _: i64, _: *mut u8); + } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ) { + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { unreachable!() } - wit_import7( - (self).handle() as i32, - (network).handle() as i32, - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ptr6, - ); - let l8 = i32::from(*ptr6.add(0).cast::()); - let result10 = match l8 { + wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { let e = (); Ok(e) }, 1 => { let e = { - let l9 = i32::from(*ptr6.add(1).cast::()); + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l9 as u8, - ) + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; + + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result10 + result9 } } } - impl TcpSocket { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn finish_bind(&self) -> Result<(), ErrorCode> { + pub fn get_send_buffer_size(&self) -> Result { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit; + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 8 + 4 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] unsafe extern "C" { - #[link_name = "[method]tcp-socket.finish-bind"] + #[link_name = "[method]udp-socket.get-send-buffer-size"] fn wit_import1(_: i32, _: *mut u8); } @@ -7170,2760 +13507,2912 @@ pub mod wasi { } wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { + let result10 = match l2 { 0 => { - let e = (); + let e = { + let l3 = *ptr0.add(8).cast::(); + + l3 as u64 + }; Ok(e) }, 1 => { let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + let l4 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l4 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e9 = { + let l5 = i32::from( + *ptr0 + .add( + 8 + 1 + * ::core::mem::size_of::<*const u8>( + ), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0 + .add( + 8 + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add( + 8 + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ); + + _rt::string_lift(bytes8) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e9) + }, + }; + + v9 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result4 + result10 } } } - impl TcpSocket { + impl UdpSocket { #[allow(unused_unsafe, clippy::all)] #[allow(async_fn_in_trait)] - pub fn start_connect( - &self, - network: &Network, - remote_address: IpSocketAddress, - ) -> Result<(), ErrorCode> { + pub fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - use super::super::super::wasi::sockets::network::IpSocketAddress as V4; - let ( - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ) = match remote_address { - V4::Ipv4(e) => { - let super::super::super::wasi::sockets::network::Ipv4SocketAddress{ port:port0, address:address0, } = e; - let (t1_0, t1_1, t1_2, t1_3) = address0; - - ( - 0i32, - _rt::as_i32(port0), - _rt::as_i32(t1_0), - _rt::as_i32(t1_1), - _rt::as_i32(t1_2), - _rt::as_i32(t1_3), - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - 0i32, - ) - }, - V4::Ipv6(e) => { - let super::super::super::wasi::sockets::network::Ipv6SocketAddress{ port:port2, flow_info:flow_info2, address:address2, scope_id:scope_id2, } = e; - let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = address2; - - ( - 1i32, - _rt::as_i32(port2), - _rt::as_i32(flow_info2), - _rt::as_i32(t3_0), - _rt::as_i32(t3_1), - _rt::as_i32(t3_2), - _rt::as_i32(t3_3), - _rt::as_i32(t3_4), - _rt::as_i32(t3_5), - _rt::as_i32(t3_6), - _rt::as_i32(t3_7), - _rt::as_i32(scope_id2), - ) - }, - }; - let ptr6 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.start-connect"] - fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ); - } + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit; 5 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); + 5 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[method]udp-socket.set-send-buffer-size"] + fn wit_import1(_: i32, _: i64, _: *mut u8); + } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import7( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: *mut u8, - ) { + unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { unreachable!() } - wit_import7( - (self).handle() as i32, - (network).handle() as i32, - result5_0, - result5_1, - result5_2, - result5_3, - result5_4, - result5_5, - result5_6, - result5_7, - result5_8, - result5_9, - result5_10, - result5_11, - ptr6, - ); - let l8 = i32::from(*ptr6.add(0).cast::()); - let result10 = match l8 { + wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { let e = (); Ok(e) }, 1 => { let e = { - let l9 = i32::from(*ptr6.add(1).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l9 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result10 - } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn finish_connect(&self) -> Result<(InputStream, OutputStream), ErrorCode> { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.finish-connect"] - fn wit_import1(_: i32, _: *mut u8); - } + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v8 = match l3 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::NotSupported, + 2 => ErrorCode::InvalidArgument, + 3 => ErrorCode::OutOfMemory, + 4 => ErrorCode::Timeout, + 5 => ErrorCode::InvalidState, + 6 => ErrorCode::AddressNotBindable, + 7 => ErrorCode::AddressInUse, + 8 => ErrorCode::RemoteUnreachable, + 9 => ErrorCode::ConnectionRefused, + 10 => ErrorCode::ConnectionBroken, + 11 => ErrorCode::ConnectionReset, + 12 => ErrorCode::ConnectionAborted, + 13 => ErrorCode::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e8 = { + let l4 = i32::from( + *ptr0 + .add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result6 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - let l4 = *ptr0.add(8).cast::(); + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add( + 3 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::<*mut u8>(); + let l6 = *ptr0 + .add( + 4 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); - (super::super::super::wasi::io::streams::InputStream::from_handle(l3 as u32), super::super::super::wasi::io::streams::OutputStream::from_handle(l4 as u32)) - }; - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr0.add(4).cast::()); + _rt::string_lift(bytes7) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e8) + }, + }; - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l5 as u8, - ) + v8 }; Err(e) }, _ => _rt::invalid_enum_discriminant(), }; - result6 + result9 } } } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn start_listen(&self) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.start-listen"] - fn wit_import1(_: i32, _: *mut u8); - } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod ip_name_lookup { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + use super::super::super::_rt; + pub type IpAddress = super::super::super::wasi::sockets::types::IpAddress; + /// Lookup error codes. + #[derive(Clone)] + pub enum ErrorCode { + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + AccessDenied, + /// `name` is a syntactically invalid domain name or IP address. + /// + /// POSIX equivalent: EINVAL + InvalidArgument, + /// Name does not exist or has no suitable associated IP addresses. + /// + /// POSIX equivalent: EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY + NameUnresolvable, + /// A temporary failure in name resolution occurred. + /// + /// POSIX equivalent: EAI_AGAIN + TemporaryResolverFailure, + /// A permanent failure in name resolution occurred. + /// + /// POSIX equivalent: EAI_FAIL + PermanentResolverFailure, + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + Other(Option<_rt::String>), + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + ErrorCode::AccessDenied => { + f.debug_tuple("ErrorCode::AccessDenied").finish() + }, + ErrorCode::InvalidArgument => { + f.debug_tuple("ErrorCode::InvalidArgument").finish() + }, + ErrorCode::NameUnresolvable => { + f.debug_tuple("ErrorCode::NameUnresolvable").finish() + }, + ErrorCode::TemporaryResolverFailure => { + f.debug_tuple("ErrorCode::TemporaryResolverFailure").finish() + }, + ErrorCode::PermanentResolverFailure => { + f.debug_tuple("ErrorCode::PermanentResolverFailure").finish() + }, + ErrorCode::Other(e) => f.debug_tuple("ErrorCode::Other").field(e).finish(), } } } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn finish_listen(&self) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.finish-listen"] - fn wit_import1(_: i32, _: *mut u8); - } + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + impl ::core::error::Error for ErrorCode {} + #[allow(unused_unsafe, clippy::all)] + /// Resolve an internet host name to a list of IP addresses. + /// + /// Unicode domain names are automatically converted to ASCII using IDNA + /// encoding. If the input is an IP address string, the address is parsed + /// and returned as-is without making any external requests. + /// + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. + /// + /// The results are returned in connection order preference. + /// + /// This function never succeeds with 0 results. It either fails or succeeds + /// with at least one address. Additionally, this function never returns + /// IPv4-mapped IPv6 addresses. + /// + /// # References: + /// - + /// - + /// - + /// - + #[allow(async_fn_in_trait)] + pub async fn resolve_addresses( + name: _rt::String, + ) -> Result<_rt::Vec, ErrorCode> { + unsafe { + #[derive(Copy, Clone)] + struct ParamsLower(*mut u8, usize); + unsafe impl Send for ParamsLower {} + + use wit_bindgen::rt::async_support::Subtask as _Subtask; + struct _MySubtask<'a> { + _unused: core::marker::PhantomData<&'a ()>, + } + #[allow(unused_parens)] + unsafe impl<'a> _Subtask for _MySubtask<'a> { + type Params = (_rt::String,); + type Results = Result<_rt::Vec, ErrorCode>; + type ParamsLower = ParamsLower; + fn abi_layout(&mut self) -> ::core::alloc::Layout { + unsafe { + ::core::alloc::Layout::from_size_align_unchecked( + (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + } } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 - } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn accept(&self) -> Result<(TcpSocket, InputStream, OutputStream), ErrorCode> { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.accept"] - fn wit_import1(_: i32, _: *mut u8); + fn results_offset(&mut self) -> usize { + 0 } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + unsafe fn call_import( + &mut self, + _params: Self::ParamsLower, + _results: *mut u8, + ) -> u32 { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15" + )] + unsafe extern "C" { + #[link_name = "[async-lower]resolve-addresses"] + fn call(_: *mut u8, _: usize, _: *mut u8) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn call(_: *mut u8, _: usize, _: *mut u8) -> i32 { + unreachable!() + } + + unsafe { call(_params.0, _params.1, _results) as u32 } } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result7 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - let l4 = *ptr0.add(8).cast::(); - let l5 = *ptr0.add(12).cast::(); - (TcpSocket::from_handle(l3 as u32), super::super::super::wasi::io::streams::InputStream::from_handle(l4 as u32), super::super::super::wasi::io::streams::OutputStream::from_handle(l5 as u32)) - }; - Ok(e) - }, - 1 => { - let e = { - let l6 = i32::from(*ptr0.add(4).cast::()); + unsafe fn params_dealloc_lists(&mut self, _params: Self::ParamsLower) { + unsafe { + _rt::cabi_dealloc(_params.0, _params.1, 1); + } + } + unsafe fn params_dealloc_lists_and_own( + &mut self, + _params: Self::ParamsLower, + ) { + unsafe { + _rt::cabi_dealloc(_params.0, _params.1, 1); + } + } + unsafe fn params_lower( + &mut self, + (_lower0,): Self::Params, + _ptr: *mut u8, + ) -> Self::ParamsLower { + unsafe { + let vec0 = (_lower0.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + ParamsLower(ptr0.cast_mut(), len0) + } + } + unsafe fn results_lift(&mut self, _ptr: *mut u8) -> Self::Results { + unsafe { + let l0 = i32::from(*_ptr.add(0).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l6 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result7 - } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn local_address(&self) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 36]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 36]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.local-address"] - fn wit_import1(_: i32, _: *mut u8); - } + match l0 { + 0 => { + let e = { + let l1 = *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l2 = *_ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base17 = l1; + let len17 = l2; + let mut result17 = _rt::Vec::with_capacity(len17); + for i in 0..len17 { + let base = base17.add(i * 18); + let e17 = { + let l3 = i32::from(*base.add(0).cast::()); + use super::super::super::wasi::sockets::types::IpAddress as V16; + let v16 = match l3 { + 0 => { + let e16 = { + let l4 = i32::from( + *base.add(2).cast::(), + ); + let l5 = i32::from( + *base.add(3).cast::(), + ); + let l6 = i32::from( + *base.add(4).cast::(), + ); + let l7 = i32::from( + *base.add(5).cast::(), + ); + + ( + l4 as u8, l5 as u8, l6 as u8, + l7 as u8, + ) + }; + V16::Ipv4(e16) + }, + n => { + debug_assert_eq!( + n, 1, + "invalid enum discriminant" + ); + let e16 = { + let l8 = i32::from( + *base.add(2).cast::(), + ); + let l9 = i32::from( + *base.add(4).cast::(), + ); + let l10 = i32::from( + *base.add(6).cast::(), + ); + let l11 = i32::from( + *base.add(8).cast::(), + ); + let l12 = i32::from( + *base.add(10).cast::(), + ); + let l13 = i32::from( + *base.add(12).cast::(), + ); + let l14 = i32::from( + *base.add(14).cast::(), + ); + let l15 = i32::from( + *base.add(16).cast::(), + ); + + ( + l8 as u16, l9 as u16, + l10 as u16, l11 as u16, + l12 as u16, l13 as u16, + l14 as u16, l15 as u16, + ) + }; + V16::Ipv6(e16) + }, + }; - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result22 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - use super::super::super::wasi::sockets::network::IpSocketAddress as V20; - let v20 = match l3 { - 0 => { - let e20 = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let l5 = i32::from(*ptr0.add(10).cast::()); - let l6 = i32::from(*ptr0.add(11).cast::()); - let l7 = i32::from(*ptr0.add(12).cast::()); - let l8 = i32::from(*ptr0.add(13).cast::()); - - super::super::super::wasi::sockets::network::Ipv4SocketAddress{ - port: l4 as u16, - address: (l5 as u8, l6 as u8, l7 as u8, l8 as u8), - } - }; - V20::Ipv4(e20) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e20 = { - let l9 = i32::from(*ptr0.add(8).cast::()); - let l10 = *ptr0.add(12).cast::(); - let l11 = i32::from(*ptr0.add(16).cast::()); - let l12 = i32::from(*ptr0.add(18).cast::()); - let l13 = i32::from(*ptr0.add(20).cast::()); - let l14 = i32::from(*ptr0.add(22).cast::()); - let l15 = i32::from(*ptr0.add(24).cast::()); - let l16 = i32::from(*ptr0.add(26).cast::()); - let l17 = i32::from(*ptr0.add(28).cast::()); - let l18 = i32::from(*ptr0.add(30).cast::()); - let l19 = *ptr0.add(32).cast::(); - - super::super::super::wasi::sockets::network::Ipv6SocketAddress{ - port: l9 as u16, - flow_info: l10 as u32, - address: (l11 as u16, l12 as u16, l13 as u16, l14 as u16, l15 as u16, l16 as u16, l17 as u16, l18 as u16), - scope_id: l19 as u32, - } - }; - V20::Ipv6(e20) - }, - }; + v16 + }; + result17.push(e17); + } + _rt::cabi_dealloc(base17, len17 * 18, 2); - v20 - }; - Ok(e) - }, - 1 => { - let e = { - let l21 = i32::from(*ptr0.add(4).cast::()); + result17 + }; + Ok(e) + }, + 1 => { + let e = { + let l18 = i32::from( + *_ptr + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let v23 = match l18 { + 0 => ErrorCode::AccessDenied, + 1 => ErrorCode::InvalidArgument, + 2 => ErrorCode::NameUnresolvable, + 3 => ErrorCode::TemporaryResolverFailure, + 4 => ErrorCode::PermanentResolverFailure, + n => { + debug_assert_eq!( + n, 5, + "invalid enum discriminant" + ); + let e23 = { + let l19 = i32::from( + *_ptr + .add( + 2 * ::core::mem::size_of::< + *const u8, + >( + ), + ) + .cast::(), + ); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l21 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result22 + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *_ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l21 = *_ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len22 = l21; + let bytes22 = + _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ); + + _rt::string_lift(bytes22) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::Other(e23) + }, + }; + + v23 + }; + Err(e) + }, + _ => _rt::invalid_enum_discriminant(), + } + } + } } + _MySubtask { _unused: core::marker::PhantomData }.call((name,)).await } } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn remote_address(&self) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 36]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 36]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.remote-address"] - fn wit_import1(_: i32, _: *mut u8); - } + } + } +} +#[allow(dead_code, clippy::all)] +pub mod exports { + pub mod streamkit { + pub mod plugin { + /// The main interface that plugins must implement + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] + pub mod node { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result22 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - use super::super::super::wasi::sockets::network::IpSocketAddress as V20; - let v20 = match l3 { - 0 => { - let e20 = { - let l4 = i32::from(*ptr0.add(8).cast::()); - let l5 = i32::from(*ptr0.add(10).cast::()); - let l6 = i32::from(*ptr0.add(11).cast::()); - let l7 = i32::from(*ptr0.add(12).cast::()); - let l8 = i32::from(*ptr0.add(13).cast::()); - - super::super::super::wasi::sockets::network::Ipv4SocketAddress{ - port: l4 as u16, - address: (l5 as u8, l6 as u8, l7 as u8, l8 as u8), - } - }; - V20::Ipv4(e20) - }, - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e20 = { - let l9 = i32::from(*ptr0.add(8).cast::()); - let l10 = *ptr0.add(12).cast::(); - let l11 = i32::from(*ptr0.add(16).cast::()); - let l12 = i32::from(*ptr0.add(18).cast::()); - let l13 = i32::from(*ptr0.add(20).cast::()); - let l14 = i32::from(*ptr0.add(22).cast::()); - let l15 = i32::from(*ptr0.add(24).cast::()); - let l16 = i32::from(*ptr0.add(26).cast::()); - let l17 = i32::from(*ptr0.add(28).cast::()); - let l18 = i32::from(*ptr0.add(30).cast::()); - let l19 = *ptr0.add(32).cast::(); - - super::super::super::wasi::sockets::network::Ipv6SocketAddress{ - port: l9 as u16, - flow_info: l10 as u32, - address: (l11 as u16, l12 as u16, l13 as u16, l14 as u16, l15 as u16, l16 as u16, l17 as u16, l18 as u16), - scope_id: l19 as u32, - } - }; - V20::Ipv6(e20) - }, - }; + use super::super::super::super::_rt; + pub type NodeMetadata = + super::super::super::super::streamkit::plugin::types::NodeMetadata; + pub type Packet = super::super::super::super::streamkit::plugin::types::Packet; + /// A stateful node instance resource. - v20 - }; - Ok(e) - }, - 1 => { - let e = { - let l21 = i32::from(*ptr0.add(4).cast::()); + #[derive(Debug)] + #[repr(transparent)] + pub struct NodeInstance { + handle: _rt::Resource, + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l21 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result22 + type _NodeInstanceRep = Option; + + impl NodeInstance { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `NodeInstance`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _NodeInstanceRep = Some(val); + let ptr: *mut _NodeInstanceRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn is_listening(&self) -> bool { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.is-listening"] - fn wit_import0(_: i32) -> i32; - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - _rt::bool_lift(ret as u8) + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn address_family(&self) -> IpAddressFamily { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.address-family"] - fn wit_import0(_: i32) -> i32; - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::sockets::network::IpAddressFamily::_lift( - ret as u8, - ) + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_listen_backlog_size(&self, value: u64) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-listen-backlog-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { handle: unsafe { _rt::Resource::from_handle(handle) } } } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn keep_alive_enabled(&self) -> Result { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.keep-alive-enabled"] - fn wit_import1(_: i32, _: *mut u8); - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - _rt::bool_lift(l3 as u8) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(1).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_keep_alive_enabled(&self, value: bool) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-keep-alive-enabled"] - fn wit_import1(_: i32, _: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { - unreachable!() - } - wit_import1( - (self).handle() as i32, - match &value { - true => 1, - false => 0, - }, - ptr0, - ); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn keep_alive_idle_time(&self) -> Result { - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.keep-alive-idle-time"] - fn wit_import1(_: i32, _: *mut u8); - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + // It's theoretically possible to implement the `GuestNodeInstance` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "atomics")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); + } - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = unsafe { _rt::Box::from_raw(handle as *mut _NodeInstanceRep) }; + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + fn as_ptr(&self) -> *mut _NodeInstanceRep { + NodeInstance::type_guard::(); + T::_resource_rep(self.handle()).cast() } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_keep_alive_idle_time(&self, value: Duration) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-keep-alive-idle-time"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, _rt::as_i64(value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + /// A borrowed version of [`NodeInstance`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct NodeInstanceBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a NodeInstance>, + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + impl<'a> NodeInstanceBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { rep: rep as *mut u8, _marker: core::marker::PhantomData } } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn keep_alive_interval(&self) -> Result { - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.keep-alive-interval"] - fn wit_import1(_: i32, _: *mut u8); - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &'a T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + fn as_ptr(&self) -> *mut _NodeInstanceRep { + NodeInstance::type_guard::(); + self.rep.cast() } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_keep_alive_interval(&self, value: Duration) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + + unsafe impl _rt::WasmResource for NodeInstance { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] + #[link(wasm_import_module = "[export]streamkit:plugin/node@0.2.0")] unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-keep-alive-interval"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[resource-drop]node-instance"] + fn drop(_: i32); } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn drop(_: i32) { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + unsafe { + drop(_handle as i32); + } } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn keep_alive_count(&self) -> Result { + + #[doc(hidden)] + #[allow(non_snake_case, unused_unsafe)] + pub unsafe fn _export_metadata_cabi() -> *mut u8 { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.keep-alive-count"] - fn wit_import1(_: i32, _: *mut u8); + _rt::run_ctors_once(); + let result0 = { T_::metadata() }; + let ptr1 = (&raw mut _RET_AREA.0).cast::(); + let super::super::super::super::streamkit::plugin::types::NodeMetadata { + kind: kind2, + inputs: inputs2, + outputs: outputs2, + param_schema: param_schema2, + categories: categories2, + } = result0; + let vec3 = (kind2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(::core::mem::size_of::<*const u8>()).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec10 = inputs2; + let len10 = vec10.len(); + let layout10 = _rt::alloc::Layout::from_size_align( + vec10.len() * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result10, _cleanup10) = wit_bindgen::rt::Cleanup::new(layout10); + if let Some(cleanup) = _cleanup10 { + cleanup.forget(); } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() + for (i, e) in vec10.into_iter().enumerate() { + let base = result10.add(i * (4 * ::core::mem::size_of::<*const u8>())); + { + let super::super::super::super::streamkit::plugin::types::InputPin{ name:name4, accepts_types:accepts_types4, } = e; + let vec5 = (name4.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *base.add(::core::mem::size_of::<*const u8>()).cast::() = + len5; + *base.add(0).cast::<*mut u8>() = ptr5.cast_mut(); + let vec9 = accepts_types4; + let len9 = vec9.len(); + let layout9 = _rt::alloc::Layout::from_size_align( + vec9.len() * (3 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result9, _cleanup9) = wit_bindgen::rt::Cleanup::new(layout9); + if let Some(cleanup) = _cleanup9 { + cleanup.forget(); + } + for (i, e) in vec9.into_iter().enumerate() { + let base = + result9.add(i * (3 * ::core::mem::size_of::<*const u8>())); + { + use super::super::super::super::streamkit::plugin::types::PacketType as V8; + match e { + V8::RawAudio(e) => { + *base.add(0).cast::() = (0i32) as u8; + let super::super::super::super::streamkit::plugin::types::AudioFormat{ sample_rate:sample_rate6, channels:channels6, sample_format:sample_format6, } = e; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = _rt::as_i32(sample_rate6); + *base + .add( + 4 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::() = + (_rt::as_i32(channels6)) as u16; + *base + .add( + 6 + 1 * ::core::mem::size_of::<*const u8>(), + ) + .cast::() = + (sample_format6.clone() as i32) as u8; + }, + V8::OpusAudio => { + *base.add(0).cast::() = (1i32) as u8; + }, + V8::Text => { + *base.add(0).cast::() = (2i32) as u8; + }, + V8::Binary => { + *base.add(0).cast::() = (3i32) as u8; + }, + V8::Custom(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec7 = (e.into_bytes()).into_boxed_slice(); + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + ::core::mem::forget(vec7); + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = len7; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr7.cast_mut(); + }, + V8::Any => { + *base.add(0).cast::() = (5i32) as u8; + }, + } + } + } + *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::() = len9; + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = result9; + } } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - l3 as u32 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 + *ptr1.add(3 * ::core::mem::size_of::<*const u8>()).cast::() = len10; + *ptr1.add(2 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = + result10; + let vec16 = outputs2; + let len16 = vec16.len(); + let layout16 = _rt::alloc::Layout::from_size_align( + vec16.len() * (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result16, _cleanup16) = wit_bindgen::rt::Cleanup::new(layout16); + if let Some(cleanup) = _cleanup16 { + cleanup.forget(); + } + for (i, e) in vec16.into_iter().enumerate() { + let base = result16.add(i * (5 * ::core::mem::size_of::<*const u8>())); + { + let super::super::super::super::streamkit::plugin::types::OutputPin{ name:name11, produces_type:produces_type11, } = e; + let vec12 = (name11.into_bytes()).into_boxed_slice(); + let ptr12 = vec12.as_ptr().cast::(); + let len12 = vec12.len(); + ::core::mem::forget(vec12); + *base.add(::core::mem::size_of::<*const u8>()).cast::() = + len12; + *base.add(0).cast::<*mut u8>() = ptr12.cast_mut(); + use super::super::super::super::streamkit::plugin::types::PacketType as V15; + match produces_type11 { + V15::RawAudio(e) => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (0i32) as u8; + let super::super::super::super::streamkit::plugin::types::AudioFormat{ sample_rate:sample_rate13, channels:channels13, sample_format:sample_format13, } = e; + *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::() = _rt::as_i32(sample_rate13); + *base + .add(4 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::() = (_rt::as_i32(channels13)) as u16; + *base + .add(6 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::() = (sample_format13.clone() as i32) as u8; + }, + V15::OpusAudio => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (1i32) as u8; + }, + V15::Text => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (2i32) as u8; + }, + V15::Binary => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (3i32) as u8; + }, + V15::Custom(e) => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (4i32) as u8; + let vec14 = (e.into_bytes()).into_boxed_slice(); + let ptr14 = vec14.as_ptr().cast::(); + let len14 = vec14.len(); + ::core::mem::forget(vec14); + *base + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::() = len14; + *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr14.cast_mut(); + }, + V15::Any => { + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (5i32) as u8; + }, + } + } + } + *ptr1.add(5 * ::core::mem::size_of::<*const u8>()).cast::() = len16; + *ptr1.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = + result16; + let vec17 = (param_schema2.into_bytes()).into_boxed_slice(); + let ptr17 = vec17.as_ptr().cast::(); + let len17 = vec17.len(); + ::core::mem::forget(vec17); + *ptr1.add(7 * ::core::mem::size_of::<*const u8>()).cast::() = len17; + *ptr1.add(6 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = + ptr17.cast_mut(); + let vec19 = categories2; + let len19 = vec19.len(); + let layout19 = _rt::alloc::Layout::from_size_align( + vec19.len() * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result19, _cleanup19) = wit_bindgen::rt::Cleanup::new(layout19); + if let Some(cleanup) = _cleanup19 { + cleanup.forget(); + } + for (i, e) in vec19.into_iter().enumerate() { + let base = result19.add(i * (2 * ::core::mem::size_of::<*const u8>())); + { + let vec18 = (e.into_bytes()).into_boxed_slice(); + let ptr18 = vec18.as_ptr().cast::(); + let len18 = vec18.len(); + ::core::mem::forget(vec18); + *base.add(::core::mem::size_of::<*const u8>()).cast::() = + len18; + *base.add(0).cast::<*mut u8>() = ptr18.cast_mut(); + } + } + *ptr1.add(9 * ::core::mem::size_of::<*const u8>()).cast::() = len19; + *ptr1.add(8 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = + result19; + ptr1 } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_keep_alive_count(&self, value: u32) -> Result<(), ErrorCode> { + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_metadata(arg0: *mut u8) { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-keep-alive-count"] - fn wit_import1(_: i32, _: i32, _: *mut u8); + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(::core::mem::size_of::<*const u8>()).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = + *arg0.add(2 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l3 = *arg0.add(3 * ::core::mem::size_of::<*const u8>()).cast::(); + let base12 = l2; + let len12 = l3; + for i in 0..len12 { + let base = base12.add(i * (4 * ::core::mem::size_of::<*const u8>())); + { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = + *base.add(::core::mem::size_of::<*const u8>()).cast::(); + _rt::cabi_dealloc(l4, l5, 1); + let l6 = *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base11 = l6; + let len11 = l7; + for i in 0..len11 { + let base = + base11.add(i * (3 * ::core::mem::size_of::<*const u8>())); + { + let l8 = i32::from(*base.add(0).cast::()); + match l8 { + 0 => (), + 1 => (), + 2 => (), + 3 => (), + 4 => { + let l9 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l10 = *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l9, l10, 1); + }, + _ => (), + } + } + } + _rt::cabi_dealloc( + base11, + len11 * (3 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + } } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { - unreachable!() + _rt::cabi_dealloc( + base12, + len12 * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + let l13 = + *arg0.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l14 = + *arg0.add(5 * ::core::mem::size_of::<*const u8>()).cast::(); + let base20 = l13; + let len20 = l14; + for i in 0..len20 { + let base = base20.add(i * (5 * ::core::mem::size_of::<*const u8>())); + { + let l15 = *base.add(0).cast::<*mut u8>(); + let l16 = + *base.add(::core::mem::size_of::<*const u8>()).cast::(); + _rt::cabi_dealloc(l15, l16, 1); + let l17 = i32::from( + *base.add(2 * ::core::mem::size_of::<*const u8>()).cast::(), + ); + match l17 { + 0 => (), + 1 => (), + 2 => (), + 3 => (), + 4 => { + let l18 = *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l19 = *base + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + _rt::cabi_dealloc(l18, l19, 1); + }, + _ => (), + } + } } - wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + _rt::cabi_dealloc( + base20, + len20 * (5 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + let l21 = + *arg0.add(6 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l22 = + *arg0.add(7 * ::core::mem::size_of::<*const u8>()).cast::(); + _rt::cabi_dealloc(l21, l22, 1); + let l23 = + *arg0.add(8 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l24 = + *arg0.add(9 * ::core::mem::size_of::<*const u8>()).cast::(); + let base27 = l23; + let len27 = l24; + for i in 0..len27 { + let base = base27.add(i * (2 * ::core::mem::size_of::<*const u8>())); + { + let l25 = *base.add(0).cast::<*mut u8>(); + let l26 = + *base.add(::core::mem::size_of::<*const u8>()).cast::(); + _rt::cabi_dealloc(l25, l26, 1); + } + } + _rt::cabi_dealloc( + base27, + len27 * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn hop_limit(&self) -> Result { + #[doc(hidden)] + #[allow(non_snake_case, unused_unsafe)] + pub unsafe fn _export_constructor_node_instance_cabi( + arg0: i32, + arg1: *mut u8, + arg2: usize, + ) -> i32 { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.hop-limit"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - l3 as u8 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(1).cast::()); + _rt::run_ctors_once(); + let result1 = { + NodeInstance::new(T_::new(match arg0 { + 0 => None, + 1 => { + let e = { + let len0 = arg2; + let bytes0 = + _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), + _rt::string_lift(bytes0) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + })) }; - result5 + (result1).take_handle() as i32 } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_hop_limit(&self, value: u8) -> Result<(), ErrorCode> { + #[doc(hidden)] + #[allow(non_snake_case, unused_unsafe)] + pub unsafe fn _export_method_node_instance_process_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: i32, + arg4: *mut u8, + arg5: usize, + arg6: *mut u8, + arg7: *mut u8, + arg8: usize, + ) -> i32 { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-hop-limit"] - fn wit_import1(_: i32, _: i32, _: *mut u8); - } + _rt::run_ctors_once(); + wit_bindgen::rt::async_support::start_task(async move { + let _task_cancel = + wit_bindgen::rt::async_support::TaskCancelOnDrop::new(); + let result7 = &{ + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + use super::super::super::super::streamkit::plugin::types::Packet as V6; + let v6 = match arg3 { + 0 => { + let e6 = { + let len1 = arg7 as usize; + + super::super::super::super::streamkit::plugin::types::AudioFrame{ + sample_rate: arg4 as i32 as u32, + channels: arg5 as i32 as u16, + samples: <_ as From<_rt::Vec<_>>>::from(_rt::Vec::from_raw_parts(arg6.cast(), len1, len1)), + } + }; + V6::Audio(e6) + }, + 1 => { + let e6 = { + let len2 = arg5; + let bytes2 = + _rt::Vec::from_raw_parts(arg4.cast(), len2, len2); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, _rt::as_i32(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + _rt::string_lift(bytes2) + }; + V6::Text(e6) + }, + 2 => { + let e6 = { + let len3 = arg5; - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) + <_ as From<_rt::Vec<_>>>::from( + _rt::Vec::from_raw_parts(arg4.cast(), len3, len3), + ) + }; + V6::Binary(e6) + }, + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e6 = { + let len4 = arg5; + let bytes4 = + _rt::Vec::from_raw_parts(arg4.cast(), len4, len4); + let len5 = arg8; + let bytes5 = + _rt::Vec::from_raw_parts(arg7.cast(), len5, len5); + + super::super::super::super::streamkit::plugin::types::CustomPacket{ + type_id: _rt::string_lift(bytes4), + encoding: super::super::super::super::streamkit::plugin::types::CustomEncoding::_lift(arg6 as i32 as u8), + data: _rt::string_lift(bytes5), + } + }; + V6::Custom(e6) + }, }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + T_::process( + NodeInstanceBorrow::lift(arg0 as u32 as usize).get(), + _rt::string_lift(bytes0), + v6, + ) + .await + }; + let (result9_0, result9_1, result9_2) = match result7 { + Ok(_) => (0i32, ::core::ptr::null_mut(), 0usize), + Err(e) => { + let vec8 = e; + let ptr8 = vec8.as_ptr().cast::(); + let len8 = vec8.len(); + + (1i32, ptr8.cast_mut(), len8) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "[export]streamkit:plugin/node@0.2.0")] + unsafe extern "C" { + #[link_name = "[task-return][method]node-instance.process"] + fn wit_import10(_: i32, _: *mut u8, _: usize); + } + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import10(_: i32, _: *mut u8, _: usize) { + unreachable!() + } + _task_cancel.forget(); + wit_import10(result9_0, result9_1, result9_2); + }) } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn receive_buffer_size(&self) -> Result { - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.receive-buffer-size"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); - - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 - } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __callback_method_node_instance_process( + event0: u32, + event1: u32, + event2: u32, + ) -> u32 { + unsafe { wit_bindgen::rt::async_support::callback(event0, event1, event2) } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { + #[doc(hidden)] + #[allow(non_snake_case, unused_unsafe)] + pub unsafe fn _export_method_node_instance_update_params_cabi< + T_: GuestNodeInstance, + >( + arg0: *mut u8, + arg1: i32, + arg2: *mut u8, + arg3: usize, + ) -> i32 { unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-receive-buffer-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); - } + _rt::run_ctors_once(); + wit_bindgen::rt::async_support::start_task(async move { + let _task_cancel = + wit_bindgen::rt::async_support::TaskCancelOnDrop::new(); + let result1 = &{ + T_::update_params( + NodeInstanceBorrow::lift(arg0 as u32 as usize).get(), + match arg1 { + 0 => None, + 1 => { + let e = { + let len0 = arg3; + let bytes0 = _rt::Vec::from_raw_parts( + arg2.cast(), + len0, + len0, + ); - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); + _rt::string_lift(bytes0) + }; + Some(e) + }, + _ => _rt::invalid_enum_discriminant(), + }, + ) + .await + }; + let (result3_0, result3_1, result3_2) = match result1 { + Ok(_) => (0i32, ::core::ptr::null_mut(), 0usize), + Err(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (1i32, ptr2.cast_mut(), len2) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "[export]streamkit:plugin/node@0.2.0")] + unsafe extern "C" { + #[link_name = "[task-return][method]node-instance.update-params"] + fn wit_import4(_: i32, _: *mut u8, _: usize); + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import4(_: i32, _: *mut u8, _: usize) { + unreachable!() + } + _task_cancel.forget(); + wit_import4(result3_0, result3_1, result3_2); + }) } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn send_buffer_size(&self) -> Result { + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __callback_method_node_instance_update_params( + event0: u32, + event1: u32, + event2: u32, + ) -> u32 { + unsafe { wit_bindgen::rt::async_support::callback(event0, event1, event2) } + } + #[doc(hidden)] + #[allow(non_snake_case, unused_unsafe)] + pub unsafe fn _export_method_node_instance_cleanup_cabi( + arg0: *mut u8, + ) { unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.send-buffer-size"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(8).cast::(); - - l3 as u64 - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), + _rt::run_ctors_once(); + { + T_::cleanup(NodeInstanceBorrow::lift(arg0 as u32 as usize).get()) }; - result5 } } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + pub trait Guest { + type NodeInstance: GuestNodeInstance; + /// Get metadata about this node type + #[allow(async_fn_in_trait)] + fn metadata() -> NodeMetadata; + } + pub trait GuestNodeInstance: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] + #[link(wasm_import_module = "[export]streamkit:plugin/node@0.2.0")] unsafe extern "C" { - #[link_name = "[method]tcp-socket.set-send-buffer-size"] - fn wit_import1(_: i32, _: i64, _: *mut u8); + #[link_name = "[resource-new]node-instance"] + fn new(_: *mut u8) -> i32; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i64, _: *mut u8) { + unsafe extern "C" fn new(_: *mut u8) -> i32 { unreachable!() } - wit_import1((self).handle() as i32, _rt::as_i64(&value), ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + unsafe { new(val) as u32 } } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]tcp-socket.subscribe"] - fn wit_import0(_: i32) -> i32; - } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl TcpSocket { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn shutdown(&self, shutdown_type: ShutdownType) -> Result<(), ErrorCode> { - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp@0.2.0")] + #[link(wasm_import_module = "[export]streamkit:plugin/node@0.2.0")] unsafe extern "C" { - #[link_name = "[method]tcp-socket.shutdown"] - fn wit_import1(_: i32, _: i32, _: *mut u8); + #[link_name = "[resource-rep]node-instance"] + fn rep(_: i32) -> *mut u8; } #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: i32, _: *mut u8) { + unsafe extern "C" fn rep(_: i32) -> *mut u8 { unreachable!() } - wit_import1((self).handle() as i32, shutdown_type.clone() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result4 = match l2 { - 0 => { - let e = (); - Ok(e) - }, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l3 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result4 + unsafe { rep(handle as i32) } } - } - } - } - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod tcp_create_socket { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + /// Construct a new stateful node instance with optional parameters (JSON string) + #[allow(async_fn_in_trait)] + fn new(params: Option<_rt::String>) -> Self; + /// Process an incoming packet from a specific input pin using this instance's state + #[allow(async_fn_in_trait)] + async fn process( + &self, + input_pin: _rt::String, + packet: Packet, + ) -> Result<(), _rt::String>; + /// Update the runtime parameters for this instance. The payload is a JSON string. + #[allow(async_fn_in_trait)] + async fn update_params( + &self, + params: Option<_rt::String>, + ) -> Result<(), _rt::String>; + /// Clean up any resources associated with this instance + #[allow(async_fn_in_trait)] + fn cleanup(&self) -> (); + } + #[doc(hidden)] + #[macro_export] + macro_rules! __export_streamkit_plugin_node_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - use super::super::super::_rt; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpAddressFamily = super::super::super::wasi::sockets::network::IpAddressFamily; - pub type TcpSocket = super::super::super::wasi::sockets::tcp::TcpSocket; - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn create_tcp_socket( - address_family: IpAddressFamily, - ) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/tcp-create-socket@0.2.0")] - unsafe extern "C" { - #[link_name = "create-tcp-socket"] - fn wit_import1(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1(address_family.clone() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result5 = match l2 { - 0 => { - let e = { - let l3 = *ptr0.add(4).cast::(); - - super::super::super::wasi::sockets::tcp::TcpSocket::from_handle( - l3 as u32, - ) - }; - Ok(e) - }, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); + #[unsafe(export_name = "streamkit:plugin/node@0.2.0#metadata")] + unsafe extern "C" fn export_metadata() -> *mut u8 { + unsafe { $($path_to_types)*::_export_metadata_cabi::<$ty>() } + } + #[unsafe(export_name = "cabi_post_streamkit:plugin/node@0.2.0#metadata")] + unsafe extern "C" fn _post_return_metadata(arg0: *mut u8,) { + unsafe { $($path_to_types)*::__post_return_metadata::<$ty>(arg0) } + } + #[unsafe(export_name = "streamkit:plugin/node@0.2.0#[constructor]node-instance")] + unsafe extern "C" fn export_constructor_node_instance(arg0: i32,arg1: *mut u8,arg2: usize,) -> i32 { + unsafe { $($path_to_types)*::_export_constructor_node_instance_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2) } + } + #[unsafe(export_name = "[async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.process")] + unsafe extern "C" fn export_method_node_instance_process(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: i32,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: *mut u8,arg8: usize,) -> i32 { + unsafe { $($path_to_types)*::_export_method_node_instance_process_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } + } + #[unsafe(export_name = "[callback][async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.process")] + unsafe extern "C" fn _callback_method_node_instance_process(event0: u32, event1: u32, event2: u32) -> u32 { + unsafe { + $($path_to_types)*::__callback_method_node_instance_process(event0, event1, event2) + } + } + #[unsafe(export_name = "[async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.update-params")] + unsafe extern "C" fn export_method_node_instance_update_params(arg0: *mut u8,arg1: i32,arg2: *mut u8,arg3: usize,) -> i32 { + unsafe { $($path_to_types)*::_export_method_node_instance_update_params_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2, arg3) } + } + #[unsafe(export_name = "[callback][async-lift]streamkit:plugin/node@0.2.0#[method]node-instance.update-params")] + unsafe extern "C" fn _callback_method_node_instance_update_params(event0: u32, event1: u32, event2: u32) -> u32 { + unsafe { + $($path_to_types)*::__callback_method_node_instance_update_params(event0, event1, event2) + } + } + #[unsafe(export_name = "streamkit:plugin/node@0.2.0#[method]node-instance.cleanup")] + unsafe extern "C" fn export_method_node_instance_cleanup(arg0: *mut u8,) { + unsafe { $($path_to_types)*::_export_method_node_instance_cleanup_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0) } + } - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l4 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result5 - } - } + const _: () = { + #[doc(hidden)] + #[unsafe(export_name = "streamkit:plugin/node@0.2.0#[dtor]node-instance")] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + unsafe { + $($path_to_types)*::NodeInstance::dtor::< + <$ty as $($path_to_types)*::Guest>::NodeInstance + >(rep) } + } + }; - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod ip_name_lookup { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; - - use super::super::super::_rt; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub type Network = super::super::super::wasi::sockets::network::Network; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpAddress = super::super::super::wasi::sockets::network::IpAddress; + };); +} + #[doc(hidden)] + pub use __export_streamkit_plugin_node_0_2_0_cabi; - #[derive(Debug)] - #[repr(transparent)] - pub struct ResolveAddressStream { - handle: _rt::Resource, + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct _RetArea( + [::core::mem::MaybeUninit; 10 * ::core::mem::size_of::<*const u8>()], + ); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 10 * ::core::mem::size_of::<*const u8>()], + ); } + } + } +} +mod _rt { + #![allow(dead_code, unused_imports, clippy::all)] + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + unsafe { + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr, layout); + } + } - impl ResolveAddressStream { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } + pub trait AsI32 { + fn as_i32(self) -> i32; + } - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - } + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } - unsafe impl _rt::WasmResource for ResolveAddressStream { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]resolve-address-stream"] - fn drop(_: i32); - } + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - unsafe { - drop(_handle as i32); - } - } - } + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - impl ResolveAddressStream { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn resolve_next_address(&self) -> Result, ErrorCode> { - unsafe { - #[repr(align(2))] - struct RetArea([::core::mem::MaybeUninit; 22]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 22]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]resolve-address-stream.resolve-next-address"] - fn wit_import1(_: i32, _: *mut u8); - } + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { - unreachable!() - } - wit_import1((self).handle() as i32, ptr0); - let l2 = i32::from(*ptr0.add(0).cast::()); - let result19 = match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(2).cast::()); + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - match l3 { - 0 => None, - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(4).cast::()); - use super::super::super::wasi::sockets::network::IpAddress as V17; - let v17 = match l4 { - 0 => { - let e17 = { - let l5 = i32::from( - *ptr0.add(6).cast::(), - ); - let l6 = i32::from( - *ptr0.add(7).cast::(), - ); - let l7 = i32::from( - *ptr0.add(8).cast::(), - ); - let l8 = i32::from( - *ptr0.add(9).cast::(), - ); + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - (l5 as u8, l6 as u8, l7 as u8, l8 as u8) - }; - V17::Ipv4(e17) - }, - n => { - debug_assert_eq!( - n, 1, - "invalid enum discriminant" - ); - let e17 = { - let l9 = i32::from( - *ptr0.add(6).cast::(), - ); - let l10 = i32::from( - *ptr0.add(8).cast::(), - ); - let l11 = i32::from( - *ptr0.add(10).cast::(), - ); - let l12 = i32::from( - *ptr0.add(12).cast::(), - ); - let l13 = i32::from( - *ptr0.add(14).cast::(), - ); - let l14 = i32::from( - *ptr0.add(16).cast::(), - ); - let l15 = i32::from( - *ptr0.add(18).cast::(), - ); - let l16 = i32::from( - *ptr0.add(20).cast::(), - ); + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } - ( - l9 as u16, l10 as u16, l11 as u16, - l12 as u16, l13 as u16, l14 as u16, - l15 as u16, l16 as u16, - ) - }; - V17::Ipv6(e17) - }, - }; + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + unsafe { String::from_utf8_unchecked(bytes) } + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + unsafe { core::hint::unreachable_unchecked() } + } + } - v17 - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - } - }; - Ok(e) - }, - 1 => { - let e = { - let l18 = i32::from(*ptr0.add(2).cast::()); + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l18 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result19 - } - } - } - impl ResolveAddressStream { - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn subscribe(&self) -> Pollable { - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - unsafe extern "C" { - #[link_name = "[method]resolve-address-stream.subscribe"] - fn wit_import0(_: i32) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import0(_: i32) -> i32 { - unreachable!() - } - let ret = wit_import0((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - #[allow(unused_unsafe, clippy::all)] - #[allow(async_fn_in_trait)] - pub fn resolve_addresses( - network: &Network, - name: &str, - ) -> Result { - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - unsafe extern "C" { - #[link_name = "resolve-addresses"] - fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8) { - unreachable!() - } - wit_import2((network).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l3 = i32::from(*ptr1.add(0).cast::()); - let result6 = match l3 { - 0 => { - let e = { - let l4 = *ptr1.add(4).cast::(); - - ResolveAddressStream::from_handle(l4 as u32) - }; - Ok(e) - }, - 1 => { - let e = { - let l5 = i32::from(*ptr1.add(4).cast::()); - - super::super::super::wasi::sockets::network::ErrorCode::_lift( - l5 as u8, - ) - }; - Err(e) - }, - _ => _rt::invalid_enum_discriminant(), - }; - result6 - } - } - } - } -} -#[allow(dead_code, clippy::all)] -pub mod exports { - pub mod streamkit { - pub mod plugin { - /// The main interface that plugins must implement - #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] - pub mod node { - #[used] - #[doc(hidden)] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; - - use super::super::super::super::_rt; - pub type NodeMetadata = - super::super::super::super::streamkit::plugin::types::NodeMetadata; - pub type Packet = super::super::super::super::streamkit::plugin::types::Packet; - /// A stateful node instance resource. - - #[derive(Debug)] - #[repr(transparent)] - pub struct NodeInstance { - handle: _rt::Resource, - } - - type _NodeInstanceRep = Option; - - impl NodeInstance { - /// Creates a new resource from the specified representation. - /// - /// This function will create a new resource handle by moving `val` onto - /// the heap and then passing that heap pointer to the component model to - /// create a handle. The owned handle is then returned as `NodeInstance`. - pub fn new(val: T) -> Self { - Self::type_guard::(); - let val: _NodeInstanceRep = Some(val); - let ptr: *mut _NodeInstanceRep = _rt::Box::into_raw(_rt::Box::new(val)); - unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } - } - - /// Gets access to the underlying `T` which represents this resource. - pub fn get(&self) -> &T { - let ptr = unsafe { &*self.as_ptr::() }; - ptr.as_ref().unwrap() - } - - /// Gets mutable access to the underlying `T` which represents this - /// resource. - pub fn get_mut(&mut self) -> &mut T { - let ptr = unsafe { &mut *self.as_ptr::() }; - ptr.as_mut().unwrap() - } - - /// Consumes this resource and returns the underlying `T`. - pub fn into_inner(self) -> T { - let ptr = unsafe { &mut *self.as_ptr::() }; - ptr.take().unwrap() - } - - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { handle: unsafe { _rt::Resource::from_handle(handle) } } - } - - #[doc(hidden)] - pub fn take_handle(&self) -> u32 { - _rt::Resource::take_handle(&self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - _rt::Resource::handle(&self.handle) - } - - // It's theoretically possible to implement the `GuestNodeInstance` trait twice - // so guard against using it with two different types here. - #[doc(hidden)] - fn type_guard() { - use core::any::TypeId; - static mut LAST_TYPE: Option = None; - unsafe { - assert!(!cfg!(target_feature = "atomics")); - let id = TypeId::of::(); - match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), - None => LAST_TYPE = Some(id), - } - } - } - - #[doc(hidden)] - pub unsafe fn dtor(handle: *mut u8) { - Self::type_guard::(); - let _ = unsafe { _rt::Box::from_raw(handle as *mut _NodeInstanceRep) }; - } - - fn as_ptr(&self) -> *mut _NodeInstanceRep { - NodeInstance::type_guard::(); - T::_resource_rep(self.handle()).cast() - } - } - - /// A borrowed version of [`NodeInstance`] which represents a borrowed value - /// with the lifetime `'a`. - #[derive(Debug)] - #[repr(transparent)] - pub struct NodeInstanceBorrow<'a> { - rep: *mut u8, - _marker: core::marker::PhantomData<&'a NodeInstance>, - } - - impl<'a> NodeInstanceBorrow<'a> { - #[doc(hidden)] - pub unsafe fn lift(rep: usize) -> Self { - Self { rep: rep as *mut u8, _marker: core::marker::PhantomData } - } - - /// Gets access to the underlying `T` in this resource. - pub fn get(&self) -> &T { - let ptr = unsafe { &mut *self.as_ptr::() }; - ptr.as_ref().unwrap() - } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - - fn as_ptr(&self) -> *mut _NodeInstanceRep { - NodeInstance::type_guard::(); - self.rep.cast() - } - } - - unsafe impl _rt::WasmResource for NodeInstance { - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "[export]streamkit:plugin/node@0.1.0")] - unsafe extern "C" { - #[link_name = "[resource-drop]node-instance"] - fn drop(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn drop(_: i32) { - unreachable!() - } - - unsafe { - drop(_handle as i32); - } - } - } - - #[doc(hidden)] - #[allow(non_snake_case, unused_unsafe)] - pub unsafe fn _export_metadata_cabi() -> *mut u8 { - unsafe { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = { T::metadata() }; - let ptr1 = (&raw mut _RET_AREA.0).cast::(); - let super::super::super::super::streamkit::plugin::types::NodeMetadata { - kind: kind2, - inputs: inputs2, - outputs: outputs2, - param_schema: param_schema2, - categories: categories2, - } = result0; - let vec3 = (kind2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - ::core::mem::forget(vec3); - *ptr1.add(::core::mem::size_of::<*const u8>()).cast::() = len3; - *ptr1.add(0).cast::<*mut u8>() = ptr3.cast_mut(); - let vec10 = inputs2; - let len10 = vec10.len(); - let layout10 = _rt::alloc::Layout::from_size_align( - vec10.len() * (4 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ) - .unwrap(); - let (result10, _cleanup10) = wit_bindgen_rt::Cleanup::new(layout10); - if let Some(cleanup) = _cleanup10 { - cleanup.forget(); - } - for (i, e) in vec10.into_iter().enumerate() { - let base = result10.add(i * (4 * ::core::mem::size_of::<*const u8>())); - { - let super::super::super::super::streamkit::plugin::types::InputPin{ name:name4, accepts_types:accepts_types4, } = e; - let vec5 = (name4.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - ::core::mem::forget(vec5); - *base.add(::core::mem::size_of::<*const u8>()).cast::() = - len5; - *base.add(0).cast::<*mut u8>() = ptr5.cast_mut(); - let vec9 = accepts_types4; - let len9 = vec9.len(); - let layout9 = _rt::alloc::Layout::from_size_align( - vec9.len() * (3 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ) - .unwrap(); - let (result9, _cleanup9) = wit_bindgen_rt::Cleanup::new(layout9); - if let Some(cleanup) = _cleanup9 { - cleanup.forget(); - } - for (i, e) in vec9.into_iter().enumerate() { - let base = - result9.add(i * (3 * ::core::mem::size_of::<*const u8>())); - { - use super::super::super::super::streamkit::plugin::types::PacketType as V8; - match e { - V8::RawAudio(e) => { - *base.add(0).cast::() = (0i32) as u8; - let super::super::super::super::streamkit::plugin::types::AudioFormat{ sample_rate:sample_rate6, channels:channels6, sample_format:sample_format6, } = e; - *base - .add(::core::mem::size_of::<*const u8>()) - .cast::() = _rt::as_i32(sample_rate6); - *base - .add( - 4 + 1 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = - (_rt::as_i32(channels6)) as u16; - *base - .add( - 6 + 1 * ::core::mem::size_of::<*const u8>(), - ) - .cast::() = - (sample_format6.clone() as i32) as u8; - }, - V8::OpusAudio => { - *base.add(0).cast::() = (1i32) as u8; - }, - V8::Text => { - *base.add(0).cast::() = (2i32) as u8; - }, - V8::Binary => { - *base.add(0).cast::() = (3i32) as u8; - }, - V8::Custom(e) => { - *base.add(0).cast::() = (4i32) as u8; - let vec7 = (e.into_bytes()).into_boxed_slice(); - let ptr7 = vec7.as_ptr().cast::(); - let len7 = vec7.len(); - ::core::mem::forget(vec7); - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = len7; - *base - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = ptr7.cast_mut(); - }, - V8::Any => { - *base.add(0).cast::() = (5i32) as u8; - }, - } - } - } - *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::() = len9; - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = result9; - } - } - *ptr1.add(3 * ::core::mem::size_of::<*const u8>()).cast::() = len10; - *ptr1.add(2 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - result10; - let vec16 = outputs2; - let len16 = vec16.len(); - let layout16 = _rt::alloc::Layout::from_size_align( - vec16.len() * (5 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ) - .unwrap(); - let (result16, _cleanup16) = wit_bindgen_rt::Cleanup::new(layout16); - if let Some(cleanup) = _cleanup16 { - cleanup.forget(); - } - for (i, e) in vec16.into_iter().enumerate() { - let base = result16.add(i * (5 * ::core::mem::size_of::<*const u8>())); - { - let super::super::super::super::streamkit::plugin::types::OutputPin{ name:name11, produces_type:produces_type11, } = e; - let vec12 = (name11.into_bytes()).into_boxed_slice(); - let ptr12 = vec12.as_ptr().cast::(); - let len12 = vec12.len(); - ::core::mem::forget(vec12); - *base.add(::core::mem::size_of::<*const u8>()).cast::() = - len12; - *base.add(0).cast::<*mut u8>() = ptr12.cast_mut(); - use super::super::super::super::streamkit::plugin::types::PacketType as V15; - match produces_type11 { - V15::RawAudio(e) => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (0i32) as u8; - let super::super::super::super::streamkit::plugin::types::AudioFormat{ sample_rate:sample_rate13, channels:channels13, sample_format:sample_format13, } = e; - *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::() = _rt::as_i32(sample_rate13); - *base - .add(4 + 3 * ::core::mem::size_of::<*const u8>()) - .cast::() = (_rt::as_i32(channels13)) as u16; - *base - .add(6 + 3 * ::core::mem::size_of::<*const u8>()) - .cast::() = (sample_format13.clone() as i32) as u8; - }, - V15::OpusAudio => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (1i32) as u8; - }, - V15::Text => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (2i32) as u8; - }, - V15::Binary => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (3i32) as u8; - }, - V15::Custom(e) => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (4i32) as u8; - let vec14 = (e.into_bytes()).into_boxed_slice(); - let ptr14 = vec14.as_ptr().cast::(); - let len14 = vec14.len(); - ::core::mem::forget(vec14); - *base - .add(4 * ::core::mem::size_of::<*const u8>()) - .cast::() = len14; - *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>() = ptr14.cast_mut(); - }, - V15::Any => { - *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = (5i32) as u8; - }, - } - } - } - *ptr1.add(5 * ::core::mem::size_of::<*const u8>()).cast::() = len16; - *ptr1.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - result16; - let vec17 = (param_schema2.into_bytes()).into_boxed_slice(); - let ptr17 = vec17.as_ptr().cast::(); - let len17 = vec17.len(); - ::core::mem::forget(vec17); - *ptr1.add(7 * ::core::mem::size_of::<*const u8>()).cast::() = len17; - *ptr1.add(6 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - ptr17.cast_mut(); - let vec19 = categories2; - let len19 = vec19.len(); - let layout19 = _rt::alloc::Layout::from_size_align( - vec19.len() * (2 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ) - .unwrap(); - let (result19, _cleanup19) = wit_bindgen_rt::Cleanup::new(layout19); - if let Some(cleanup) = _cleanup19 { - cleanup.forget(); - } - for (i, e) in vec19.into_iter().enumerate() { - let base = result19.add(i * (2 * ::core::mem::size_of::<*const u8>())); - { - let vec18 = (e.into_bytes()).into_boxed_slice(); - let ptr18 = vec18.as_ptr().cast::(); - let len18 = vec18.len(); - ::core::mem::forget(vec18); - *base.add(::core::mem::size_of::<*const u8>()).cast::() = - len18; - *base.add(0).cast::<*mut u8>() = ptr18.cast_mut(); - } - } - *ptr1.add(9 * ::core::mem::size_of::<*const u8>()).cast::() = len19; - *ptr1.add(8 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - result19; - ptr1 - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_metadata(arg0: *mut u8) { - unsafe { - let l0 = *arg0.add(0).cast::<*mut u8>(); - let l1 = *arg0.add(::core::mem::size_of::<*const u8>()).cast::(); - _rt::cabi_dealloc(l0, l1, 1); - let l2 = - *arg0.add(2 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); - let l3 = *arg0.add(3 * ::core::mem::size_of::<*const u8>()).cast::(); - let base12 = l2; - let len12 = l3; - for i in 0..len12 { - let base = base12.add(i * (4 * ::core::mem::size_of::<*const u8>())); - { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = - *base.add(::core::mem::size_of::<*const u8>()).cast::(); - _rt::cabi_dealloc(l4, l5, 1); - let l6 = *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l7 = *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::(); - let base11 = l6; - let len11 = l7; - for i in 0..len11 { - let base = - base11.add(i * (3 * ::core::mem::size_of::<*const u8>())); - { - let l8 = i32::from(*base.add(0).cast::()); - match l8 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), - 4 => { - let l9 = *base - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l10 = *base - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l9, l10, 1); - }, - _ => (), - } - } - } - _rt::cabi_dealloc( - base11, - len11 * (3 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - } - } - _rt::cabi_dealloc( - base12, - len12 * (4 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - let l13 = - *arg0.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); - let l14 = - *arg0.add(5 * ::core::mem::size_of::<*const u8>()).cast::(); - let base20 = l13; - let len20 = l14; - for i in 0..len20 { - let base = base20.add(i * (5 * ::core::mem::size_of::<*const u8>())); - { - let l15 = *base.add(0).cast::<*mut u8>(); - let l16 = - *base.add(::core::mem::size_of::<*const u8>()).cast::(); - _rt::cabi_dealloc(l15, l16, 1); - let l17 = i32::from( - *base.add(2 * ::core::mem::size_of::<*const u8>()).cast::(), - ); - match l17 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), - 4 => { - let l18 = *base - .add(3 * ::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l19 = *base - .add(4 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l18, l19, 1); - }, - _ => (), - } - } - } - _rt::cabi_dealloc( - base20, - len20 * (5 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - let l21 = - *arg0.add(6 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); - let l22 = - *arg0.add(7 * ::core::mem::size_of::<*const u8>()).cast::(); - _rt::cabi_dealloc(l21, l22, 1); - let l23 = - *arg0.add(8 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); - let l24 = - *arg0.add(9 * ::core::mem::size_of::<*const u8>()).cast::(); - let base27 = l23; - let len27 = l24; - for i in 0..len27 { - let base = base27.add(i * (2 * ::core::mem::size_of::<*const u8>())); - { - let l25 = *base.add(0).cast::<*mut u8>(); - let l26 = - *base.add(::core::mem::size_of::<*const u8>()).cast::(); - _rt::cabi_dealloc(l25, l26, 1); - } - } - _rt::cabi_dealloc( - base27, - len27 * (2 * ::core::mem::size_of::<*const u8>()), - ::core::mem::size_of::<*const u8>(), - ); - } + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != 0 && handle != u32::MAX); + Self { handle: AtomicU32::new(handle), _marker: marker::PhantomData } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource").field("handle", &self.handle).finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {}, + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), } - #[doc(hidden)] - #[allow(non_snake_case, unused_unsafe)] - pub unsafe fn _export_constructor_node_instance_cabi( - arg0: i32, - arg1: *mut u8, - arg2: usize, - ) -> i32 { - unsafe { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result1 = { - NodeInstance::new(T::new(match arg0 { - 0 => None, - 1 => { - let e = { - let len0 = arg2; - let bytes0 = - _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + } + } + } - _rt::string_lift(bytes0) - }; - Some(e) - }, - _ => _rt::invalid_enum_discriminant(), - })) + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen::rt::run_ctors_once(); + } + pub use alloc_crate::alloc; + extern crate alloc as alloc_crate; +} +pub mod wit_future { + #![allow(dead_code, unused_variables, clippy::all)] + + #[doc(hidden)] + pub trait FuturePayload: Unpin + Sized + 'static { + const VTABLE: &'static wit_bindgen::rt::async_support::FutureVtable; + } + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable0 { + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8) -> u32 { + unreachable!() + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/stdin@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[future-new-1]read-via-stream"] + fn new() -> u64; + #[link_name = "[future-cancel-write-1]read-via-stream"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[future-cancel-read-1]read-via-stream"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[future-drop-writable-1]read-via-stream"] + fn drop_writable(_: u32); + #[link_name = "[future-drop-readable-1]read-via-stream"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][future-read-1]read-via-stream"] + fn start_read(_: u32, _: *mut u8) -> u32; + #[link_name = "[async-lower][future-write-1]read-via-stream"] + fn start_write(_: u32, _: *const u8) -> u32; + } + + unsafe fn lift(ptr: *mut u8) -> Result<(), super::super::wasi::cli::stdin::ErrorCode> { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = { + let l1 = i32::from(*ptr.add(1).cast::()); + + super::super::wasi::cli::types::ErrorCode::_lift(l1 as u8) }; - (result1).take_handle() as i32 - } + Err(e) + }, + _ => super::super::_rt::invalid_enum_discriminant(), } - #[doc(hidden)] - #[allow(non_snake_case, unused_unsafe)] - pub unsafe fn _export_method_node_instance_process_cabi( - arg0: *mut u8, - arg1: *mut u8, - arg2: usize, - arg3: i32, - arg4: *mut u8, - arg5: usize, - arg6: *mut u8, - arg7: *mut u8, - arg8: usize, - ) -> *mut u8 { - unsafe { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result7 = { - let len0 = arg2; - let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); - use super::super::super::super::streamkit::plugin::types::Packet as V6; - let v6 = match arg3 { - 0 => { - let e6 = { - let len1 = arg7 as usize; - - super::super::super::super::streamkit::plugin::types::AudioFrame{ - sample_rate: arg4 as i32 as u32, - channels: arg5 as i32 as u16, - samples: _rt::Vec::from_raw_parts(arg6.cast(), len1, len1), - } - }; - V6::Audio(e6) - }, - 1 => { - let e6 = { - let len2 = arg5; - let bytes2 = - _rt::Vec::from_raw_parts(arg4.cast(), len2, len2); + } + } + unsafe fn lower( + value: Result<(), super::super::wasi::cli::stdin::ErrorCode>, + ptr: *mut u8, + ) { + unsafe { + match value { + Ok(_) => { + *ptr.add(0).cast::() = (0i32) as u8; + }, + Err(e) => { + *ptr.add(0).cast::() = (1i32) as u8; + *ptr.add(1).cast::() = (e.clone() as i32) as u8; + }, + }; + } + } + unsafe fn dealloc_lists(ptr: *mut u8) { + unsafe {} + } - _rt::string_lift(bytes2) - }; - V6::Text(e6) - }, - 2 => { - let e6 = { - let len3 = arg5; + pub static VTABLE: wit_bindgen::rt::async_support::FutureVtable< + Result<(), super::super::wasi::cli::stdin::ErrorCode>, + > = wit_bindgen::rt::async_support::FutureVtable::< + Result<(), super::super::wasi::cli::stdin::ErrorCode>, + > { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists, + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(2, 1) }, + lift, + lower, + new, + start_read, + start_write, + }; + + impl super::FuturePayload for Result<(), super::super::wasi::cli::stdin::ErrorCode> { + const VTABLE: &'static wit_bindgen::rt::async_support::FutureVtable = &VTABLE; + } + } - _rt::Vec::from_raw_parts(arg4.cast(), len3, len3) - }; - V6::Binary(e6) - }, - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e6 = { - let len4 = arg5; - let bytes4 = - _rt::Vec::from_raw_parts(arg4.cast(), len4, len4); - let len5 = arg8; - let bytes5 = - _rt::Vec::from_raw_parts(arg7.cast(), len5, len5); - - super::super::super::super::streamkit::plugin::types::CustomPacket{ - type_id: _rt::string_lift(bytes4), - encoding: super::super::super::super::streamkit::plugin::types::CustomEncoding::_lift(arg6 as i32 as u8), - data: _rt::string_lift(bytes5), - } + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable1 { + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8) -> u32 { + unreachable!() + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[future-new-1][method]descriptor.read-via-stream"] + fn new() -> u64; + #[link_name = "[future-cancel-write-1][method]descriptor.read-via-stream"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[future-cancel-read-1][method]descriptor.read-via-stream"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[future-drop-writable-1][method]descriptor.read-via-stream"] + fn drop_writable(_: u32); + #[link_name = "[future-drop-readable-1][method]descriptor.read-via-stream"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][future-read-1][method]descriptor.read-via-stream"] + fn start_read(_: u32, _: *mut u8) -> u32; + #[link_name = "[async-lower][future-write-1][method]descriptor.read-via-stream"] + fn start_write(_: u32, _: *const u8) -> u32; + } + + unsafe fn lift( + ptr: *mut u8, + ) -> Result<(), super::super::wasi::filesystem::types::ErrorCode> { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = + { + let l1 = i32::from( + *ptr.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + use super::super::wasi::filesystem::types::ErrorCode as V6; + let v6 = + match l1 { + 0 => V6::Access, + 1 => V6::Already, + 2 => V6::BadDescriptor, + 3 => V6::Busy, + 4 => V6::Deadlock, + 5 => V6::Quota, + 6 => V6::Exist, + 7 => V6::FileTooLarge, + 8 => V6::IllegalByteSequence, + 9 => V6::InProgress, + 10 => V6::Interrupted, + 11 => V6::Invalid, + 12 => V6::Io, + 13 => V6::IsDirectory, + 14 => V6::Loop, + 15 => V6::TooManyLinks, + 16 => V6::MessageSize, + 17 => V6::NameTooLong, + 18 => V6::NoDevice, + 19 => V6::NoEntry, + 20 => V6::NoLock, + 21 => V6::InsufficientMemory, + 22 => V6::InsufficientSpace, + 23 => V6::NotDirectory, + 24 => V6::NotEmpty, + 25 => V6::NotRecoverable, + 26 => V6::Unsupported, + 27 => V6::NoTty, + 28 => V6::NoSuchDevice, + 29 => V6::Overflow, + 30 => V6::NotPermitted, + 31 => V6::Pipe, + 32 => V6::ReadOnly, + 33 => V6::InvalidSeek, + 34 => V6::TextFileBusy, + 35 => V6::CrossDevice, + n => { + debug_assert_eq!(n, 36, "invalid enum discriminant"); + let e6 = + { + let l2 = i32::from( + *ptr.add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = super::super::_rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + super::super::_rt::string_lift(bytes5) + }; + Some(e) + } + _ => super::super::_rt::invalid_enum_discriminant(), + } + }; + V6::Other(e6) + }, }; - V6::Custom(e6) - }, + + v6 }; - T::process( - NodeInstanceBorrow::lift(arg0 as u32 as usize).get(), - _rt::string_lift(bytes0), - v6, - ) - }; - let ptr8 = (&raw mut _RET_AREA.0).cast::(); - match result7 { - Ok(_) => { - *ptr8.add(0).cast::() = (0i32) as u8; - }, - Err(e) => { - *ptr8.add(0).cast::() = (1i32) as u8; - let vec9 = (e.into_bytes()).into_boxed_slice(); - let ptr9 = vec9.as_ptr().cast::(); - let len9 = vec9.len(); - ::core::mem::forget(vec9); - *ptr8 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = len9; - *ptr8.add(::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - ptr9.cast_mut(); + Err(e) + }, + _ => super::super::_rt::invalid_enum_discriminant(), + } + } + } + unsafe fn lower( + value: Result<(), super::super::wasi::filesystem::types::ErrorCode>, + ptr: *mut u8, + ) { + unsafe { + match value { + Ok(_) => { + *ptr.add(0).cast::() = (0i32) as u8; + }, + Err(e) => { + *ptr.add(0).cast::() = (1i32) as u8; + use super::super::wasi::filesystem::types::ErrorCode as V1; + match e { + V1::Access => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (0i32) as u8; + }, + V1::Already => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (1i32) as u8; + }, + V1::BadDescriptor => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (2i32) as u8; + }, + V1::Busy => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (3i32) as u8; + }, + V1::Deadlock => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (4i32) as u8; + }, + V1::Quota => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (5i32) as u8; + }, + V1::Exist => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (6i32) as u8; + }, + V1::FileTooLarge => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (7i32) as u8; + }, + V1::IllegalByteSequence => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (8i32) as u8; + }, + V1::InProgress => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (9i32) as u8; + }, + V1::Interrupted => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (10i32) as u8; + }, + V1::Invalid => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (11i32) as u8; + }, + V1::Io => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (12i32) as u8; + }, + V1::IsDirectory => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (13i32) as u8; + }, + V1::Loop => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (14i32) as u8; + }, + V1::TooManyLinks => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (15i32) as u8; + }, + V1::MessageSize => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (16i32) as u8; + }, + V1::NameTooLong => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (17i32) as u8; + }, + V1::NoDevice => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (18i32) as u8; + }, + V1::NoEntry => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (19i32) as u8; }, - }; - ptr8 - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_method_node_instance_process( - arg0: *mut u8, - ) { - unsafe { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { - 0 => (), - _ => { - let l1 = *arg0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l2 = *arg0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l1, l2, 1); + V1::NoLock => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (20i32) as u8; }, - } - } - } - #[doc(hidden)] - #[allow(non_snake_case, unused_unsafe)] - pub unsafe fn _export_method_node_instance_update_params_cabi< - T: GuestNodeInstance, - >( - arg0: *mut u8, - arg1: i32, - arg2: *mut u8, - arg3: usize, - ) -> *mut u8 { - unsafe { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result1 = { - T::update_params( - NodeInstanceBorrow::lift(arg0 as u32 as usize).get(), - match arg1 { - 0 => None, - 1 => { - let e = { - let len0 = arg3; - let bytes0 = - _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); - - _rt::string_lift(bytes0) - }; - Some(e) + V1::InsufficientMemory => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (21i32) as u8; + }, + V1::InsufficientSpace => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (22i32) as u8; + }, + V1::NotDirectory => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (23i32) as u8; + }, + V1::NotEmpty => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (24i32) as u8; + }, + V1::NotRecoverable => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (25i32) as u8; + }, + V1::Unsupported => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (26i32) as u8; + }, + V1::NoTty => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (27i32) as u8; + }, + V1::NoSuchDevice => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (28i32) as u8; + }, + V1::Overflow => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (29i32) as u8; + }, + V1::NotPermitted => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (30i32) as u8; + }, + V1::Pipe => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (31i32) as u8; + }, + V1::ReadOnly => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (32i32) as u8; + }, + V1::InvalidSeek => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (33i32) as u8; + }, + V1::TextFileBusy => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (34i32) as u8; + }, + V1::CrossDevice => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (35i32) as u8; + }, + V1::Other(e) => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (36i32) as u8; + match e { + Some(e) => { + *ptr.add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (1i32) as u8; + let vec0 = (e.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *ptr.add(4 * ::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *ptr.add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr0.cast_mut(); }, - _ => _rt::invalid_enum_discriminant(), - }, - ) - }; - let ptr2 = (&raw mut _RET_AREA.0).cast::(); - match result1 { - Ok(_) => { - *ptr2.add(0).cast::() = (0i32) as u8; - }, - Err(e) => { - *ptr2.add(0).cast::() = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - ::core::mem::forget(vec3); - *ptr2 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::() = len3; - *ptr2.add(::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = - ptr3.cast_mut(); + None => { + *ptr.add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (0i32) as u8; + }, + }; }, - }; - ptr2 - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_method_node_instance_update_params< - T: GuestNodeInstance, - >( - arg0: *mut u8, - ) { - unsafe { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { + } + }, + }; + } + } + unsafe fn dealloc_lists(ptr: *mut u8) { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = + i32::from(*ptr.add(::core::mem::size_of::<*const u8>()).cast::()); + match l1 { 0 => (), + 1 => (), + 2 => (), + 3 => (), + 4 => (), + 5 => (), + 6 => (), + 7 => (), + 8 => (), + 9 => (), + 10 => (), + 11 => (), + 12 => (), + 13 => (), + 14 => (), + 15 => (), + 16 => (), + 17 => (), + 18 => (), + 19 => (), + 20 => (), + 21 => (), + 22 => (), + 23 => (), + 24 => (), + 25 => (), + 26 => (), + 27 => (), + 28 => (), + 29 => (), + 30 => (), + 31 => (), + 32 => (), + 33 => (), + 34 => (), + 35 => (), _ => { - let l1 = *arg0 - .add(::core::mem::size_of::<*const u8>()) - .cast::<*mut u8>(); - let l2 = *arg0 - .add(2 * ::core::mem::size_of::<*const u8>()) - .cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l2 = i32::from( + *ptr.add(2 * ::core::mem::size_of::<*const u8>()).cast::(), + ); + match l2 { + 0 => (), + _ => { + let l3 = *ptr + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + super::super::_rt::cabi_dealloc(l3, l4, 1); + }, + } }, } - } - } - #[doc(hidden)] - #[allow(non_snake_case, unused_unsafe)] - pub unsafe fn _export_method_node_instance_cleanup_cabi( - arg0: *mut u8, - ) { - unsafe { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - { - T::cleanup(NodeInstanceBorrow::lift(arg0 as u32 as usize).get()) - }; - } - } - pub trait Guest { - type NodeInstance: GuestNodeInstance; - /// Get metadata about this node type - #[allow(async_fn_in_trait)] - fn metadata() -> NodeMetadata; + }, } - pub trait GuestNodeInstance: 'static { - #[doc(hidden)] - unsafe fn _resource_new(val: *mut u8) -> u32 - where - Self: Sized, - { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "[export]streamkit:plugin/node@0.1.0")] - unsafe extern "C" { - #[link_name = "[resource-new]node-instance"] - fn new(_: *mut u8) -> i32; - } + } + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn new(_: *mut u8) -> i32 { - unreachable!() - } + pub static VTABLE: wit_bindgen::rt::async_support::FutureVtable< + Result<(), super::super::wasi::filesystem::types::ErrorCode>, + > = wit_bindgen::rt::async_support::FutureVtable::< + Result<(), super::super::wasi::filesystem::types::ErrorCode>, + > { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists, + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(20, 4) }, + lift, + lower, + new, + start_read, + start_write, + }; + + impl super::FuturePayload for Result<(), super::super::wasi::filesystem::types::ErrorCode> { + const VTABLE: &'static wit_bindgen::rt::async_support::FutureVtable = &VTABLE; + } + } - unsafe { new(val) as u32 } - } + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable2 { - #[doc(hidden)] - fn _resource_rep(handle: u32) -> *mut u8 - where - Self: Sized, - { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "[export]streamkit:plugin/node@0.1.0")] - unsafe extern "C" { - #[link_name = "[resource-rep]node-instance"] - fn rep(_: i32) -> *mut u8; - } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8) -> u32 { + unreachable!() + } - #[cfg(not(target_arch = "wasm32"))] - unsafe extern "C" fn rep(_: i32) -> *mut u8 { - unreachable!() - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[future-new-1][method]tcp-socket.send"] + fn new() -> u64; + #[link_name = "[future-cancel-write-1][method]tcp-socket.send"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[future-cancel-read-1][method]tcp-socket.send"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[future-drop-writable-1][method]tcp-socket.send"] + fn drop_writable(_: u32); + #[link_name = "[future-drop-readable-1][method]tcp-socket.send"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][future-read-1][method]tcp-socket.send"] + fn start_read(_: u32, _: *mut u8) -> u32; + #[link_name = "[async-lower][future-write-1][method]tcp-socket.send"] + fn start_write(_: u32, _: *const u8) -> u32; + } - unsafe { rep(handle as i32) } - } + unsafe fn lift(ptr: *mut u8) -> Result<(), super::super::wasi::sockets::types::ErrorCode> { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + + match l0 { + 0 => { + let e = (); + Ok(e) + }, + 1 => { + let e = + { + let l1 = i32::from( + *ptr.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + use super::super::wasi::sockets::types::ErrorCode as V6; + let v6 = + match l1 { + 0 => V6::AccessDenied, + 1 => V6::NotSupported, + 2 => V6::InvalidArgument, + 3 => V6::OutOfMemory, + 4 => V6::Timeout, + 5 => V6::InvalidState, + 6 => V6::AddressNotBindable, + 7 => V6::AddressInUse, + 8 => V6::RemoteUnreachable, + 9 => V6::ConnectionRefused, + 10 => V6::ConnectionBroken, + 11 => V6::ConnectionReset, + 12 => V6::ConnectionAborted, + 13 => V6::DatagramTooLarge, + n => { + debug_assert_eq!(n, 14, "invalid enum discriminant"); + let e6 = + { + let l2 = i32::from( + *ptr.add( + 2 * ::core::mem::size_of::<*const u8>(), + ) + .cast::(), + ); - /// Construct a new stateful node instance with optional parameters (JSON string) - #[allow(async_fn_in_trait)] - fn new(params: Option<_rt::String>) -> Self; - /// Process an incoming packet from a specific input pin using this instance's state - #[allow(async_fn_in_trait)] - fn process( - &self, - input_pin: _rt::String, - packet: Packet, - ) -> Result<(), _rt::String>; - /// Update the runtime parameters for this instance. The payload is a JSON string. - #[allow(async_fn_in_trait)] - fn update_params(&self, params: Option<_rt::String>) - -> Result<(), _rt::String>; - /// Clean up any resources associated with this instance - #[allow(async_fn_in_trait)] - fn cleanup(&self) -> (); - } - #[doc(hidden)] - #[macro_export] - macro_rules! __export_streamkit_plugin_node_0_1_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *ptr.add(3*::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l4 = *ptr.add(4*::core::mem::size_of::<*const u8>()).cast::(); + let len5 = l4; + let bytes5 = super::super::_rt::Vec::from_raw_parts(l3.cast(), len5, len5); - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#metadata")] - unsafe extern "C" fn export_metadata() -> *mut u8 { - unsafe { $($path_to_types)*::_export_metadata_cabi::<$ty>() } - } - #[unsafe(export_name = "cabi_post_streamkit:plugin/node@0.1.0#metadata")] - unsafe extern "C" fn _post_return_metadata(arg0: *mut u8,) { - unsafe { $($path_to_types)*::__post_return_metadata::<$ty>(arg0) } - } - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#[constructor]node-instance")] - unsafe extern "C" fn export_constructor_node_instance(arg0: i32,arg1: *mut u8,arg2: usize,) -> i32 { - unsafe { $($path_to_types)*::_export_constructor_node_instance_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2) } - } - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#[method]node-instance.process")] - unsafe extern "C" fn export_method_node_instance_process(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: i32,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: *mut u8,arg8: usize,) -> *mut u8 { - unsafe { $($path_to_types)*::_export_method_node_instance_process_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } - } - #[unsafe(export_name = "cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.process")] - unsafe extern "C" fn _post_return_method_node_instance_process(arg0: *mut u8,) { - unsafe { $($path_to_types)*::__post_return_method_node_instance_process::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0) } - } - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#[method]node-instance.update-params")] - unsafe extern "C" fn export_method_node_instance_update_params(arg0: *mut u8,arg1: i32,arg2: *mut u8,arg3: usize,) -> *mut u8 { - unsafe { $($path_to_types)*::_export_method_node_instance_update_params_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0, arg1, arg2, arg3) } - } - #[unsafe(export_name = "cabi_post_streamkit:plugin/node@0.1.0#[method]node-instance.update-params")] - unsafe extern "C" fn _post_return_method_node_instance_update_params(arg0: *mut u8,) { - unsafe { $($path_to_types)*::__post_return_method_node_instance_update_params::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0) } - } - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#[method]node-instance.cleanup")] - unsafe extern "C" fn export_method_node_instance_cleanup(arg0: *mut u8,) { - unsafe { $($path_to_types)*::_export_method_node_instance_cleanup_cabi::<<$ty as $($path_to_types)*::Guest>::NodeInstance>(arg0) } - } + super::super::_rt::string_lift(bytes5) + }; + Some(e) + } + _ => super::super::_rt::invalid_enum_discriminant(), + } + }; + V6::Other(e6) + }, + }; - const _: () = { - #[doc(hidden)] - #[unsafe(export_name = "streamkit:plugin/node@0.1.0#[dtor]node-instance")] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - unsafe { - $($path_to_types)*::NodeInstance::dtor::< - <$ty as $($path_to_types)*::Guest>::NodeInstance - >(rep) + v6 + }; + Err(e) + }, + _ => super::super::_rt::invalid_enum_discriminant(), + } + } } - } - }; - - };); -} - #[doc(hidden)] - pub use __export_streamkit_plugin_node_0_1_0_cabi; - - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - struct _RetArea( - [::core::mem::MaybeUninit; 10 * ::core::mem::size_of::<*const u8>()], - ); - static mut _RET_AREA: _RetArea = _RetArea( - [::core::mem::MaybeUninit::uninit(); 10 * ::core::mem::size_of::<*const u8>()], - ); + unsafe fn lower( + value: Result<(), super::super::wasi::sockets::types::ErrorCode>, + ptr: *mut u8, + ) { + unsafe { + match value { + Ok(_) => { + *ptr.add(0).cast::() = (0i32) as u8; + }, + Err(e) => { + *ptr.add(0).cast::() = (1i32) as u8; + use super::super::wasi::sockets::types::ErrorCode as V1; + match e { + V1::AccessDenied => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (0i32) as u8; + }, + V1::NotSupported => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (1i32) as u8; + }, + V1::InvalidArgument => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (2i32) as u8; + }, + V1::OutOfMemory => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (3i32) as u8; + }, + V1::Timeout => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (4i32) as u8; + }, + V1::InvalidState => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (5i32) as u8; + }, + V1::AddressNotBindable => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (6i32) as u8; + }, + V1::AddressInUse => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (7i32) as u8; + }, + V1::RemoteUnreachable => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (8i32) as u8; + }, + V1::ConnectionRefused => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (9i32) as u8; + }, + V1::ConnectionBroken => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (10i32) as u8; + }, + V1::ConnectionReset => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (11i32) as u8; + }, + V1::ConnectionAborted => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (12i32) as u8; + }, + V1::DatagramTooLarge => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (13i32) as u8; + }, + V1::Other(e) => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (14i32) as u8; + match e { + Some(e) => { + *ptr.add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (1i32) as u8; + let vec0 = (e.into_bytes()).into_boxed_slice(); + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + ::core::mem::forget(vec0); + *ptr.add(4 * ::core::mem::size_of::<*const u8>()) + .cast::() = len0; + *ptr.add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr0.cast_mut(); + }, + None => { + *ptr.add(2 * ::core::mem::size_of::<*const u8>()) + .cast::() = (0i32) as u8; + }, + }; + }, + } + }, + }; + } + } + unsafe fn dealloc_lists(ptr: *mut u8) { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = + i32::from(*ptr.add(::core::mem::size_of::<*const u8>()).cast::()); + match l1 { + 0 => (), + 1 => (), + 2 => (), + 3 => (), + 4 => (), + 5 => (), + 6 => (), + 7 => (), + 8 => (), + 9 => (), + 10 => (), + 11 => (), + 12 => (), + 13 => (), + _ => { + let l2 = i32::from( + *ptr.add(2 * ::core::mem::size_of::<*const u8>()).cast::(), + ); + match l2 { + 0 => (), + _ => { + let l3 = *ptr + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + super::super::_rt::cabi_dealloc(l3, l4, 1); + }, + } + }, + } + }, + } } } - } -} -mod _rt { - #![allow(dead_code, clippy::all)] - pub use alloc_crate::string::String; - pub use alloc_crate::vec::Vec; - pub fn as_i32(t: T) -> i32 { - t.as_i32() + pub static VTABLE: wit_bindgen::rt::async_support::FutureVtable< + Result<(), super::super::wasi::sockets::types::ErrorCode>, + > = wit_bindgen::rt::async_support::FutureVtable::< + Result<(), super::super::wasi::sockets::types::ErrorCode>, + > { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists, + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(20, 4) }, + lift, + lower, + new, + start_read, + start_write, + }; + + impl super::FuturePayload for Result<(), super::super::wasi::sockets::types::ErrorCode> { + const VTABLE: &'static wit_bindgen::rt::async_support::FutureVtable = &VTABLE; + } } - - pub trait AsI32 { - fn as_i32(self) -> i32; + /// Creates a new Component Model `future` with the specified payload type. + /// + /// The `default` function provided computes the default value to be sent in + /// this future if no other value was otherwise sent. + pub fn new( + default: fn() -> T, + ) -> ( + wit_bindgen::rt::async_support::FutureWriter, + wit_bindgen::rt::async_support::FutureReader, + ) { + unsafe { wit_bindgen::rt::async_support::future_new::(default, T::VTABLE) } } +} +pub mod wit_stream { + #![allow(dead_code, unused_variables, clippy::all)] - impl<'a, T: Copy + AsI32> AsI32 for &'a T { - fn as_i32(self) -> i32 { - (*self).as_i32() - } + pub trait StreamPayload: Unpin + Sized + 'static { + const VTABLE: &'static wit_bindgen::rt::async_support::StreamVtable; } + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable0 { - impl AsI32 for i32 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() } - } - - impl AsI32 for u32 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() } - } - - impl AsI32 for i16 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() } - } - - impl AsI32 for u16 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() } - } - - impl AsI32 for i8 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() } - } - - impl AsI32 for u8 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8, _: usize) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8, _: usize) -> u32 { + unreachable!() } - } - impl AsI32 for char { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/stdin@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[stream-new-0]read-via-stream"] + fn new() -> u64; + #[link_name = "[stream-cancel-write-0]read-via-stream"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[stream-cancel-read-0]read-via-stream"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[stream-drop-writable-0]read-via-stream"] + fn drop_writable(_: u32); + #[link_name = "[stream-drop-readable-0]read-via-stream"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][stream-read-0]read-via-stream"] + fn start_read(_: u32, _: *mut u8, _: usize) -> u32; + #[link_name = "[async-lower][stream-write-0]read-via-stream"] + fn start_write(_: u32, _: *const u8, _: usize) -> u32; } - } - impl AsI32 for usize { - #[inline] - fn as_i32(self) -> i32 { - self as i32 + pub static VTABLE: wit_bindgen::rt::async_support::StreamVtable = + wit_bindgen::rt::async_support::StreamVtable:: { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists: None, + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(1, 1) }, + lift: None, + lower: None, + new, + start_read, + start_write, + }; + + impl super::StreamPayload for u8 { + const VTABLE: &'static wit_bindgen::rt::async_support::StreamVtable = &VTABLE; } } - pub unsafe fn string_lift(bytes: Vec) -> String { - if cfg!(debug_assertions) { - String::from_utf8(bytes).unwrap() - } else { - unsafe { String::from_utf8_unchecked(bytes) } + + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable1 { + + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() } - } - pub unsafe fn invalid_enum_discriminant() -> T { - if cfg!(debug_assertions) { - panic!("invalid enum discriminant") - } else { - unsafe { core::hint::unreachable_unchecked() } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() } - } - pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { - if size == 0 { - return; + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() } - unsafe { - let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr, layout); + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() } - } - - use core::fmt; - use core::marker; - use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; - - /// A type which represents a component model resource, either imported or - /// exported into this component. - /// - /// This is a low-level wrapper which handles the lifetime of the resource - /// (namely this has a destructor). The `T` provided defines the component model - /// intrinsics that this wrapper uses. - /// - /// One of the chief purposes of this type is to provide `Deref` implementations - /// to access the underlying data when it is owned. - /// - /// This type is primarily used in generated code for exported and imported - /// resources. - #[repr(transparent)] - pub struct Resource { - // NB: This would ideally be `u32` but it is not. The fact that this has - // interior mutability is not exposed in the API of this type except for the - // `take_handle` method which is supposed to in theory be private. - // - // This represents, almost all the time, a valid handle value. When it's - // invalid it's stored as `u32::MAX`. - handle: AtomicU32, - _marker: marker::PhantomData, - } - - /// A trait which all wasm resources implement, namely providing the ability to - /// drop a resource. - /// - /// This generally is implemented by generated code, not user-facing code. - #[allow(clippy::missing_safety_doc)] - pub unsafe trait WasmResource { - /// Invokes the `[resource-drop]...` intrinsic. - unsafe fn drop(handle: u32); - } - - impl Resource { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - debug_assert!(handle != 0 && handle != u32::MAX); - Self { handle: AtomicU32::new(handle), _marker: marker::PhantomData } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() } - - /// Takes ownership of the handle owned by `resource`. - /// - /// Note that this ideally would be `into_handle` taking `Resource` by - /// ownership. The code generator does not enable that in all situations, - /// unfortunately, so this is provided instead. - /// - /// Also note that `take_handle` is in theory only ever called on values - /// owned by a generated function. For example a generated function might - /// take `Resource` as an argument but then call `take_handle` on a - /// reference to that argument. In that sense the dynamic nature of - /// `take_handle` should only be exposed internally to generated code, not - /// to user code. - #[doc(hidden)] - pub fn take_handle(resource: &Resource) -> u32 { - resource.handle.swap(u32::MAX, Relaxed) + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8, _: usize) -> u32 { + unreachable!() } - - #[doc(hidden)] - pub fn handle(resource: &Resource) -> u32 { - resource.handle.load(Relaxed) + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8, _: usize) -> u32 { + unreachable!() } - } - impl fmt::Debug for Resource { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Resource").field("handle", &self.handle).finish() + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[stream-new-0][method]descriptor.read-directory"] + fn new() -> u64; + #[link_name = "[stream-cancel-write-0][method]descriptor.read-directory"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[stream-cancel-read-0][method]descriptor.read-directory"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[stream-drop-writable-0][method]descriptor.read-directory"] + fn drop_writable(_: u32); + #[link_name = "[stream-drop-readable-0][method]descriptor.read-directory"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][stream-read-0][method]descriptor.read-directory"] + fn start_read(_: u32, _: *mut u8, _: usize) -> u32; + #[link_name = "[async-lower][stream-write-0][method]descriptor.read-directory"] + fn start_write(_: u32, _: *const u8, _: usize) -> u32; } - } - impl Drop for Resource { - fn drop(&mut self) { + unsafe fn lift(ptr: *mut u8) -> super::super::wasi::filesystem::types::DirectoryEntry { unsafe { - match self.handle.load(Relaxed) { - // If this handle was "taken" then don't do anything in the - // destructor. - u32::MAX => {}, + let l0 = i32::from(*ptr.add(0).cast::()); + use super::super::wasi::filesystem::types::DescriptorType as V5; + let v5 = match l0 { + 0 => V5::BlockDevice, + 1 => V5::CharacterDevice, + 2 => V5::Directory, + 3 => V5::Fifo, + 4 => V5::SymbolicLink, + 5 => V5::RegularFile, + 6 => V5::Socket, + n => { + debug_assert_eq!(n, 7, "invalid enum discriminant"); + let e5 = { + let l1 = i32::from( + *ptr.add(::core::mem::size_of::<*const u8>()).cast::(), + ); - // ... but otherwise do actually destroy it with the imported - // component model intrinsic as defined through `T`. - other => T::drop(other), + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *ptr + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len4 = l3; + let bytes4 = super::super::_rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); + + super::super::_rt::string_lift(bytes4) + }; + Some(e) + }, + _ => super::super::_rt::invalid_enum_discriminant(), + } + }; + V5::Other(e5) + }, + }; + let l6 = *ptr.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l7 = *ptr.add(5 * ::core::mem::size_of::<*const u8>()).cast::(); + let len8 = l7; + let bytes8 = super::super::_rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + super::super::wasi::filesystem::types::DirectoryEntry { + type_: v5, + name: super::super::_rt::string_lift(bytes8), } } } - } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), + unsafe fn lower( + value: super::super::wasi::filesystem::types::DirectoryEntry, + ptr: *mut u8, + ) { + unsafe { + let super::super::wasi::filesystem::types::DirectoryEntry { + type_: type_0, + name: name0, + } = value; + use super::super::wasi::filesystem::types::DescriptorType as V2; + match type_0 { + V2::BlockDevice => { + *ptr.add(0).cast::() = (0i32) as u8; + }, + V2::CharacterDevice => { + *ptr.add(0).cast::() = (1i32) as u8; + }, + V2::Directory => { + *ptr.add(0).cast::() = (2i32) as u8; + }, + V2::Fifo => { + *ptr.add(0).cast::() = (3i32) as u8; + }, + V2::SymbolicLink => { + *ptr.add(0).cast::() = (4i32) as u8; + }, + V2::RegularFile => { + *ptr.add(0).cast::() = (5i32) as u8; + }, + V2::Socket => { + *ptr.add(0).cast::() = (6i32) as u8; + }, + V2::Other(e) => { + *ptr.add(0).cast::() = (7i32) as u8; + match e { + Some(e) => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (1i32) as u8; + let vec1 = (e.into_bytes()).into_boxed_slice(); + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + ::core::mem::forget(vec1); + *ptr.add(3 * ::core::mem::size_of::<*const u8>()).cast::() = + len1; + *ptr.add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr1.cast_mut(); + }, + None => { + *ptr.add(::core::mem::size_of::<*const u8>()).cast::() = + (0i32) as u8; + }, + }; + }, + } + let vec3 = (name0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr.add(5 * ::core::mem::size_of::<*const u8>()).cast::() = len3; + *ptr.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>() = + ptr3.cast_mut(); + } + } + unsafe fn dealloc_lists(ptr: *mut u8) { + unsafe { + let l0 = i32::from(*ptr.add(0).cast::()); + match l0 { + 0 => (), + 1 => (), + 2 => (), + 3 => (), + 4 => (), + 5 => (), + 6 => (), + _ => { + let l1 = + i32::from(*ptr.add(::core::mem::size_of::<*const u8>()).cast::()); + match l1 { + 0 => (), + _ => { + let l2 = *ptr + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l3 = *ptr + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + super::super::_rt::cabi_dealloc(l2, l3, 1); + }, + } + }, + } + let l4 = *ptr.add(4 * ::core::mem::size_of::<*const u8>()).cast::<*mut u8>(); + let l5 = *ptr.add(5 * ::core::mem::size_of::<*const u8>()).cast::(); + super::super::_rt::cabi_dealloc(l4, l5, 1); } - } else { - val != 0 } - } - pub use alloc_crate::alloc; - pub fn as_i64(t: T) -> i64 { - t.as_i64() + pub static VTABLE: wit_bindgen::rt::async_support::StreamVtable< + super::super::wasi::filesystem::types::DirectoryEntry, + > = wit_bindgen::rt::async_support::StreamVtable::< + super::super::wasi::filesystem::types::DirectoryEntry, + > { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists: Some(dealloc_lists), + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(24, 4) }, + lift: Some(lift), + lower: Some(lower), + new, + start_read, + start_write, + }; + + impl super::StreamPayload for super::super::wasi::filesystem::types::DirectoryEntry { + const VTABLE: &'static wit_bindgen::rt::async_support::StreamVtable = &VTABLE; + } } - pub trait AsI64 { - fn as_i64(self) -> i64; - } + #[doc(hidden)] + #[allow(unused_unsafe)] + pub mod vtable2 { - impl<'a, T: Copy + AsI64> AsI64 for &'a T { - fn as_i64(self) -> i64 { - (*self).as_i64() + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_write(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn cancel_read(_: u32) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_writable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop_readable(_: u32) { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn new() -> u64 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_read(_: u32, _: *mut u8, _: usize) -> u32 { + unreachable!() + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn start_write(_: u32, _: *const u8, _: usize) -> u32 { + unreachable!() } - } - impl AsI64 for i64 { - #[inline] - fn as_i64(self) -> i64 { - self as i64 + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/types@0.3.0-rc-2026-03-15")] + unsafe extern "C" { + #[link_name = "[stream-new-0][method]tcp-socket.listen"] + fn new() -> u64; + #[link_name = "[stream-cancel-write-0][method]tcp-socket.listen"] + fn cancel_write(_: u32) -> u32; + #[link_name = "[stream-cancel-read-0][method]tcp-socket.listen"] + fn cancel_read(_: u32) -> u32; + #[link_name = "[stream-drop-writable-0][method]tcp-socket.listen"] + fn drop_writable(_: u32); + #[link_name = "[stream-drop-readable-0][method]tcp-socket.listen"] + fn drop_readable(_: u32); + #[link_name = "[async-lower][stream-read-0][method]tcp-socket.listen"] + fn start_read(_: u32, _: *mut u8, _: usize) -> u32; + #[link_name = "[async-lower][stream-write-0][method]tcp-socket.listen"] + fn start_write(_: u32, _: *const u8, _: usize) -> u32; } - } - impl AsI64 for u64 { - #[inline] - fn as_i64(self) -> i64 { - self as i64 + unsafe fn lift(ptr: *mut u8) -> super::super::wasi::sockets::types::TcpSocket { + unsafe { + let l0 = *ptr.add(0).cast::(); + + super::super::wasi::sockets::types::TcpSocket::from_handle(l0 as u32) + } + } + unsafe fn lower(value: super::super::wasi::sockets::types::TcpSocket, ptr: *mut u8) { + unsafe { + *ptr.add(0).cast::() = (value).take_handle() as i32; + } + } + unsafe fn dealloc_lists(ptr: *mut u8) { + unsafe {} } - } - pub use alloc_crate::boxed::Box; - #[cfg(target_arch = "wasm32")] - pub fn run_ctors_once() { - wit_bindgen_rt::run_ctors_once(); + pub static VTABLE: wit_bindgen::rt::async_support::StreamVtable< + super::super::wasi::sockets::types::TcpSocket, + > = wit_bindgen::rt::async_support::StreamVtable::< + super::super::wasi::sockets::types::TcpSocket, + > { + cancel_write, + cancel_read, + drop_writable, + drop_readable, + dealloc_lists: Some(dealloc_lists), + layout: unsafe { ::core::alloc::Layout::from_size_align_unchecked(4, 4) }, + lift: Some(lift), + lower: Some(lower), + new, + start_read, + start_write, + }; + + impl super::StreamPayload for super::super::wasi::sockets::types::TcpSocket { + const VTABLE: &'static wit_bindgen::rt::async_support::StreamVtable = &VTABLE; + } + } + /// Creates a new Component Model `stream` with the specified payload type. + pub fn new() -> ( + wit_bindgen::rt::async_support::StreamWriter, + wit_bindgen::rt::async_support::StreamReader, + ) { + unsafe { wit_bindgen::rt::async_support::stream_new::(T::VTABLE) } } - extern crate alloc as alloc_crate; } /// Generates `#[unsafe(no_mangle)]` functions to export the specified type as @@ -9948,15 +16437,15 @@ mod _rt { macro_rules! __export_plugin_impl { ($ty:ident) => (self::export!($ty with_types_in self);); ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( - $($path_to_types_root)*::exports::streamkit::plugin::node::__export_streamkit_plugin_node_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::streamkit::plugin::node); + $($path_to_types_root)*::exports::streamkit::plugin::node::__export_streamkit_plugin_node_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::streamkit::plugin::node); const _: () = { #[cfg(target_arch = "wasm32")] - #[unsafe(link_section = "component-type:wit-bindgen:0.44.0:streamkit:plugin@0.1.0:plugin:imports and exports")] + #[unsafe(link_section = "component-type:wit-bindgen:0.58.0:streamkit:plugin@0.2.0:plugin:imports and exports")] #[doc(hidden)] #[allow(clippy::octal_escapes)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 11826] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb5[\x01A\x02\x01AO\x01\ + pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9244] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9fG\x01A\x02\x01A9\x01\ B\x1a\x01m\x02\x07float32\x06s16-le\x04\0\x0dsample-format\x03\0\0\x01r\x03\x0bs\ ample-ratey\x08channels{\x0dsample-format\x01\x04\0\x0caudio-format\x03\0\x02\x01\ q\x06\x09raw-audio\x01\x03\0\x0aopus-audio\0\0\x04text\0\0\x06binary\0\0\x06cust\ @@ -9968,235 +16457,176 @@ input-pin\x03\0\x0b\x01r\x02\x04names\x0dproduces-type\x05\x04\0\x0aoutput-pin\x param-schemas\x0acategories\x11\x04\0\x0dnode-metadata\x03\0\x12\x01pv\x01r\x03\x0b\ sample-ratey\x08channels{\x07samples\x14\x04\0\x0baudio-frame\x03\0\x15\x01p}\x01\ q\x04\x05audio\x01\x16\0\x04text\x01s\0\x06binary\x01\x17\0\x06custom\x01\x09\0\x04\ -\0\x06packet\x03\0\x18\x03\0\x1cstreamkit:plugin/types@0.1.0\x05\0\x02\x03\0\0\x06\ +\0\x06packet\x03\0\x18\x03\0\x1cstreamkit:plugin/types@0.2.0\x05\0\x02\x03\0\0\x06\ packet\x01B\x09\x02\x03\x02\x01\x01\x04\0\x06packet\x03\0\0\x01m\x04\x05debug\x04\ -info\x04warn\x05error\x04\0\x09log-level\x03\0\x02\x01j\0\x01s\x01@\x02\x08pin-n\ +info\x04warn\x05error\x04\0\x09log-level\x03\0\x02\x01j\0\x01s\x01C\x02\x08pin-n\ ames\x06packet\x01\0\x04\x04\0\x0bsend-output\x01\x05\x01@\x02\x05level\x03\x07m\ -essages\x01\0\x04\0\x03log\x01\x06\x03\0\x1bstreamkit:plugin/host@0.1.0\x05\x02\x01\ +essages\x01\0\x04\0\x03log\x01\x06\x03\0\x1bstreamkit:plugin/host@0.2.0\x05\x02\x01\ B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ -\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ -\x06\x03\0\x1awasi:cli/environment@0.2.0\x05\x03\x01B\x03\x01j\0\0\x01@\x01\x06s\ -tatus\0\x01\0\x04\0\x04exit\x01\x01\x03\0\x13wasi:cli/exit@0.2.0\x05\x04\x01B\x04\ -\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\0\x1d[method]error.to\ --debug-string\x01\x02\x03\0\x13wasi:io/error@0.2.0\x05\x05\x01B\x0a\x04\0\x08pol\ -lable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[method]pollable.ready\x01\ -\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollable.block\x01\x03\x01p\x01\ -\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\0\x12wasi:io/poll@0.2.\ -0\x05\x06\x02\x03\0\x04\x05error\x02\x03\0\x05\x08pollable\x01B(\x02\x03\x02\x01\ -\x07\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\x02\x01i\ -\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0cstream-e\ -rror\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\ -\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19[met\ -hod]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\x01\ -j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-stream.\ -skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\x0e\x01i\x03\x01@\x01\ -\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\x01\x10\x01h\x08\x01@\ -\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-write\x01\x12\x01j\0\x01\ -\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b[method]output-stream.w\ -rite\x01\x14\x04\0.[method]output-stream.blocking-write-and-flush\x01\x14\x01@\x01\ -\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\x01\x15\x04\0$[method]ou\ -tput-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]o\ -utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method\ -]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ -eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ -method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ -\x18\x03\0\x15wasi:io/streams@0.2.0\x05\x09\x02\x03\0\x06\x0cinput-stream\x01B\x05\ -\x02\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x09\ -get-stdin\x01\x03\x03\0\x14wasi:cli/stdin@0.2.0\x05\x0b\x02\x03\0\x06\x0doutput-\ -stream\x01B\x05\x02\x03\x02\x01\x0c\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\ -\0\0\x02\x04\0\x0aget-stdout\x01\x03\x03\0\x15wasi:cli/stdout@0.2.0\x05\x0d\x01B\ -\x05\x02\x03\x02\x01\x0c\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\ -\0\x0aget-stderr\x01\x03\x03\0\x15wasi:cli/stderr@0.2.0\x05\x0e\x01B\x01\x04\0\x0e\ -terminal-input\x03\x01\x03\0\x1dwasi:cli/terminal-input@0.2.0\x05\x0f\x01B\x01\x04\ -\0\x0fterminal-output\x03\x01\x03\0\x1ewasi:cli/terminal-output@0.2.0\x05\x10\x02\ -\x03\0\x0a\x0eterminal-input\x01B\x06\x02\x03\x02\x01\x11\x04\0\x0eterminal-inpu\ -t\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\x12get-terminal-stdin\x01\x04\x03\ -\0\x1dwasi:cli/terminal-stdin@0.2.0\x05\x12\x02\x03\0\x0b\x0fterminal-output\x01\ -B\x06\x02\x03\x02\x01\x13\x04\0\x0fterminal-output\x03\0\0\x01i\x01\x01k\x02\x01\ -@\0\0\x03\x04\0\x13get-terminal-stdout\x01\x04\x03\0\x1ewasi:cli/terminal-stdout\ -@0.2.0\x05\x14\x01B\x06\x02\x03\x02\x01\x13\x04\0\x0fterminal-output\x03\0\0\x01\ -i\x01\x01k\x02\x01@\0\0\x03\x04\0\x13get-terminal-stderr\x01\x04\x03\0\x1ewasi:c\ -li/terminal-stderr@0.2.0\x05\x15\x01B\x0f\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\ -\0\0\x01w\x04\0\x07instant\x03\0\x02\x01w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\ -\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\ -\x04when\x03\0\x08\x04\0\x11subscribe-instant\x01\x09\x01@\x01\x04when\x05\0\x08\ -\x04\0\x12subscribe-duration\x01\x0a\x03\0!wasi:clocks/monotonic-clock@0.2.0\x05\ -\x16\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01\ -@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\0\x1cwasi:clocks/\ -wall-clock@0.2.0\x05\x17\x02\x03\0\x06\x05error\x02\x03\0\x10\x08datetime\x01Br\x02\ -\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x0c\x04\0\x0doutp\ -ut-stream\x03\0\x02\x02\x03\x02\x01\x18\x04\0\x05error\x03\0\x04\x02\x03\x02\x01\ -\x19\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesize\x03\0\x08\x01m\x08\x07un\ -known\x0cblock-device\x10character-device\x09directory\x04fifo\x0dsymbolic-link\x0c\ -regular-file\x06socket\x04\0\x0fdescriptor-type\x03\0\x0a\x01n\x06\x04read\x05wr\ -ite\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10mut\ -ate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01n\x01\x0esymlink-follow\x04\ -\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ -ate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-count\x03\0\x12\x01k\x07\x01\ -r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15data-access-timestamp\x14\x1b\ -data-modification-timestamp\x14\x17status-change-timestamp\x14\x04\0\x0fdescript\ -or-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x07\0\x04\ -\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04names\x04\0\x0fdirectory-e\ -ntry\x03\0\x19\x01m%\x06access\x0bwould-block\x07already\x0ebad-descriptor\x04bu\ -sy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15illegal-byte-sequence\x0bi\ -n-progress\x0binterrupted\x07invalid\x02io\x0cis-directory\x04loop\x0etoo-many-l\ -inks\x0cmessage-size\x0dname-too-long\x09no-device\x08no-entry\x07no-lock\x13ins\ -ufficient-memory\x12insufficient-space\x0dnot-directory\x09not-empty\x0fnot-reco\ -verable\x0bunsupported\x06no-tty\x0eno-such-device\x08overflow\x0dnot-permitted\x04\ -pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\x0ccross-device\x04\0\x0aerr\ -or-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09don\ -t-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05lowerw\x05upperw\x04\0\x13\ -metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\x04\0\x16directory-ent\ -ry-stream\x03\x01\x01h!\x01i\x01\x01j\x01$\x01\x1c\x01@\x02\x04self#\x06offset\x09\ -\0%\x04\0\"[method]descriptor.read-via-stream\x01&\x01i\x03\x01j\x01'\x01\x1c\x01\ -@\x02\x04self#\x06offset\x09\0(\x04\0#[method]descriptor.write-via-stream\x01)\x01\ -@\x01\x04self#\0(\x04\0$[method]descriptor.append-via-stream\x01*\x01j\0\x01\x1c\ -\x01@\x04\x04self#\x06offset\x09\x06length\x09\x06advice\x1e\0+\x04\0\x19[method\ -]descriptor.advise\x01,\x01@\x01\x04self#\0+\x04\0\x1c[method]descriptor.sync-da\ -ta\x01-\x01j\x01\x0d\x01\x1c\x01@\x01\x04self#\0.\x04\0\x1c[method]descriptor.ge\ -t-flags\x01/\x01j\x01\x0b\x01\x1c\x01@\x01\x04self#\00\x04\0\x1b[method]descript\ -or.get-type\x011\x01@\x02\x04self#\x04size\x09\0+\x04\0\x1b[method]descriptor.se\ -t-size\x012\x01@\x03\x04self#\x15data-access-timestamp\x18\x1bdata-modification-\ -timestamp\x18\0+\x04\0\x1c[method]descriptor.set-times\x013\x01p}\x01o\x024\x7f\x01\ -j\x015\x01\x1c\x01@\x03\x04self#\x06length\x09\x06offset\x09\06\x04\0\x17[method\ -]descriptor.read\x017\x01j\x01\x09\x01\x1c\x01@\x03\x04self#\x06buffer4\x06offse\ -t\x09\08\x04\0\x18[method]descriptor.write\x019\x01i\"\x01j\x01:\x01\x1c\x01@\x01\ -\x04self#\0;\x04\0![method]descriptor.read-directory\x01<\x04\0\x17[method]descr\ -iptor.sync\x01-\x01@\x02\x04self#\x04paths\0+\x04\0&[method]descriptor.create-di\ -rectory-at\x01=\x01j\x01\x16\x01\x1c\x01@\x01\x04self#\0>\x04\0\x17[method]descr\ -iptor.stat\x01?\x01@\x03\x04self#\x0apath-flags\x0f\x04paths\0>\x04\0\x1a[method\ -]descriptor.stat-at\x01@\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x15data-ac\ -cess-timestamp\x18\x1bdata-modification-timestamp\x18\0+\x04\0\x1f[method]descri\ -ptor.set-times-at\x01A\x01@\x05\x04self#\x0eold-path-flags\x0f\x08old-paths\x0en\ -ew-descriptor#\x08new-paths\0+\x04\0\x1a[method]descriptor.link-at\x01B\x01i!\x01\ -j\x01\xc3\0\x01\x1c\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x0aopen-flags\x11\ -\x05flags\x0d\0\xc4\0\x04\0\x1a[method]descriptor.open-at\x01E\x01j\x01s\x01\x1c\ -\x01@\x02\x04self#\x04paths\0\xc6\0\x04\0\x1e[method]descriptor.readlink-at\x01G\ -\x04\0&[method]descriptor.remove-directory-at\x01=\x01@\x04\x04self#\x08old-path\ -s\x0enew-descriptor#\x08new-paths\0+\x04\0\x1c[method]descriptor.rename-at\x01H\x01\ -@\x03\x04self#\x08old-paths\x08new-paths\0+\x04\0\x1d[method]descriptor.symlink-\ -at\x01I\x04\0![method]descriptor.unlink-file-at\x01=\x01@\x02\x04self#\x05other#\ -\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\x01\x1c\x01@\x01\ -\x04self#\0\xcb\0\x04\0\x20[method]descriptor.metadata-hash\x01L\x01@\x03\x04sel\ -f#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metadata-hash-at\x01\ -M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\xd0\0\x04\03[m\ -ethod]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01k\x1c\x01@\x01\ -\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\0\x1bwasi:filesyst\ -em/types@0.2.0\x05\x1a\x02\x03\0\x11\x0adescriptor\x01B\x07\x02\x03\x02\x01\x1b\x04\ -\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0fg\ -et-directories\x01\x05\x03\0\x1ewasi:filesystem/preopens@0.2.0\x05\x1c\x01B\x11\x04\ -\0\x07network\x03\x01\x01m\x15\x07unknown\x0daccess-denied\x0dnot-supported\x10i\ -nvalid-argument\x0dout-of-memory\x07timeout\x14concurrency-conflict\x0fnot-in-pr\ -ogress\x0bwould-block\x0dinvalid-state\x10new-socket-limit\x14address-not-bindab\ -le\x0eaddress-in-use\x12remote-unreachable\x12connection-refused\x10connection-r\ -eset\x12connection-aborted\x12datagram-too-large\x11name-unresolvable\x1atempora\ -ry-resolver-failure\x1apermanent-resolver-failure\x04\0\x0aerror-code\x03\0\x01\x01\ -m\x02\x04ipv4\x04ipv6\x04\0\x11ip-address-family\x03\0\x03\x01o\x04}}}}\x04\0\x0c\ -ipv4-address\x03\0\x05\x01o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x07\x01q\x02\ -\x04ipv4\x01\x06\0\x04ipv6\x01\x08\0\x04\0\x0aip-address\x03\0\x09\x01r\x02\x04p\ -ort{\x07address\x06\x04\0\x13ipv4-socket-address\x03\0\x0b\x01r\x04\x04port{\x09\ -flow-infoy\x07address\x08\x08scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0d\x01\ -q\x02\x04ipv4\x01\x0c\0\x04ipv6\x01\x0e\0\x04\0\x11ip-socket-address\x03\0\x0f\x03\ -\0\x1awasi:sockets/network@0.2.0\x05\x1d\x02\x03\0\x13\x07network\x01B\x05\x02\x03\ -\x02\x01\x1e\x04\0\x07network\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x10instance-ne\ -twork\x01\x03\x03\0#wasi:sockets/instance-network@0.2.0\x05\x1f\x02\x03\0\x13\x0a\ -error-code\x02\x03\0\x13\x11ip-socket-address\x02\x03\0\x13\x11ip-address-family\ -\x01BD\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x07\ -network\x03\0\x02\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x04\x02\x03\x02\x01\ -!\x04\0\x11ip-socket-address\x03\0\x06\x02\x03\x02\x01\"\x04\0\x11ip-address-fam\ -ily\x03\0\x08\x01p}\x01r\x02\x04data\x0a\x0eremote-address\x07\x04\0\x11incoming\ --datagram\x03\0\x0b\x01k\x07\x01r\x02\x04data\x0a\x0eremote-address\x0d\x04\0\x11\ -outgoing-datagram\x03\0\x0e\x04\0\x0audp-socket\x03\x01\x04\0\x18incoming-datagr\ -am-stream\x03\x01\x04\0\x18outgoing-datagram-stream\x03\x01\x01h\x10\x01h\x03\x01\ -j\0\x01\x05\x01@\x03\x04self\x13\x07network\x14\x0dlocal-address\x07\0\x15\x04\0\ -\x1d[method]udp-socket.start-bind\x01\x16\x01@\x01\x04self\x13\0\x15\x04\0\x1e[m\ -ethod]udp-socket.finish-bind\x01\x17\x01i\x11\x01i\x12\x01o\x02\x18\x19\x01j\x01\ -\x1a\x01\x05\x01@\x02\x04self\x13\x0eremote-address\x0d\0\x1b\x04\0\x19[method]u\ -dp-socket.stream\x01\x1c\x01j\x01\x07\x01\x05\x01@\x01\x04self\x13\0\x1d\x04\0\x20\ -[method]udp-socket.local-address\x01\x1e\x04\0![method]udp-socket.remote-address\ -\x01\x1e\x01@\x01\x04self\x13\0\x09\x04\0![method]udp-socket.address-family\x01\x1f\ -\x01j\x01}\x01\x05\x01@\x01\x04self\x13\0\x20\x04\0$[method]udp-socket.unicast-h\ -op-limit\x01!\x01@\x02\x04self\x13\x05value}\0\x15\x04\0([method]udp-socket.set-\ -unicast-hop-limit\x01\"\x01j\x01w\x01\x05\x01@\x01\x04self\x13\0#\x04\0&[method]\ -udp-socket.receive-buffer-size\x01$\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[\ -method]udp-socket.set-receive-buffer-size\x01%\x04\0#[method]udp-socket.send-buf\ -fer-size\x01$\x04\0'[method]udp-socket.set-send-buffer-size\x01%\x01i\x01\x01@\x01\ -\x04self\x13\0&\x04\0\x1c[method]udp-socket.subscribe\x01'\x01h\x11\x01p\x0c\x01\ -j\x01)\x01\x05\x01@\x02\x04self(\x0bmax-resultsw\0*\x04\0([method]incoming-datag\ -ram-stream.receive\x01+\x01@\x01\x04self(\0&\x04\0*[method]incoming-datagram-str\ -eam.subscribe\x01,\x01h\x12\x01@\x01\x04self-\0#\x04\0+[method]outgoing-datagram\ --stream.check-send\x01.\x01p\x0f\x01@\x02\x04self-\x09datagrams/\0#\x04\0%[metho\ -d]outgoing-datagram-stream.send\x010\x01@\x01\x04self-\0&\x04\0*[method]outgoing\ --datagram-stream.subscribe\x011\x03\0\x16wasi:sockets/udp@0.2.0\x05#\x02\x03\0\x15\ -\x0audp-socket\x01B\x0c\x02\x03\x02\x01\x1e\x04\0\x07network\x03\0\0\x02\x03\x02\ -\x01\x20\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\"\x04\0\x11ip-address-fam\ -ily\x03\0\x04\x02\x03\x02\x01$\x04\0\x0audp-socket\x03\0\x06\x01i\x07\x01j\x01\x08\ -\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11create-udp-socket\x01\x0a\ -\x03\0$wasi:sockets/udp-create-socket@0.2.0\x05%\x02\x03\0\x0f\x08duration\x01BT\ -\x02\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x0c\x04\0\x0d\ -output-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\x04\x02\x03\x02\ -\x01&\x04\0\x08duration\x03\0\x06\x02\x03\x02\x01\x1e\x04\0\x07network\x03\0\x08\ -\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x0a\x02\x03\x02\x01!\x04\0\x11ip-\ -socket-address\x03\0\x0c\x02\x03\x02\x01\"\x04\0\x11ip-address-family\x03\0\x0e\x01\ -m\x03\x07receive\x04send\x04both\x04\0\x0dshutdown-type\x03\0\x10\x04\0\x0atcp-s\ -ocket\x03\x01\x01h\x12\x01h\x09\x01j\0\x01\x0b\x01@\x03\x04self\x13\x07network\x14\ -\x0dlocal-address\x0d\0\x15\x04\0\x1d[method]tcp-socket.start-bind\x01\x16\x01@\x01\ -\x04self\x13\0\x15\x04\0\x1e[method]tcp-socket.finish-bind\x01\x17\x01@\x03\x04s\ -elf\x13\x07network\x14\x0eremote-address\x0d\0\x15\x04\0\x20[method]tcp-socket.s\ -tart-connect\x01\x18\x01i\x01\x01i\x03\x01o\x02\x19\x1a\x01j\x01\x1b\x01\x0b\x01\ -@\x01\x04self\x13\0\x1c\x04\0![method]tcp-socket.finish-connect\x01\x1d\x04\0\x1f\ -[method]tcp-socket.start-listen\x01\x17\x04\0\x20[method]tcp-socket.finish-liste\ -n\x01\x17\x01i\x12\x01o\x03\x1e\x19\x1a\x01j\x01\x1f\x01\x0b\x01@\x01\x04self\x13\ -\0\x20\x04\0\x19[method]tcp-socket.accept\x01!\x01j\x01\x0d\x01\x0b\x01@\x01\x04\ -self\x13\0\"\x04\0\x20[method]tcp-socket.local-address\x01#\x04\0![method]tcp-so\ -cket.remote-address\x01#\x01@\x01\x04self\x13\0\x7f\x04\0\x1f[method]tcp-socket.\ -is-listening\x01$\x01@\x01\x04self\x13\0\x0f\x04\0![method]tcp-socket.address-fa\ -mily\x01%\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[method]tcp-socket.set-list\ -en-backlog-size\x01&\x01j\x01\x7f\x01\x0b\x01@\x01\x04self\x13\0'\x04\0%[method]\ -tcp-socket.keep-alive-enabled\x01(\x01@\x02\x04self\x13\x05value\x7f\0\x15\x04\0\ -)[method]tcp-socket.set-keep-alive-enabled\x01)\x01j\x01\x07\x01\x0b\x01@\x01\x04\ -self\x13\0*\x04\0'[method]tcp-socket.keep-alive-idle-time\x01+\x01@\x02\x04self\x13\ -\x05value\x07\0\x15\x04\0+[method]tcp-socket.set-keep-alive-idle-time\x01,\x04\0\ -&[method]tcp-socket.keep-alive-interval\x01+\x04\0*[method]tcp-socket.set-keep-a\ -live-interval\x01,\x01j\x01y\x01\x0b\x01@\x01\x04self\x13\0-\x04\0#[method]tcp-s\ -ocket.keep-alive-count\x01.\x01@\x02\x04self\x13\x05valuey\0\x15\x04\0'[method]t\ -cp-socket.set-keep-alive-count\x01/\x01j\x01}\x01\x0b\x01@\x01\x04self\x13\00\x04\ -\0\x1c[method]tcp-socket.hop-limit\x011\x01@\x02\x04self\x13\x05value}\0\x15\x04\ -\0\x20[method]tcp-socket.set-hop-limit\x012\x01j\x01w\x01\x0b\x01@\x01\x04self\x13\ -\03\x04\0&[method]tcp-socket.receive-buffer-size\x014\x04\0*[method]tcp-socket.s\ -et-receive-buffer-size\x01&\x04\0#[method]tcp-socket.send-buffer-size\x014\x04\0\ -'[method]tcp-socket.set-send-buffer-size\x01&\x01i\x05\x01@\x01\x04self\x13\05\x04\ -\0\x1c[method]tcp-socket.subscribe\x016\x01@\x02\x04self\x13\x0dshutdown-type\x11\ -\0\x15\x04\0\x1b[method]tcp-socket.shutdown\x017\x03\0\x16wasi:sockets/tcp@0.2.0\ -\x05'\x02\x03\0\x17\x0atcp-socket\x01B\x0c\x02\x03\x02\x01\x1e\x04\0\x07network\x03\ -\0\0\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\"\x04\0\x11\ -ip-address-family\x03\0\x04\x02\x03\x02\x01(\x04\0\x0atcp-socket\x03\0\x06\x01i\x07\ -\x01j\x01\x08\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11create-tcp-s\ -ocket\x01\x0a\x03\0$wasi:sockets/tcp-create-socket@0.2.0\x05)\x02\x03\0\x13\x0ai\ -p-address\x01B\x16\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\ -\x1e\x04\0\x07network\x03\0\x02\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x04\ -\x02\x03\x02\x01*\x04\0\x0aip-address\x03\0\x06\x04\0\x16resolve-address-stream\x03\ -\x01\x01h\x08\x01k\x07\x01j\x01\x0a\x01\x05\x01@\x01\x04self\x09\0\x0b\x04\03[me\ -thod]resolve-address-stream.resolve-next-address\x01\x0c\x01i\x01\x01@\x01\x04se\ -lf\x09\0\x0d\x04\0([method]resolve-address-stream.subscribe\x01\x0e\x01h\x03\x01\ -i\x08\x01j\x01\x10\x01\x05\x01@\x02\x07network\x0f\x04names\0\x11\x04\0\x11resol\ -ve-addresses\x01\x12\x03\0!wasi:sockets/ip-name-lookup@0.2.0\x05+\x01B\x05\x01p}\ -\x01@\x01\x03lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0eget-r\ -andom-u64\x01\x02\x03\0\x18wasi:random/random@0.2.0\x05,\x01B\x05\x01p}\x01@\x01\ -\x03lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\x04\0\x17get-i\ -nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.0\x05-\x01B\x03\x01\ -o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\ -seed@0.2.0\x05.\x02\x03\0\0\x0dnode-metadata\x01B\x13\x02\x03\x02\x01/\x04\0\x0d\ -node-metadata\x03\0\0\x02\x03\x02\x01\x01\x04\0\x06packet\x03\0\x02\x04\0\x0dnod\ -e-instance\x03\x01\x01ks\x01i\x04\x01@\x01\x06params\x05\0\x06\x04\0\x1a[constru\ -ctor]node-instance\x01\x07\x01h\x04\x01j\0\x01s\x01@\x03\x04self\x08\x09input-pi\ -ns\x06packet\x03\0\x09\x04\0\x1d[method]node-instance.process\x01\x0a\x01@\x02\x04\ -self\x08\x06params\x05\0\x09\x04\0#[method]node-instance.update-params\x01\x0b\x01\ -@\x01\x04self\x08\x01\0\x04\0\x1d[method]node-instance.cleanup\x01\x0c\x01@\0\0\x01\ -\x04\0\x08metadata\x01\x0d\x04\0\x1bstreamkit:plugin/node@0.1.0\x050\x04\0\x1dst\ -reamkit:plugin/plugin@0.1.0\x04\0\x0b\x0c\x01\0\x06plugin\x03\0\0\0G\x09producer\ -s\x01\x0cprocessed-by\x02\x0dwit-component\x070.236.0\x10wit-bindgen-rust\x060.4\ -4.0"; +\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0fget-initial-\ +cwd\x01\x06\x03\0(wasi:cli/environment@0.3.0-rc-2026-03-15\x05\x03\x01B\x03\x01j\ +\0\0\x01@\x01\x06status\0\x01\0\x04\0\x04exit\x01\x01\x03\0!wasi:cli/exit@0.3.0-\ +rc-2026-03-15\x05\x04\x01B\x02\x01m\x03\x02io\x15illegal-byte-sequence\x04pipe\x04\ +\0\x0aerror-code\x03\0\0\x03\0\"wasi:cli/types@0.3.0-rc-2026-03-15\x05\x05\x02\x03\ +\0\x04\x0aerror-code\x01B\x08\x02\x03\x02\x01\x06\x04\0\x0aerror-code\x03\0\0\x01\ +f\x01}\x01j\0\x01\x01\x01e\x01\x03\x01o\x02\x02\x04\x01@\0\0\x05\x04\0\x0fread-v\ +ia-stream\x01\x06\x03\0\"wasi:cli/stdin@0.3.0-rc-2026-03-15\x05\x07\x01B\x07\x02\ +\x03\x02\x01\x06\x04\0\x0aerror-code\x03\0\0\x01f\x01}\x01j\0\x01\x01\x01e\x01\x03\ +\x01@\x01\x04data\x02\0\x04\x04\0\x10write-via-stream\x01\x05\x03\0#wasi:cli/std\ +out@0.3.0-rc-2026-03-15\x05\x08\x01B\x07\x02\x03\x02\x01\x06\x04\0\x0aerror-code\ +\x03\0\0\x01f\x01}\x01j\0\x01\x01\x01e\x01\x03\x01@\x01\x04data\x02\0\x04\x04\0\x10\ +write-via-stream\x01\x05\x03\0#wasi:cli/stderr@0.3.0-rc-2026-03-15\x05\x09\x01B\x01\ +\x04\0\x0eterminal-input\x03\x01\x03\0+wasi:cli/terminal-input@0.3.0-rc-2026-03-\ +15\x05\x0a\x01B\x01\x04\0\x0fterminal-output\x03\x01\x03\0,wasi:cli/terminal-out\ +put@0.3.0-rc-2026-03-15\x05\x0b\x02\x03\0\x08\x0eterminal-input\x01B\x06\x02\x03\ +\x02\x01\x0c\x04\0\x0eterminal-input\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\ +\x12get-terminal-stdin\x01\x04\x03\0+wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15\ +\x05\x0d\x02\x03\0\x09\x0fterminal-output\x01B\x06\x02\x03\x02\x01\x0e\x04\0\x0f\ +terminal-output\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\x13get-terminal-std\ +out\x01\x04\x03\0,wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15\x05\x0f\x01B\x06\x02\ +\x03\x02\x01\x0e\x04\0\x0fterminal-output\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\ +\x04\0\x13get-terminal-stderr\x01\x04\x03\0,wasi:cli/terminal-stderr@0.3.0-rc-20\ +26-03-15\x05\x10\x01B\x02\x01w\x04\0\x08duration\x03\0\0\x03\0%wasi:clocks/types\ +@0.3.0-rc-2026-03-15\x05\x11\x02\x03\0\x0d\x08duration\x01B\x0c\x02\x03\x02\x01\x12\ +\x04\0\x08duration\x03\0\0\x01w\x04\0\x04mark\x03\0\x02\x01@\0\0\x03\x04\0\x03no\ +w\x01\x04\x01@\0\0\x01\x04\0\x0eget-resolution\x01\x05\x01C\x01\x04when\x03\x01\0\ +\x04\0\x0await-until\x01\x06\x01C\x01\x08how-long\x01\x01\0\x04\0\x08wait-for\x01\ +\x07\x03\0/wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15\x05\x13\x01B\x08\x02\x03\ +\x02\x01\x12\x04\0\x08duration\x03\0\0\x01r\x02\x07secondsx\x0bnanosecondsy\x04\0\ +\x07instant\x03\0\x02\x01@\0\0\x03\x04\0\x03now\x01\x04\x01@\0\0\x01\x04\0\x0ege\ +t-resolution\x01\x05\x03\0,wasi:clocks/system-clock@0.3.0-rc-2026-03-15\x05\x14\x02\ +\x03\0\x0f\x07instant\x01BZ\x02\x03\x02\x01\x15\x04\0\x07instant\x03\0\0\x01w\x04\ +\0\x08filesize\x03\0\x02\x01ks\x01q\x08\x0cblock-device\0\0\x10character-device\0\ +\0\x09directory\0\0\x04fifo\0\0\x0dsymbolic-link\0\0\x0cregular-file\0\0\x06sock\ +et\0\0\x05other\x01\x04\0\x04\0\x0fdescriptor-type\x03\0\x05\x01n\x06\x04read\x05\ +write\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10m\ +utate-directory\x04\0\x10descriptor-flags\x03\0\x07\x01n\x01\x0esymlink-follow\x04\ +\0\x0apath-flags\x03\0\x09\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ +ate\x04\0\x0aopen-flags\x03\0\x0b\x01w\x04\0\x0alink-count\x03\0\x0d\x01k\x01\x01\ +r\x06\x04type\x06\x0alink-count\x0e\x04size\x03\x15data-access-timestamp\x0f\x1b\ +data-modification-timestamp\x0f\x17status-change-timestamp\x0f\x04\0\x0fdescript\ +or-stat\x03\0\x10\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x01\0\x04\ +\0\x0dnew-timestamp\x03\0\x12\x01r\x02\x04type\x06\x04names\x04\0\x0fdirectory-e\ +ntry\x03\0\x14\x01q%\x06access\0\0\x07already\0\0\x0ebad-descriptor\0\0\x04busy\0\ +\0\x08deadlock\0\0\x05quota\0\0\x05exist\0\0\x0efile-too-large\0\0\x15illegal-by\ +te-sequence\0\0\x0bin-progress\0\0\x0binterrupted\0\0\x07invalid\0\0\x02io\0\0\x0c\ +is-directory\0\0\x04loop\0\0\x0etoo-many-links\0\0\x0cmessage-size\0\0\x0dname-t\ +oo-long\0\0\x09no-device\0\0\x08no-entry\0\0\x07no-lock\0\0\x13insufficient-memo\ +ry\0\0\x12insufficient-space\0\0\x0dnot-directory\0\0\x09not-empty\0\0\x0fnot-re\ +coverable\0\0\x0bunsupported\0\0\x06no-tty\0\0\x0eno-such-device\0\0\x08overflow\ +\0\0\x0dnot-permitted\0\0\x04pipe\0\0\x09read-only\0\0\x0cinvalid-seek\0\0\x0ete\ +xt-file-busy\0\0\x0ccross-device\0\0\x05other\x01\x04\0\x04\0\x0aerror-code\x03\0\ +\x16\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09dont-need\x08no-\ +reuse\x04\0\x06advice\x03\0\x18\x01r\x02\x05lowerw\x05upperw\x04\0\x13metadata-h\ +ash-value\x03\0\x1a\x04\0\x0adescriptor\x03\x01\x01h\x1c\x01f\x01}\x01j\0\x01\x17\ +\x01e\x01\x1f\x01o\x02\x1e\x20\x01@\x02\x04self\x1d\x06offset\x03\0!\x04\0\"[met\ +hod]descriptor.read-via-stream\x01\"\x01@\x03\x04self\x1d\x04data\x1e\x06offset\x03\ +\0\x20\x04\0#[method]descriptor.write-via-stream\x01#\x01@\x02\x04self\x1d\x04da\ +ta\x1e\0\x20\x04\0$[method]descriptor.append-via-stream\x01$\x01C\x04\x04self\x1d\ +\x06offset\x03\x06length\x03\x06advice\x19\0\x1f\x04\0\x19[method]descriptor.adv\ +ise\x01%\x01C\x01\x04self\x1d\0\x1f\x04\0\x1c[method]descriptor.sync-data\x01&\x01\ +j\x01\x08\x01\x17\x01C\x01\x04self\x1d\0'\x04\0\x1c[method]descriptor.get-flags\x01\ +(\x01j\x01\x06\x01\x17\x01C\x01\x04self\x1d\0)\x04\0\x1b[method]descriptor.get-t\ +ype\x01*\x01C\x02\x04self\x1d\x04size\x03\0\x1f\x04\0\x1b[method]descriptor.set-\ +size\x01+\x01C\x03\x04self\x1d\x15data-access-timestamp\x13\x1bdata-modification\ +-timestamp\x13\0\x1f\x04\0\x1c[method]descriptor.set-times\x01,\x01f\x01\x15\x01\ +o\x02-\x20\x01@\x01\x04self\x1d\0.\x04\0![method]descriptor.read-directory\x01/\x04\ +\0\x17[method]descriptor.sync\x01&\x01C\x02\x04self\x1d\x04paths\0\x1f\x04\0&[me\ +thod]descriptor.create-directory-at\x010\x01j\x01\x11\x01\x17\x01C\x01\x04self\x1d\ +\01\x04\0\x17[method]descriptor.stat\x012\x01C\x03\x04self\x1d\x0apath-flags\x0a\ +\x04paths\01\x04\0\x1a[method]descriptor.stat-at\x013\x01C\x05\x04self\x1d\x0apa\ +th-flags\x0a\x04paths\x15data-access-timestamp\x13\x1bdata-modification-timestam\ +p\x13\0\x1f\x04\0\x1f[method]descriptor.set-times-at\x014\x01C\x05\x04self\x1d\x0e\ +old-path-flags\x0a\x08old-paths\x0enew-descriptor\x1d\x08new-paths\0\x1f\x04\0\x1a\ +[method]descriptor.link-at\x015\x01i\x1c\x01j\x016\x01\x17\x01C\x05\x04self\x1d\x0a\ +path-flags\x0a\x04paths\x0aopen-flags\x0c\x05flags\x08\07\x04\0\x1a[method]descr\ +iptor.open-at\x018\x01j\x01s\x01\x17\x01C\x02\x04self\x1d\x04paths\09\x04\0\x1e[\ +method]descriptor.readlink-at\x01:\x04\0&[method]descriptor.remove-directory-at\x01\ +0\x01C\x04\x04self\x1d\x08old-paths\x0enew-descriptor\x1d\x08new-paths\0\x1f\x04\ +\0\x1c[method]descriptor.rename-at\x01;\x01C\x03\x04self\x1d\x08old-paths\x08new\ +-paths\0\x1f\x04\0\x1d[method]descriptor.symlink-at\x01<\x04\0![method]descripto\ +r.unlink-file-at\x010\x01C\x02\x04self\x1d\x05other\x1d\0\x7f\x04\0![method]desc\ +riptor.is-same-object\x01=\x01j\x01\x1b\x01\x17\x01C\x01\x04self\x1d\0>\x04\0\x20\ +[method]descriptor.metadata-hash\x01?\x01C\x03\x04self\x1d\x0apath-flags\x0a\x04\ +paths\0>\x04\0#[method]descriptor.metadata-hash-at\x01@\x03\0)wasi:filesystem/ty\ +pes@0.3.0-rc-2026-03-15\x05\x16\x02\x03\0\x10\x0adescriptor\x01B\x07\x02\x03\x02\ +\x01\x17\x04\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\ +\x04\0\x0fget-directories\x01\x05\x03\0,wasi:filesystem/preopens@0.3.0-rc-2026-0\ +3-15\x05\x18\x01Br\x02\x03\x02\x01\x12\x04\0\x08duration\x03\0\0\x01ks\x01q\x0f\x0d\ +access-denied\0\0\x0dnot-supported\0\0\x10invalid-argument\0\0\x0dout-of-memory\0\ +\0\x07timeout\0\0\x0dinvalid-state\0\0\x14address-not-bindable\0\0\x0eaddress-in\ +-use\0\0\x12remote-unreachable\0\0\x12connection-refused\0\0\x11connection-broke\ +n\0\0\x10connection-reset\0\0\x12connection-aborted\0\0\x12datagram-too-large\0\0\ +\x05other\x01\x02\0\x04\0\x0aerror-code\x03\0\x03\x01m\x02\x04ipv4\x04ipv6\x04\0\ +\x11ip-address-family\x03\0\x05\x01o\x04}}}}\x04\0\x0cipv4-address\x03\0\x07\x01\ +o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x09\x01q\x02\x04ipv4\x01\x08\0\x04ipv6\ +\x01\x0a\0\x04\0\x0aip-address\x03\0\x0b\x01r\x02\x04port{\x07address\x08\x04\0\x13\ +ipv4-socket-address\x03\0\x0d\x01r\x04\x04port{\x09flow-infoy\x07address\x0a\x08\ +scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0f\x01q\x02\x04ipv4\x01\x0e\0\x04i\ +pv6\x01\x10\0\x04\0\x11ip-socket-address\x03\0\x11\x04\0\x0atcp-socket\x03\x01\x04\ +\0\x0audp-socket\x03\x01\x01i\x13\x01j\x01\x15\x01\x04\x01@\x01\x0eaddress-famil\ +y\x06\0\x16\x04\0\x19[static]tcp-socket.create\x01\x17\x01h\x13\x01j\0\x01\x04\x01\ +@\x02\x04self\x18\x0dlocal-address\x12\0\x19\x04\0\x17[method]tcp-socket.bind\x01\ +\x1a\x01C\x02\x04self\x18\x0eremote-address\x12\0\x19\x04\0\x1a[method]tcp-socke\ +t.connect\x01\x1b\x01f\x01\x15\x01j\x01\x1c\x01\x04\x01@\x01\x04self\x18\0\x1d\x04\ +\0\x19[method]tcp-socket.listen\x01\x1e\x01f\x01}\x01e\x01\x19\x01@\x02\x04self\x18\ +\x04data\x1f\0\x20\x04\0\x17[method]tcp-socket.send\x01!\x01o\x02\x1f\x20\x01@\x01\ +\x04self\x18\0\"\x04\0\x1a[method]tcp-socket.receive\x01#\x01j\x01\x12\x01\x04\x01\ +@\x01\x04self\x18\0$\x04\0$[method]tcp-socket.get-local-address\x01%\x04\0%[meth\ +od]tcp-socket.get-remote-address\x01%\x01@\x01\x04self\x18\0\x7f\x04\0#[method]t\ +cp-socket.get-is-listening\x01&\x01@\x01\x04self\x18\0\x06\x04\0%[method]tcp-soc\ +ket.get-address-family\x01'\x01@\x02\x04self\x18\x05valuew\0\x19\x04\0*[method]t\ +cp-socket.set-listen-backlog-size\x01(\x01j\x01\x7f\x01\x04\x01@\x01\x04self\x18\ +\0)\x04\0)[method]tcp-socket.get-keep-alive-enabled\x01*\x01@\x02\x04self\x18\x05\ +value\x7f\0\x19\x04\0)[method]tcp-socket.set-keep-alive-enabled\x01+\x01j\x01\x01\ +\x01\x04\x01@\x01\x04self\x18\0,\x04\0+[method]tcp-socket.get-keep-alive-idle-ti\ +me\x01-\x01@\x02\x04self\x18\x05value\x01\0\x19\x04\0+[method]tcp-socket.set-kee\ +p-alive-idle-time\x01.\x04\0*[method]tcp-socket.get-keep-alive-interval\x01-\x04\ +\0*[method]tcp-socket.set-keep-alive-interval\x01.\x01j\x01y\x01\x04\x01@\x01\x04\ +self\x18\0/\x04\0'[method]tcp-socket.get-keep-alive-count\x010\x01@\x02\x04self\x18\ +\x05valuey\0\x19\x04\0'[method]tcp-socket.set-keep-alive-count\x011\x01j\x01}\x01\ +\x04\x01@\x01\x04self\x18\02\x04\0\x20[method]tcp-socket.get-hop-limit\x013\x01@\ +\x02\x04self\x18\x05value}\0\x19\x04\0\x20[method]tcp-socket.set-hop-limit\x014\x01\ +j\x01w\x01\x04\x01@\x01\x04self\x18\05\x04\0*[method]tcp-socket.get-receive-buff\ +er-size\x016\x04\0*[method]tcp-socket.set-receive-buffer-size\x01(\x04\0'[method\ +]tcp-socket.get-send-buffer-size\x016\x04\0'[method]tcp-socket.set-send-buffer-s\ +ize\x01(\x01i\x14\x01j\x017\x01\x04\x01@\x01\x0eaddress-family\x06\08\x04\0\x19[\ +static]udp-socket.create\x019\x01h\x14\x01@\x02\x04self:\x0dlocal-address\x12\0\x19\ +\x04\0\x17[method]udp-socket.bind\x01;\x01@\x02\x04self:\x0eremote-address\x12\0\ +\x19\x04\0\x1a[method]udp-socket.connect\x01<\x01@\x01\x04self:\0\x19\x04\0\x1d[\ +method]udp-socket.disconnect\x01=\x01p}\x01k\x12\x01C\x03\x04self:\x04data>\x0er\ +emote-address?\0\x19\x04\0\x17[method]udp-socket.send\x01@\x01o\x02>\x12\x01j\x01\ +\xc1\0\x01\x04\x01C\x01\x04self:\0\xc2\0\x04\0\x1a[method]udp-socket.receive\x01\ +C\x01@\x01\x04self:\0$\x04\0$[method]udp-socket.get-local-address\x01D\x04\0%[me\ +thod]udp-socket.get-remote-address\x01D\x01@\x01\x04self:\0\x06\x04\0%[method]ud\ +p-socket.get-address-family\x01E\x01@\x01\x04self:\02\x04\0([method]udp-socket.g\ +et-unicast-hop-limit\x01F\x01@\x02\x04self:\x05value}\0\x19\x04\0([method]udp-so\ +cket.set-unicast-hop-limit\x01G\x01@\x01\x04self:\05\x04\0*[method]udp-socket.ge\ +t-receive-buffer-size\x01H\x01@\x02\x04self:\x05valuew\0\x19\x04\0*[method]udp-s\ +ocket.set-receive-buffer-size\x01I\x04\0'[method]udp-socket.get-send-buffer-size\ +\x01H\x04\0'[method]udp-socket.set-send-buffer-size\x01I\x03\0&wasi:sockets/type\ +s@0.3.0-rc-2026-03-15\x05\x19\x02\x03\0\x12\x0aip-address\x01B\x09\x02\x03\x02\x01\ +\x1a\x04\0\x0aip-address\x03\0\0\x01ks\x01q\x06\x0daccess-denied\0\0\x10invalid-\ +argument\0\0\x11name-unresolvable\0\0\x1atemporary-resolver-failure\0\0\x1aperma\ +nent-resolver-failure\0\0\x05other\x01\x02\0\x04\0\x0aerror-code\x03\0\x03\x01p\x01\ +\x01j\x01\x05\x01\x04\x01C\x01\x04names\0\x06\x04\0\x11resolve-addresses\x01\x07\ +\x03\0/wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15\x05\x1b\x01B\x05\x01p}\x01\ +@\x01\x07max-lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0eget-r\ +andom-u64\x01\x02\x03\0&wasi:random/random@0.3.0-rc-2026-03-15\x05\x1c\x01B\x05\x01\ +p}\x01@\x01\x07max-lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\ +\x04\0\x17get-insecure-random-u64\x01\x02\x03\0(wasi:random/insecure@0.3.0-rc-20\ +26-03-15\x05\x1d\x01B\x03\x01o\x02ww\x01@\0\0\0\x04\0\x11get-insecure-seed\x01\x01\ +\x03\0-wasi:random/insecure-seed@0.3.0-rc-2026-03-15\x05\x1e\x02\x03\0\0\x0dnode\ +-metadata\x01B\x13\x02\x03\x02\x01\x1f\x04\0\x0dnode-metadata\x03\0\0\x02\x03\x02\ +\x01\x01\x04\0\x06packet\x03\0\x02\x04\0\x0dnode-instance\x03\x01\x01ks\x01i\x04\ +\x01@\x01\x06params\x05\0\x06\x04\0\x1a[constructor]node-instance\x01\x07\x01h\x04\ +\x01j\0\x01s\x01C\x03\x04self\x08\x09input-pins\x06packet\x03\0\x09\x04\0\x1d[me\ +thod]node-instance.process\x01\x0a\x01C\x02\x04self\x08\x06params\x05\0\x09\x04\0\ +#[method]node-instance.update-params\x01\x0b\x01@\x01\x04self\x08\x01\0\x04\0\x1d\ +[method]node-instance.cleanup\x01\x0c\x01@\0\0\x01\x04\0\x08metadata\x01\x0d\x04\ +\0\x1bstreamkit:plugin/node@0.2.0\x05\x20\x04\0\x1dstreamkit:plugin/plugin@0.2.0\ +\x04\0\x0b\x0c\x01\0\x06plugin\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.251.0\x10wit-bindgen-rust\x060.58.0"; }; ) } @@ -10204,11 +16634,11 @@ s\x01\x0cprocessed-by\x02\x0dwit-component\x070.236.0\x10wit-bindgen-rust\x060.4 pub use __export_plugin_impl as export; #[cfg(target_arch = "wasm32")] -#[unsafe(link_section = "component-type:wit-bindgen:0.44.0:streamkit:plugin@0.1.0:plugin-with-all-of-its-exports-removed:encoded world")] +#[unsafe(link_section = "component-type:wit-bindgen:0.58.0:streamkit:plugin@0.2.0:plugin-with-all-of-its-exports-removed:encoded world")] #[doc(hidden)] #[allow(clippy::octal_escapes)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 11534] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf1X\x01A\x02\x01AL\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8952] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdbD\x01A\x02\x01A6\x01\ B\x1a\x01m\x02\x07float32\x06s16-le\x04\0\x0dsample-format\x03\0\0\x01r\x03\x0bs\ ample-ratey\x08channels{\x0dsample-format\x01\x04\0\x0caudio-format\x03\0\x02\x01\ q\x06\x09raw-audio\x01\x03\0\x0aopus-audio\0\0\x04text\0\0\x06binary\0\0\x06cust\ @@ -10220,231 +16650,172 @@ input-pin\x03\0\x0b\x01r\x02\x04names\x0dproduces-type\x05\x04\0\x0aoutput-pin\x param-schemas\x0acategories\x11\x04\0\x0dnode-metadata\x03\0\x12\x01pv\x01r\x03\x0b\ sample-ratey\x08channels{\x07samples\x14\x04\0\x0baudio-frame\x03\0\x15\x01p}\x01\ q\x04\x05audio\x01\x16\0\x04text\x01s\0\x06binary\x01\x17\0\x06custom\x01\x09\0\x04\ -\0\x06packet\x03\0\x18\x03\0\x1cstreamkit:plugin/types@0.1.0\x05\0\x02\x03\0\0\x06\ +\0\x06packet\x03\0\x18\x03\0\x1cstreamkit:plugin/types@0.2.0\x05\0\x02\x03\0\0\x06\ packet\x01B\x09\x02\x03\x02\x01\x01\x04\0\x06packet\x03\0\0\x01m\x04\x05debug\x04\ -info\x04warn\x05error\x04\0\x09log-level\x03\0\x02\x01j\0\x01s\x01@\x02\x08pin-n\ +info\x04warn\x05error\x04\0\x09log-level\x03\0\x02\x01j\0\x01s\x01C\x02\x08pin-n\ ames\x06packet\x01\0\x04\x04\0\x0bsend-output\x01\x05\x01@\x02\x05level\x03\x07m\ -essages\x01\0\x04\0\x03log\x01\x06\x03\0\x1bstreamkit:plugin/host@0.1.0\x05\x02\x01\ +essages\x01\0\x04\0\x03log\x01\x06\x03\0\x1bstreamkit:plugin/host@0.2.0\x05\x02\x01\ B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ -\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ -\x06\x03\0\x1awasi:cli/environment@0.2.0\x05\x03\x01B\x03\x01j\0\0\x01@\x01\x06s\ -tatus\0\x01\0\x04\0\x04exit\x01\x01\x03\0\x13wasi:cli/exit@0.2.0\x05\x04\x01B\x04\ -\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\0\x1d[method]error.to\ --debug-string\x01\x02\x03\0\x13wasi:io/error@0.2.0\x05\x05\x01B\x0a\x04\0\x08pol\ -lable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[method]pollable.ready\x01\ -\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollable.block\x01\x03\x01p\x01\ -\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\0\x12wasi:io/poll@0.2.\ -0\x05\x06\x02\x03\0\x04\x05error\x02\x03\0\x05\x08pollable\x01B(\x02\x03\x02\x01\ -\x07\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\x02\x01i\ -\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0cstream-e\ -rror\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\ -\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19[met\ -hod]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\x01\ -j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-stream.\ -skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\x0e\x01i\x03\x01@\x01\ -\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\x01\x10\x01h\x08\x01@\ -\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-write\x01\x12\x01j\0\x01\ -\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b[method]output-stream.w\ -rite\x01\x14\x04\0.[method]output-stream.blocking-write-and-flush\x01\x14\x01@\x01\ -\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\x01\x15\x04\0$[method]ou\ -tput-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]o\ -utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method\ -]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ -eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ -method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ -\x18\x03\0\x15wasi:io/streams@0.2.0\x05\x09\x02\x03\0\x06\x0cinput-stream\x01B\x05\ -\x02\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x09\ -get-stdin\x01\x03\x03\0\x14wasi:cli/stdin@0.2.0\x05\x0b\x02\x03\0\x06\x0doutput-\ -stream\x01B\x05\x02\x03\x02\x01\x0c\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\ -\0\0\x02\x04\0\x0aget-stdout\x01\x03\x03\0\x15wasi:cli/stdout@0.2.0\x05\x0d\x01B\ -\x05\x02\x03\x02\x01\x0c\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\ -\0\x0aget-stderr\x01\x03\x03\0\x15wasi:cli/stderr@0.2.0\x05\x0e\x01B\x01\x04\0\x0e\ -terminal-input\x03\x01\x03\0\x1dwasi:cli/terminal-input@0.2.0\x05\x0f\x01B\x01\x04\ -\0\x0fterminal-output\x03\x01\x03\0\x1ewasi:cli/terminal-output@0.2.0\x05\x10\x02\ -\x03\0\x0a\x0eterminal-input\x01B\x06\x02\x03\x02\x01\x11\x04\0\x0eterminal-inpu\ -t\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\x12get-terminal-stdin\x01\x04\x03\ -\0\x1dwasi:cli/terminal-stdin@0.2.0\x05\x12\x02\x03\0\x0b\x0fterminal-output\x01\ -B\x06\x02\x03\x02\x01\x13\x04\0\x0fterminal-output\x03\0\0\x01i\x01\x01k\x02\x01\ -@\0\0\x03\x04\0\x13get-terminal-stdout\x01\x04\x03\0\x1ewasi:cli/terminal-stdout\ -@0.2.0\x05\x14\x01B\x06\x02\x03\x02\x01\x13\x04\0\x0fterminal-output\x03\0\0\x01\ -i\x01\x01k\x02\x01@\0\0\x03\x04\0\x13get-terminal-stderr\x01\x04\x03\0\x1ewasi:c\ -li/terminal-stderr@0.2.0\x05\x15\x01B\x0f\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\ -\0\0\x01w\x04\0\x07instant\x03\0\x02\x01w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\ -\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\ -\x04when\x03\0\x08\x04\0\x11subscribe-instant\x01\x09\x01@\x01\x04when\x05\0\x08\ -\x04\0\x12subscribe-duration\x01\x0a\x03\0!wasi:clocks/monotonic-clock@0.2.0\x05\ -\x16\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01\ -@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\0\x1cwasi:clocks/\ -wall-clock@0.2.0\x05\x17\x02\x03\0\x06\x05error\x02\x03\0\x10\x08datetime\x01Br\x02\ -\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x0c\x04\0\x0doutp\ -ut-stream\x03\0\x02\x02\x03\x02\x01\x18\x04\0\x05error\x03\0\x04\x02\x03\x02\x01\ -\x19\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesize\x03\0\x08\x01m\x08\x07un\ -known\x0cblock-device\x10character-device\x09directory\x04fifo\x0dsymbolic-link\x0c\ -regular-file\x06socket\x04\0\x0fdescriptor-type\x03\0\x0a\x01n\x06\x04read\x05wr\ -ite\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10mut\ -ate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01n\x01\x0esymlink-follow\x04\ -\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ -ate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-count\x03\0\x12\x01k\x07\x01\ -r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15data-access-timestamp\x14\x1b\ -data-modification-timestamp\x14\x17status-change-timestamp\x14\x04\0\x0fdescript\ -or-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x07\0\x04\ -\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04names\x04\0\x0fdirectory-e\ -ntry\x03\0\x19\x01m%\x06access\x0bwould-block\x07already\x0ebad-descriptor\x04bu\ -sy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15illegal-byte-sequence\x0bi\ -n-progress\x0binterrupted\x07invalid\x02io\x0cis-directory\x04loop\x0etoo-many-l\ -inks\x0cmessage-size\x0dname-too-long\x09no-device\x08no-entry\x07no-lock\x13ins\ -ufficient-memory\x12insufficient-space\x0dnot-directory\x09not-empty\x0fnot-reco\ -verable\x0bunsupported\x06no-tty\x0eno-such-device\x08overflow\x0dnot-permitted\x04\ -pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\x0ccross-device\x04\0\x0aerr\ -or-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09don\ -t-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05lowerw\x05upperw\x04\0\x13\ -metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\x04\0\x16directory-ent\ -ry-stream\x03\x01\x01h!\x01i\x01\x01j\x01$\x01\x1c\x01@\x02\x04self#\x06offset\x09\ -\0%\x04\0\"[method]descriptor.read-via-stream\x01&\x01i\x03\x01j\x01'\x01\x1c\x01\ -@\x02\x04self#\x06offset\x09\0(\x04\0#[method]descriptor.write-via-stream\x01)\x01\ -@\x01\x04self#\0(\x04\0$[method]descriptor.append-via-stream\x01*\x01j\0\x01\x1c\ -\x01@\x04\x04self#\x06offset\x09\x06length\x09\x06advice\x1e\0+\x04\0\x19[method\ -]descriptor.advise\x01,\x01@\x01\x04self#\0+\x04\0\x1c[method]descriptor.sync-da\ -ta\x01-\x01j\x01\x0d\x01\x1c\x01@\x01\x04self#\0.\x04\0\x1c[method]descriptor.ge\ -t-flags\x01/\x01j\x01\x0b\x01\x1c\x01@\x01\x04self#\00\x04\0\x1b[method]descript\ -or.get-type\x011\x01@\x02\x04self#\x04size\x09\0+\x04\0\x1b[method]descriptor.se\ -t-size\x012\x01@\x03\x04self#\x15data-access-timestamp\x18\x1bdata-modification-\ -timestamp\x18\0+\x04\0\x1c[method]descriptor.set-times\x013\x01p}\x01o\x024\x7f\x01\ -j\x015\x01\x1c\x01@\x03\x04self#\x06length\x09\x06offset\x09\06\x04\0\x17[method\ -]descriptor.read\x017\x01j\x01\x09\x01\x1c\x01@\x03\x04self#\x06buffer4\x06offse\ -t\x09\08\x04\0\x18[method]descriptor.write\x019\x01i\"\x01j\x01:\x01\x1c\x01@\x01\ -\x04self#\0;\x04\0![method]descriptor.read-directory\x01<\x04\0\x17[method]descr\ -iptor.sync\x01-\x01@\x02\x04self#\x04paths\0+\x04\0&[method]descriptor.create-di\ -rectory-at\x01=\x01j\x01\x16\x01\x1c\x01@\x01\x04self#\0>\x04\0\x17[method]descr\ -iptor.stat\x01?\x01@\x03\x04self#\x0apath-flags\x0f\x04paths\0>\x04\0\x1a[method\ -]descriptor.stat-at\x01@\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x15data-ac\ -cess-timestamp\x18\x1bdata-modification-timestamp\x18\0+\x04\0\x1f[method]descri\ -ptor.set-times-at\x01A\x01@\x05\x04self#\x0eold-path-flags\x0f\x08old-paths\x0en\ -ew-descriptor#\x08new-paths\0+\x04\0\x1a[method]descriptor.link-at\x01B\x01i!\x01\ -j\x01\xc3\0\x01\x1c\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x0aopen-flags\x11\ -\x05flags\x0d\0\xc4\0\x04\0\x1a[method]descriptor.open-at\x01E\x01j\x01s\x01\x1c\ -\x01@\x02\x04self#\x04paths\0\xc6\0\x04\0\x1e[method]descriptor.readlink-at\x01G\ -\x04\0&[method]descriptor.remove-directory-at\x01=\x01@\x04\x04self#\x08old-path\ -s\x0enew-descriptor#\x08new-paths\0+\x04\0\x1c[method]descriptor.rename-at\x01H\x01\ -@\x03\x04self#\x08old-paths\x08new-paths\0+\x04\0\x1d[method]descriptor.symlink-\ -at\x01I\x04\0![method]descriptor.unlink-file-at\x01=\x01@\x02\x04self#\x05other#\ -\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\x01\x1c\x01@\x01\ -\x04self#\0\xcb\0\x04\0\x20[method]descriptor.metadata-hash\x01L\x01@\x03\x04sel\ -f#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metadata-hash-at\x01\ -M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\xd0\0\x04\03[m\ -ethod]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01k\x1c\x01@\x01\ -\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\0\x1bwasi:filesyst\ -em/types@0.2.0\x05\x1a\x02\x03\0\x11\x0adescriptor\x01B\x07\x02\x03\x02\x01\x1b\x04\ -\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0fg\ -et-directories\x01\x05\x03\0\x1ewasi:filesystem/preopens@0.2.0\x05\x1c\x01B\x11\x04\ -\0\x07network\x03\x01\x01m\x15\x07unknown\x0daccess-denied\x0dnot-supported\x10i\ -nvalid-argument\x0dout-of-memory\x07timeout\x14concurrency-conflict\x0fnot-in-pr\ -ogress\x0bwould-block\x0dinvalid-state\x10new-socket-limit\x14address-not-bindab\ -le\x0eaddress-in-use\x12remote-unreachable\x12connection-refused\x10connection-r\ -eset\x12connection-aborted\x12datagram-too-large\x11name-unresolvable\x1atempora\ -ry-resolver-failure\x1apermanent-resolver-failure\x04\0\x0aerror-code\x03\0\x01\x01\ -m\x02\x04ipv4\x04ipv6\x04\0\x11ip-address-family\x03\0\x03\x01o\x04}}}}\x04\0\x0c\ -ipv4-address\x03\0\x05\x01o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x07\x01q\x02\ -\x04ipv4\x01\x06\0\x04ipv6\x01\x08\0\x04\0\x0aip-address\x03\0\x09\x01r\x02\x04p\ -ort{\x07address\x06\x04\0\x13ipv4-socket-address\x03\0\x0b\x01r\x04\x04port{\x09\ -flow-infoy\x07address\x08\x08scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0d\x01\ -q\x02\x04ipv4\x01\x0c\0\x04ipv6\x01\x0e\0\x04\0\x11ip-socket-address\x03\0\x0f\x03\ -\0\x1awasi:sockets/network@0.2.0\x05\x1d\x02\x03\0\x13\x07network\x01B\x05\x02\x03\ -\x02\x01\x1e\x04\0\x07network\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x10instance-ne\ -twork\x01\x03\x03\0#wasi:sockets/instance-network@0.2.0\x05\x1f\x02\x03\0\x13\x0a\ -error-code\x02\x03\0\x13\x11ip-socket-address\x02\x03\0\x13\x11ip-address-family\ -\x01BD\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x07\ -network\x03\0\x02\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x04\x02\x03\x02\x01\ -!\x04\0\x11ip-socket-address\x03\0\x06\x02\x03\x02\x01\"\x04\0\x11ip-address-fam\ -ily\x03\0\x08\x01p}\x01r\x02\x04data\x0a\x0eremote-address\x07\x04\0\x11incoming\ --datagram\x03\0\x0b\x01k\x07\x01r\x02\x04data\x0a\x0eremote-address\x0d\x04\0\x11\ -outgoing-datagram\x03\0\x0e\x04\0\x0audp-socket\x03\x01\x04\0\x18incoming-datagr\ -am-stream\x03\x01\x04\0\x18outgoing-datagram-stream\x03\x01\x01h\x10\x01h\x03\x01\ -j\0\x01\x05\x01@\x03\x04self\x13\x07network\x14\x0dlocal-address\x07\0\x15\x04\0\ -\x1d[method]udp-socket.start-bind\x01\x16\x01@\x01\x04self\x13\0\x15\x04\0\x1e[m\ -ethod]udp-socket.finish-bind\x01\x17\x01i\x11\x01i\x12\x01o\x02\x18\x19\x01j\x01\ -\x1a\x01\x05\x01@\x02\x04self\x13\x0eremote-address\x0d\0\x1b\x04\0\x19[method]u\ -dp-socket.stream\x01\x1c\x01j\x01\x07\x01\x05\x01@\x01\x04self\x13\0\x1d\x04\0\x20\ -[method]udp-socket.local-address\x01\x1e\x04\0![method]udp-socket.remote-address\ -\x01\x1e\x01@\x01\x04self\x13\0\x09\x04\0![method]udp-socket.address-family\x01\x1f\ -\x01j\x01}\x01\x05\x01@\x01\x04self\x13\0\x20\x04\0$[method]udp-socket.unicast-h\ -op-limit\x01!\x01@\x02\x04self\x13\x05value}\0\x15\x04\0([method]udp-socket.set-\ -unicast-hop-limit\x01\"\x01j\x01w\x01\x05\x01@\x01\x04self\x13\0#\x04\0&[method]\ -udp-socket.receive-buffer-size\x01$\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[\ -method]udp-socket.set-receive-buffer-size\x01%\x04\0#[method]udp-socket.send-buf\ -fer-size\x01$\x04\0'[method]udp-socket.set-send-buffer-size\x01%\x01i\x01\x01@\x01\ -\x04self\x13\0&\x04\0\x1c[method]udp-socket.subscribe\x01'\x01h\x11\x01p\x0c\x01\ -j\x01)\x01\x05\x01@\x02\x04self(\x0bmax-resultsw\0*\x04\0([method]incoming-datag\ -ram-stream.receive\x01+\x01@\x01\x04self(\0&\x04\0*[method]incoming-datagram-str\ -eam.subscribe\x01,\x01h\x12\x01@\x01\x04self-\0#\x04\0+[method]outgoing-datagram\ --stream.check-send\x01.\x01p\x0f\x01@\x02\x04self-\x09datagrams/\0#\x04\0%[metho\ -d]outgoing-datagram-stream.send\x010\x01@\x01\x04self-\0&\x04\0*[method]outgoing\ --datagram-stream.subscribe\x011\x03\0\x16wasi:sockets/udp@0.2.0\x05#\x02\x03\0\x15\ -\x0audp-socket\x01B\x0c\x02\x03\x02\x01\x1e\x04\0\x07network\x03\0\0\x02\x03\x02\ -\x01\x20\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\"\x04\0\x11ip-address-fam\ -ily\x03\0\x04\x02\x03\x02\x01$\x04\0\x0audp-socket\x03\0\x06\x01i\x07\x01j\x01\x08\ -\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11create-udp-socket\x01\x0a\ -\x03\0$wasi:sockets/udp-create-socket@0.2.0\x05%\x02\x03\0\x0f\x08duration\x01BT\ -\x02\x03\x02\x01\x0a\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x0c\x04\0\x0d\ -output-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\x04\x02\x03\x02\ -\x01&\x04\0\x08duration\x03\0\x06\x02\x03\x02\x01\x1e\x04\0\x07network\x03\0\x08\ -\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x0a\x02\x03\x02\x01!\x04\0\x11ip-\ -socket-address\x03\0\x0c\x02\x03\x02\x01\"\x04\0\x11ip-address-family\x03\0\x0e\x01\ -m\x03\x07receive\x04send\x04both\x04\0\x0dshutdown-type\x03\0\x10\x04\0\x0atcp-s\ -ocket\x03\x01\x01h\x12\x01h\x09\x01j\0\x01\x0b\x01@\x03\x04self\x13\x07network\x14\ -\x0dlocal-address\x0d\0\x15\x04\0\x1d[method]tcp-socket.start-bind\x01\x16\x01@\x01\ -\x04self\x13\0\x15\x04\0\x1e[method]tcp-socket.finish-bind\x01\x17\x01@\x03\x04s\ -elf\x13\x07network\x14\x0eremote-address\x0d\0\x15\x04\0\x20[method]tcp-socket.s\ -tart-connect\x01\x18\x01i\x01\x01i\x03\x01o\x02\x19\x1a\x01j\x01\x1b\x01\x0b\x01\ -@\x01\x04self\x13\0\x1c\x04\0![method]tcp-socket.finish-connect\x01\x1d\x04\0\x1f\ -[method]tcp-socket.start-listen\x01\x17\x04\0\x20[method]tcp-socket.finish-liste\ -n\x01\x17\x01i\x12\x01o\x03\x1e\x19\x1a\x01j\x01\x1f\x01\x0b\x01@\x01\x04self\x13\ -\0\x20\x04\0\x19[method]tcp-socket.accept\x01!\x01j\x01\x0d\x01\x0b\x01@\x01\x04\ -self\x13\0\"\x04\0\x20[method]tcp-socket.local-address\x01#\x04\0![method]tcp-so\ -cket.remote-address\x01#\x01@\x01\x04self\x13\0\x7f\x04\0\x1f[method]tcp-socket.\ -is-listening\x01$\x01@\x01\x04self\x13\0\x0f\x04\0![method]tcp-socket.address-fa\ -mily\x01%\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[method]tcp-socket.set-list\ -en-backlog-size\x01&\x01j\x01\x7f\x01\x0b\x01@\x01\x04self\x13\0'\x04\0%[method]\ -tcp-socket.keep-alive-enabled\x01(\x01@\x02\x04self\x13\x05value\x7f\0\x15\x04\0\ -)[method]tcp-socket.set-keep-alive-enabled\x01)\x01j\x01\x07\x01\x0b\x01@\x01\x04\ -self\x13\0*\x04\0'[method]tcp-socket.keep-alive-idle-time\x01+\x01@\x02\x04self\x13\ -\x05value\x07\0\x15\x04\0+[method]tcp-socket.set-keep-alive-idle-time\x01,\x04\0\ -&[method]tcp-socket.keep-alive-interval\x01+\x04\0*[method]tcp-socket.set-keep-a\ -live-interval\x01,\x01j\x01y\x01\x0b\x01@\x01\x04self\x13\0-\x04\0#[method]tcp-s\ -ocket.keep-alive-count\x01.\x01@\x02\x04self\x13\x05valuey\0\x15\x04\0'[method]t\ -cp-socket.set-keep-alive-count\x01/\x01j\x01}\x01\x0b\x01@\x01\x04self\x13\00\x04\ -\0\x1c[method]tcp-socket.hop-limit\x011\x01@\x02\x04self\x13\x05value}\0\x15\x04\ -\0\x20[method]tcp-socket.set-hop-limit\x012\x01j\x01w\x01\x0b\x01@\x01\x04self\x13\ -\03\x04\0&[method]tcp-socket.receive-buffer-size\x014\x04\0*[method]tcp-socket.s\ -et-receive-buffer-size\x01&\x04\0#[method]tcp-socket.send-buffer-size\x014\x04\0\ -'[method]tcp-socket.set-send-buffer-size\x01&\x01i\x05\x01@\x01\x04self\x13\05\x04\ -\0\x1c[method]tcp-socket.subscribe\x016\x01@\x02\x04self\x13\x0dshutdown-type\x11\ -\0\x15\x04\0\x1b[method]tcp-socket.shutdown\x017\x03\0\x16wasi:sockets/tcp@0.2.0\ -\x05'\x02\x03\0\x17\x0atcp-socket\x01B\x0c\x02\x03\x02\x01\x1e\x04\0\x07network\x03\ -\0\0\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\"\x04\0\x11\ -ip-address-family\x03\0\x04\x02\x03\x02\x01(\x04\0\x0atcp-socket\x03\0\x06\x01i\x07\ -\x01j\x01\x08\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11create-tcp-s\ -ocket\x01\x0a\x03\0$wasi:sockets/tcp-create-socket@0.2.0\x05)\x02\x03\0\x13\x0ai\ -p-address\x01B\x16\x02\x03\x02\x01\x08\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\ -\x1e\x04\0\x07network\x03\0\x02\x02\x03\x02\x01\x20\x04\0\x0aerror-code\x03\0\x04\ -\x02\x03\x02\x01*\x04\0\x0aip-address\x03\0\x06\x04\0\x16resolve-address-stream\x03\ -\x01\x01h\x08\x01k\x07\x01j\x01\x0a\x01\x05\x01@\x01\x04self\x09\0\x0b\x04\03[me\ -thod]resolve-address-stream.resolve-next-address\x01\x0c\x01i\x01\x01@\x01\x04se\ -lf\x09\0\x0d\x04\0([method]resolve-address-stream.subscribe\x01\x0e\x01h\x03\x01\ -i\x08\x01j\x01\x10\x01\x05\x01@\x02\x07network\x0f\x04names\0\x11\x04\0\x11resol\ -ve-addresses\x01\x12\x03\0!wasi:sockets/ip-name-lookup@0.2.0\x05+\x01B\x05\x01p}\ -\x01@\x01\x03lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0eget-r\ -andom-u64\x01\x02\x03\0\x18wasi:random/random@0.2.0\x05,\x01B\x05\x01p}\x01@\x01\ -\x03lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\x04\0\x17get-i\ -nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.0\x05-\x01B\x03\x01\ -o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\ -seed@0.2.0\x05.\x04\0=streamkit:plugin/plugin-with-all-of-its-exports-removed@0.\ -1.0\x04\0\x0b,\x01\0&plugin-with-all-of-its-exports-removed\x03\0\0\0G\x09produc\ -ers\x01\x0cprocessed-by\x02\x0dwit-component\x070.236.0\x10wit-bindgen-rust\x060\ -.44.0"; +\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0fget-initial-\ +cwd\x01\x06\x03\0(wasi:cli/environment@0.3.0-rc-2026-03-15\x05\x03\x01B\x03\x01j\ +\0\0\x01@\x01\x06status\0\x01\0\x04\0\x04exit\x01\x01\x03\0!wasi:cli/exit@0.3.0-\ +rc-2026-03-15\x05\x04\x01B\x02\x01m\x03\x02io\x15illegal-byte-sequence\x04pipe\x04\ +\0\x0aerror-code\x03\0\0\x03\0\"wasi:cli/types@0.3.0-rc-2026-03-15\x05\x05\x02\x03\ +\0\x04\x0aerror-code\x01B\x08\x02\x03\x02\x01\x06\x04\0\x0aerror-code\x03\0\0\x01\ +f\x01}\x01j\0\x01\x01\x01e\x01\x03\x01o\x02\x02\x04\x01@\0\0\x05\x04\0\x0fread-v\ +ia-stream\x01\x06\x03\0\"wasi:cli/stdin@0.3.0-rc-2026-03-15\x05\x07\x01B\x07\x02\ +\x03\x02\x01\x06\x04\0\x0aerror-code\x03\0\0\x01f\x01}\x01j\0\x01\x01\x01e\x01\x03\ +\x01@\x01\x04data\x02\0\x04\x04\0\x10write-via-stream\x01\x05\x03\0#wasi:cli/std\ +out@0.3.0-rc-2026-03-15\x05\x08\x01B\x07\x02\x03\x02\x01\x06\x04\0\x0aerror-code\ +\x03\0\0\x01f\x01}\x01j\0\x01\x01\x01e\x01\x03\x01@\x01\x04data\x02\0\x04\x04\0\x10\ +write-via-stream\x01\x05\x03\0#wasi:cli/stderr@0.3.0-rc-2026-03-15\x05\x09\x01B\x01\ +\x04\0\x0eterminal-input\x03\x01\x03\0+wasi:cli/terminal-input@0.3.0-rc-2026-03-\ +15\x05\x0a\x01B\x01\x04\0\x0fterminal-output\x03\x01\x03\0,wasi:cli/terminal-out\ +put@0.3.0-rc-2026-03-15\x05\x0b\x02\x03\0\x08\x0eterminal-input\x01B\x06\x02\x03\ +\x02\x01\x0c\x04\0\x0eterminal-input\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\ +\x12get-terminal-stdin\x01\x04\x03\0+wasi:cli/terminal-stdin@0.3.0-rc-2026-03-15\ +\x05\x0d\x02\x03\0\x09\x0fterminal-output\x01B\x06\x02\x03\x02\x01\x0e\x04\0\x0f\ +terminal-output\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\x04\0\x13get-terminal-std\ +out\x01\x04\x03\0,wasi:cli/terminal-stdout@0.3.0-rc-2026-03-15\x05\x0f\x01B\x06\x02\ +\x03\x02\x01\x0e\x04\0\x0fterminal-output\x03\0\0\x01i\x01\x01k\x02\x01@\0\0\x03\ +\x04\0\x13get-terminal-stderr\x01\x04\x03\0,wasi:cli/terminal-stderr@0.3.0-rc-20\ +26-03-15\x05\x10\x01B\x02\x01w\x04\0\x08duration\x03\0\0\x03\0%wasi:clocks/types\ +@0.3.0-rc-2026-03-15\x05\x11\x02\x03\0\x0d\x08duration\x01B\x0c\x02\x03\x02\x01\x12\ +\x04\0\x08duration\x03\0\0\x01w\x04\0\x04mark\x03\0\x02\x01@\0\0\x03\x04\0\x03no\ +w\x01\x04\x01@\0\0\x01\x04\0\x0eget-resolution\x01\x05\x01C\x01\x04when\x03\x01\0\ +\x04\0\x0await-until\x01\x06\x01C\x01\x08how-long\x01\x01\0\x04\0\x08wait-for\x01\ +\x07\x03\0/wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15\x05\x13\x01B\x08\x02\x03\ +\x02\x01\x12\x04\0\x08duration\x03\0\0\x01r\x02\x07secondsx\x0bnanosecondsy\x04\0\ +\x07instant\x03\0\x02\x01@\0\0\x03\x04\0\x03now\x01\x04\x01@\0\0\x01\x04\0\x0ege\ +t-resolution\x01\x05\x03\0,wasi:clocks/system-clock@0.3.0-rc-2026-03-15\x05\x14\x02\ +\x03\0\x0f\x07instant\x01BZ\x02\x03\x02\x01\x15\x04\0\x07instant\x03\0\0\x01w\x04\ +\0\x08filesize\x03\0\x02\x01ks\x01q\x08\x0cblock-device\0\0\x10character-device\0\ +\0\x09directory\0\0\x04fifo\0\0\x0dsymbolic-link\0\0\x0cregular-file\0\0\x06sock\ +et\0\0\x05other\x01\x04\0\x04\0\x0fdescriptor-type\x03\0\x05\x01n\x06\x04read\x05\ +write\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10m\ +utate-directory\x04\0\x10descriptor-flags\x03\0\x07\x01n\x01\x0esymlink-follow\x04\ +\0\x0apath-flags\x03\0\x09\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ +ate\x04\0\x0aopen-flags\x03\0\x0b\x01w\x04\0\x0alink-count\x03\0\x0d\x01k\x01\x01\ +r\x06\x04type\x06\x0alink-count\x0e\x04size\x03\x15data-access-timestamp\x0f\x1b\ +data-modification-timestamp\x0f\x17status-change-timestamp\x0f\x04\0\x0fdescript\ +or-stat\x03\0\x10\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x01\0\x04\ +\0\x0dnew-timestamp\x03\0\x12\x01r\x02\x04type\x06\x04names\x04\0\x0fdirectory-e\ +ntry\x03\0\x14\x01q%\x06access\0\0\x07already\0\0\x0ebad-descriptor\0\0\x04busy\0\ +\0\x08deadlock\0\0\x05quota\0\0\x05exist\0\0\x0efile-too-large\0\0\x15illegal-by\ +te-sequence\0\0\x0bin-progress\0\0\x0binterrupted\0\0\x07invalid\0\0\x02io\0\0\x0c\ +is-directory\0\0\x04loop\0\0\x0etoo-many-links\0\0\x0cmessage-size\0\0\x0dname-t\ +oo-long\0\0\x09no-device\0\0\x08no-entry\0\0\x07no-lock\0\0\x13insufficient-memo\ +ry\0\0\x12insufficient-space\0\0\x0dnot-directory\0\0\x09not-empty\0\0\x0fnot-re\ +coverable\0\0\x0bunsupported\0\0\x06no-tty\0\0\x0eno-such-device\0\0\x08overflow\ +\0\0\x0dnot-permitted\0\0\x04pipe\0\0\x09read-only\0\0\x0cinvalid-seek\0\0\x0ete\ +xt-file-busy\0\0\x0ccross-device\0\0\x05other\x01\x04\0\x04\0\x0aerror-code\x03\0\ +\x16\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09dont-need\x08no-\ +reuse\x04\0\x06advice\x03\0\x18\x01r\x02\x05lowerw\x05upperw\x04\0\x13metadata-h\ +ash-value\x03\0\x1a\x04\0\x0adescriptor\x03\x01\x01h\x1c\x01f\x01}\x01j\0\x01\x17\ +\x01e\x01\x1f\x01o\x02\x1e\x20\x01@\x02\x04self\x1d\x06offset\x03\0!\x04\0\"[met\ +hod]descriptor.read-via-stream\x01\"\x01@\x03\x04self\x1d\x04data\x1e\x06offset\x03\ +\0\x20\x04\0#[method]descriptor.write-via-stream\x01#\x01@\x02\x04self\x1d\x04da\ +ta\x1e\0\x20\x04\0$[method]descriptor.append-via-stream\x01$\x01C\x04\x04self\x1d\ +\x06offset\x03\x06length\x03\x06advice\x19\0\x1f\x04\0\x19[method]descriptor.adv\ +ise\x01%\x01C\x01\x04self\x1d\0\x1f\x04\0\x1c[method]descriptor.sync-data\x01&\x01\ +j\x01\x08\x01\x17\x01C\x01\x04self\x1d\0'\x04\0\x1c[method]descriptor.get-flags\x01\ +(\x01j\x01\x06\x01\x17\x01C\x01\x04self\x1d\0)\x04\0\x1b[method]descriptor.get-t\ +ype\x01*\x01C\x02\x04self\x1d\x04size\x03\0\x1f\x04\0\x1b[method]descriptor.set-\ +size\x01+\x01C\x03\x04self\x1d\x15data-access-timestamp\x13\x1bdata-modification\ +-timestamp\x13\0\x1f\x04\0\x1c[method]descriptor.set-times\x01,\x01f\x01\x15\x01\ +o\x02-\x20\x01@\x01\x04self\x1d\0.\x04\0![method]descriptor.read-directory\x01/\x04\ +\0\x17[method]descriptor.sync\x01&\x01C\x02\x04self\x1d\x04paths\0\x1f\x04\0&[me\ +thod]descriptor.create-directory-at\x010\x01j\x01\x11\x01\x17\x01C\x01\x04self\x1d\ +\01\x04\0\x17[method]descriptor.stat\x012\x01C\x03\x04self\x1d\x0apath-flags\x0a\ +\x04paths\01\x04\0\x1a[method]descriptor.stat-at\x013\x01C\x05\x04self\x1d\x0apa\ +th-flags\x0a\x04paths\x15data-access-timestamp\x13\x1bdata-modification-timestam\ +p\x13\0\x1f\x04\0\x1f[method]descriptor.set-times-at\x014\x01C\x05\x04self\x1d\x0e\ +old-path-flags\x0a\x08old-paths\x0enew-descriptor\x1d\x08new-paths\0\x1f\x04\0\x1a\ +[method]descriptor.link-at\x015\x01i\x1c\x01j\x016\x01\x17\x01C\x05\x04self\x1d\x0a\ +path-flags\x0a\x04paths\x0aopen-flags\x0c\x05flags\x08\07\x04\0\x1a[method]descr\ +iptor.open-at\x018\x01j\x01s\x01\x17\x01C\x02\x04self\x1d\x04paths\09\x04\0\x1e[\ +method]descriptor.readlink-at\x01:\x04\0&[method]descriptor.remove-directory-at\x01\ +0\x01C\x04\x04self\x1d\x08old-paths\x0enew-descriptor\x1d\x08new-paths\0\x1f\x04\ +\0\x1c[method]descriptor.rename-at\x01;\x01C\x03\x04self\x1d\x08old-paths\x08new\ +-paths\0\x1f\x04\0\x1d[method]descriptor.symlink-at\x01<\x04\0![method]descripto\ +r.unlink-file-at\x010\x01C\x02\x04self\x1d\x05other\x1d\0\x7f\x04\0![method]desc\ +riptor.is-same-object\x01=\x01j\x01\x1b\x01\x17\x01C\x01\x04self\x1d\0>\x04\0\x20\ +[method]descriptor.metadata-hash\x01?\x01C\x03\x04self\x1d\x0apath-flags\x0a\x04\ +paths\0>\x04\0#[method]descriptor.metadata-hash-at\x01@\x03\0)wasi:filesystem/ty\ +pes@0.3.0-rc-2026-03-15\x05\x16\x02\x03\0\x10\x0adescriptor\x01B\x07\x02\x03\x02\ +\x01\x17\x04\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\ +\x04\0\x0fget-directories\x01\x05\x03\0,wasi:filesystem/preopens@0.3.0-rc-2026-0\ +3-15\x05\x18\x01Br\x02\x03\x02\x01\x12\x04\0\x08duration\x03\0\0\x01ks\x01q\x0f\x0d\ +access-denied\0\0\x0dnot-supported\0\0\x10invalid-argument\0\0\x0dout-of-memory\0\ +\0\x07timeout\0\0\x0dinvalid-state\0\0\x14address-not-bindable\0\0\x0eaddress-in\ +-use\0\0\x12remote-unreachable\0\0\x12connection-refused\0\0\x11connection-broke\ +n\0\0\x10connection-reset\0\0\x12connection-aborted\0\0\x12datagram-too-large\0\0\ +\x05other\x01\x02\0\x04\0\x0aerror-code\x03\0\x03\x01m\x02\x04ipv4\x04ipv6\x04\0\ +\x11ip-address-family\x03\0\x05\x01o\x04}}}}\x04\0\x0cipv4-address\x03\0\x07\x01\ +o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x09\x01q\x02\x04ipv4\x01\x08\0\x04ipv6\ +\x01\x0a\0\x04\0\x0aip-address\x03\0\x0b\x01r\x02\x04port{\x07address\x08\x04\0\x13\ +ipv4-socket-address\x03\0\x0d\x01r\x04\x04port{\x09flow-infoy\x07address\x0a\x08\ +scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0f\x01q\x02\x04ipv4\x01\x0e\0\x04i\ +pv6\x01\x10\0\x04\0\x11ip-socket-address\x03\0\x11\x04\0\x0atcp-socket\x03\x01\x04\ +\0\x0audp-socket\x03\x01\x01i\x13\x01j\x01\x15\x01\x04\x01@\x01\x0eaddress-famil\ +y\x06\0\x16\x04\0\x19[static]tcp-socket.create\x01\x17\x01h\x13\x01j\0\x01\x04\x01\ +@\x02\x04self\x18\x0dlocal-address\x12\0\x19\x04\0\x17[method]tcp-socket.bind\x01\ +\x1a\x01C\x02\x04self\x18\x0eremote-address\x12\0\x19\x04\0\x1a[method]tcp-socke\ +t.connect\x01\x1b\x01f\x01\x15\x01j\x01\x1c\x01\x04\x01@\x01\x04self\x18\0\x1d\x04\ +\0\x19[method]tcp-socket.listen\x01\x1e\x01f\x01}\x01e\x01\x19\x01@\x02\x04self\x18\ +\x04data\x1f\0\x20\x04\0\x17[method]tcp-socket.send\x01!\x01o\x02\x1f\x20\x01@\x01\ +\x04self\x18\0\"\x04\0\x1a[method]tcp-socket.receive\x01#\x01j\x01\x12\x01\x04\x01\ +@\x01\x04self\x18\0$\x04\0$[method]tcp-socket.get-local-address\x01%\x04\0%[meth\ +od]tcp-socket.get-remote-address\x01%\x01@\x01\x04self\x18\0\x7f\x04\0#[method]t\ +cp-socket.get-is-listening\x01&\x01@\x01\x04self\x18\0\x06\x04\0%[method]tcp-soc\ +ket.get-address-family\x01'\x01@\x02\x04self\x18\x05valuew\0\x19\x04\0*[method]t\ +cp-socket.set-listen-backlog-size\x01(\x01j\x01\x7f\x01\x04\x01@\x01\x04self\x18\ +\0)\x04\0)[method]tcp-socket.get-keep-alive-enabled\x01*\x01@\x02\x04self\x18\x05\ +value\x7f\0\x19\x04\0)[method]tcp-socket.set-keep-alive-enabled\x01+\x01j\x01\x01\ +\x01\x04\x01@\x01\x04self\x18\0,\x04\0+[method]tcp-socket.get-keep-alive-idle-ti\ +me\x01-\x01@\x02\x04self\x18\x05value\x01\0\x19\x04\0+[method]tcp-socket.set-kee\ +p-alive-idle-time\x01.\x04\0*[method]tcp-socket.get-keep-alive-interval\x01-\x04\ +\0*[method]tcp-socket.set-keep-alive-interval\x01.\x01j\x01y\x01\x04\x01@\x01\x04\ +self\x18\0/\x04\0'[method]tcp-socket.get-keep-alive-count\x010\x01@\x02\x04self\x18\ +\x05valuey\0\x19\x04\0'[method]tcp-socket.set-keep-alive-count\x011\x01j\x01}\x01\ +\x04\x01@\x01\x04self\x18\02\x04\0\x20[method]tcp-socket.get-hop-limit\x013\x01@\ +\x02\x04self\x18\x05value}\0\x19\x04\0\x20[method]tcp-socket.set-hop-limit\x014\x01\ +j\x01w\x01\x04\x01@\x01\x04self\x18\05\x04\0*[method]tcp-socket.get-receive-buff\ +er-size\x016\x04\0*[method]tcp-socket.set-receive-buffer-size\x01(\x04\0'[method\ +]tcp-socket.get-send-buffer-size\x016\x04\0'[method]tcp-socket.set-send-buffer-s\ +ize\x01(\x01i\x14\x01j\x017\x01\x04\x01@\x01\x0eaddress-family\x06\08\x04\0\x19[\ +static]udp-socket.create\x019\x01h\x14\x01@\x02\x04self:\x0dlocal-address\x12\0\x19\ +\x04\0\x17[method]udp-socket.bind\x01;\x01@\x02\x04self:\x0eremote-address\x12\0\ +\x19\x04\0\x1a[method]udp-socket.connect\x01<\x01@\x01\x04self:\0\x19\x04\0\x1d[\ +method]udp-socket.disconnect\x01=\x01p}\x01k\x12\x01C\x03\x04self:\x04data>\x0er\ +emote-address?\0\x19\x04\0\x17[method]udp-socket.send\x01@\x01o\x02>\x12\x01j\x01\ +\xc1\0\x01\x04\x01C\x01\x04self:\0\xc2\0\x04\0\x1a[method]udp-socket.receive\x01\ +C\x01@\x01\x04self:\0$\x04\0$[method]udp-socket.get-local-address\x01D\x04\0%[me\ +thod]udp-socket.get-remote-address\x01D\x01@\x01\x04self:\0\x06\x04\0%[method]ud\ +p-socket.get-address-family\x01E\x01@\x01\x04self:\02\x04\0([method]udp-socket.g\ +et-unicast-hop-limit\x01F\x01@\x02\x04self:\x05value}\0\x19\x04\0([method]udp-so\ +cket.set-unicast-hop-limit\x01G\x01@\x01\x04self:\05\x04\0*[method]udp-socket.ge\ +t-receive-buffer-size\x01H\x01@\x02\x04self:\x05valuew\0\x19\x04\0*[method]udp-s\ +ocket.set-receive-buffer-size\x01I\x04\0'[method]udp-socket.get-send-buffer-size\ +\x01H\x04\0'[method]udp-socket.set-send-buffer-size\x01I\x03\0&wasi:sockets/type\ +s@0.3.0-rc-2026-03-15\x05\x19\x02\x03\0\x12\x0aip-address\x01B\x09\x02\x03\x02\x01\ +\x1a\x04\0\x0aip-address\x03\0\0\x01ks\x01q\x06\x0daccess-denied\0\0\x10invalid-\ +argument\0\0\x11name-unresolvable\0\0\x1atemporary-resolver-failure\0\0\x1aperma\ +nent-resolver-failure\0\0\x05other\x01\x02\0\x04\0\x0aerror-code\x03\0\x03\x01p\x01\ +\x01j\x01\x05\x01\x04\x01C\x01\x04names\0\x06\x04\0\x11resolve-addresses\x01\x07\ +\x03\0/wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15\x05\x1b\x01B\x05\x01p}\x01\ +@\x01\x07max-lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0eget-r\ +andom-u64\x01\x02\x03\0&wasi:random/random@0.3.0-rc-2026-03-15\x05\x1c\x01B\x05\x01\ +p}\x01@\x01\x07max-lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\ +\x04\0\x17get-insecure-random-u64\x01\x02\x03\0(wasi:random/insecure@0.3.0-rc-20\ +26-03-15\x05\x1d\x01B\x03\x01o\x02ww\x01@\0\0\0\x04\0\x11get-insecure-seed\x01\x01\ +\x03\0-wasi:random/insecure-seed@0.3.0-rc-2026-03-15\x05\x1e\x04\0=streamkit:plu\ +gin/plugin-with-all-of-its-exports-removed@0.2.0\x04\0\x0b,\x01\0&plugin-with-al\ +l-of-its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-\ +component\x070.251.0\x10wit-bindgen-rust\x060.58.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { - wit_bindgen_rt::maybe_link_cabi_realloc(); + wit_bindgen::rt::maybe_link_cabi_realloc(); } diff --git a/sdks/plugin-sdk/wasm/rust/src/lib.rs b/sdks/plugin-sdk/wasm/rust/src/lib.rs index 33a18607f..8efbc9695 100644 --- a/sdks/plugin-sdk/wasm/rust/src/lib.rs +++ b/sdks/plugin-sdk/wasm/rust/src/lib.rs @@ -12,7 +12,7 @@ //! ```toml //! [dependencies] //! streamkit-plugin-sdk-wasm = "0.1.0" -//! wit-bindgen = "0.44" +//! wit-bindgen = "0.58" //! serde_json = "1" //! //! [lib] @@ -29,8 +29,8 @@ //! path: "wit", //! generate_all, //! with: { -//! "streamkit:plugin/types@0.1.0": sdk::types, -//! "streamkit:plugin/host@0.1.0": sdk::host, +//! "streamkit:plugin/types@0.2.0": sdk::types, +//! "streamkit:plugin/host@0.2.0": sdk::host, //! }, //! }); //! @@ -60,11 +60,12 @@ //! Self { /* ... */ } //! } //! -//! fn process(&self, input_pin: String, packet: Packet) -> Result<(), String> { +//! async fn process(&self, input_pin: String, packet: Packet) -> Result<(), String> { +//! // Push results to an output pin with `sdk::host::send_output(...).await` //! Ok(()) //! } //! -//! fn update_params(&self, params: Option) -> Result<(), String> { +//! async fn update_params(&self, params: Option) -> Result<(), String> { //! Ok(()) //! } //! diff --git a/sdks/plugin-sdk/wit/streamkit-plugin.wasm b/sdks/plugin-sdk/wit/streamkit-plugin.wasm index bdab95bd1..c3fb2f4ee 100644 Binary files a/sdks/plugin-sdk/wit/streamkit-plugin.wasm and b/sdks/plugin-sdk/wit/streamkit-plugin.wasm differ diff --git a/wit/deps/wasi-cli-0.2.0/package.wit b/wit/deps/wasi-cli-0.2.0/package.wit deleted file mode 100644 index 0a2737b7c..000000000 --- a/wit/deps/wasi-cli-0.2.0/package.wit +++ /dev/null @@ -1,159 +0,0 @@ -package wasi:cli@0.2.0; - -interface environment { - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. - get-environment: func() -> list>; - - /// Get the POSIX-style arguments to the program. - get-arguments: func() -> list; - - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. - initial-cwd: func() -> option; -} - -interface exit { - /// Exit the current instance and any linked instances. - exit: func(status: result); -} - -interface run { - /// Run the program. - run: func() -> result; -} - -interface stdin { - use wasi:io/streams@0.2.0.{input-stream}; - - get-stdin: func() -> input-stream; -} - -interface stdout { - use wasi:io/streams@0.2.0.{output-stream}; - - get-stdout: func() -> output-stream; -} - -interface stderr { - use wasi:io/streams@0.2.0.{output-stream}; - - get-stderr: func() -> output-stream; -} - -/// 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; -} - -/// 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; -} - -/// An interface providing an optional `terminal-input` for stdin as a -/// link-time authority. -interface terminal-stdin { - use terminal-input.{terminal-input}; - - /// If stdin is connected to a terminal, return a `terminal-input` handle - /// allowing further interaction with it. - get-terminal-stdin: func() -> option; -} - -/// An interface providing an optional `terminal-output` for stdout as a -/// link-time authority. -interface terminal-stdout { - use terminal-output.{terminal-output}; - - /// If stdout is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. - get-terminal-stdout: func() -> option; -} - -/// An interface providing an optional `terminal-output` for stderr as a -/// link-time authority. -interface terminal-stderr { - use terminal-output.{terminal-output}; - - /// If stderr is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. - get-terminal-stderr: func() -> option; -} - -world imports { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; -} -world command { - import environment; - import exit; - import wasi:io/error@0.2.0; - import wasi:io/poll@0.2.0; - import wasi:io/streams@0.2.0; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; - import wasi:clocks/monotonic-clock@0.2.0; - import wasi:clocks/wall-clock@0.2.0; - import wasi:filesystem/types@0.2.0; - import wasi:filesystem/preopens@0.2.0; - import wasi:sockets/network@0.2.0; - import wasi:sockets/instance-network@0.2.0; - import wasi:sockets/udp@0.2.0; - import wasi:sockets/udp-create-socket@0.2.0; - import wasi:sockets/tcp@0.2.0; - import wasi:sockets/tcp-create-socket@0.2.0; - import wasi:sockets/ip-name-lookup@0.2.0; - import wasi:random/random@0.2.0; - import wasi:random/insecure@0.2.0; - import wasi:random/insecure-seed@0.2.0; - - export run; -} diff --git a/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/cli.wit b/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/cli.wit new file mode 100644 index 000000000..8ba52c5cd --- /dev/null +++ b/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/cli.wit @@ -0,0 +1,256 @@ +package wasi:cli@0.3.0-rc-2026-03-15; + +@since(version = 0.3.0-rc-2026-03-15) +interface environment { + /// Get the POSIX-style environment variables. + /// + /// Each environment variable is provided as a pair of string variable names + /// and string value. + /// + /// Morally, these are a value import, but until value imports are available + /// in the component model, this import function should return the same + /// values each time it is called. + @since(version = 0.3.0-rc-2026-03-15) + get-environment: func() -> list>; + + /// Get the POSIX-style arguments to the program. + @since(version = 0.3.0-rc-2026-03-15) + get-arguments: func() -> list; + + /// Return a path that programs should use as their initial current working + /// directory, interpreting `.` as shorthand for this. + @since(version = 0.3.0-rc-2026-03-15) + get-initial-cwd: func() -> option; +} + +@since(version = 0.3.0-rc-2026-03-15) +interface exit { + /// Exit the current instance and any linked instances. + @since(version = 0.3.0-rc-2026-03-15) + exit: func(status: result); + + /// Exit the current instance and any linked instances, reporting the + /// specified status code to the host. + /// + /// The meaning of the code depends on the context, with 0 usually meaning + /// "success", and other values indicating various types of failure. + /// + /// This function does not return; the effect is analogous to a trap, but + /// without the connotation that something bad has happened. + @unstable(feature = cli-exit-with-code) + exit-with-code: func(status-code: u8); +} + +@since(version = 0.3.0-rc-2026-03-15) +interface run { + /// Run the program. + @since(version = 0.3.0-rc-2026-03-15) + run: async func() -> result; +} + +@since(version = 0.3.0-rc-2026-03-15) +interface types { + @since(version = 0.3.0-rc-2026-03-15) + enum error-code { + /// Input/output error + io, + /// Invalid or incomplete multibyte or wide character + illegal-byte-sequence, + /// Broken pipe + pipe, + } +} + +@since(version = 0.3.0-rc-2026-03-15) +interface stdin { + use types.{error-code}; + + /// Return a stream for reading from stdin. + /// + /// This function returns a stream which provides data read from stdin, + /// and a future to signal read results. + /// + /// If the stream's readable end is dropped the future will resolve to success. + /// + /// If the stream's writable end is dropped the future will either resolve to + /// success if stdin was closed by the writer or to an error-code if reading + /// failed for some other reason. + /// + /// Multiple streams may be active at the same time. The behavior of concurrent + /// reads is implementation-specific. + @since(version = 0.3.0-rc-2026-03-15) + read-via-stream: func() -> tuple, future>>; +} + +@since(version = 0.3.0-rc-2026-03-15) +interface stdout { + use types.{error-code}; + + /// Write the given stream to stdout. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. + @since(version = 0.3.0-rc-2026-03-15) + write-via-stream: func(data: stream) -> future>; +} + +@since(version = 0.3.0-rc-2026-03-15) +interface stderr { + use types.{error-code}; + + /// Write the given stream to stderr. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. + @since(version = 0.3.0-rc-2026-03-15) + write-via-stream: func(data: stream) -> future>; +} + +/// 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. +@since(version = 0.3.0-rc-2026-03-15) +interface terminal-input { + /// The input side of a terminal. + @since(version = 0.3.0-rc-2026-03-15) + resource terminal-input; +} + +/// 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. +@since(version = 0.3.0-rc-2026-03-15) +interface terminal-output { + /// The output side of a terminal. + @since(version = 0.3.0-rc-2026-03-15) + resource terminal-output; +} + +/// An interface providing an optional `terminal-input` for stdin as a +/// link-time authority. +@since(version = 0.3.0-rc-2026-03-15) +interface terminal-stdin { + @since(version = 0.3.0-rc-2026-03-15) + use terminal-input.{terminal-input}; + + /// If stdin is connected to a terminal, return a `terminal-input` handle + /// allowing further interaction with it. + @since(version = 0.3.0-rc-2026-03-15) + get-terminal-stdin: func() -> option; +} + +/// An interface providing an optional `terminal-output` for stdout as a +/// link-time authority. +@since(version = 0.3.0-rc-2026-03-15) +interface terminal-stdout { + @since(version = 0.3.0-rc-2026-03-15) + use terminal-output.{terminal-output}; + + /// If stdout is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + @since(version = 0.3.0-rc-2026-03-15) + get-terminal-stdout: func() -> option; +} + +/// An interface providing an optional `terminal-output` for stderr as a +/// link-time authority. +@since(version = 0.3.0-rc-2026-03-15) +interface terminal-stderr { + @since(version = 0.3.0-rc-2026-03-15) + use terminal-output.{terminal-output}; + + /// If stderr is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + @since(version = 0.3.0-rc-2026-03-15) + get-terminal-stderr: func() -> option; +} + +@since(version = 0.3.0-rc-2026-03-15) +world imports { + @since(version = 0.3.0-rc-2026-03-15) + import environment; + @since(version = 0.3.0-rc-2026-03-15) + import exit; + @since(version = 0.3.0-rc-2026-03-15) + import types; + @since(version = 0.3.0-rc-2026-03-15) + import stdin; + @since(version = 0.3.0-rc-2026-03-15) + import stdout; + @since(version = 0.3.0-rc-2026-03-15) + import stderr; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-input; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-output; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stdin; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stdout; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stderr; + import wasi:clocks/types@0.3.0-rc-2026-03-15; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15; + import wasi:clocks/system-clock@0.3.0-rc-2026-03-15; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.3.0-rc-2026-03-15; + import wasi:filesystem/types@0.3.0-rc-2026-03-15; + import wasi:filesystem/preopens@0.3.0-rc-2026-03-15; + import wasi:sockets/types@0.3.0-rc-2026-03-15; + import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15; + import wasi:random/random@0.3.0-rc-2026-03-15; + import wasi:random/insecure@0.3.0-rc-2026-03-15; + import wasi:random/insecure-seed@0.3.0-rc-2026-03-15; +} +@since(version = 0.3.0-rc-2026-03-15) +world command { + @since(version = 0.3.0-rc-2026-03-15) + import environment; + @since(version = 0.3.0-rc-2026-03-15) + import exit; + @since(version = 0.3.0-rc-2026-03-15) + import types; + @since(version = 0.3.0-rc-2026-03-15) + import stdin; + @since(version = 0.3.0-rc-2026-03-15) + import stdout; + @since(version = 0.3.0-rc-2026-03-15) + import stderr; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-input; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-output; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stdin; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stdout; + @since(version = 0.3.0-rc-2026-03-15) + import terminal-stderr; + import wasi:clocks/types@0.3.0-rc-2026-03-15; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-03-15; + import wasi:clocks/system-clock@0.3.0-rc-2026-03-15; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.3.0-rc-2026-03-15; + import wasi:filesystem/types@0.3.0-rc-2026-03-15; + import wasi:filesystem/preopens@0.3.0-rc-2026-03-15; + import wasi:sockets/types@0.3.0-rc-2026-03-15; + import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15; + import wasi:random/random@0.3.0-rc-2026-03-15; + import wasi:random/insecure@0.3.0-rc-2026-03-15; + import wasi:random/insecure-seed@0.3.0-rc-2026-03-15; + + @since(version = 0.3.0-rc-2026-03-15) + export run; +} diff --git a/wit/deps/wasi-clocks-0.2.0/package.wit b/wit/deps/wasi-clocks-0.2.0/package.wit deleted file mode 100644 index 9e0ba3dca..000000000 --- a/wit/deps/wasi-clocks-0.2.0/package.wit +++ /dev/null @@ -1,29 +0,0 @@ -package wasi:clocks@0.2.0; - -interface monotonic-clock { - use wasi:io/poll@0.2.0.{pollable}; - - type instant = u64; - - type duration = u64; - - now: func() -> instant; - - resolution: func() -> duration; - - subscribe-instant: func(when: instant) -> pollable; - - subscribe-duration: func(when: duration) -> pollable; -} - -interface wall-clock { - record datetime { - seconds: u64, - nanoseconds: u32, - } - - now: func() -> datetime; - - resolution: func() -> datetime; -} - diff --git a/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/clocks.wit b/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/clocks.wit new file mode 100644 index 000000000..19fc4bcd5 --- /dev/null +++ b/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/clocks.wit @@ -0,0 +1,161 @@ +package wasi:clocks@0.3.0-rc-2026-03-15; + +/// This interface common types used throughout wasi:clocks. +@since(version = 0.3.0-rc-2026-03-15) +interface types { + /// A duration of time, in nanoseconds. + @since(version = 0.3.0-rc-2026-03-15) + type duration = u64; +} + +/// WASI Monotonic Clock is a clock API intended to let users measure elapsed +/// time. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +/// +/// A monotonic clock is a clock which has an unspecified initial value, and +/// successive reads of the clock will produce non-decreasing values. +@since(version = 0.3.0-rc-2026-03-15) +interface monotonic-clock { + use types.{duration}; + + /// A mark on a monotonic clock is a number of nanoseconds since an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + @since(version = 0.3.0-rc-2026-03-15) + type mark = u64; + + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + /// + /// For completeness, this function traps if it's not possible to represent + /// the value of the clock in a `mark`. Consequently, implementations + /// should ensure that the starting time is low enough to avoid the + /// possibility of overflow in practice. + @since(version = 0.3.0-rc-2026-03-15) + now: func() -> mark; + + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + @since(version = 0.3.0-rc-2026-03-15) + get-resolution: func() -> duration; + + /// Wait until the specified mark has occurred. + @since(version = 0.3.0-rc-2026-03-15) + wait-until: async func(when: mark); + + /// Wait for the specified duration to elapse. + @since(version = 0.3.0-rc-2026-03-15) + wait-for: async func(how-long: duration); +} + +/// WASI System Clock is a clock API intended to let users query the current +/// time. The clock is not necessarily monotonic as it may be reset. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +/// +/// External references may be reset, so this clock is not necessarily +/// monotonic, making it unsuitable for measuring elapsed time. +/// +/// It is intended for reporting the current date and time for humans. +@since(version = 0.3.0-rc-2026-03-15) +interface system-clock { + use types.{duration}; + + /// An "instant", or "exact time", is a point in time without regard to any + /// time zone: just the time since a particular external reference point, + /// often called an "epoch". + /// + /// Here, the epoch is 1970-01-01T00:00:00Z, also known as + /// [POSIX's Seconds Since the Epoch], also known as [Unix Time]. + /// + /// Note that even if the seconds field is negative, incrementing + /// nanoseconds always represents moving forwards in time. + /// For example, `{ -1 seconds, 999999999 nanoseconds }` represents the + /// instant one nanosecond before the epoch. + /// For more on various different ways to represent time, see + /// https://tc39.es/proposal-temporal/docs/timezone.html + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + @since(version = 0.3.0-rc-2026-03-15) + record instant { + seconds: s64, + nanoseconds: u32, + } + + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The nanoseconds field of the output is always less than 1000000000. + @since(version = 0.3.0-rc-2026-03-15) + now: func() -> instant; + + /// Query the resolution of the clock. Returns the smallest duration of time + /// that the implementation permits distinguishing. + @since(version = 0.3.0-rc-2026-03-15) + get-resolution: func() -> duration; +} + +@unstable(feature = clocks-timezone) +interface timezone { + @unstable(feature = clocks-timezone) + use system-clock.{instant}; + + /// Return the IANA identifier of the currently configured timezone. This + /// should be an identifier from the IANA Time Zone Database. + /// + /// For displaying to a user, the identifier should be converted into a + /// localized name by means of an internationalization API. + /// + /// If the implementation does not expose an actual timezone, or is unable + /// to provide mappings from times to deltas between the configured timezone + /// and UTC, or determining the current timezone fails, or the timezone does + /// not have an IANA identifier, this returns nothing. + @unstable(feature = clocks-timezone) + iana-id: func() -> option; + + /// The number of nanoseconds difference between UTC time and the local + /// time of the currently configured timezone, at the exact time of + /// `instant`. + /// + /// The magnitude of the returned value will always be less than + /// 86,400,000,000,000 which is the number of nanoseconds in a day + /// (24*60*60*1e9). + /// + /// If the implementation does not expose an actual timezone, or is unable + /// to provide mappings from times to deltas between the configured timezone + /// and UTC, or determining the current timezone fails, this returns + /// nothing. + @unstable(feature = clocks-timezone) + utc-offset: func(when: instant) -> option; + + /// Returns a string that is suitable to assist humans in debugging whether + /// any timezone is available, and if so, which. This may be the same string + /// as `iana-id`, or a formatted representation of the UTC offset such as + /// `-04:00`, or something else. + /// + /// WARNING: The returned string should not be consumed mechanically! It may + /// change across platforms, hosts, or other implementation details. Parsing + /// this string is a major platform-compatibility hazard. + @unstable(feature = clocks-timezone) + to-debug-string: func() -> string; +} + +@since(version = 0.3.0-rc-2026-03-15) +world imports { + @since(version = 0.3.0-rc-2026-03-15) + import types; + @since(version = 0.3.0-rc-2026-03-15) + import monotonic-clock; + @since(version = 0.3.0-rc-2026-03-15) + import system-clock; + @unstable(feature = clocks-timezone) + import timezone; +} diff --git a/wit/deps/wasi-filesystem-0.2.0/package.wit b/wit/deps/wasi-filesystem-0.2.0/package.wit deleted file mode 100644 index cb6a2beb8..000000000 --- a/wit/deps/wasi-filesystem-0.2.0/package.wit +++ /dev/null @@ -1,158 +0,0 @@ -package wasi:filesystem@0.2.0; - -interface types { - use wasi:io/streams@0.2.0.{input-stream, output-stream, error}; - use wasi:clocks/wall-clock@0.2.0.{datetime}; - - type filesize = u64; - - enum descriptor-type { - unknown, - block-device, - character-device, - directory, - fifo, - symbolic-link, - regular-file, - socket, - } - - flags descriptor-flags { - read, - write, - file-integrity-sync, - data-integrity-sync, - requested-write-sync, - mutate-directory, - } - - flags path-flags { - symlink-follow, - } - - flags open-flags { - create, - directory, - exclusive, - truncate, - } - - type link-count = u64; - - record descriptor-stat { - %type: descriptor-type, - link-count: link-count, - size: filesize, - data-access-timestamp: option, - data-modification-timestamp: option, - status-change-timestamp: option, - } - - variant new-timestamp { - no-change, - now, - timestamp(datetime), - } - - record directory-entry { - %type: descriptor-type, - name: string, - } - - enum error-code { - access, - would-block, - already, - bad-descriptor, - busy, - deadlock, - quota, - exist, - file-too-large, - illegal-byte-sequence, - in-progress, - interrupted, - invalid, - io, - is-directory, - loop, - too-many-links, - message-size, - name-too-long, - no-device, - no-entry, - no-lock, - insufficient-memory, - insufficient-space, - not-directory, - not-empty, - not-recoverable, - unsupported, - no-tty, - no-such-device, - overflow, - not-permitted, - pipe, - read-only, - invalid-seek, - text-file-busy, - cross-device, - } - - enum advice { - normal, - sequential, - random, - will-need, - dont-need, - no-reuse, - } - - record metadata-hash-value { - lower: u64, - upper: u64, - } - - resource descriptor { - read-via-stream: func(offset: filesize) -> result; - write-via-stream: func(offset: filesize) -> result; - append-via-stream: func() -> result; - advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; - sync-data: func() -> result<_, error-code>; - get-flags: func() -> result; - get-type: func() -> result; - set-size: func(size: filesize) -> result<_, error-code>; - set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; - read: func(length: filesize, offset: filesize) -> result, bool>, error-code>; - write: func(buffer: list, offset: filesize) -> result; - read-directory: func() -> result; - sync: func() -> result<_, error-code>; - create-directory-at: func(path: string) -> result<_, error-code>; - stat: func() -> result; - stat-at: func(path-flags: path-flags, path: string) -> result; - set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; - link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; - open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; - readlink-at: func(path: string) -> result; - remove-directory-at: func(path: string) -> result<_, error-code>; - rename-at: func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; - symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>; - unlink-file-at: func(path: string) -> result<_, error-code>; - is-same-object: func(other: borrow) -> bool; - metadata-hash: func() -> result; - metadata-hash-at: func(path-flags: path-flags, path: string) -> result; - } - - resource directory-entry-stream { - read-directory-entry: func() -> result, error-code>; - } - - filesystem-error-code: func(err: borrow) -> option; -} - -interface preopens { - use types.{descriptor}; - - get-directories: func() -> list>; -} - diff --git a/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/filesystem.wit b/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/filesystem.wit new file mode 100644 index 000000000..697681f30 --- /dev/null +++ b/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/filesystem.wit @@ -0,0 +1,575 @@ +package wasi:filesystem@0.3.0-rc-2026-03-15; + +/// 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. +/// +/// Paths are passed as interface-type `string`s, meaning they must consist of +/// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain +/// paths which are not accessible by this API. +/// +/// The directory separator in WASI is always the forward-slash (`/`). +/// +/// All paths in WASI are relative paths, and are interpreted relative to a +/// `descriptor` referring to a base directory. If a `path` argument to any WASI +/// function starts with `/`, or if any step of resolving a `path`, including +/// `..` and symbolic link steps, reaches a directory outside of the base +/// directory, or reaches a symlink to an absolute or rooted path in the +/// underlying filesystem, the function fails with `error-code::not-permitted`. +/// +/// For more information about WASI path resolution and sandboxing, see +/// [WASI filesystem path resolution]. +/// +/// Though this package presents a portable interface modelled on POSIX, it +/// prioritizes compatibility over portability: allowing users to access their +/// files on their machine is more important than exposing a single semantics +/// across all platforms. Notably, depending on the underlying operating system +/// and file system: +/// * Paths may be case-folded or not. +/// * Deleting (unlinking) a file may fail if there are other file descriptors +/// open. +/// * Durability and atomicity of changes to underlying files when there are +/// concurrent writers. +/// +/// Users that need well-defined, portable semantics should use a key-value +/// store or a database instead. +/// +/// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md +@since(version = 0.3.0-rc-2026-03-15) +interface types { + @since(version = 0.3.0-rc-2026-03-15) + use wasi:clocks/system-clock@0.3.0-rc-2026-03-15.{instant}; + + /// File size or length of a region within a file. + @since(version = 0.3.0-rc-2026-03-15) + type filesize = u64; + + /// The type of a filesystem object referenced by a descriptor. + /// + /// Note: This was called `filetype` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + variant descriptor-type { + /// The descriptor refers to a block device inode. + block-device, + /// The descriptor refers to a character device inode. + character-device, + /// The descriptor refers to a directory inode. + directory, + /// The descriptor refers to a named pipe. + fifo, + /// The file refers to a symbolic link inode. + symbolic-link, + /// The descriptor refers to a regular file inode. + regular-file, + /// The descriptor refers to a socket. + socket, + /// The type of the descriptor or file is different from any of the + /// other types specified. + other(option), + } + + /// Descriptor flags. + /// + /// Note: This was called `fdflags` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + flags descriptor-flags { + /// Read mode: Data can be read. + read, + /// Write mode: Data can be written to. + write, + /// Request that writes be performed according to synchronized I/O file + /// integrity completion. The data stored in the file and the file's + /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + file-integrity-sync, + /// Request that writes be performed according to synchronized I/O data + /// integrity completion. Only the data stored in the file is + /// synchronized. This is similar to `O_DSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + data-integrity-sync, + /// Requests that reads be performed at the same level of integrity + /// requested for writes. This is similar to `O_RSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + requested-write-sync, + /// Mutating directories mode: Directory contents may be mutated. + /// + /// When this flag is unset on a descriptor, operations using the + /// descriptor which would create, rename, delete, modify the data or + /// metadata of filesystem objects, or obtain another handle which + /// would permit any of those, shall fail with `error-code::read-only` if + /// they would otherwise succeed. + /// + /// This may only be set on directories. + mutate-directory, + } + + /// Flags determining the method of how paths are resolved. + @since(version = 0.3.0-rc-2026-03-15) + flags path-flags { + /// As long as the resolved path corresponds to a symbolic link, it is + /// expanded. + symlink-follow, + } + + /// Open flags used by `open-at`. + @since(version = 0.3.0-rc-2026-03-15) + flags open-flags { + /// Create file if it does not exist, similar to `O_CREAT` in POSIX. + create, + /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. + directory, + /// Fail if file already exists, similar to `O_EXCL` in POSIX. + exclusive, + /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. + truncate, + } + + /// Number of hard links to an inode. + @since(version = 0.3.0-rc-2026-03-15) + type link-count = u64; + + /// File attributes. + /// + /// Note: This was called `filestat` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + record descriptor-stat { + /// File type. + %type: descriptor-type, + /// Number of hard links to the file. + link-count: link-count, + /// For regular files, the file size in bytes. For symbolic links, the + /// length in bytes of the pathname contained in the symbolic link. + size: filesize, + /// Last data access timestamp. + /// + /// If the `option` is none, the platform doesn't maintain an access + /// timestamp for this file. + data-access-timestamp: option, + /// Last data modification timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// modification timestamp for this file. + data-modification-timestamp: option, + /// Last file status-change timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// status-change timestamp for this file. + status-change-timestamp: option, + } + + /// When setting a timestamp, this gives the value to set it to. + @since(version = 0.3.0-rc-2026-03-15) + variant new-timestamp { + /// Leave the timestamp set to its previous value. + no-change, + /// Set the timestamp to the current time of the system clock associated + /// with the filesystem. + now, + /// Set the timestamp to the given value. + timestamp(instant), + } + + /// A directory entry. + @since(version = 0.3.0-rc-2026-03-15) + record directory-entry { + /// The type of the file referred to by this directory entry. + %type: descriptor-type, + /// The name of the object. + name: string, + } + + /// Error codes returned by functions, similar to `errno` in POSIX. + /// Not all of these error codes are returned by the functions provided by this + /// API; some are used in higher-level library layers, and others are provided + /// merely for alignment with POSIX. + @since(version = 0.3.0-rc-2026-03-15) + variant error-code { + /// Permission denied, similar to `EACCES` in POSIX. + access, + /// Connection already in progress, similar to `EALREADY` in POSIX. + already, + /// Bad descriptor, similar to `EBADF` in POSIX. + bad-descriptor, + /// Device or resource busy, similar to `EBUSY` in POSIX. + busy, + /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. + deadlock, + /// Storage quota exceeded, similar to `EDQUOT` in POSIX. + quota, + /// File exists, similar to `EEXIST` in POSIX. + exist, + /// File too large, similar to `EFBIG` in POSIX. + file-too-large, + /// Illegal byte sequence, similar to `EILSEQ` in POSIX. + illegal-byte-sequence, + /// Operation in progress, similar to `EINPROGRESS` in POSIX. + in-progress, + /// Interrupted function, similar to `EINTR` in POSIX. + interrupted, + /// Invalid argument, similar to `EINVAL` in POSIX. + invalid, + /// I/O error, similar to `EIO` in POSIX. + io, + /// Is a directory, similar to `EISDIR` in POSIX. + is-directory, + /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. + loop, + /// Too many links, similar to `EMLINK` in POSIX. + too-many-links, + /// Message too large, similar to `EMSGSIZE` in POSIX. + message-size, + /// Filename too long, similar to `ENAMETOOLONG` in POSIX. + name-too-long, + /// No such device, similar to `ENODEV` in POSIX. + no-device, + /// No such file or directory, similar to `ENOENT` in POSIX. + no-entry, + /// No locks available, similar to `ENOLCK` in POSIX. + no-lock, + /// Not enough space, similar to `ENOMEM` in POSIX. + insufficient-memory, + /// No space left on device, similar to `ENOSPC` in POSIX. + insufficient-space, + /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. + not-directory, + /// Directory not empty, similar to `ENOTEMPTY` in POSIX. + not-empty, + /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. + not-recoverable, + /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. + unsupported, + /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. + no-tty, + /// No such device or address, similar to `ENXIO` in POSIX. + no-such-device, + /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. + overflow, + /// Operation not permitted, similar to `EPERM` in POSIX. + not-permitted, + /// Broken pipe, similar to `EPIPE` in POSIX. + pipe, + /// Read-only file system, similar to `EROFS` in POSIX. + read-only, + /// Invalid seek, similar to `ESPIPE` in POSIX. + invalid-seek, + /// Text file busy, similar to `ETXTBSY` in POSIX. + text-file-busy, + /// Cross-device link, similar to `EXDEV` in POSIX. + cross-device, + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + other(option), + } + + /// File or memory access pattern advisory information. + @since(version = 0.3.0-rc-2026-03-15) + enum advice { + /// The application has no advice to give on its behavior with respect + /// to the specified data. + normal, + /// The application expects to access the specified data sequentially + /// from lower offsets to higher offsets. + sequential, + /// The application expects to access the specified data in a random + /// order. + random, + /// The application expects to access the specified data in the near + /// future. + will-need, + /// The application expects that it will not access the specified data + /// in the near future. + dont-need, + /// The application expects to access the specified data once and then + /// not reuse it thereafter. + no-reuse, + } + + /// A 128-bit hash value, split into parts because wasm doesn't have a + /// 128-bit integer type. + @since(version = 0.3.0-rc-2026-03-15) + record metadata-hash-value { + /// 64 bits of a 128-bit hash value. + lower: u64, + /// Another 64 bits of a 128-bit hash value. + upper: u64, + } + + /// A descriptor is a reference to a filesystem object, which may be a file, + /// directory, named pipe, special file, or other object on which filesystem + /// calls may be made. + @since(version = 0.3.0-rc-2026-03-15) + resource descriptor { + /// Return a stream for reading from a file. + /// + /// Multiple read, write, and append streams may be active on the same open + /// file and they do not interfere with each other. + /// + /// This function returns a `stream` which provides the data received from the + /// file, and a `future` providing additional error information in case an + /// error is encountered. + /// + /// If no error is encountered, `stream.read` on the `stream` will return + /// `read-status::closed` with no `error-context` and the future resolves to + /// the value `ok`. If an error is encountered, `stream.read` on the + /// `stream` returns `read-status::closed` with an `error-context` and the future + /// resolves to `err` with an `error-code`. + /// + /// Note: This is similar to `pread` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + read-via-stream: func(offset: filesize) -> tuple, future>>; + /// Return a stream for writing to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be written. + /// + /// It is valid to write past the end of a file; the file is extended to the + /// extent of the write, with bytes between the previous end and the start of + /// the write set to zero. + /// + /// This function returns once either full contents of the stream are + /// written or an error is encountered. + /// + /// Note: This is similar to `pwrite` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + write-via-stream: func(data: stream, offset: filesize) -> future>; + /// Return a stream for appending to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be appended. + /// + /// This function returns once either full contents of the stream are + /// written or an error is encountered. + /// + /// Note: This is similar to `write` with `O_APPEND` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + append-via-stream: func(data: stream) -> future>; + /// Provide file advisory information on a descriptor. + /// + /// This is similar to `posix_fadvise` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; + /// Synchronize the data of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fdatasync` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + sync-data: async func() -> result<_, error-code>; + /// Get flags associated with a descriptor. + /// + /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + /// + /// Note: This returns the value that was the `fs_flags` value returned + /// from `fdstat_get` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + get-flags: async func() -> result; + /// Get the dynamic type of a descriptor. + /// + /// Note: This returns the same value as the `type` field of the `fd-stat` + /// returned by `stat`, `stat-at` and similar. + /// + /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided + /// by `fstat` in POSIX. + /// + /// Note: This returns the value that was the `fs_filetype` value returned + /// from `fdstat_get` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + get-type: async func() -> result; + /// Adjust the size of an open file. If this increases the file's size, the + /// extra bytes are filled with zeros. + /// + /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + set-size: async func(size: filesize) -> result<_, error-code>; + /// Adjust the timestamps of an open file or directory. + /// + /// Note: This is similar to `futimens` in POSIX. + /// + /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; + /// Read directory entries from a directory. + /// + /// On filesystems where directories contain entries referring to themselves + /// and their parents, often named `.` and `..` respectively, these entries + /// are omitted. + /// + /// This always returns a new stream which starts at the beginning of the + /// directory. Multiple streams may be active on the same directory, and they + /// do not interfere with each other. + /// + /// This function returns a future, which will resolve to an error code if + /// reading full contents of the directory fails. + @since(version = 0.3.0-rc-2026-03-15) + read-directory: func() -> tuple, future>>; + /// Synchronize the data and metadata of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fsync` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + sync: async func() -> result<_, error-code>; + /// Create a directory. + /// + /// Note: This is similar to `mkdirat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + create-directory-at: async func(path: string) -> result<_, error-code>; + /// Return the attributes of an open file or directory. + /// + /// Note: This is similar to `fstat` in POSIX, except that it does not return + /// device and inode information. For testing whether two descriptors refer to + /// the same underlying filesystem object, use `is-same-object`. To obtain + /// additional data that can be used do determine whether a file has been + /// modified, use `metadata-hash`. + /// + /// Note: This was called `fd_filestat_get` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + stat: async func() -> result; + /// Return the attributes of a file or directory. + /// + /// Note: This is similar to `fstatat` in POSIX, except that it does not + /// return device and inode information. See the `stat` description for a + /// discussion of alternatives. + /// + /// Note: This was called `path_filestat_get` in earlier versions of WASI. + @since(version = 0.3.0-rc-2026-03-15) + stat-at: async func(path-flags: path-flags, path: string) -> result; + /// Adjust the timestamps of a file or directory. + /// + /// Note: This is similar to `utimensat` in POSIX. + /// + /// Note: This was called `path_filestat_set_times` in earlier versions of + /// WASI. + @since(version = 0.3.0-rc-2026-03-15) + set-times-at: async func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; + /// Create a hard link. + /// + /// Fails with `error-code::no-entry` if the old path does not exist, + /// with `error-code::exist` if the new path already exists, and + /// `error-code::not-permitted` if the old path is not a file. + /// + /// Note: This is similar to `linkat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + link-at: async func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; + /// Open a file or directory. + /// + /// If `flags` contains `descriptor-flags::mutate-directory`, and the base + /// descriptor doesn't have `descriptor-flags::mutate-directory` set, + /// `open-at` fails with `error-code::read-only`. + /// + /// If `flags` contains `write` or `mutate-directory`, or `open-flags` + /// contains `truncate` or `create`, and the base descriptor doesn't have + /// `descriptor-flags::mutate-directory` set, `open-at` fails with + /// `error-code::read-only`. + /// + /// Note: This is similar to `openat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + open-at: async func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; + /// Read the contents of a symbolic link. + /// + /// If the contents contain an absolute or rooted path in the underlying + /// filesystem, this function fails with `error-code::not-permitted`. + /// + /// Note: This is similar to `readlinkat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + readlink-at: async func(path: string) -> result; + /// Remove a directory. + /// + /// Return `error-code::not-empty` if the directory is not empty. + /// + /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + remove-directory-at: async func(path: string) -> result<_, error-code>; + /// Rename a filesystem object. + /// + /// Note: This is similar to `renameat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + rename-at: async func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; + /// Create a symbolic link (also known as a "symlink"). + /// + /// If `old-path` starts with `/`, the function fails with + /// `error-code::not-permitted`. + /// + /// Note: This is similar to `symlinkat` in POSIX. + @since(version = 0.3.0-rc-2026-03-15) + symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>; + /// Unlink a filesystem object that is not a directory. + /// + /// This is similar to `unlinkat(fd, path, 0)` in POSIX. + /// + /// Error returns are as specified by POSIX. + /// + /// If the filesystem object is a directory, `error-code::access` or + /// `error-code::is-directory` may be returned instead of the + /// POSIX-specified `error-code::not-permitted`. + @since(version = 0.3.0-rc-2026-03-15) + unlink-file-at: async func(path: string) -> result<_, error-code>; + /// Test whether two descriptors refer to the same filesystem object. + /// + /// In POSIX, this corresponds to testing whether the two descriptors have the + /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. + /// wasi-filesystem does not expose device and inode numbers, so this function + /// may be used instead. + @since(version = 0.3.0-rc-2026-03-15) + is-same-object: async func(other: borrow) -> bool; + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a descriptor. + /// + /// This returns a hash of the last-modification timestamp and file size, and + /// may also include the inode number, device number, birth timestamp, and + /// other metadata fields that may change when the file is modified or + /// replaced. It may also include a secret value chosen by the + /// implementation and not otherwise exposed. + /// + /// Implementations are encouraged to provide the following properties: + /// + /// - If the file is not modified or replaced, the computed hash value should + /// usually not change. + /// - If the object is modified or replaced, the computed hash value should + /// usually change. + /// - The inputs to the hash should not be easily computable from the + /// computed hash. + /// + /// However, none of these is required. + @since(version = 0.3.0-rc-2026-03-15) + metadata-hash: async func() -> result; + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a directory descriptor and a relative path. + /// + /// This performs the same hash computation as `metadata-hash`. + @since(version = 0.3.0-rc-2026-03-15) + metadata-hash-at: async func(path-flags: path-flags, path: string) -> result; + } +} + +@since(version = 0.3.0-rc-2026-03-15) +interface preopens { + @since(version = 0.3.0-rc-2026-03-15) + use types.{descriptor}; + + /// Return the set of preopened directories, and their paths. + @since(version = 0.3.0-rc-2026-03-15) + get-directories: func() -> list>; +} + +@since(version = 0.3.0-rc-2026-03-15) +world imports { + @since(version = 0.3.0-rc-2026-03-15) + import wasi:clocks/types@0.3.0-rc-2026-03-15; + @since(version = 0.3.0-rc-2026-03-15) + import wasi:clocks/system-clock@0.3.0-rc-2026-03-15; + @since(version = 0.3.0-rc-2026-03-15) + import types; + @since(version = 0.3.0-rc-2026-03-15) + import preopens; +} diff --git a/wit/deps/wasi-io-0.2.0/package.wit b/wit/deps/wasi-io-0.2.0/package.wit deleted file mode 100644 index 184002998..000000000 --- a/wit/deps/wasi-io-0.2.0/package.wit +++ /dev/null @@ -1,48 +0,0 @@ -package wasi:io@0.2.0; - -interface error { - resource error { - to-debug-string: func() -> string; - } -} - -interface poll { - resource pollable { - ready: func() -> bool; - block: func(); - } - - poll: func(in: list>) -> list; -} - -interface streams { - use error.{error}; - use poll.{pollable}; - - variant stream-error { - last-operation-failed(error), - closed, - } - - resource input-stream { - read: func(len: u64) -> result, stream-error>; - blocking-read: func(len: u64) -> result, stream-error>; - skip: func(len: u64) -> result; - blocking-skip: func(len: u64) -> result; - subscribe: func() -> pollable; - } - - resource output-stream { - check-write: func() -> result; - write: func(contents: list) -> result<_, stream-error>; - blocking-write-and-flush: func(contents: list) -> result<_, stream-error>; - flush: func() -> result<_, stream-error>; - blocking-flush: func() -> result<_, stream-error>; - subscribe: func() -> pollable; - write-zeroes: func(len: u64) -> result<_, stream-error>; - blocking-write-zeroes-and-flush: func(len: u64) -> result<_, stream-error>; - splice: func(src: borrow, len: u64) -> result; - blocking-splice: func(src: borrow, len: u64) -> result; - } -} - diff --git a/wit/deps/wasi-random-0.2.0/package.wit b/wit/deps/wasi-random-0.2.0/package.wit deleted file mode 100644 index 58c179e1b..000000000 --- a/wit/deps/wasi-random-0.2.0/package.wit +++ /dev/null @@ -1,18 +0,0 @@ -package wasi:random@0.2.0; - -interface random { - get-random-bytes: func(len: u64) -> list; - - get-random-u64: func() -> u64; -} - -interface insecure { - get-insecure-random-bytes: func(len: u64) -> list; - - get-insecure-random-u64: func() -> u64; -} - -interface insecure-seed { - insecure-seed: func() -> tuple; -} - diff --git a/wit/deps/wasi-random-0.3.0-rc-2026-03-15/random.wit b/wit/deps/wasi-random-0.3.0-rc-2026-03-15/random.wit new file mode 100644 index 000000000..026f44a10 --- /dev/null +++ b/wit/deps/wasi-random-0.3.0-rc-2026-03-15/random.wit @@ -0,0 +1,107 @@ +package wasi:random@0.3.0-rc-2026-03-15; + +/// The insecure-seed interface for seeding hash-map DoS resistance. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +@since(version = 0.3.0-rc-2026-03-15) +interface insecure-seed { + /// Return a 128-bit value that may contain a pseudo-random value. + /// + /// The returned value is not required to be computed from a CSPRNG, and may + /// even be entirely deterministic. Host implementations are encouraged to + /// provide pseudo-random values to any program exposed to + /// attacker-controlled content, to enable DoS protection built into many + /// languages' hash-map implementations. + /// + /// This function is intended to only be called once, by a source language + /// to initialize Denial Of Service (DoS) protection in its hash-map + /// implementation. + /// + /// # Expected future evolution + /// + /// This will likely be changed to a value import, to prevent it from being + /// called multiple times and potentially used for purposes other than DoS + /// protection. + @since(version = 0.3.0-rc-2026-03-15) + get-insecure-seed: func() -> tuple; +} + +/// The insecure interface for insecure pseudo-random numbers. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +@since(version = 0.3.0-rc-2026-03-15) +interface insecure { + /// Return up to `max-len` insecure pseudo-random bytes. + /// + /// This function is not cryptographically secure. Do not use it for + /// anything related to security. + /// + /// There are no requirements on the values of the returned bytes, however + /// implementations are encouraged to return evenly distributed values with + /// a long period. + /// + /// Implementations MAY return fewer bytes than requested (a short read). + /// Callers that require exactly `max-len` bytes MUST call this function in + /// a loop until the desired number of bytes has been accumulated. + /// Implementations MUST return at least 1 byte when `max-len` is greater + /// than zero. When `max-len` is zero, implementations MUST return an empty + /// list without trapping. + @since(version = 0.3.0-rc-2026-03-15) + get-insecure-random-bytes: func(max-len: u64) -> list; + + /// Return an insecure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-insecure-random-bytes`, represented as a `u64`. + @since(version = 0.3.0-rc-2026-03-15) + get-insecure-random-u64: func() -> u64; +} + +/// WASI Random is a random data API. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +@since(version = 0.3.0-rc-2026-03-15) +interface random { + /// Return up to `max-len` cryptographically-secure random or pseudo-random + /// bytes. + /// + /// This function must produce data at least as cryptographically secure and + /// fast as an adequately seeded cryptographically-secure pseudo-random + /// number generator (CSPRNG). It must not block, from the perspective of + /// the calling program, under any circumstances, including on the first + /// request and on requests for numbers of bytes. The returned data must + /// always be unpredictable. + /// + /// Implementations MAY return fewer bytes than requested (a short read). + /// Callers that require exactly `max-len` bytes MUST call this function in + /// a loop until the desired number of bytes has been accumulated. + /// Implementations MUST return at least 1 byte when `max-len` is greater + /// than zero. When `max-len` is zero, implementations MUST return an empty + /// list without trapping. + /// + /// This function must always return fresh data. Deterministic environments + /// must omit this function, rather than implementing it with deterministic + /// data. + @since(version = 0.3.0-rc-2026-03-15) + get-random-bytes: func(max-len: u64) -> list; + + /// Return a cryptographically-secure random or pseudo-random `u64` value. + /// + /// This function returns the same type of data as `get-random-bytes`, + /// represented as a `u64`. + @since(version = 0.3.0-rc-2026-03-15) + get-random-u64: func() -> u64; +} + +@since(version = 0.3.0-rc-2026-03-15) +world imports { + @since(version = 0.3.0-rc-2026-03-15) + import random; + @since(version = 0.3.0-rc-2026-03-15) + import insecure; + @since(version = 0.3.0-rc-2026-03-15) + import insecure-seed; +} diff --git a/wit/deps/wasi-sockets-0.2.0/package.wit b/wit/deps/wasi-sockets-0.2.0/package.wit deleted file mode 100644 index 0602b855d..000000000 --- a/wit/deps/wasi-sockets-0.2.0/package.wit +++ /dev/null @@ -1,179 +0,0 @@ -package wasi:sockets@0.2.0; - -interface network { - resource network; - - enum error-code { - unknown, - access-denied, - not-supported, - invalid-argument, - out-of-memory, - timeout, - concurrency-conflict, - not-in-progress, - would-block, - invalid-state, - new-socket-limit, - address-not-bindable, - address-in-use, - remote-unreachable, - connection-refused, - connection-reset, - connection-aborted, - datagram-too-large, - name-unresolvable, - temporary-resolver-failure, - permanent-resolver-failure, - } - - enum ip-address-family { - ipv4, - ipv6, - } - - type ipv4-address = tuple; - - type ipv6-address = tuple; - - variant ip-address { - ipv4(ipv4-address), - ipv6(ipv6-address), - } - - record ipv4-socket-address { - port: u16, - address: ipv4-address, - } - - record ipv6-socket-address { - port: u16, - flow-info: u32, - address: ipv6-address, - scope-id: u32, - } - - variant ip-socket-address { - ipv4(ipv4-socket-address), - ipv6(ipv6-socket-address), - } -} - -interface instance-network { - use network.{network}; - - instance-network: func() -> network; -} - -interface udp { - use wasi:io/poll@0.2.0.{pollable}; - use network.{network, error-code, ip-socket-address, ip-address-family}; - - record incoming-datagram { - data: list, - remote-address: ip-socket-address, - } - - record outgoing-datagram { - data: list, - remote-address: option, - } - - resource udp-socket { - start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; - finish-bind: func() -> result<_, error-code>; - %stream: func(remote-address: option) -> result, error-code>; - local-address: func() -> result; - remote-address: func() -> result; - address-family: func() -> ip-address-family; - unicast-hop-limit: func() -> result; - set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; - 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>; - subscribe: func() -> pollable; - } - - resource incoming-datagram-stream { - receive: func(max-results: u64) -> result, error-code>; - subscribe: func() -> pollable; - } - - resource outgoing-datagram-stream { - check-send: func() -> result; - send: func(datagrams: list) -> result; - subscribe: func() -> pollable; - } -} - -interface udp-create-socket { - use network.{network, error-code, ip-address-family}; - use udp.{udp-socket}; - - create-udp-socket: func(address-family: ip-address-family) -> result; -} - -interface tcp { - 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 { - receive, - send, - both, - } - - resource tcp-socket { - start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; - finish-bind: func() -> result<_, error-code>; - start-connect: func(network: borrow, remote-address: ip-socket-address) -> result<_, error-code>; - finish-connect: func() -> result, error-code>; - start-listen: func() -> result<_, error-code>; - finish-listen: func() -> result<_, error-code>; - accept: func() -> result, error-code>; - local-address: func() -> result; - remote-address: func() -> result; - is-listening: func() -> bool; - address-family: func() -> ip-address-family; - set-listen-backlog-size: func(value: u64) -> result<_, error-code>; - keep-alive-enabled: func() -> result; - set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; - keep-alive-idle-time: func() -> result; - set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; - keep-alive-interval: func() -> result; - set-keep-alive-interval: func(value: duration) -> result<_, error-code>; - keep-alive-count: func() -> result; - set-keep-alive-count: func(value: u32) -> result<_, error-code>; - hop-limit: func() -> result; - set-hop-limit: func(value: u8) -> result<_, error-code>; - 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>; - subscribe: func() -> pollable; - shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>; - } -} - -interface tcp-create-socket { - use network.{network, error-code, ip-address-family}; - use tcp.{tcp-socket}; - - create-tcp-socket: func(address-family: ip-address-family) -> result; -} - -interface ip-name-lookup { - use wasi:io/poll@0.2.0.{pollable}; - use network.{network, error-code, ip-address}; - - resource resolve-address-stream { - resolve-next-address: func() -> result, error-code>; - subscribe: func() -> pollable; - } - - resolve-addresses: func(network: borrow, name: string) -> result; -} - diff --git a/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/sockets.wit b/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/sockets.wit new file mode 100644 index 000000000..cde2e4d6e --- /dev/null +++ b/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/sockets.wit @@ -0,0 +1,839 @@ +package wasi:sockets@0.3.0-rc-2026-03-15; + +@since(version = 0.3.0-rc-2026-03-15) +interface types { + @since(version = 0.3.0-rc-2026-03-15) + use wasi:clocks/types@0.3.0-rc-2026-03-15.{duration}; + + /// Error codes. + /// + /// In theory, every API can return any error code. + /// In practice, API's typically only return the errors documented per API + /// combined with a couple of errors that are always possible: + /// - `other` + /// - `access-denied` + /// - `not-supported` + /// - `out-of-memory` + /// + /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + @since(version = 0.3.0-rc-2026-03-15) + variant error-code { + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + access-denied, + /// The operation is not supported. + /// + /// POSIX equivalent: EOPNOTSUPP, ENOPROTOOPT, EPFNOSUPPORT, EPROTONOSUPPORT, ESOCKTNOSUPPORT + not-supported, + /// One of the arguments is invalid. + /// + /// POSIX equivalent: EINVAL, EDESTADDRREQ, EAFNOSUPPORT + invalid-argument, + /// Not enough memory to complete the operation. + /// + /// POSIX equivalent: ENOMEM, ENOBUFS + out-of-memory, + /// The operation timed out before it could finish completely. + /// + /// POSIX equivalent: ETIMEDOUT + timeout, + /// The operation is not valid in the socket's current state. + invalid-state, + /// The local address is not available. + /// + /// POSIX equivalent: EADDRNOTAVAIL + address-not-bindable, + /// A bind operation failed because the provided address is already in + /// use or because there are no ephemeral ports available. + /// + /// POSIX equivalent: EADDRINUSE + address-in-use, + /// The remote address is not reachable. + /// + /// POSIX equivalent: EHOSTUNREACH, EHOSTDOWN, ENETDOWN, ENETUNREACH, ENONET + remote-unreachable, + /// The connection was forcefully rejected. + /// + /// POSIX equivalent: ECONNREFUSED + connection-refused, + /// A write failed because the connection was broken. + /// + /// POSIX equivalent: EPIPE + connection-broken, + /// The connection was reset. + /// + /// POSIX equivalent: ECONNRESET + connection-reset, + /// The connection was aborted. + /// + /// POSIX equivalent: ECONNABORTED + connection-aborted, + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. + /// + /// POSIX equivalent: EMSGSIZE + datagram-too-large, + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + other(option), + } + + @since(version = 0.3.0-rc-2026-03-15) + enum ip-address-family { + /// Similar to `AF_INET` in POSIX. + ipv4, + /// Similar to `AF_INET6` in POSIX. + ipv6, + } + + @since(version = 0.3.0-rc-2026-03-15) + type ipv4-address = tuple; + + @since(version = 0.3.0-rc-2026-03-15) + type ipv6-address = tuple; + + @since(version = 0.3.0-rc-2026-03-15) + variant ip-address { + ipv4(ipv4-address), + ipv6(ipv6-address), + } + + @since(version = 0.3.0-rc-2026-03-15) + record ipv4-socket-address { + /// sin_port + port: u16, + /// sin_addr + address: ipv4-address, + } + + @since(version = 0.3.0-rc-2026-03-15) + record ipv6-socket-address { + /// sin6_port + port: u16, + /// sin6_flowinfo + flow-info: u32, + /// sin6_addr + address: ipv6-address, + /// sin6_scope_id + scope-id: u32, + } + + @since(version = 0.3.0-rc-2026-03-15) + variant ip-socket-address { + ipv4(ipv4-socket-address), + ipv6(ipv6-socket-address), + } + + /// A TCP socket resource. + /// + /// The socket can be in one of the following states: + /// - `unbound` + /// - `bound` (See note below) + /// - `listening` + /// - `connecting` + /// - `connected` + /// - `closed` + /// See + /// for 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`, `listening`, `connecting` or `connected`) + /// + /// WASI uses shared ownership semantics: the `tcp-socket` handle and all + /// derived `stream` and `future` values reference a single underlying OS + /// socket: + /// - Send/receive streams remain functional after the original `tcp-socket` + /// handle is dropped. + /// - The stream returned by `listen` behaves similarly. + /// - Client sockets returned by `tcp-socket::listen` are independent and do + /// not keep the listening socket alive. + /// + /// The OS socket is closed only after the last handle is dropped. This + /// model has observable effects; for example, it affects when the local + /// port binding is released. + /// + /// In addition to the general error codes documented on the + /// `types::error-code` type, TCP socket methods may always return + /// `error(invalid-state)` when in the `closed` state. + @since(version = 0.3.0-rc-2026-03-15) + resource tcp-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. + /// + /// Unlike POSIX, WASI sockets have no notion of a socket-level + /// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's + /// async support. + /// + /// # Typical errors + /// - `not-supported`: The `address-family` is not supported. (EAFNOSUPPORT) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + create: static func(address-family: ip-address-family) -> result; + /// Bind the socket to the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is + /// left to the implementation to decide which network interface(s) to + /// bind to. If the TCP/UDP port is zero, the socket will be bound to a + /// random free port. + /// + /// 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 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. (EINVAL) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `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 can be bound to. (EADDRNOTAVAIL) + /// + /// # Implementors note + /// The 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. + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + bind: func(local-address: ip-socket-address) -> result<_, error-code>; + /// Connect to a remote endpoint. + /// + /// On success, the socket is transitioned into the `connected` state + /// and the `remote-address` of the socket is updated. + /// The `local-address` may be updated as well, based on the best network + /// path to `remote-address`. If the socket was not already explicitly + /// bound, this function will implicitly bind the socket to a random + /// free port. + /// + /// 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. + /// + /// # 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. (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-state`: The socket is already in the `connecting` state. (EALREADY) + /// - `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) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + connect: async func(remote-address: ip-socket-address) -> result<_, error-code>; + /// Start listening and return a stream of new inbound connections. + /// + /// Transitions the socket into the `listening` state. This can be called + /// at most once per socket. + /// + /// If the socket is not already explicitly bound, this function will + /// implicitly bind the socket to a random free port. + /// + /// Normally, the returned sockets are bound, in the `connected` state + /// and immediately ready for I/O. Though, depending on exact timing and + /// circumstances, a newly accepted connection may already be `closed` + /// by the time the server attempts to perform its first I/O on it. This + /// is true regardless of whether the WASI implementation uses + /// "synthesized" sockets or not (see Implementors Notes below). + /// + /// The following properties are inherited from the listener socket: + /// - `address-family` + /// - `keep-alive-enabled` + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// - `hop-limit` + /// - `receive-buffer-size` + /// - `send-buffer-size` + /// + /// # Typical 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) + /// + /// # Implementors note + /// This method returns a single perpetual stream that should only close + /// on fatal errors (if any). Yet, the POSIX' `accept` function may also + /// return transient errors (e.g. ECONNABORTED). The exact details differ + /// per operation system. For example, the Linux manual mentions: + /// + /// > Linux accept() passes already-pending network errors on the new + /// > socket as an error code from accept(). This behavior differs from + /// > other BSD socket implementations. For reliable operation the + /// > application should detect the network errors defined for the + /// > protocol after accept() and treat them like EAGAIN by retrying. + /// > In the case of TCP/IP, these are ENETDOWN, EPROTO, ENOPROTOOPT, + /// > EHOSTDOWN, ENONET, EHOSTUNREACH, EOPNOTSUPP, and ENETUNREACH. + /// Source: https://man7.org/linux/man-pages/man2/accept.2.html + /// + /// WASI implementations have two options to handle this: + /// - Optionally log it and then skip over non-fatal errors returned by + /// `accept`. Guest code never gets to see these failures. Or: + /// - Synthesize a `tcp-socket` resource that exposes the error when + /// attempting to send or receive on it. Guest code then sees these + /// failures as regular I/O errors. + /// + /// In either case, the stream returned by this `listen` method remains + /// operational. + /// + /// WASI requires `listen` to perform an implicit bind if the socket + /// has not already been bound. Not all platforms (notably Windows) + /// exhibit this behavior out of the box. On platforms that require it, + /// the WASI implementation can emulate this behavior by performing + /// the bind itself if the guest hasn't already done so. + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + listen: func() -> result, error-code>; + /// Transmit data to peer. + /// + /// The caller should close the stream when it has no more data to send + /// to the peer. Under normal circumstances this will cause a FIN packet + /// to be sent out. Closing the stream is equivalent to calling + /// `shutdown(SHUT_WR)` in POSIX. + /// + /// This function may be called at most once and returns once the full + /// contents of the stream are transmitted or an error is encountered. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// - `invalid-state`: `send` has already been called on this socket. + /// - `connection-broken`: The connection is not writable anymore. (EPIPE, ECONNABORTED on Windows) + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + send: func(data: stream) -> future>; + /// Read data from peer. + /// + /// Returns a `stream` of data sent by the peer. The implementation + /// drops the stream once no more data is available. At that point, the + /// returned `future` resolves to: + /// - `ok` after a graceful shutdown from the peer (i.e. a FIN packet), or + /// - `err` if the socket was closed abnormally. + /// + /// `receive` may be called only once per socket. Subsequent calls return + /// a closed stream and a future resolved to `err(invalid-state)`. + /// + /// If the caller is not expecting to receive any more data from the peer, + /// they should drop the stream. Any data still in the receive queue + /// will be discarded. This is equivalent to calling `shutdown(SHUT_RD)` + /// in POSIX. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// - `invalid-state`: `receive` has already been called on this socket. + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + receive: func() -> tuple, future>>; + /// Get the bound local address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `get-local-address` to return + /// `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + get-local-address: func() -> result; + /// Get the remote address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + get-remote-address: func() -> result; + /// Whether the socket is in the `listening` state. + /// + /// Equivalent to the SO_ACCEPTCONN socket option. + @since(version = 0.3.0-rc-2026-03-15) + get-is-listening: func() -> bool; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// This is the value passed to the constructor. + /// + /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.3.0-rc-2026-03-15) + get-address-family: func() -> ip-address-family; + /// Hints the desired listen queue size. Implementations are free to + /// ignore this. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently + /// clamped and/or rounded. + /// + /// # 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 in the `connecting` or `connected` state. + @since(version = 0.3.0-rc-2026-03-15) + set-listen-backlog-size: func(value: u64) -> result<_, error-code>; + /// Enables or disables keepalive. + /// + /// The keepalive behavior can be adjusted using: + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// These properties can be configured while `keep-alive-enabled` is + /// false, but only come into effect when `keep-alive-enabled` is true. + /// + /// Equivalent to the SO_KEEPALIVE socket option. + @since(version = 0.3.0-rc-2026-03-15) + get-keep-alive-enabled: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; + /// Amount of time the connection has to be idle before TCP starts + /// sending keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.3.0-rc-2026-03-15) + get-keep-alive-idle-time: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; + /// The time between keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPINTVL socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.3.0-rc-2026-03-15) + get-keep-alive-interval: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-keep-alive-interval: func(value: duration) -> result<_, error-code>; + /// The maximum amount of keepalive packets TCP should send before + /// aborting the connection. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the TCP_KEEPCNT socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.3.0-rc-2026-03-15) + get-keep-alive-count: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-keep-alive-count: func(value: u32) -> 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. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.3.0-rc-2026-03-15) + get-hop-limit: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-hop-limit: func(value: u8) -> result<_, error-code>; + /// Kernel buffer space reserved for sending/receiving on this socket. + /// Implementations usually treat this as a cap the buffer can grow to, + /// rather than allocating the full amount immediately. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// This is only a performance hint. The implementation may ignore it or + /// tweak it based on real traffic patterns. + /// Linux and macOS appear to behave differently depending on whether a + /// buffer size was explicitly set. When set, they tend to honor it; when + /// not set, they dynamically adjust the buffer size as the connection + /// progresses. This is especially noticeable when comparing the values + /// from before and after connection establishment. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.3.0-rc-2026-03-15) + get-receive-buffer-size: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-03-15) + get-send-buffer-size: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-send-buffer-size: func(value: u64) -> result<_, error-code>; + } + + /// A UDP socket handle. + @since(version = 0.3.0-rc-2026-03-15) + resource udp-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. + /// + /// Unlike POSIX, WASI sockets have no notion of a socket-level + /// `O_NONBLOCK` flag. Instead they fully rely on the Component Model's + /// async support. + /// + /// # References: + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + create: static func(address-family: ip-address-family) -> result; + /// Bind the socket to the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is + /// left to the implementation to decide which network interface(s) to + /// bind to. If the port is zero, the socket will be bound to a random + /// free port. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `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 can be bound to. (EADDRNOTAVAIL) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + bind: func(local-address: ip-socket-address) -> result<_, error-code>; + /// Associate this socket with a specific peer address. + /// + /// On success, the `remote-address` of the socket is updated. + /// The `local-address` may be updated as well, based on the best network + /// path to `remote-address`. If the socket was not already explicitly + /// bound, this function will implicitly bind the socket to a random + /// free port. + /// + /// When a UDP socket is "connected", the `send` and `receive` methods + /// are limited to communicating with that peer only: + /// - `send` can only be used to send to this destination. + /// - `receive` will only return datagrams sent from the provided `remote-address`. + /// + /// The name "connect" was kept to align with the existing POSIX + /// terminology. Other than that, this function only changes the local + /// socket configuration and does not generate any network traffic. + /// The peer is not aware of this "connection". + /// + /// This method may be called multiple times on the same socket to change + /// its association, but only the most recent one will be effective. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `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) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// + /// # Implementors note + /// If the socket is already connected, some platforms (e.g. Linux) + /// require a disconnect before connecting to a different peer address. + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + connect: func(remote-address: ip-socket-address) -> result<_, error-code>; + /// Dissociate this socket from its peer address. + /// + /// After calling this method, `send` & `receive` are free to communicate + /// with any remote address again. + /// + /// The POSIX equivalent of this is calling `connect` with an `AF_UNSPEC` address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected. + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + disconnect: func() -> result<_, error-code>; + /// Send a message on the socket to a particular peer. + /// + /// If the socket is connected, the peer address may be left empty. In + /// that case this is equivalent to `send` in POSIX. Otherwise it is + /// equivalent to `sendto`. + /// + /// Additionally, if the socket is connected, a `remote-address` argument + /// _may_ be provided but then it must be identical to the address + /// passed to `connect`. + /// + /// If the socket has not been explicitly bound, it will be + /// implicitly bound to a random free port. + /// + /// Implementations may trap if the `data` length exceeds 64 KiB. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `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 `connect`. (EISCONN) + /// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) + /// + /// # Implementors note + /// WASI requires `send` to perform an implicit bind if the socket + /// has not been bound. Not all platforms (notably Windows) exhibit + /// this behavior natively. On such platforms, the WASI implementation + /// should emulate it by performing the bind if the guest has not + /// already done so. + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + send: async func(data: list, remote-address: option) -> result<_, error-code>; + /// Receive a message on the socket. + /// + /// On success, the return value contains a tuple of the received data + /// and the address of the sender. Theoretical maximum length of the + /// data is 64 KiB. Though in practice, it will typically be less than + /// 1500 bytes. + /// + /// If the socket is connected, the sender address is guaranteed to + /// match the remote address passed to `connect`. + /// + /// # Typical errors + /// - `invalid-state`: The socket has not been bound yet. + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + receive: async func() -> result, ip-socket-address>, error-code>; + /// Get the current bound address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `get-local-address` to return + /// `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + get-local-address: func() -> result; + /// Get the address the socket is currently "connected" to. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not "connected" to a specific remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + get-remote-address: func() -> result; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// This is the value passed to the constructor. + /// + /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.3.0-rc-2026-03-15) + get-address-family: func() -> ip-address-family; + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.3.0-rc-2026-03-15) + get-unicast-hop-limit: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; + /// Kernel buffer space reserved for sending/receiving on this socket. + /// Implementations usually treat this as a cap the buffer can grow to, + /// rather than allocating the full amount immediately. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// All other values are accepted without error, but may be + /// clamped or rounded. As a result, the value read back from + /// this setting may differ from the value that was set. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.3.0-rc-2026-03-15) + get-receive-buffer-size: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-03-15) + get-send-buffer-size: func() -> result; + @since(version = 0.3.0-rc-2026-03-15) + set-send-buffer-size: func(value: u64) -> result<_, error-code>; + } +} + +@since(version = 0.3.0-rc-2026-03-15) +interface ip-name-lookup { + @since(version = 0.3.0-rc-2026-03-15) + use types.{ip-address}; + + /// Lookup error codes. + @since(version = 0.3.0-rc-2026-03-15) + variant error-code { + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + access-denied, + /// `name` is a syntactically invalid domain name or IP address. + /// + /// POSIX equivalent: EINVAL + invalid-argument, + /// Name does not exist or has no suitable associated IP addresses. + /// + /// POSIX equivalent: EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY + name-unresolvable, + /// A temporary failure in name resolution occurred. + /// + /// POSIX equivalent: EAI_AGAIN + temporary-resolver-failure, + /// A permanent failure in name resolution occurred. + /// + /// POSIX equivalent: EAI_FAIL + permanent-resolver-failure, + /// A catch-all for errors not captured by the existing variants. + /// Implementations can use this to extend the error type without + /// breaking existing code. + other(option), + } + + /// Resolve an internet host name to a list of IP addresses. + /// + /// Unicode domain names are automatically converted to ASCII using IDNA + /// encoding. If the input is an IP address string, the address is parsed + /// and returned as-is without making any external requests. + /// + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. + /// + /// The results are returned in connection order preference. + /// + /// This function never succeeds with 0 results. It either fails or succeeds + /// with at least one address. Additionally, this function never returns + /// IPv4-mapped IPv6 addresses. + /// + /// # References: + /// - + /// - + /// - + /// - + @since(version = 0.3.0-rc-2026-03-15) + resolve-addresses: async func(name: string) -> result, error-code>; +} + +@since(version = 0.3.0-rc-2026-03-15) +world imports { + @since(version = 0.3.0-rc-2026-03-15) + import wasi:clocks/types@0.3.0-rc-2026-03-15; + @since(version = 0.3.0-rc-2026-03-15) + import types; + @since(version = 0.3.0-rc-2026-03-15) + import ip-name-lookup; +} diff --git a/wit/plugin.wit b/wit/plugin.wit index 24e50a35c..a3b5e210b 100644 --- a/wit/plugin.wit +++ b/wit/plugin.wit @@ -1,4 +1,4 @@ -package streamkit:plugin@0.1.0; +package streamkit:plugin@0.2.0; /// Core types for audio processing interface types { @@ -92,7 +92,7 @@ interface host { } /// Send a packet to an output pin - send-output: func(pin-name: string, packet: packet) -> result<_, string>; + send-output: async func(pin-name: string, packet: packet) -> result<_, string>; /// Log a message to the host log: func(level: log-level, message: string); @@ -111,10 +111,10 @@ interface node { constructor(params: option); /// Process an incoming packet from a specific input pin using this instance's state - process: func(input-pin: string, packet: packet) -> result<_, string>; + process: async func(input-pin: string, packet: packet) -> result<_, string>; /// Update the runtime parameters for this instance. The payload is a JSON string. - update-params: func(params: option) -> result<_, string>; + update-params: async func(params: option) -> result<_, string>; /// Clean up any resources associated with this instance cleanup: func(); @@ -125,7 +125,7 @@ interface node { world plugin { import host; - include wasi:cli/imports@0.2.0; + include wasi:cli/imports@0.3.0-rc-2026-03-15; export node; } diff --git a/wkg.lock b/wkg.lock deleted file mode 100644 index 1604270bc..000000000 --- a/wkg.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated. -# It is not intended for manual editing. -version = 1 - -[[packages]] -name = "wasi:cli" -registry = "wasi.dev" - -[[packages.versions]] -requirement = "=0.2.0" -version = "0.2.0" -digest = "sha256:e7e85458e11caf76554b724ebf4f113259decf0f3b1ee2e2930de096f72114a7"