From 1e7c7898e5b1f5ede873896af5f23f613ea89771 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 27 Dec 2022 15:24:29 +0000 Subject: [PATCH 01/46] Integrate experimental HTTP into wasmtime. --- .github/workflows/main.yml | 2 +- .gitmodules | 3 + Cargo.lock | 576 ++- Cargo.toml | 3 + crates/cli-flags/src/lib.rs | 22 +- crates/wasi-http/Cargo.toml | 21 + crates/wasi-http/example/main.c | 117 + crates/wasi-http/example/main.wasm | Bin 0 -> 50300 bytes crates/wasi-http/example/proxy.c | 1211 ++++++ crates/wasi-http/example/proxy.h | 335 ++ .../wasi-http/example/proxy_component_type.o | Bin 0 -> 8260 bytes crates/wasi-http/expansion.txt | 3613 +++++++++++++++++ crates/wasi-http/src/component_impl.rs | 433 ++ crates/wasi-http/src/http_impl.rs | 145 + crates/wasi-http/src/lib.rs | 27 + crates/wasi-http/src/streams_impl.rs | 86 + crates/wasi-http/src/struct.rs | 76 + crates/wasi-http/src/types_impl.rs | 260 ++ crates/wasi-http/wasi-http | 1 + crates/wasi-http/wit | 1 + src/commands/run.rs | 9 + 21 files changed, 6888 insertions(+), 53 deletions(-) create mode 100644 crates/wasi-http/Cargo.toml create mode 100644 crates/wasi-http/example/main.c create mode 100755 crates/wasi-http/example/main.wasm create mode 100644 crates/wasi-http/example/proxy.c create mode 100644 crates/wasi-http/example/proxy.h create mode 100644 crates/wasi-http/example/proxy_component_type.o create mode 100644 crates/wasi-http/expansion.txt create mode 100644 crates/wasi-http/src/component_impl.rs create mode 100644 crates/wasi-http/src/http_impl.rs create mode 100644 crates/wasi-http/src/lib.rs create mode 100644 crates/wasi-http/src/streams_impl.rs create mode 100644 crates/wasi-http/src/struct.rs create mode 100644 crates/wasi-http/src/types_impl.rs create mode 160000 crates/wasi-http/wasi-http create mode 120000 crates/wasi-http/wit diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e08191a89013..33314a5449bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -393,7 +393,7 @@ jobs: run: | set -ex sudo apt-get update - sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build + sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build libssl-dev # Configure Cargo for cross compilation and tell it how it can run # cross executables diff --git a/.gitmodules b/.gitmodules index ba7f6793433a..f361970532fc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "tests/wasi_testsuite/wasi-threads"] path = tests/wasi_testsuite/wasi-threads url = https://github.com/WebAssembly/wasi-threads +[submodule "crates/wasi-http/wasi-http"] + path = crates/wasi-http/wasi-http + url = https://github.com/WebAssembly/wasi-http diff --git a/Cargo.lock b/Cargo.lock index f61028eb3e25..e2a065982780 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,6 +234,16 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + [[package]] name = "bytes" version = "1.1.0" @@ -249,7 +259,7 @@ dependencies = [ "cap-primitives", "cap-std", "io-lifetimes", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -265,7 +275,7 @@ dependencies = [ "ipnet", "maybe-owned", "rustix", - "windows-sys", + "windows-sys 0.45.0", "winx", ] @@ -526,6 +536,22 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpp_demangle" version = "0.3.5" @@ -694,7 +720,7 @@ dependencies = [ "region", "target-lexicon", "wasmtime-jit-icache-coherence", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1215,7 +1241,7 @@ checksum = "8ef1a30ae415c3a691a4f41afddc2dbcd6d70baf338368d85ebc1e8ed92cedb9" dependencies = [ "cfg-if", "rustix", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1272,6 +1298,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1289,7 +1330,7 @@ checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" dependencies = [ "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1302,6 +1343,101 @@ dependencies = [ "winapi", ] +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "futures" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" + +[[package]] +name = "futures-executor" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" + +[[package]] +name = "futures-macro" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" + +[[package]] +name = "futures-task" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" + +[[package]] +name = "futures-util" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -1381,6 +1517,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes 1.1.0", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.8", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "1.8.2" @@ -1452,6 +1607,75 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "http" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +dependencies = [ + "bytes 0.4.12", + "fnv", + "itoa 0.4.8", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes 1.1.0", + "fnv", + "itoa 1.0.1", +] + +[[package]] +name = "http-body" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.31", + "http 0.1.21", + "tokio-buf", +] + +[[package]] +name = "http-body" +version = "1.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951dfc2e32ac02d67c90c0d65bd27009a635dc9b381a2cc7d284ab01e3a0150d" +dependencies = [ + "bytes 1.1.0", + "http 0.2.8", +] + +[[package]] +name = "http-body-util" +version = "0.1.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92445bc9cc14bfa0a3ce56817dc3b5bcc227a168781a356b702410789cec0d10" +dependencies = [ + "bytes 1.1.0", + "futures-util", + "http 0.2.8", + "http-body 1.0.0-rc.2", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + [[package]] name = "humantime" version = "1.3.0" @@ -1467,6 +1691,28 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "1.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75264b2003a3913f118d35c586e535293b3e22e41f074930762929d071e092" +dependencies = [ + "bytes 1.1.0", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.8", + "http-body 1.0.0-rc.2", + "httparse", + "httpdate", + "itoa 1.0.1", + "pin-project-lite", + "tokio", + "tracing", + "want", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -1528,7 +1774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d79107d6e60d78351e11f0a2dc9d0eaf304a7efb592e92603783afb8479c7d97" dependencies = [ "io-lifetimes", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1538,7 +1784,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", ] [[package]] @@ -1556,7 +1811,7 @@ dependencies = [ "hermit-abi 0.3.0", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1587,6 +1842,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "itoa" version = "1.0.1" @@ -1795,34 +2056,32 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "miow", - "ntapi", "wasi 0.11.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", + "windows-sys 0.42.0", ] [[package]] -name = "ntapi" -version = "0.3.7" +name = "native-tls" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ - "winapi", + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -1950,6 +2209,51 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67" +dependencies = [ + "autocfg 1.1.0", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "openvino" version = "0.4.2" @@ -2017,7 +2321,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.7", ] [[package]] @@ -2034,6 +2348,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + [[package]] name = "paste" version = "1.0.7" @@ -2061,6 +2388,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkcs1" version = "0.2.4" @@ -2085,6 +2418,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + [[package]] name = "plotters" version = "0.3.1" @@ -2510,11 +2849,11 @@ dependencies = [ "bitflags", "errno", "io-lifetimes", - "itoa", + "itoa 1.0.1", "libc", "linux-raw-sys", "once_cell", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -2544,12 +2883,44 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "security-framework" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.137" @@ -2576,7 +2947,7 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -2635,6 +3006,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "1.3.2" @@ -2651,6 +3031,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3" +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg 1.1.0", +] + [[package]] name = "slice-group-by" version = "0.3.0" @@ -2668,9 +3057,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -2771,7 +3160,7 @@ dependencies = [ "fd-lock", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.45.0", "winx", ] @@ -2895,19 +3284,32 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.18.4" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bfb875c82dc0a4f1f37a30e720dee181a2b3a06a428b0fc6873ea38d6407850" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ - "bytes", + "autocfg 1.1.0", + "bytes 1.1.0", "libc", "memchr", "mio", "num_cpus", + "parking_lot 0.12.1", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", - "winapi", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-buf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.31", ] [[package]] @@ -2921,6 +3323,30 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes 1.1.0", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.9" @@ -2975,6 +3401,12 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "typenum" version = "1.15.0" @@ -3066,6 +3498,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -3092,6 +3530,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -3130,7 +3578,7 @@ dependencies = [ "tempfile", "tracing", "wasi-common", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3148,7 +3596,7 @@ dependencies = [ "tracing", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3167,7 +3615,7 @@ dependencies = [ "hmac", "k256", "p256", - "parking_lot", + "parking_lot 0.11.2", "pqcrypto", "rand_core 0.5.1", "rand_core 0.6.3", @@ -3180,6 +3628,22 @@ dependencies = [ "zeroize", ] +[[package]] +name = "wasi-http" +version = "0.0.1" +dependencies = [ + "anyhow", + "bytes 1.1.0", + "futures 0.3.27", + "http-body 0.1.0", + "http-body-util", + "hyper", + "thiserror", + "tokio", + "tokio-native-tls", + "wasmtime", +] + [[package]] name = "wasi-tokio" version = "8.0.0" @@ -3423,7 +3887,7 @@ dependencies = [ "wasmtime-runtime", "wasmtime-wasi", "wat", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3493,7 +3957,7 @@ dependencies = [ "sha2 0.10.2", "tempfile", "toml", - "windows-sys", + "windows-sys 0.45.0", "zstd", ] @@ -3525,6 +3989,7 @@ dependencies = [ "tempfile", "test-programs", "tokio", + "wasi-http", "wasm-coredump-builder", "wasmparser", "wasmtime", @@ -3542,7 +4007,7 @@ dependencies = [ "wasmtime-wast", "wast 55.0.0", "wat", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3670,7 +4135,7 @@ dependencies = [ "cfg-if", "rustix", "wasmtime-asm-macros", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3746,7 +4211,7 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3764,7 +4229,7 @@ version = "8.0.0" dependencies = [ "cfg-if", "libc", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -3789,7 +4254,7 @@ dependencies = [ "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -4079,6 +4544,21 @@ dependencies = [ "winch-test-macros", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -4153,7 +4633,7 @@ checksum = "129cd8ee937d535e1a239d9d3c9c0525af0454bc0967d9211a251be062513520" dependencies = [ "bitflags", "io-lifetimes", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f2634cffc9d1..be9b4877ce6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ wasmtime-wasi = { workspace = true, features = ["exit"] } wasmtime-wasi-crypto = { workspace = true, optional = true } wasmtime-wasi-nn = { workspace = true, optional = true } wasmtime-wasi-threads = { workspace = true, optional = true } +wasi-http = { workspace = true } clap = { workspace = true, features = ["color", "suggestions", "derive"] } anyhow = { workspace = true } target-lexicon = { workspace = true } @@ -162,6 +163,8 @@ cranelift-fuzzgen = { path = "cranelift/fuzzgen" } cranelift-bforest = { path = "cranelift/bforest", version = "0.95.0" } cranelift = { path = "cranelift/umbrella", version = "0.95.0" } +wasi-http = { path = "crates/wasi-http", version = "=0.0.1" } + winch-codegen = { path = "winch/codegen", version = "=0.6.0" } winch-filetests = { path = "winch/filetests" } winch-test-macros = { path = "winch/test-macros" } diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index cb9f0ef82d15..243587cbf8d8 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -66,6 +66,10 @@ pub const SUPPORTED_WASI_MODULES: &[(&str, &str)] = &[ "experimental-wasi-threads", "enables support for the WASI threading API (experimental), see https://github.com/WebAssembly/wasi-threads", ), + ( + "experimental-wasi-http", + "enables support for the WASI HTTP APIs (experimental), see https://github.com/WebAssembly/wasi-http", + ), ]; fn pick_profiling_strategy(jitdump: bool, vtune: bool) -> Result { @@ -504,6 +508,7 @@ fn parse_wasi_modules(modules: &str) -> Result { "experimental-wasi-crypto" => Ok(wasi_modules.wasi_crypto = enable), "experimental-wasi-nn" => Ok(wasi_modules.wasi_nn = enable), "experimental-wasi-threads" => Ok(wasi_modules.wasi_threads = enable), + "experimental-wasi-http" => Ok(wasi_modules.wasi_http = enable), "default" => bail!("'default' cannot be specified with other WASI modules"), _ => bail!("unsupported WASI module '{}'", module), }; @@ -538,6 +543,9 @@ pub struct WasiModules { /// Enable the experimental wasi-threads implementation. pub wasi_threads: bool, + + /// Enable the experimental wasi-http implementation + pub wasi_http: bool, } impl Default for WasiModules { @@ -547,6 +555,7 @@ impl Default for WasiModules { wasi_crypto: false, wasi_nn: false, wasi_threads: false, + wasi_http: false, } } } @@ -559,6 +568,7 @@ impl WasiModules { wasi_nn: false, wasi_crypto: false, wasi_threads: false, + wasi_http: false, } } } @@ -713,7 +723,8 @@ mod test { wasi_common: true, wasi_crypto: false, wasi_nn: false, - wasi_threads: false + wasi_threads: false, + wasi_http: false, } ); } @@ -727,7 +738,8 @@ mod test { wasi_common: true, wasi_crypto: false, wasi_nn: false, - wasi_threads: false + wasi_threads: false, + wasi_http: false } ); } @@ -745,7 +757,8 @@ mod test { wasi_common: false, wasi_crypto: false, wasi_nn: true, - wasi_threads: false + wasi_threads: false, + wasi_http: false, } ); } @@ -760,7 +773,8 @@ mod test { wasi_common: false, wasi_crypto: false, wasi_nn: false, - wasi_threads: false + wasi_threads: false, + wasi_http: false, } ); } diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml new file mode 100644 index 000000000000..cd0c315f1e55 --- /dev/null +++ b/crates/wasi-http/Cargo.toml @@ -0,0 +1,21 @@ +[package] + name = "wasi-http" + version = "0.0.1" + authors.workspace = true + edition.workspace = true + repository = "https://github.com/WebAssembly/wasi-http" + license = "Apache-2.0 WITH LLVM-exception" + description = "Experimental HTTP library for WebAssembly in Wasmtime" + readme = "readme.md" + +[dependencies] + anyhow = { workspace = true } + bytes = "1.1.0" + hyper = { version = "1.0.0-rc.3", features = ["full"] } + tokio = { version = "1", features = ["full"] } + tokio-native-tls = { version = "0.3.1" } + futures = { version = "0.3.27" } + http-body = "0.1.0-rc.2" + http-body-util = "0.1.0-rc.2" + thiserror = { workspace = true } + wasmtime = { workspace = true, features = ['component-model'] } diff --git a/crates/wasi-http/example/main.c b/crates/wasi-http/example/main.c new file mode 100644 index 000000000000..5085b0c0f56e --- /dev/null +++ b/crates/wasi-http/example/main.c @@ -0,0 +1,117 @@ +#include "proxy.h" +#include + +void http_handle(uint32_t arg, uint32_t arg0) { + +} + +int request(uint8_t method_tag, uint8_t scheme_tag, const char * authority_str, const char* path_str, const char* query_str, const char* body) { + types_tuple2_string_string_t content_type[] = {{ + .f0 = { .ptr = "User-agent", .len = 10 }, + .f1 = { .ptr = "WASI-HTTP/0.0.1", .len = 15}, + }, + { + .f0 = { .ptr = "Content-type", .len = 12 }, + .f1 = { .ptr = "application/json", .len = 16}, + }}; + types_list_tuple2_string_string_t headers_list = { + .ptr = &content_type[0], + .len = 2, + }; + types_fields_t headers = types_new_fields(&headers_list); + types_method_t method = { .tag = method_tag }; + types_scheme_t scheme = { .tag = scheme_tag }; + proxy_string_t path, authority, query; + proxy_string_set(&path, path_str); + proxy_string_set(&authority, authority_str); + proxy_string_set(&query, query_str); + + default_outgoing_http_outgoing_request_t req = types_new_outgoing_request(&method, &path, &query, &scheme, &authority, headers); + default_outgoing_http_future_incoming_response_t res; + + if (req == 0) { + printf("Error creating request\n"); + return 4; + } + if (body != NULL) { + types_outgoing_stream_t ret; + if (!types_outgoing_request_write(req, &ret)) { + printf("Error getting output stream\n"); + return 7; + } + streams_list_u8_t buf = { + .ptr = (uint8_t *) body, + .len = strlen(body), + }; + uint64_t ret_val; + streams_write(ret, &buf, &ret_val, NULL); + } + + res = default_outgoing_http_handle(req, NULL); + if (res == 0) { + printf("Error sending request\n"); + return 5; + } + + types_result_incoming_response_error_t result; + if (!types_future_incoming_response_get(res, &result)) { + printf("failed to get value for incoming request\n"); + return 1; + } + + if (result.is_err) { + printf("response is error!\n"); + return 2; + } + poll_drop_pollable(res); + + types_status_code_t code = types_incoming_response_status(result.val.ok); + printf("STATUS: %d\n", code); + + types_headers_t header_handle = types_incoming_response_headers(result.val.ok); + types_list_tuple2_string_string_t header_list; + types_fields_entries(header_handle, &header_list); + + for (int i = 0; i < header_list.len; i++) { + char name[128]; + char value[128]; + strncpy(name, header_list.ptr[i].f0.ptr, header_list.ptr[i].f0.len); + name[header_list.ptr[i].f0.len] = 0; + strncpy(value, header_list.ptr[i].f1.ptr, header_list.ptr[i].f1.len); + value[header_list.ptr[i].f1.len] = 0; + printf("%s: %s\n", name, value); + } + + + types_incoming_stream_t stream; + if (!types_incoming_response_consume(result.val.ok, &stream)) { + printf("stream is error!\n"); + return 3; + } + + printf("Stream is %d\n", stream); + + int32_t len = 64 * 1024; + streams_tuple2_list_u8_bool_t body_res; + streams_stream_error_t err; + if (!streams_read(stream, len, &body_res, &err)) { + printf("BODY read is error!\n"); + return 6; + } + printf("data from read: %s\n", body_res.f0.ptr); + streams_tuple2_list_u8_bool_free(&body_res); + + + types_drop_outgoing_request(req); + streams_drop_input_stream(stream); + types_drop_incoming_response(result.val.ok); + + return 0; +} + +int main() { + request(TYPES_METHOD_GET, TYPES_SCHEME_HTTPS, "postman-echo.com", "/get", "?some=arg&goes=here", NULL); + request(TYPES_METHOD_POST, TYPES_SCHEME_HTTPS, "postman-echo.com", "/post", "", "{\"foo\": \"bar\"}"); + request(TYPES_METHOD_PUT, TYPES_SCHEME_HTTP, "postman-echo.com", "/put", "", NULL); + return 0; +} \ No newline at end of file diff --git a/crates/wasi-http/example/main.wasm b/crates/wasi-http/example/main.wasm new file mode 100755 index 0000000000000000000000000000000000000000..c565b511dbf979ecafc609940ea4846f5a4b3697 GIT binary patch literal 50300 zcmeI53!Gh7UGMkWd!Lyzb7nFpnMY?5TTnOB4 zaDPlW5235&cX0m(l{EjOlTpuNUc`M26qUKoT!Y~LHeam=ehTi18x0#|kBsu*1@mC| ziMTJGpPQNKo?M)pAJyIXiJ58;w%3;ytK+BZF~28+D1Y4OnoZ5lFE5Sy7R{!Gvx`$p z)gUe`ou9APJ7=qBM^8>wXC~`G!53}tkE7MurNyagJ!tdA{SM~b^3nryQ?n0@E>;(o ztM#QI^tFA0v!=4$R}QSM81*=0kOwksC+1Fj$o2WT**dfHy$7deSJg15@ulT@Q1lIk z);2f=IjW0K)nbAnmQPpn*=;?!ytKSn9bF6Rf$CDw)<0Q2Ilerz)STk6d+xcb?bP_} zBy8vyI6GdS8mrHa&(}}QEsf1DR?kdT&t6kJIXN~lGsjelmuS&Vi<6U@&X~q2T%uV! z&Fah24d)SS%C@ZEf8f zieXr2D;7FSVOO!Ms}PimXoD#PJ>`vE8@h`8hk6wFQHNktTrl&7yT}A#TM?;GFTOu6 zweO4DPFGLQEuIg9wlSu+xD@nvO^lzI8beTLX67b>fs!b=Go#?{j!qM#rWC*6@R2(^ zKk(M@SQwOUHs(TjI6RyNBjICjzj!g|4pJKJ_YdVaU8Jb|e*I2@@{j3igKpDP3WAai z%0H}vp!5gE^j_G>J+0!@CIuVY!gSJR+jhA^+h&9P;UE_P_i+jLhh;9&{;F~`uZHMhFf6xs?jVnS~A zOiw;Jla`av8XHb0k&Uu8ktWw=Bh4eW@kkga1+Zzeg{0lKF_(5*yglgv8;AZvQUaUO zEzH$*>9SoTp^)z`e?aJ!7-NHt?1mZ>>G5Oql#ZLWF9(V8w+j@I3P38cyhBlfO;@Na!Kb=^-Dr!1K@l%t7pSG|+418g`Z7=_h2eB2ta2o zDcRD$7JmR=0{;)h?QN_TgZymZr@@;zeLT2?-EjLBNiR(8-Vg>REW!L90QVdU z%FsfBUaldD8}v>6a(UEyZCSyY$43_?#|IAn)LgRW#t z`bCor+bwo@A=%16+w9h4yWN)Tu-om9TN4XTiM2LaNGf!%9175n-BFP2w0(BxfiOsm z$u4ep)soAo=W@BdT;g|yz06(#251~0MyMMBeN3q43&%uiRYLUH=orKIj4$e=^laY5?#aY5>?N(Wa- zos)!v-ojmn)OCt1C0*jgS;szXLx(NdE-b`rb1CdY^fpKedmusC_SkYm3VRw-xREh8 z9txaT^(C9^rrl8y0mSSbh>D)mvc`QhaRd#LexME5emk&`Y<8U9EKaK%(l`?COAtdl zcpwtLw(yfnB2cy-3U2iL+C~L3X}2#RmTh(i6%PE3E5uWT+e!7#8WOoH<5#7pv}j5> zai5;K75$wh#XgB>?Y4kvdPI~$vm@CgF4CwDXPTlFrpb2nlzzZO-7q!G#|=|^3A?xz z!v;?W0pu1rXIU9Bw(VL2Fq2yu(^*T5q3tMtjbj)EgEES;q8LSSn8vm%Gp1d#{z82N zg&U;uv2?Zv!_y<(v2ZxfjEE=HmoL^|dr7hW$Bt+-vpTt{!N5Z=xb-;u>B*;t^;k~tKFBh0uQReZWZ(F7< z3pE0|(VNFxS&R*~vCsA|Bm)@M0anZOV6vHRn`?;TU^0ZI*@7%?sUd@I#I1I#49+$? zY`1xXvz^=RHDqwBE?7m;J+V7%0^LjMbstu;A}!jPb|ky(PP;4DB5%=~zwOQqo!Is$ zF0{25J33{SE(4p(&~I)p=k{`RoZBn7#gJar)!_|k(T?~wyQ$di+g!=*m1wTLWxV=GbSObg6b9s8MZ}U8EpXb}$$nA}4V=@jL2KCe)wrMRnLfw)5;RwvQ ziQAj#EG~^CH`|-VyIUx{1u(wws68s3xs}3O0SLI!;9znL$vJM1+2aezZO($-CfSLT z+mRoM=<{pI3+xN*?Tg7BJl!FGlp*?(JMEnkgu7tK3+-L@g-t=QcWsEodhz^4^m!4^ zE4O!ZdpAnYtrX!Ntc>Puk{9#zV&CQ^+`h!Oc`3IqRU1F=zT{qzdYQe~zO0tKoVu6G za|)AJaQg~*#~>9a_u2b2?^jazO4%1z_$vD<)s0a&20#sYKlk_V4|l0SIT`0^e1B;5 z)Rmmz=>%@Bo{Gr?PZJn0Z>cAFnxr3dsB&AS6SpV1JxLF4AK>-@nmb-ymz)xieaVzA zS0y!F?oFocw2++fPp9o^VK=L%dy+Xjr@DFnv|txhx2UIGNnID4Ea|c}S=MDRIit(- zle6}$`knJn=k0m*`zk#hOI~eH*(qDIGj`U_+eKTqOLp0wvFGep*;kjp&e{D3!TUj3 zS9%1=L$YWOQ}l2xxnM737VV*)(uYH{JvV!oHu{4YU#wnV+SN4rcx75voMFfOi?q(s zFTXA~_$)WJLn74)gD``(l#7(@Y^>0370?RpAgo#i#3O^PjAbh^Sh1k3jB2or#5L+I z&yq_Yo@JlHnt-mYt2t0M9}0GOz7JB#I&Oy+Fru;DLWKjrBN?VuXy>`~GnpeUpUkP}{Zfbr<(-X$_h;()O*v`r|1#9`nAgN^z;+)B zj(K<+u-`7zP{TVbOEn4cYG_-jVmb^TFIgw`D`@Jd_fFt^CxjHJqVs$#(E`(V<)*he2W! zEesXfRJ2UE!ku=f){b2i?$Szv2WoL~ti23pN{jvoUQTQ;ui@cbk&FOzw;i#&YXpX_ z{~o(XK(C?=9tYA) z-danLh27DJcQ|MW-)^(V>}@sNjS<|9ICnQFxx?O}wdhWJyS-EXXZmrx4O-k)!{K;g z@*;rVZC_;XuHjAq^dNr3J@&;O=u5bLNiBIPc-%{uduwt*2JHLon7zM-Z!j(|`GmdCp75|IxSgmalXhH}s;#R2q@A=U zsh7MROCDfRIAtHOrxubaDPj%KwVD?G%*0OhlzzXxT~UOzRzJ7p_BKqP3@)L$Gk`&J zPYLN$Yjb9|uE?3uwv_4Ksi%|elh+3oSQLG_rH|E6i56np8p`E{B#_W#hwNrMBx00V z4LAFcVo;a$LW<3PJsiwJ3iWp(g{Qu#Re@SNZN=_fNOn2J+?C;S8Ms{LGA_v#;4)&b zup>3pC{|p6YRl8T(q1Wj-vf-R>>hj7LNe-Li~_^AxSFne?bUW~&FhXFHG}gX%lSud zlgj&c*6IWv-fOn@%^onml5=9|7cKLk$`c7KBqD0Atc+SU}~!r zN^ZSek{f}DTkrI~jBXv)_$h@cD(c72bZe0DZ=wS4zAqae_g-nHTYz)a-eQj~B)7Wp zZ*7c!4Bj}ezLwm^{BO6n+1qPg!Q?j^eEQhFz$va=p@y!-(lwXr$dt`H<1eK33#pKQ z^&;+Z>CtaFrFZj$SC4U!Z;B?$vA;o2gD7My#~#BYKkFqt;oC!1S(BIYgnN%QlW})S z>Vq6+`!ecY#t7WLoLfBo!`!}tTRi<6xV?|t`;?K)wAKerucGu-K4==_7GIwj2kgFF9&@=4J?63xJ?3&1Zv6eI_X#_JT378!`#|}doriO1-r`X3z8L4<917m6Yq&prm#(BP9@UlH z#oKfxdGY2L7T~t;jy{49CfEISF}{1zmTF`%x@;$zFV%j~)pn;Bm9i;jse0R;)xO8o z62jT?f#~yiqr0O=UC~C0HXewcjM66~vK>XcsfK~-#TO{b7x-*M0NBrc|NiiaDE(}N zxhi^dwOL7z@^?9=4N*9>Kl}`ttx;x%%__=+|74VYQf@)f4m-<*{~r4^94U|^0gL|* zYh}{u_1+kxRkX>W;NwyH@d#I-Xe%|W*3M)Xy)Lu6oS~xE74~v_h3ho}wOIEbi?CQ^ zGPLktN$z5g9Vx%XIaP#O?~2I?eNa~^1_^6)yM6wx$qTS4caUMYV=S<^j#5aebK(K zhShlyw&pH-cln(ToqOoz7W{?eCG>g;c)W*jCt%GFFefjy_vU!CV^4~*C*Tq0cw`xb zH@n$@*DLHRvdtN#?656wb2W_r%Jj_n|Ey1Bbipiz~&lQJOX_c)}p?7({*?Ds^;DKI|;=6~-fI7RE4BJ~{e0v~aJ2 zXaLkRbU#aC;Os(jj_&8g+|Lo(1<85(f0aFNzbfw^l2s_$S2y~PgrN4IeX#siAtL@g z5+x7Whsy7Ah`C(C_2yqfTina<+O?hwU)6ky~cj8gYj-Rf%nkC zzK8PvX6%16$$O3E|9A8JJ_EVlZ|wVweLo9BpbXLXsqyzw`2k};V3O~5gE8s{^HD#f zQGdYL4;lLdjQU|?sroP-e$dz-WYl8vLwTPc&inj``h3LLA2IeL^!ZU^srpg+{Ft#n zMxUzd+^3js3Vue$herB^CY>g}-d z3Xrq5fSn43+C@LUc*4&m;8as{(v%@{+vVnQzo^^e^=>$XY@Zb_EX0GVFSoT z7W6+-4YHT?{5{><1vGs&MD?P>jm z3jcz_&l>w#ll-NzK=@N*|J>NWH0AGb6Z{{V;9nX0KaBk=CisLV_=G0-I_D?+wI=vK zjs0t5|7QcYw&ZUF`EOb$cr1BRWlvI8PT%Av__s=M{hdnx4jlfMv43mq|7rjM>CdU| zbJYF4v43xpe=znRO!>`1OY_9a|8Haew<$lGm)w_p-q_EZ^4szPnD~#z{-Y^>w@SeD z{|Ms$ad`QaB2NCv$Qk>BD!#x_|7`3(n=DrRCr*$2P-rg8-8MOf#s=0*bF?D#jR5M- zC3tUL{(T|+6q!{{Riqzt*Y@;p-L**54(*AvyJkB%TcP_dTd-XVY^s&mp2r^qi;nX9 zgzXkQtPOzc$-tG<4>>R!)3-UwZ%Qw^=U##7;~Yuf0&yev18lKsQQcJXtN zQKFb;CmF@ zKx1z-El*c6iiU@Ec;{0(yi*Cg1Nkv3cpK~qDv=gFo*vaxBF`laj$AkpzDLj8UcC4S zba^Z|;9I2dAuZO@`Gxe8@BQuf7U~teWCtmw_5SdKzMF0@x?5=syGB70rWYYyz|o{f zkfgYlUZ?>qo?h_f!@gp=Qb>O_`gH{`XCxSJeg z*7xH3! zf2f{jzCZl5a1!bEhmU8sL@bWI9-NJ8DT%MRBu=mQ&j#re=5|Sf!2Ya&RNB)r#l7Mz z*V6G}7!jSR@PC{}3kZn-F?q9Kqs7$JD{X1CREcsj#x}|*%$iYXH zqotISN=x7iZKf9&vYQ12trCNI*O|0TA#+L#XVT(ArOn2R8dg&b&!q7}C0YbIH)V4s z4Ocyz#xsa%@=X~6x)(1^o=~}137V6S&Ms8g{C8y5^xG7=7A?mn-1MPFHf7OJG_8SD zVY=ewiNjeHnmRd%nQ)N_+hTfdA)~y~Vk6-vMUy0QJZev|s_<^9(y`zY==@GOiGM_n&9gO;1;AD{o#hj{kY>rC*Gj#q_z`n z{>oE34VTi-5tIcrk(W_prmypZk;UH2kA*Ir>?l`aXw#PVxpqhf(GSeXTElL5ZKLCr zwqbh4V!&{Ms3dL9`vC5sJ9)=VSEa)SM*+rt5k7NqcINmND2CLM6A+Cc0y>7e^wlbi z59@sw5V@rr_z&2u#e)Iw=%C%P} zWPZUjxVkZLX$|K-M7T6W?dBU(t<#ZT{WB@*`~ zh|-4r?QtateA`mmb4EI_XxkQ@`B{>lru{WyrG>?mEdz35m}Q8cTNZ?E1%ujhCN^jq zi#8bxXFR;ISn-Up$ewE}sKZ()n`I;wEwahPk0+Q|m6a>t49%SwBR|X&S@JTASPnxN zh~Xz@J7f+b38+&`7$X8ARD($fIBvQyA03iq?pMh&qj*_H@VYpUq7Ex%)Cs3#*-NXJ zWwLaYRWk2o87!O*g0h$8A|M;MA&&*Ou&*>%lw#}BGF37_E!GY>%gqh9xe=lfOQbW7 zH20=cCQWO4zI3pVBK(b|L(6Bwgz47NDqnffIFF@UP0@(L3qU0lDo|P2Mc(>?1oZL? zt#deB2er%w4xPbt@H|B47{MXY;9Xk1lL%D5w1d@EYdTn8+Pz}$4JCtlqQ@`b;}jtx z$VStZ_600i0gC_$I0*EE!l5zWFOXTnX1Ntq7=F$@!|Ph5(?%i!J~PX#1HTeL8jwJ7 zj##|V&CqV)2{lvao+YuV9Hn0cBEFh!hi;T{)?>QCb(VC; z4lJ%mQ?!kffZ@b758VTC#|Ka_S4pS#X#@9tRVbMhDh9Y^nkhS{BLB{ML7A_fY?cj^ghS0HbCu;zuJK}n7{RL}$`FK+$} z`FRNs^8#n8+!K@Y|J2ckA1>Nxh=@j#h`K;SfHeE%u#V%V5gUD-tq=oI3fm)vVo&~;5KJYMtrm(-iN3N zCR?EiW)`(!ms_l zd*%lq(4IfIZ-l?{EIlA;8ga%#YJen$b1F*2br6u`AzpBFix81V zflKDl(AX}nAja!x#&`%A#_{MDe#3uWFmO?Z7HN8O&e;v;05O_OryG)m2mczB)P?@? zNt}SR%O@ca#89X$zDDE8SwH7YMRJS0TheIi9B?3IK9$U%xXM{ORuhkehTe)SH#}Ge z+EKX=C<``w;oWtV61lPmklab%LQ z`?3nAsEIRsfzWYE*oK!!Y6=m8X9=q&!jnEsB#q0IGqouv3>0S^lslb=ht5rJ@JU)r zGX;k%+|o64pb;EKF8||?&1t#G!@(?E2S0_1$Wl@3&kltE8nZR#a1ll`=Ex(AX3WvH zRKaw&#vFl*IS`da8xV6u`0WfGwZ<3Me6TNq~_-^x%QQ&RA|uso-Pd$>7&u6gBvY;Y2)*D!I9og%7=jC(3MCc%kp@rSvI1&|+hbySz~?O>4M$ z#PX;HiJOje=cUYXZeActo-=Z;eH!czU$2!=JGp4dZohsW2uYvvT*SV+YM$0#W)WJq zlG1n=avMo7Xc=&E&bSsCmu`^X1g@f{7iEX|bVZ6O;cp~5f=rm9R704tpq|-2XC+|{ zoG=HuFb54`R$Px3%AHUU z#idJ*BJB`nRse)K_QFgkBVq1;#n#@eRY{+2eG_ z4JYDhROt?oi7X}CypNPAmMpE*j2^ksP>MqtCAq6v7a{CfgUR<@+?)hmb_U-rTO0-7 zxt9%BQUMy)O95K8)CTP?Mi9)ThieKES;N)}Vsvs{zt3u`% zxK#n;?^2r;?0jQE;FU=hgis4Y$C?EJozsGV^t%+1EE5QGY%w$XioQj3#bhv%HG%4E z&_Ph7ZHfsvb*lYuh7+BkTA)t4iXuNmv8 znY;n=N4c6Q(Dn&M7N&-pAqsxo_7hT$6a2flI7z`1^J<2tk*OIBd3tJw9mE0cCms;hT()vhP%ikk)U2ey9!E1+CoFW zA|F+uUrM57`c+t=Uj?sU&iu6wD5_~(4VWnlk5U$ojaL@eLrtMG8CzLuw}yxQ1!5;L zz*+6%G^Lp=Cc-2iCzs|HS>{b+WSO_o*cy;5`^L_>;eA6d%g(uS^6E09l4Y9Vz({-> zvMj;QW!Y7?$}-~7D$7h}tt_*WIzK&=WkuUQ*@Ing$nsO=#=T58GUG(}&i(P$^b)yo zC%oR_VOq|-x!JiCD6)|!#gXnTqoiO>DL(dCYr9BmTx2q(PB>8hem#`_q??m+FemT| zeyihBQREP#vf|~QHLb9!BdFZxYjOCw58M37(gP4WG#|hFyvLOjpixH`C2;ork z9A?WW9c7z=bVfTm4R5~9dGk6OKm-%7@#YInZyv2C;KQ4zofH9J2%?-Adh@cXW2FPc z>#XwT-H5evWoClF!(;lmjRbay zy}&a>xuT`QPp<4iBk)x8slvDvwTP4rt9Pl~Mi#q!#9ayik@(R2KPVov@If20P}376 zL@J!s?g6e(ifbnf0H(1Q7qUa;SRIM=ZmDx@)RE~mp(R;C0Q)er0lYSBt8k(mbITwJ|kgYyEM@CvV!9oIGmg1I8FdXc4H^DGqeiICx zTVmv})wz)I)972R@y-Rx*zn;S?voEm6{Rq&d?#!tn4@Q~Nz0cHNpVBuXPA6enxke- zJNyiW$BPfW7Y|ZcPQU3%y2JTeQ(l__IQ_4AYV6syOMyC$ITec}vAPnCuuDL1nk&u8MQbRVO$71C5yHo=W(X^sIafB%WR3;lK>W1J15QwYebe^ z&N<;*Kv}BM_i^5MQD2H^q#8M#3ouO%4LgiC79vt0K^I^REa|=#h#opt? zckZ0aEH4XF2p1&@Ety3t8=X0l0Sz525`0f zwK&JbG%Zetiw1M&SP7uq>0owQs@vt;lF!M=hI$j&4STdUpG0i1XzRx8j($6%LNw5>P>&PSo zUWZaLmB7wLmD?_s%TS`~hWt{Z8p{638>vLQW|@{bu}eNm+%+m%@@s?Gt;jOY47BL6s-SZCSt4Vwm^#c?md zGQ1{_(qVm`ePdT8JltR<(JU6&`Ny(qz{fLVQFeT`QDWQ*j*KMm)5t$l?v#r%R?-L! z$dmJr0j(i3|Cock9EL>fS`LY^ck(p-V+^79k1@APjJ$fo#*N-czO`=H;2&#xP4AdN zo!@}-gI!>X$RSho-Z2xFcZ}xyIcbKF7D}((uaS(cagNDJ2s`H-3s=l!i*pROGv}CP zNLHzJJP}XBG9I9DAM_;OScS3<9y1Wk$y_S+(53t>TCX5$;_HY?hV;?c4Mml;VJ2cLd>Kxz;zbxw+(AML&*KnDoN)T|$7WGl$uS(vc95Y&zT* zn27I}f9VhxWkXQ@Q4LW3CH*d4&j%lOatHn#ArE)CTRFf?GW|Gj7&`3BKdTlAwi?CH z+L+R3jVa*zgQ3?hjn1AzSpH?Th7BraCzA$v-_owj14m_yu%jYfsG% zr@=7?iltOXJ(4Iwjup#`u~p>o2H3O8!zl;z>#q_q}2I> zyf#kEl0&E@HCpEL64#fp3)0-Y&1JfqJS{;hpGsbatdG}M1g{%0EbL#cr5C%eg-W|0S2R}9D=Qz-odO7d$11A=#S;8WKM~x{CuNq>$9cmf zsO>dD`j}p{z{)ac`IC~H(t^pqye5&1ytr{nHuj>HUbszkPq*d=++3c~$rBvzs+E68 zP+ZQAK?z{oF*xcBQfb%CA%0FW9dIR8m1S-Ye-51 zwD~91!ZdC<>}*0J;Tm(mbclW^ifkwZA~nItLaBfF5-KW`VGAD&uR2DK%J2~m(dby{gyMY=BEJ?09E63jBIp(cKLsf$f^Mp zFZXj@As_l21gz64KY}F7E~rOYN1iSyk&;^>=eJx6Ey8*R=3OHuU<(Qz8HRZPDL0p# z%F)OmpdfpsfrqRGLwa$A;OeV;E3i01n$rP#!lmufR4aJ#n-!d?9?; zJXqxW+S#J>BxlPCS&KsYvmEy9a)u8WPX@JVUf?gJPw=4<9d|!aW8=CYLZ=VcdBe-M z=Usf6LzNa6^{$t@?O5akgJ*n`Y2M2BZTSdo54Q*TMi2Dc$j>HzdOiK4!&WbO@kLho zOkZrT-^QB3Q%&CsUj5JZVRkFMB4A%)q}uvt^`h8-r`FlqLlU^pD zyVvV9U*xJ$PkG2IWxc6FYd!%m;2IGs;rJx|C0;V?o31qRs`TI1O~xbJRss*mEj&Or zDF1|nZ%fJccFSu5d@s_$$2+aLDlnD7^sZWEAnnkmvSHM8m#jJtr@lNu3%$Fh&m<2d zn#;kb+bj43YA4#+p~Ym#4pe%tf-+eztD~h^vzE>> zH4gNZ4DSgCcEZhg+(Z$N8~!gjlv>&;8`djCA(R?NOY8-v7a!7Yn)~?ZM%nj`oc8tO zi9lK?9GkcBO+*7!?4+_ebfiJaZjo8W*RWfr`GCSudhxM<$>^vEO&q2kHy!2e zO$M?G$J8z9C*JbmKMzEn3&81|sSMyZK#qY-jBXzWq)<*gDJlb^wV!OKR%LKF*1bXJ zBz!9vMhC~cmUcl`x8wm4a^0c4@o%zpi$ z_y#z*bi$zf2IVykx?F=OZ!ox~LD@Bk^9FWJgFe@wkT)1v(}4999NO{*`_?qr>Ke4? z4GykpU|j=N3_pv<|oyJ+TQOlr)UXe3ZlTpeXH>4?@v*G#9^ zoi>qrgMtH6ysM?m11?`W3<4_lYSs{Jp2HTwrdPC%U=J`D;^7*v5Nx-bxDj7q0OR0{ zwijwwo(Z%%OFIT6&}3f*@$%9gXA)sVKS>IRIo02qcIa3QU+QHp*;gO8S(6Mzhmktv z6t}gC^EQdI;nQKfkm@2ytRmt(D1r>Tsq#@Ijeyx2u!DSHY^&zFHASvbap;M%$gW^2 z)34zb(4&%fXO?7I2hu|`weUPw@bnzW$_j%vOpq6EXvTJlZ`sBLzE0W8`qi{QR$ zh({Cgh&RM{uMR{9v6(dVB-+%qK??&S)0+!~vQL|(>Pl{-Mr_P;j$#N!ef2_R8!zEH z&1db}E*3xaKc;b^=4Upxz!1GUz|H=g<~3Z|k$&_-ZNtIxrtVGUa(Pqpzb@TI`Ez+w zv7q__1sx_1H*M1-`IA7+36FS|7_vpH8Xmkk>JwC&Z#p;Y**j?-tP>y;3om9A&Zb)XP{ks3XhVZn-U@6_FP61Lx|%n5E>e?zt8V=S z7!6lp>o6;=c*%4z%@@lr2eeHRM>W)UCAnzSd9jil>3sO1cQ@uFXXWii6Qi3WSIH*t zc1}o>43f{zS(g6Jndz)&FH5Z!Y&s4}Tft#i{NnBPW8IrXbEyR%k{=#UwlxTRBzO_i z(pS<3J*h#lS0>aG&GG>|Toq5XAy>z$#U2#$a6@pQRjQ%Q5K&2=Yot#okN8ln{8L(^ z5E`a0LBuS)|LZBSy~7Eg2-62m2mR8TU)eJF4fUxE$=zvH98BSD-R*L)Q1y0JPzRAQ z2bKK>aTiMC?Yh&t;P^Z;Jvx1+Gq4BUH9=No@nkRfYFv02qVkpgpu$(EWmh@iRkH)- z-*X7y3>~XLO}^F$38v*{@tryOc!L!2ZfEc9ymutWZm1iYf$Xtvy^sd6FFwXQn(E5h zPhtnSIKZjZ<8-B;eNZ5=8Cn?_ER!IM4OUI5=lzqy9!zb886y-kPBAM#=@q{6)}(^W?u0tK(ziIBzHE)Q``WiP zYSXtnjeo0tdyU^YoLpvi-jeLn(3Q8`9Jv3Uyf6V-cFMm+#GE+jfCPy4XTrcY6eJA& zL;?~9{dyY0K(7_TKsSUzVG6RjS{UG8O9%lPid$*yBnzY)ymb{xuV&zD(@(l-zR~Ha zEPbVSIQ?r^_FpsIwR~Is#BdrlfHcKk?zWeT|Fp>>rO?)HX-I`q_QV7kmv&TVn%D+V&(GmkKNmacovQ4quuQ(f4;-n)?r*H^~x+96r5l! zr2C2%`8Xd;-{H@PYJz3NfDGjK~17U!&;Qg=;QbjLq_^3}n^HEo$O=5;vzxwz#zoGp@YLa5_{= zJ7(n-@5bo`Raw^#u)Q&c2t(NlnKlr+CD9_tR~_@uZ$#2@seZ*y(sWi8NN+=i~L-setG)m zmG7H(q zes}MT7Soi|KKLInU9^-;Fbl_T`IWAM?;XNory1Ma>^0Zf%H_6SLkqU;WlMocGwsXW zA%aYS4&THAz+e(kUK8d|mpEzLh8$|0)tOAgU&?ZJTWw2Ozfa$oYhZr!`5WCR!&y0x zg8(*XD!Yjj2JLQ6K<#1lU0`#WK#$4_?s;pn$7-=DF*3Ar;v8T;_dIGVGCC^N5{&rJ zIYU&`;!jQ3EBO+y7H_#7TEkouJ0OYhisTAq1f)0!fs`en`GfRBl)m_F%vx)MgOCtT z{3`^BD3ah=;)0|SDj?rDVKqB4EddaAXhts)*T4&4g<)7Xx+q-XbJ$*=9b>kFx19fE zx6ICvBHIgyrNJr13Jl#w(W`G;sPq$d@uxpX13zrJ-=RPAp>CDk2-sO=_?)|{0VE59 z-pRpFO*`jlfqbFPBr3E%%P1nm`s$yz=5Ui|IDm7!$Ny9Z7n1||H?!!J4`;d15J5-IBH z@K7AXA~@D-p<|u#RsoYSfRQKRj;1hc{%(YlH2ox~((qWf`*2HtTI7tm#J@v{Av=T} zl@qh?P;js9auVu6fTjn9_#lM6S!pjXHufSr6GH_J()aQyx8CWdFNr2&aR%*X z(pzH1E-kT*=IMLogkm*XA{~eMHkr*_V`NvfrupZbY}ONv@@~k{?foAvdR(JBtY8h@ z84v+kjD48h2LTmkGbJ}+ePkiOCv1`vvM(pb`cv))zYhHz8*a{nXN-~znVbGL<=bg; zn>dG`iTKOO2Q+Bl_wW^nUyv{B64=cxR2}kdrZ6lKz1>bSkH4!Vs{!X(F}WGUw()Jc zhISSt*?eCZdDvnHoZ(|@f+M`xe;3YfgKE@?sChVx>$W1C-QJ?C==N7SoNb5zIL6(eIO`NY-G9nuSjmT9L5rs>5p!l|O!4Pm=@Fw`3TeVC%{cOCchX?X2x-l)e*x+pRvbmMKmg-jQT)FnzTTL+I4f zy4mmFa>tmxiei-B)?k~pw0Zv@=ilym$D>35nu7ED_q>B}zzLztHw;N$wOi42=P=-2 z{@FukMNdl&`ESknw#t9&qVDBC>&gy%Q~vL?CAsfAd2IrbQfkMoX?S+qc+x zE1Wy$vU7?^UV>jH{Vsbm;q~csLW5S`>wHrjr;8WQX|J1rVaD8kv|Q8wFa*7|ZAll4eOh{9tSr8_H1b>i!;+oSKgjC*{v6y2EWc0K|q3Bx|efk|qUqQ|ZI8GmkPFPyLUL%(Jx(n>GgQ zKStT#v+U~L&{GEFsv{GDHP?mgv-8gFfC3{`7vg*r1X4Uk+WZy5@pm9>=%Od+)uzRB5IbvD);}Q)*khNST zE`-{p(s!BWX}*iRJXi4Igl=+vSur;+Q?gGb{j^49`hw3zy}_Z~h&Z!uNk|9YOIc;! zLbYt_6@6GmvKJrZnKbkdcrESp&C^V*OIw5VkMv#h^l|MOmw!eR+LE7cE(YnR++ow# z>eyd+xcrN%R>-S_l1D~oTPYfpBS-dz)t)Dt9TeUoOUW}wXLKo6-1`wwpI6%6pSrSL z8^78Sk?nI@T<5<2LoaP!ep+L@p*)nQ9O!8e<6(cqeR)^Y_{zh6OsBlR;&_+ta|bjv z&l?cr3mm%PXzL9g{XqKdHYOmhKl7Tp)9M^93^{MFUY9dwk=;u7d9Zk;nWW|AYGqO#NWS4LnULmE2p~<_|znN(G)i; zl+fgsSLo+9H!NLGP5K&v;!g|+xJ3Ffw~^T$XhY=x*Xq6vRY3X%Q80ilh zp=xQOw1lhtLWvu9@ZWuefHFB;sF5^BM0Jm8lyx{1P^ChHNoD#Dt!?1%u9dj?cVI-%$|C?Z+2<- zoWht%oXe_1eDJ*CP@|!~7DPjQL|w}M(nYuVMz@*9-KoaiWDbheE?!6n7yV~4tl&o9 zcSOore%PIK#?cESh-upnM1%g~zTUv!I`>bI5#A*_>D4&lC^J<0i*^&c_Zl28EO7=+ z{M&`@gAY8yS5J6SJlHBlayqC8S$K^Q!N!8=muu;`!S^40OVDyh8rN$XihUt`b1>No zR?BF;meHXgq9s{#jm}1gT5>7qKm()N@C%)RlN=kWiR#^p2~0_^R_A{i02wH2YanvM zO=SfAVQpC^o|v4!XQyw3xw|6Y2ct7@9x7Ppf;i|qb+mTWcjR8TkKmN`Avae$c!0Cz zu}CjCT!14EgzmLe7Yv1&b!bAn}LYT;r34`N8J^gvUNb45{L_-3ph(!pcUur^{)cQk{Cw%Ts| zj*zz{2(b~Zf-WZAAc;&js3jlv-oQtcpqmFHF;Y*C9R`5m)q5TawcR)(q2{~MgW+P* zZU?4YEdkR5n2>pb9b9w_(}@0@BT%v_X_&z54;F^FSqydNBrY)k|g>MBMB=t0@zWToZV#CS0;6p4F6PtPaI$HR0l> z<36RLVLV-==v&+ph0!zR-4>HO^7dnpMy8_WlW zhjYB{7J6s5uoyeY%tdu3uZeRO5amU&u+BPzUE$z#oiV=n&;N9`#@`2F!8wQM$p=&f z5Q)jF2X{M^z|l@DV5k;_WRn>y9|!@9WSP~O3w#x!VUF7>NB<*OU+~)t*^7Iu#=j{^ z;2nt4--mdS^novtWI+E!LdO`b#(HE}ptDZOS&*643>mn|Q>Gz~%IfO^s=jiEIWYC0^z7WE#ErddA3!T*ftyd!y%*+<$iyw4;BR7X>`om-a$Nuo_)Un2Mau-0*^nBSzQu&*VdFkD^OKeE$aSxKH#5~2*1y;TNkV5@`JLx~ zU0#ooodr?uAg_4xrgy?5cb+Q&HD`d*!#>qOGr7&LIp-cjcUp<<^{=~l;kE8;E)0C~ z#z#KtKSojd<;@(QxL7Pb-v8>#$+@}8AzL{yzF2uE7~Ny7-FNT4bHV7od-v?Sm;2Fu z=l1M7XDQk{zr4h+x%yJ@;(B#)bo_zpECml#mxA&6`I)JS@ujJ`*}b*;+-xvAJ{zdz z>G9do>cpwJt0(482UD{rgB$B}r>oB$Uwq*52j;5v=boxAR)d@7W|sgpx^#ZN8r+fI z5gfncXzI_bfPt8;(?b4hDBYS3iW|=?lNXw~N#$M6VL#S70Cs!0-RzGAft9J&I<4fcArO*h>y&(F^-E;&5F<@C7k zKQjm7lXJ@_W~v_1x;jrRFD^ocne%pXsysp@2K=X`b1 ziIwZe!|AD|CCcxZv-RbPQ}!f0w=j8fYOy-8G`D!ZQ8T|d=P)~}7S(f8^`(075+@W( zbNppaB+!e8`_Ynu(@Mu)xk&tBWn9TbeozdI;^x#wVBS zQ1TdBDyA>bBFqz~9CGR8B(M<5SxcMX$l}~|b=J;Lp`OS0-kI?;XF-NGOh7!KdJY8G(pfR>o)RAdsZeqH1gobcU!hcoTvvbP;pPRrq zU}whBF0Vinb7#;Dsn1=D$j#hx-Oinztx6MCs0~J9qKYXAjxNu7DN+Ba)AKV`(bB8Z zX}E?pmy|O#gbXt(TYMZXT$(yL1=vNT{|v34FY9t@ylziap=V0Q!e5s$4^T&1))*tR4AKKkT+a8#vRqAvvZ5nQk+TX9^}uhTC|>K&ia0> zia36P6~f_%0-QVvt-Td$PUvn&JdHKsm7UgEnXqaWHm&9OjMlF6(qIJh0jHMD+SXEp z3L$l3eTo$WfqLQc91CFe+(flHDYjs>r%uhyTNW>w9ExrlpC3OlH8Zs|<+P^`+EWu# zQq3S(4(|wl$NWkBqw%2m=E7fx1M%Ml-yWIhVB!1CYs{U|-gtZPTZMN9o1*Q}$IKr_ z#o+ygz)XgJYpR9o!qGkN>pr_VDxZ)9Ko&)YSwT1NB#dUfM|b@*a_x7O$F{8bBY{+|}*Sigb}U(D~;`n;XL zZfbelsC)OT!x!_L|F=-OWs82V|KEywN4)jhHA?#$cR{dO_wHARFXne^eM?hr2U;Hc zb?<(4_+ozZ|GsOkeb#l)-hbfWbJ8O>-F(YYc2~BQo-i42U4PR8CBF^1iTL@Hn}1#^ z&iVgzG__g!rSBfk*!-o&#cOioeqQ71A^R`KQLfgP^WQOX{>dBraQATOP(bHHA428N zoezWP?9@`h-TU9cc>Q!&V1o81Hj?)?M?!NxF3!)*c#i~nM6sUw=Es*#9m3I{nQ8ti z1R)I?t<8~Q7!ePy>~9u>xXU}7qt4r8vKpk@JItfLio%$}uBlm^=w?}4)b8u+gC2pY zxxHCIel3I`VODfh!AkJv$gEI{)(pT5LKCk=2B52F5}Q}Yr8>*)a(#4SZn6r>ZDt{g z6^~#!bh(@B9RBvAsRwaeec}}BDb0$^Y$N8@dDx?x_xR%YX(~F+^m(%wZOW|msGKsY zM^D$g`cFa-f!`hX0PcY~LYgK`BVp4h z&e5WEnTm2tg^Qsm-((g#BSmyUe2N8xi;MSyNU>kgHi;{-R1JdmY!=+*7zBl-MVx1- z0{13Pt)R~7>e8vXNx=8TJ$X3RMA8V!MsW+0n}uXcMULbU<%1`emzEc+qb=2*=8Q5- zeH&iO%%ljjEiQr?p4g(Ew#V(7SoUBR;?k7CDGXJBP_&KD=Y6l_3&oNwbLnv(MJ zZ1vncK6iDpQ5F|+c~8t?lMTMz1aWC{ac+JzL&oehb78%1=6BJk9d%t~0lf^II%lhA z8;veE^L2AL%z?ymVC%sZai@neD)yKWb2wVrqToW_D;P6xNHh?b-D^P6qB{eX@zY#+ z3260}w#4{E%z@d{GQr@octZv%n@wP@YOUWMcV+bxgsRoRjGE~kG%)pn;Ocnbw{=fz?8Yz{Z1X8t0;K4w#x52v)Q|xK4Z2yiUv&;7c8DYxC3Yk2R@!!A+o^ zS-xj?H1MeB3TA`exKDz;mc)k`zNdBg-r)LpV0F9Ev&@UZZvf9?ZWl@t1;^pMq-kZ% zbAh|ju*Dk)c%#qrf*a$0v|)6eE{9ti4mN(7uAQ z+0x)wm%!Y#vaOAW)(kz`VB5_r8y{S+af4^KphT^USbLK(8{_^}jLA_y+B(8UxUzZ8 z{BpM3N>g)kD}>nQjohUyvN;A@24TzeFN!Vn34SSvw_eJEdjofS*0K;+6y~!GF3pWz zs!L#=9~TrJ*30wL4;dNzoHXS|^Q zcrPfrq&niUhihC<6|Qz_Rdz`?&m8HHe7CLZ#X3*FeLXMP`TE7D^d4g~9bq|hkHX|0 zZd*`@+p-i1S%&5meA(jV&bl+p@#&EfaXspK2s*<8psOKYaXXjOCbX!mUGjALyQ z1g0dGsZH0KHr;VtpPrfz%!Zr@B*x>R`tk{Fkewi3HAnQ`lE*VWjfPNbV-||HHYhXD z+2%lnh+U6jurV%V(cY#U&4NdBW8CFxM!%}M$dQ4-^ulpBk3v*moX95AO%6_H5C|9h zngCP}=yvuKksYSmpJRuR#amWPgN3>k&4ETs=CR4mV^xdIPa|Q;YbimrI$;^Do3Jdb zpRjDZM8Yy!k$Qb5VfjqLQpY=+Cqr`SR7RE|DXs-2zf!Jd#~OgtxCp!R(qL)w^fDw-|77*#IEP1?`G4)3 zKHW4)$x)#ZrL<6CZ7h{VU|lVNQZr0;Q|(@VQ#Qm^Y$SS~DgtvmzaI4lN_pt8x}dNj z_WSKV7wtCS_qyNg_>XpQH@Q5)2BhiYR%aC1M?7)fbhBH}W^=ZYU)Xo`{;T&Xb?tik z)U~^f+JfLmd)%&|`G%hR0y{Q#mW}-}&UA5*XiVY9nA}x&rxRjk%gPqnruvwi|L}_S z>l^^**pK<<(eU~WoogO%Us>tW?_=yRjQP#KLS?;rUpJO*9JcLVuZ_baPoaUaTh7`? z)@!QaR<|r(xn9fFt;XCWI@WEQ5yBrK1_8fM(s|W-aC1RuG=p|JLQoogdabi1mUCrqL(+8c zuzL2Iv6GWy?C#d9<-Jd!FLd~odKVzoM$odU0qEiH4V^4hVy z^2FTSjB7Dec4{jN8ci{E`ha;lHBd zAv~41k8FJ^0pC58@t-ptvY#!oe`TrVVNbqJT-7r+#)doDqw$$Boo^p4PR^WmB64*s zk=WZdIiu@7dbr|ix;fC#IhyL&#Hr=k>1zStG%44cXZ1A;n#ytAhGwZW;MpzR9P9U& zvjz=WK2UInNe{;L6N}T&DNHV(K7Ibs3i+Otd|%(@ULZJmL&wB`IXbW`CZ$&>oc#WN>8>|09yIyN!4SUuW4 z&w9ie=v$-t@yTODdTU|KzqK&N3D&X3$=l&r``L*_-Mpdzx6jSDZ!!TaLb4~O zS$layqq^9!ksX|?S@3zK#1yX9CAj>O9su(ipM9Y1nrHLE%Yk5f4>kxRId+maUC5!< R&7RVU<(X-MIlYMRe*q~y-1`6k literal 0 HcmV?d00001 diff --git a/crates/wasi-http/example/proxy.c b/crates/wasi-http/example/proxy.c new file mode 100644 index 000000000000..a6555102af98 --- /dev/null +++ b/crates/wasi-http/example/proxy.c @@ -0,0 +1,1211 @@ +#include "proxy.h" + + +typedef struct { + bool is_err; + union { + streams_tuple2_list_u8_bool_t ok; + } val; +} streams_result_tuple2_list_u8_bool_stream_error_t; + +typedef struct { + bool is_err; + union { + streams_tuple2_u64_bool_t ok; + } val; +} streams_result_tuple2_u64_bool_stream_error_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + } val; +} streams_result_u64_stream_error_t; + +typedef struct { + bool is_some; + types_trailers_t val; +} types_option_trailers_t; + +typedef struct { + bool is_some; + types_scheme_t val; +} types_option_scheme_t; + +typedef struct { + bool is_err; + union { + types_incoming_stream_t ok; + } val; +} types_result_incoming_stream_void_t; + +typedef struct { + bool is_err; + union { + types_outgoing_stream_t ok; + } val; +} types_result_outgoing_stream_void_t; + +typedef struct { + bool is_err; + union { + } val; +} types_result_void_void_t; + +typedef struct { + bool is_some; + types_result_incoming_response_error_t val; +} types_option_result_incoming_response_error_t; + +typedef struct { + bool is_some; + default_outgoing_http_request_options_t val; +} default_outgoing_http_option_request_options_t; + +__attribute__((import_module("random"), import_name("get-random-bytes"))) +void __wasm_import_random_get_random_bytes(int64_t, int32_t); + +__attribute__((import_module("random"), import_name("get-random-u64"))) +int64_t __wasm_import_random_get_random_u64(void); + +__attribute__((import_module("random"), import_name("insecure-random"))) +void __wasm_import_random_insecure_random(int32_t); + +__attribute__((import_module("console"), import_name("log"))) +void __wasm_import_console_log(int32_t, int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("poll"), import_name("drop-pollable"))) +void __wasm_import_poll_drop_pollable(int32_t); + +__attribute__((import_module("poll"), import_name("poll-oneoff"))) +void __wasm_import_poll_poll_oneoff(int32_t, int32_t, int32_t); + +__attribute__((import_module("streams"), import_name("read"))) +void __wasm_import_streams_read(int32_t, int64_t, int32_t); + +__attribute__((import_module("streams"), import_name("skip"))) +void __wasm_import_streams_skip(int32_t, int64_t, int32_t); + +__attribute__((import_module("streams"), import_name("subscribe-to-input-stream"))) +int32_t __wasm_import_streams_subscribe_to_input_stream(int32_t); + +__attribute__((import_module("streams"), import_name("drop-input-stream"))) +void __wasm_import_streams_drop_input_stream(int32_t); + +__attribute__((import_module("streams"), import_name("write"))) +void __wasm_import_streams_write(int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("streams"), import_name("write-zeroes"))) +void __wasm_import_streams_write_zeroes(int32_t, int64_t, int32_t); + +__attribute__((import_module("streams"), import_name("splice"))) +void __wasm_import_streams_splice(int32_t, int32_t, int64_t, int32_t); + +__attribute__((import_module("streams"), import_name("forward"))) +void __wasm_import_streams_forward(int32_t, int32_t, int32_t); + +__attribute__((import_module("streams"), import_name("subscribe-to-output-stream"))) +int32_t __wasm_import_streams_subscribe_to_output_stream(int32_t); + +__attribute__((import_module("streams"), import_name("drop-output-stream"))) +void __wasm_import_streams_drop_output_stream(int32_t); + +__attribute__((import_module("types"), import_name("drop-fields"))) +void __wasm_import_types_drop_fields(int32_t); + +__attribute__((import_module("types"), import_name("new-fields"))) +int32_t __wasm_import_types_new_fields(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-get"))) +void __wasm_import_types_fields_get(int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-set"))) +void __wasm_import_types_fields_set(int32_t, int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-delete"))) +void __wasm_import_types_fields_delete(int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-append"))) +void __wasm_import_types_fields_append(int32_t, int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-entries"))) +void __wasm_import_types_fields_entries(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("fields-clone"))) +int32_t __wasm_import_types_fields_clone(int32_t); + +__attribute__((import_module("types"), import_name("finish-incoming-stream"))) +void __wasm_import_types_finish_incoming_stream(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("finish-outgoing-stream"))) +void __wasm_import_types_finish_outgoing_stream(int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("drop-incoming-request"))) +void __wasm_import_types_drop_incoming_request(int32_t); + +__attribute__((import_module("types"), import_name("drop-outgoing-request"))) +void __wasm_import_types_drop_outgoing_request(int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-method"))) +void __wasm_import_types_incoming_request_method(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-path"))) +void __wasm_import_types_incoming_request_path(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-query"))) +void __wasm_import_types_incoming_request_query(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-scheme"))) +void __wasm_import_types_incoming_request_scheme(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-authority"))) +void __wasm_import_types_incoming_request_authority(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-headers"))) +int32_t __wasm_import_types_incoming_request_headers(int32_t); + +__attribute__((import_module("types"), import_name("incoming-request-consume"))) +void __wasm_import_types_incoming_request_consume(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("new-outgoing-request"))) +int32_t __wasm_import_types_new_outgoing_request(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); + +__attribute__((import_module("types"), import_name("outgoing-request-write"))) +void __wasm_import_types_outgoing_request_write(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("drop-response-outparam"))) +void __wasm_import_types_drop_response_outparam(int32_t); + +__attribute__((import_module("types"), import_name("set-response-outparam"))) +int32_t __wasm_import_types_set_response_outparam(int32_t, int32_t, int32_t, int32_t); + +__attribute__((import_module("types"), import_name("drop-incoming-response"))) +void __wasm_import_types_drop_incoming_response(int32_t); + +__attribute__((import_module("types"), import_name("drop-outgoing-response"))) +void __wasm_import_types_drop_outgoing_response(int32_t); + +__attribute__((import_module("types"), import_name("incoming-response-status"))) +int32_t __wasm_import_types_incoming_response_status(int32_t); + +__attribute__((import_module("types"), import_name("incoming-response-headers"))) +int32_t __wasm_import_types_incoming_response_headers(int32_t); + +__attribute__((import_module("types"), import_name("incoming-response-consume"))) +void __wasm_import_types_incoming_response_consume(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("new-outgoing-response"))) +int32_t __wasm_import_types_new_outgoing_response(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("outgoing-response-write"))) +void __wasm_import_types_outgoing_response_write(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("drop-future-incoming-response"))) +void __wasm_import_types_drop_future_incoming_response(int32_t); + +__attribute__((import_module("types"), import_name("future-incoming-response-get"))) +void __wasm_import_types_future_incoming_response_get(int32_t, int32_t); + +__attribute__((import_module("types"), import_name("listen-to-future-incoming-response"))) +int32_t __wasm_import_types_listen_to_future_incoming_response(int32_t); + +__attribute__((import_module("default-outgoing-HTTP"), import_name("handle"))) +int32_t __wasm_import_default_outgoing_http_handle(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t); + +__attribute__((weak, export_name("cabi_realloc"))) +void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { + if (new_size == 0) return (void*) align; + void *ret = realloc(ptr, new_size); + if (!ret) abort(); + return ret; +} + +// Helper Functions + +void random_list_u8_free(random_list_u8_t *ptr) { + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void poll_list_pollable_free(poll_list_pollable_t *ptr) { + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void poll_list_u8_free(poll_list_u8_t *ptr) { + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void streams_list_u8_free(streams_list_u8_t *ptr) { + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void streams_tuple2_list_u8_bool_free(streams_tuple2_list_u8_bool_t *ptr) { + streams_list_u8_free(&ptr->f0); +} + +void types_scheme_free(types_scheme_t *ptr) { + switch ((int32_t) ptr->tag) { + case 2: { + proxy_string_free(&ptr->val.other); + break; + } + } +} + +void types_method_free(types_method_t *ptr) { + switch ((int32_t) ptr->tag) { + case 9: { + proxy_string_free(&ptr->val.other); + break; + } + } +} + +void types_error_free(types_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + proxy_string_free(&ptr->val.invalid_url); + break; + } + case 1: { + proxy_string_free(&ptr->val.timeout_error); + break; + } + case 2: { + proxy_string_free(&ptr->val.protocol_error); + break; + } + case 3: { + proxy_string_free(&ptr->val.unexpected_error); + break; + } + } +} + +void types_tuple2_string_string_free(types_tuple2_string_string_t *ptr) { + proxy_string_free(&ptr->f0); + proxy_string_free(&ptr->f1); +} + +void types_list_tuple2_string_string_free(types_list_tuple2_string_string_t *ptr) { + for (size_t i = 0; i < ptr->len; i++) { + types_tuple2_string_string_free(&ptr->ptr[i]); + } + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void types_list_string_free(types_list_string_t *ptr) { + for (size_t i = 0; i < ptr->len; i++) { + proxy_string_free(&ptr->ptr[i]); + } + if (ptr->len > 0) { + free(ptr->ptr); + } +} + +void types_result_outgoing_response_error_free(types_result_outgoing_response_error_t *ptr) { + if (!ptr->is_err) { + } else { + types_error_free(&ptr->val.err); + } +} + +void types_result_incoming_response_error_free(types_result_incoming_response_error_t *ptr) { + if (!ptr->is_err) { + } else { + types_error_free(&ptr->val.err); + } +} + +void proxy_string_set(proxy_string_t *ret, const char*s) { + ret->ptr = (char*) s; + ret->len = strlen(s); +} + +void proxy_string_dup(proxy_string_t *ret, const char*s) { + ret->len = strlen(s); + ret->ptr = cabi_realloc(NULL, 0, 1, ret->len * 1); + memcpy(ret->ptr, s, ret->len * 1); +} + +void proxy_string_free(proxy_string_t *ret) { + if (ret->len > 0) { + free(ret->ptr); + } + ret->ptr = NULL; + ret->len = 0; +} + +// Component Adapters + +void random_get_random_bytes(uint64_t len, random_list_u8_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_random_get_random_bytes((int64_t) (len), ptr); + *ret = (random_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +uint64_t random_get_random_u64(void) { + int64_t ret = __wasm_import_random_get_random_u64(); + return (uint64_t) (ret); +} + +void random_insecure_random(random_tuple2_u64_u64_t *ret) { + __attribute__((aligned(8))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_random_insecure_random(ptr); + *ret = (random_tuple2_u64_u64_t) { + (uint64_t) (*((int64_t*) (ptr + 0))), + (uint64_t) (*((int64_t*) (ptr + 8))), + }; +} + +void console_log(console_level_t level, proxy_string_t *context, proxy_string_t *message) { + __wasm_import_console_log((int32_t) level, (int32_t) (*context).ptr, (int32_t) (*context).len, (int32_t) (*message).ptr, (int32_t) (*message).len); +} + +void poll_drop_pollable(poll_pollable_t this) { + __wasm_import_poll_drop_pollable((int32_t) (this)); +} + +void poll_poll_oneoff(poll_list_pollable_t *in, poll_list_u8_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_poll_poll_oneoff((int32_t) (*in).ptr, (int32_t) (*in).len, ptr); + *ret = (poll_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +bool streams_read(streams_input_stream_t this, uint64_t len, streams_tuple2_list_u8_bool_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(4))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_read((int32_t) (this), (int64_t) (len), ptr); + streams_result_tuple2_list_u8_bool_stream_error_t result; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + result.is_err = false; + result.val.ok = (streams_tuple2_list_u8_bool_t) { + (streams_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }, + (int32_t) (*((uint8_t*) (ptr + 12))), + }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool streams_skip(streams_input_stream_t this, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(8))) + uint8_t ret_area[24]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_skip((int32_t) (this), (int64_t) (len), ptr); + streams_result_tuple2_u64_bool_stream_error_t result; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + result.is_err = false; + result.val.ok = (streams_tuple2_u64_bool_t) { + (uint64_t) (*((int64_t*) (ptr + 8))), + (int32_t) (*((uint8_t*) (ptr + 16))), + }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +streams_pollable_t streams_subscribe_to_input_stream(streams_input_stream_t this) { + int32_t ret = __wasm_import_streams_subscribe_to_input_stream((int32_t) (this)); + return (uint32_t) (ret); +} + +void streams_drop_input_stream(streams_input_stream_t this) { + __wasm_import_streams_drop_input_stream((int32_t) (this)); +} + +bool streams_write(streams_output_stream_t this, streams_list_u8_t *buf, uint64_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(8))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_write((int32_t) (this), (int32_t) (*buf).ptr, (int32_t) (*buf).len, ptr); + 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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool streams_write_zeroes(streams_output_stream_t this, uint64_t len, uint64_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(8))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_write_zeroes((int32_t) (this), (int64_t) (len), ptr); + 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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool streams_splice(streams_output_stream_t this, streams_input_stream_t src, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(8))) + uint8_t ret_area[24]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_splice((int32_t) (this), (int32_t) (src), (int64_t) (len), ptr); + streams_result_tuple2_u64_bool_stream_error_t result; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + result.is_err = false; + result.val.ok = (streams_tuple2_u64_bool_t) { + (uint64_t) (*((int64_t*) (ptr + 8))), + (int32_t) (*((uint8_t*) (ptr + 16))), + }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool streams_forward(streams_output_stream_t this, streams_input_stream_t src, uint64_t *ret, streams_stream_error_t *err) { + __attribute__((aligned(8))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_streams_forward((int32_t) (this), (int32_t) (src), ptr); + 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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +streams_pollable_t streams_subscribe_to_output_stream(streams_output_stream_t this) { + int32_t ret = __wasm_import_streams_subscribe_to_output_stream((int32_t) (this)); + return (uint32_t) (ret); +} + +void streams_drop_output_stream(streams_output_stream_t this) { + __wasm_import_streams_drop_output_stream((int32_t) (this)); +} + +void types_drop_fields(types_fields_t fields) { + __wasm_import_types_drop_fields((int32_t) (fields)); +} + +types_fields_t types_new_fields(types_list_tuple2_string_string_t *entries) { + int32_t ret = __wasm_import_types_new_fields((int32_t) (*entries).ptr, (int32_t) (*entries).len); + return (uint32_t) (ret); +} + +void types_fields_get(types_fields_t fields, proxy_string_t *name, types_list_string_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_fields_get((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, ptr); + *ret = (types_list_string_t) { (proxy_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +void types_fields_set(types_fields_t fields, proxy_string_t *name, types_list_string_t *value) { + __wasm_import_types_fields_set((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, (int32_t) (*value).ptr, (int32_t) (*value).len); +} + +void types_fields_delete(types_fields_t fields, proxy_string_t *name) { + __wasm_import_types_fields_delete((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len); +} + +void types_fields_append(types_fields_t fields, proxy_string_t *name, proxy_string_t *value) { + __wasm_import_types_fields_append((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, (int32_t) (*value).ptr, (int32_t) (*value).len); +} + +void types_fields_entries(types_fields_t fields, types_list_tuple2_string_string_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_fields_entries((int32_t) (fields), ptr); + *ret = (types_list_tuple2_string_string_t) { (types_tuple2_string_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +types_fields_t types_fields_clone(types_fields_t fields) { + int32_t ret = __wasm_import_types_fields_clone((int32_t) (fields)); + return (uint32_t) (ret); +} + +bool types_finish_incoming_stream(types_incoming_stream_t s, types_trailers_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_finish_incoming_stream((int32_t) (s), ptr); + types_option_trailers_t option; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (uint32_t) (*((int32_t*) (ptr + 4))); + break; + } + } + *ret = option.val; + return option.is_some; +} + +void types_finish_outgoing_stream(types_outgoing_stream_t s, types_trailers_t *maybe_trailers) { + types_option_trailers_t trailers; + trailers.is_some = maybe_trailers != NULL;if (maybe_trailers) { + trailers.val = *maybe_trailers; + } + int32_t option; + int32_t option1; + if ((trailers).is_some) { + const types_trailers_t *payload0 = &(trailers).val; + option = 1; + option1 = (int32_t) (*payload0); + } else { + option = 0; + option1 = 0; + } + __wasm_import_types_finish_outgoing_stream((int32_t) (s), option, option1); +} + +void types_drop_incoming_request(types_incoming_request_t request) { + __wasm_import_types_drop_incoming_request((int32_t) (request)); +} + +void types_drop_outgoing_request(types_outgoing_request_t request) { + __wasm_import_types_drop_outgoing_request((int32_t) (request)); +} + +void types_incoming_request_method(types_incoming_request_t request, types_method_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[12]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_method((int32_t) (request), ptr); + types_method_t variant; + variant.tag = (int32_t) (*((uint8_t*) (ptr + 0))); + 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: { + variant.val.other = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; + break; + } + } + *ret = variant; +} + +void types_incoming_request_path(types_incoming_request_t request, proxy_string_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_path((int32_t) (request), ptr); + *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +void types_incoming_request_query(types_incoming_request_t request, proxy_string_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_query((int32_t) (request), ptr); + *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +bool types_incoming_request_scheme(types_incoming_request_t request, types_scheme_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[16]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_scheme((int32_t) (request), ptr); + types_option_scheme_t option; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + types_scheme_t variant; + variant.tag = (int32_t) (*((uint8_t*) (ptr + 4))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 8))), (size_t)(*((int32_t*) (ptr + 12))) }; + break; + } + } + + option.val = variant; + break; + } + } + *ret = option.val; + return option.is_some; +} + +void types_incoming_request_authority(types_incoming_request_t request, proxy_string_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_authority((int32_t) (request), ptr); + *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; +} + +types_headers_t types_incoming_request_headers(types_incoming_request_t request) { + int32_t ret = __wasm_import_types_incoming_request_headers((int32_t) (request)); + return (uint32_t) (ret); +} + +bool types_incoming_request_consume(types_incoming_request_t request, types_incoming_stream_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_request_consume((int32_t) (request), ptr); + types_result_incoming_stream_void_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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +types_outgoing_request_t types_new_outgoing_request(types_method_t *method, proxy_string_t *path, proxy_string_t *query, types_scheme_t *maybe_scheme, proxy_string_t *authority, types_headers_t headers) { + types_option_scheme_t scheme; + scheme.is_some = maybe_scheme != NULL;if (maybe_scheme) { + scheme.val = *maybe_scheme; + } + int32_t variant; + int32_t variant9; + int32_t variant10; + switch ((int32_t) (*method).tag) { + case 0: { + variant = 0; + variant9 = 0; + variant10 = 0; + break; + } + case 1: { + variant = 1; + variant9 = 0; + variant10 = 0; + break; + } + case 2: { + variant = 2; + variant9 = 0; + variant10 = 0; + break; + } + case 3: { + variant = 3; + variant9 = 0; + variant10 = 0; + break; + } + case 4: { + variant = 4; + variant9 = 0; + variant10 = 0; + break; + } + case 5: { + variant = 5; + variant9 = 0; + variant10 = 0; + break; + } + case 6: { + variant = 6; + variant9 = 0; + variant10 = 0; + break; + } + case 7: { + variant = 7; + variant9 = 0; + variant10 = 0; + break; + } + case 8: { + variant = 8; + variant9 = 0; + variant10 = 0; + break; + } + case 9: { + const proxy_string_t *payload8 = &(*method).val.other; + variant = 9; + variant9 = (int32_t) (*payload8).ptr; + variant10 = (int32_t) (*payload8).len; + break; + } + } + int32_t option; + int32_t option19; + int32_t option20; + int32_t option21; + if ((scheme).is_some) { + const types_scheme_t *payload12 = &(scheme).val; + int32_t variant16; + int32_t variant17; + int32_t variant18; + switch ((int32_t) (*payload12).tag) { + case 0: { + variant16 = 0; + variant17 = 0; + variant18 = 0; + break; + } + case 1: { + variant16 = 1; + variant17 = 0; + variant18 = 0; + break; + } + case 2: { + const proxy_string_t *payload15 = &(*payload12).val.other; + variant16 = 2; + variant17 = (int32_t) (*payload15).ptr; + variant18 = (int32_t) (*payload15).len; + break; + } + } + option = 1; + option19 = variant16; + option20 = variant17; + option21 = variant18; + } else { + option = 0; + option19 = 0; + option20 = 0; + option21 = 0; + } + int32_t ret = __wasm_import_types_new_outgoing_request(variant, variant9, variant10, (int32_t) (*path).ptr, (int32_t) (*path).len, (int32_t) (*query).ptr, (int32_t) (*query).len, option, option19, option20, option21, (int32_t) (*authority).ptr, (int32_t) (*authority).len, (int32_t) (headers)); + return (uint32_t) (ret); +} + +bool types_outgoing_request_write(types_outgoing_request_t request, types_outgoing_stream_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_outgoing_request_write((int32_t) (request), ptr); + types_result_outgoing_stream_void_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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +void types_drop_response_outparam(types_response_outparam_t response) { + __wasm_import_types_drop_response_outparam((int32_t) (response)); +} + +bool types_set_response_outparam(types_result_outgoing_response_error_t *response) { + int32_t result; + int32_t result7; + int32_t result8; + int32_t result9; + if ((*response).is_err) { + const types_error_t *payload0 = &(*response).val.err;int32_t variant; + int32_t variant5; + int32_t variant6; + switch ((int32_t) (*payload0).tag) { + case 0: { + const proxy_string_t *payload1 = &(*payload0).val.invalid_url; + variant = 0; + variant5 = (int32_t) (*payload1).ptr; + variant6 = (int32_t) (*payload1).len; + break; + } + case 1: { + const proxy_string_t *payload2 = &(*payload0).val.timeout_error; + variant = 1; + variant5 = (int32_t) (*payload2).ptr; + variant6 = (int32_t) (*payload2).len; + break; + } + case 2: { + const proxy_string_t *payload3 = &(*payload0).val.protocol_error; + variant = 2; + variant5 = (int32_t) (*payload3).ptr; + variant6 = (int32_t) (*payload3).len; + break; + } + case 3: { + const proxy_string_t *payload4 = &(*payload0).val.unexpected_error; + variant = 3; + variant5 = (int32_t) (*payload4).ptr; + variant6 = (int32_t) (*payload4).len; + break; + } + } + result = 1; + result7 = variant; + result8 = variant5; + result9 = variant6; + } else { + const types_outgoing_response_t *payload = &(*response).val.ok;result = 0; + result7 = (int32_t) (*payload); + result8 = 0; + result9 = 0; + } + int32_t ret = __wasm_import_types_set_response_outparam(result, result7, result8, result9); + types_result_void_void_t result10; + switch (ret) { + case 0: { + result10.is_err = false; + break; + } + case 1: { + result10.is_err = true; + break; + } + } + if (!result10.is_err) { + return 1; + } else { + return 0; + } +} + +void types_drop_incoming_response(types_incoming_response_t response) { + __wasm_import_types_drop_incoming_response((int32_t) (response)); +} + +void types_drop_outgoing_response(types_outgoing_response_t response) { + __wasm_import_types_drop_outgoing_response((int32_t) (response)); +} + +types_status_code_t types_incoming_response_status(types_incoming_response_t response) { + int32_t ret = __wasm_import_types_incoming_response_status((int32_t) (response)); + return (uint16_t) (ret); +} + +types_headers_t types_incoming_response_headers(types_incoming_response_t response) { + int32_t ret = __wasm_import_types_incoming_response_headers((int32_t) (response)); + return (uint32_t) (ret); +} + +bool types_incoming_response_consume(types_incoming_response_t response, types_incoming_stream_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_incoming_response_consume((int32_t) (response), ptr); + types_result_incoming_stream_void_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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +types_outgoing_response_t types_new_outgoing_response(types_status_code_t status_code, types_headers_t headers) { + int32_t ret = __wasm_import_types_new_outgoing_response((int32_t) (status_code), (int32_t) (headers)); + return (uint32_t) (ret); +} + +bool types_outgoing_response_write(types_outgoing_response_t response, types_outgoing_stream_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[8]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_outgoing_response_write((int32_t) (response), ptr); + types_result_outgoing_stream_void_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; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +void types_drop_future_incoming_response(types_future_incoming_response_t f) { + __wasm_import_types_drop_future_incoming_response((int32_t) (f)); +} + +bool types_future_incoming_response_get(types_future_incoming_response_t f, types_result_incoming_response_error_t *ret) { + __attribute__((aligned(4))) + uint8_t ret_area[20]; + int32_t ptr = (int32_t) &ret_area; + __wasm_import_types_future_incoming_response_get((int32_t) (f), ptr); + types_option_result_incoming_response_error_t option; + switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + types_result_incoming_response_error_t result; + switch ((int32_t) (*((uint8_t*) (ptr + 4)))) { + case 0: { + result.is_err = false; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + types_error_t variant; + variant.tag = (int32_t) (*((uint8_t*) (ptr + 8))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.invalid_url = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; + break; + } + case 1: { + variant.val.timeout_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; + break; + } + case 2: { + variant.val.protocol_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; + break; + } + case 3: { + variant.val.unexpected_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + + option.val = result; + break; + } + } + *ret = option.val; + return option.is_some; +} + +types_pollable_t types_listen_to_future_incoming_response(types_future_incoming_response_t f) { + int32_t ret = __wasm_import_types_listen_to_future_incoming_response((int32_t) (f)); + return (uint32_t) (ret); +} + +default_outgoing_http_future_incoming_response_t default_outgoing_http_handle(default_outgoing_http_outgoing_request_t request, default_outgoing_http_request_options_t *maybe_options) { + default_outgoing_http_option_request_options_t options; + options.is_some = maybe_options != NULL;if (maybe_options) { + options.val = *maybe_options; + } + int32_t option12; + int32_t option13; + int32_t option14; + int32_t option15; + int32_t option16; + int32_t option17; + int32_t option18; + if ((options).is_some) { + const default_outgoing_http_request_options_t *payload0 = &(options).val; + int32_t option; + int32_t option3; + if (((*payload0).connect_timeout_ms).is_some) { + const uint32_t *payload2 = &((*payload0).connect_timeout_ms).val; + option = 1; + option3 = (int32_t) (*payload2); + } else { + option = 0; + option3 = 0; + } + int32_t option6; + int32_t option7; + if (((*payload0).first_byte_timeout_ms).is_some) { + const uint32_t *payload5 = &((*payload0).first_byte_timeout_ms).val; + option6 = 1; + option7 = (int32_t) (*payload5); + } else { + option6 = 0; + option7 = 0; + } + int32_t option10; + int32_t option11; + if (((*payload0).between_bytes_timeout_ms).is_some) { + const uint32_t *payload9 = &((*payload0).between_bytes_timeout_ms).val; + option10 = 1; + option11 = (int32_t) (*payload9); + } else { + option10 = 0; + option11 = 0; + } + option12 = 1; + option13 = option; + option14 = option3; + option15 = option6; + option16 = option7; + option17 = option10; + option18 = option11; + } else { + option12 = 0; + option13 = 0; + option14 = 0; + option15 = 0; + option16 = 0; + option17 = 0; + option18 = 0; + } + int32_t ret = __wasm_import_default_outgoing_http_handle((int32_t) (request), option12, option13, option14, option15, option16, option17, option18); + return (uint32_t) (ret); +} + +__attribute__((export_name("HTTP#handle"))) +void __wasm_export_http_handle(int32_t arg, int32_t arg0) { + http_handle((uint32_t) (arg), (uint32_t) (arg0)); +} + +extern void __component_type_object_force_link_proxy(void); +void __component_type_object_force_link_proxy_public_use_in_this_compilation_unit(void) { + __component_type_object_force_link_proxy(); +} diff --git a/crates/wasi-http/example/proxy.h b/crates/wasi-http/example/proxy.h new file mode 100644 index 000000000000..17030384af30 --- /dev/null +++ b/crates/wasi-http/example/proxy.h @@ -0,0 +1,335 @@ +#ifndef __BINDINGS_PROXY_H +#define __BINDINGS_PROXY_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +typedef struct { + char*ptr; + size_t len; +} proxy_string_t; + +typedef struct { + uint8_t *ptr; + size_t len; +} random_list_u8_t; + +typedef struct { + uint64_t f0; + uint64_t f1; +} random_tuple2_u64_u64_t; + +// A log level, describing a kind of message. +typedef uint8_t console_level_t; + +#define CONSOLE_LEVEL_TRACE 0 +#define CONSOLE_LEVEL_DEBUG 1 +#define CONSOLE_LEVEL_INFO 2 +#define CONSOLE_LEVEL_WARN 3 +#define CONSOLE_LEVEL_ERROR 4 + +// A "pollable" handle. +// +// This is conceptually represents a `stream<_, _>`, or in other words, +// a stream that one can wait on, repeatedly, but which does not itself +// produce any data. It's temporary scaffolding until component-model's +// async features are ready. +// +// And at present, it is a `u32` instead of being an actual handle, until +// the wit-bindgen implementation of handles and resources is ready. +// +// `pollable` lifetimes are not automatically managed. Users must ensure +// that they do not outlive the resource they reference. +// +// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). +typedef uint32_t poll_pollable_t; + +typedef struct { + poll_pollable_t *ptr; + size_t len; +} poll_list_pollable_t; + +typedef struct { + uint8_t *ptr; + size_t len; +} poll_list_u8_t; + +typedef poll_pollable_t streams_pollable_t; + +// An error type returned from a stream operation. Currently this +// doesn't provide any additional information. +typedef struct { +} streams_stream_error_t; + +// An output bytestream. In the future, this will be replaced by handle +// types. +// +// This conceptually represents a `stream`. It's temporary +// scaffolding until component-model's async features are ready. +// +// `output-stream`s are *non-blocking* to the extent practical on +// underlying platforms. Except where specified otherwise, I/O operations also +// always return promptly, after the number of bytes that can be written +// promptly, which could even be zero. To wait for the stream to be ready to +// accept data, the `subscribe-to-output-stream` function to obtain a +// `pollable` which can be polled for using `wasi_poll`. +// +// And at present, it is a `u32` instead of being an actual handle, until +// the wit-bindgen implementation of handles and resources is ready. +// +// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). +typedef uint32_t streams_output_stream_t; + +// An input bytestream. In the future, this will be replaced by handle +// types. +// +// This conceptually represents a `stream`. It's temporary +// scaffolding until component-model's async features are ready. +// +// `input-stream`s are *non-blocking* to the extent practical on underlying +// platforms. I/O operations always return promptly; if fewer bytes are +// promptly available than requested, they return the number of bytes promptly +// available, which could even be zero. To wait for data to be available, +// use the `subscribe-to-input-stream` function to obtain a `pollable` which +// can be polled for using `wasi_poll`. +// +// And at present, it is a `u32` instead of being an actual handle, until +// the wit-bindgen implementation of handles and resources is ready. +// +// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). +typedef uint32_t streams_input_stream_t; + +typedef struct { + uint8_t *ptr; + size_t len; +} streams_list_u8_t; + +typedef struct { + streams_list_u8_t f0; + bool f1; +} streams_tuple2_list_u8_bool_t; + +typedef struct { + uint64_t f0; + bool f1; +} streams_tuple2_u64_bool_t; + +typedef streams_input_stream_t types_input_stream_t; + +typedef streams_output_stream_t types_output_stream_t; + +typedef poll_pollable_t types_pollable_t; + +typedef uint16_t types_status_code_t; + +typedef struct { + uint8_t tag; + union { + proxy_string_t other; + } val; +} types_scheme_t; + +#define TYPES_SCHEME_HTTP 0 +#define TYPES_SCHEME_HTTPS 1 +#define TYPES_SCHEME_OTHER 2 + +typedef uint32_t types_response_outparam_t; + +typedef struct { + bool is_some; + uint32_t val; +} types_option_u32_t; + +typedef struct { + types_option_u32_t connect_timeout_ms; + types_option_u32_t first_byte_timeout_ms; + types_option_u32_t between_bytes_timeout_ms; +} types_request_options_t; + +typedef types_output_stream_t types_outgoing_stream_t; + +typedef uint32_t types_outgoing_response_t; + +typedef uint32_t types_outgoing_request_t; + +typedef struct { + uint8_t tag; + union { + proxy_string_t other; + } val; +} types_method_t; + +#define TYPES_METHOD_GET 0 +#define TYPES_METHOD_HEAD 1 +#define TYPES_METHOD_POST 2 +#define TYPES_METHOD_PUT 3 +#define TYPES_METHOD_DELETE 4 +#define TYPES_METHOD_CONNECT 5 +#define TYPES_METHOD_OPTIONS 6 +#define TYPES_METHOD_TRACE 7 +#define TYPES_METHOD_PATCH 8 +#define TYPES_METHOD_OTHER 9 + +typedef types_input_stream_t types_incoming_stream_t; + +typedef uint32_t types_incoming_response_t; + +typedef uint32_t types_incoming_request_t; + +typedef uint32_t types_future_incoming_response_t; + +typedef uint32_t types_fields_t; + +typedef types_fields_t types_trailers_t; + +typedef types_fields_t types_headers_t; + +typedef struct { + uint8_t tag; + union { + proxy_string_t invalid_url; + proxy_string_t timeout_error; + proxy_string_t protocol_error; + proxy_string_t unexpected_error; + } val; +} types_error_t; + +#define TYPES_ERROR_INVALID_URL 0 +#define TYPES_ERROR_TIMEOUT_ERROR 1 +#define TYPES_ERROR_PROTOCOL_ERROR 2 +#define TYPES_ERROR_UNEXPECTED_ERROR 3 + +typedef struct { + proxy_string_t f0; + proxy_string_t f1; +} types_tuple2_string_string_t; + +typedef struct { + types_tuple2_string_string_t *ptr; + size_t len; +} types_list_tuple2_string_string_t; + +typedef struct { + proxy_string_t *ptr; + size_t len; +} types_list_string_t; + +typedef struct { + bool is_err; + union { + types_outgoing_response_t ok; + types_error_t err; + } val; +} types_result_outgoing_response_error_t; + +typedef struct { + bool is_err; + union { + types_incoming_response_t ok; + types_error_t err; + } val; +} types_result_incoming_response_error_t; + +typedef types_outgoing_request_t default_outgoing_http_outgoing_request_t; + +typedef types_request_options_t default_outgoing_http_request_options_t; + +typedef types_future_incoming_response_t default_outgoing_http_future_incoming_response_t; + +typedef types_incoming_request_t http_incoming_request_t; + +typedef types_response_outparam_t http_response_outparam_t; + +// Imported Functions from `random` +void random_get_random_bytes(uint64_t len, random_list_u8_t *ret); +uint64_t random_get_random_u64(void); +void random_insecure_random(random_tuple2_u64_u64_t *ret); + +// Imported Functions from `console` +void console_log(console_level_t level, proxy_string_t *context, proxy_string_t *message); + +// Imported Functions from `poll` +void poll_drop_pollable(poll_pollable_t this); +void poll_poll_oneoff(poll_list_pollable_t *in, poll_list_u8_t *ret); + +// Imported Functions from `streams` +bool streams_read(streams_input_stream_t this, uint64_t len, streams_tuple2_list_u8_bool_t *ret, streams_stream_error_t *err); +bool streams_skip(streams_input_stream_t this, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err); +streams_pollable_t streams_subscribe_to_input_stream(streams_input_stream_t this); +void streams_drop_input_stream(streams_input_stream_t this); +bool streams_write(streams_output_stream_t this, streams_list_u8_t *buf, uint64_t *ret, streams_stream_error_t *err); +bool streams_write_zeroes(streams_output_stream_t this, uint64_t len, uint64_t *ret, streams_stream_error_t *err); +bool streams_splice(streams_output_stream_t this, streams_input_stream_t src, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err); +bool streams_forward(streams_output_stream_t this, streams_input_stream_t src, uint64_t *ret, streams_stream_error_t *err); +streams_pollable_t streams_subscribe_to_output_stream(streams_output_stream_t this); +void streams_drop_output_stream(streams_output_stream_t this); + +// Imported Functions from `types` +void types_drop_fields(types_fields_t fields); +types_fields_t types_new_fields(types_list_tuple2_string_string_t *entries); +void types_fields_get(types_fields_t fields, proxy_string_t *name, types_list_string_t *ret); +void types_fields_set(types_fields_t fields, proxy_string_t *name, types_list_string_t *value); +void types_fields_delete(types_fields_t fields, proxy_string_t *name); +void types_fields_append(types_fields_t fields, proxy_string_t *name, proxy_string_t *value); +void types_fields_entries(types_fields_t fields, types_list_tuple2_string_string_t *ret); +types_fields_t types_fields_clone(types_fields_t fields); +bool types_finish_incoming_stream(types_incoming_stream_t s, types_trailers_t *ret); +void types_finish_outgoing_stream(types_outgoing_stream_t s, types_trailers_t *maybe_trailers); +void types_drop_incoming_request(types_incoming_request_t request); +void types_drop_outgoing_request(types_outgoing_request_t request); +void types_incoming_request_method(types_incoming_request_t request, types_method_t *ret); +void types_incoming_request_path(types_incoming_request_t request, proxy_string_t *ret); +void types_incoming_request_query(types_incoming_request_t request, proxy_string_t *ret); +bool types_incoming_request_scheme(types_incoming_request_t request, types_scheme_t *ret); +void types_incoming_request_authority(types_incoming_request_t request, proxy_string_t *ret); +types_headers_t types_incoming_request_headers(types_incoming_request_t request); +bool types_incoming_request_consume(types_incoming_request_t request, types_incoming_stream_t *ret); +types_outgoing_request_t types_new_outgoing_request(types_method_t *method, proxy_string_t *path, proxy_string_t *query, types_scheme_t *maybe_scheme, proxy_string_t *authority, types_headers_t headers); +bool types_outgoing_request_write(types_outgoing_request_t request, types_outgoing_stream_t *ret); +void types_drop_response_outparam(types_response_outparam_t response); +bool types_set_response_outparam(types_result_outgoing_response_error_t *response); +void types_drop_incoming_response(types_incoming_response_t response); +void types_drop_outgoing_response(types_outgoing_response_t response); +types_status_code_t types_incoming_response_status(types_incoming_response_t response); +types_headers_t types_incoming_response_headers(types_incoming_response_t response); +bool types_incoming_response_consume(types_incoming_response_t response, types_incoming_stream_t *ret); +types_outgoing_response_t types_new_outgoing_response(types_status_code_t status_code, types_headers_t headers); +bool types_outgoing_response_write(types_outgoing_response_t response, types_outgoing_stream_t *ret); +void types_drop_future_incoming_response(types_future_incoming_response_t f); +bool types_future_incoming_response_get(types_future_incoming_response_t f, types_result_incoming_response_error_t *ret); +types_pollable_t types_listen_to_future_incoming_response(types_future_incoming_response_t f); + +// Imported Functions from `default-outgoing-HTTP` +default_outgoing_http_future_incoming_response_t default_outgoing_http_handle(default_outgoing_http_outgoing_request_t request, default_outgoing_http_request_options_t *maybe_options); + +// Exported Functions from `HTTP` +void http_handle(http_incoming_request_t request, http_response_outparam_t response_out); + +// Helper Functions + +void random_list_u8_free(random_list_u8_t *ptr); +void poll_list_pollable_free(poll_list_pollable_t *ptr); +void poll_list_u8_free(poll_list_u8_t *ptr); +void streams_list_u8_free(streams_list_u8_t *ptr); +void streams_tuple2_list_u8_bool_free(streams_tuple2_list_u8_bool_t *ptr); +void types_scheme_free(types_scheme_t *ptr); +void types_method_free(types_method_t *ptr); +void types_error_free(types_error_t *ptr); +void types_tuple2_string_string_free(types_tuple2_string_string_t *ptr); +void types_list_tuple2_string_string_free(types_list_tuple2_string_string_t *ptr); +void types_list_string_free(types_list_string_t *ptr); +void types_result_outgoing_response_error_free(types_result_outgoing_response_error_t *ptr); +void types_result_incoming_response_error_free(types_result_incoming_response_error_t *ptr); +void proxy_string_set(proxy_string_t *ret, const char*s); +void proxy_string_dup(proxy_string_t *ret, const char*s); +void proxy_string_free(proxy_string_t *ret); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crates/wasi-http/example/proxy_component_type.o b/crates/wasi-http/example/proxy_component_type.o new file mode 100644 index 0000000000000000000000000000000000000000..c584bd3ba5417a4dd5db963c0aba743d9b589219 GIT binary patch literal 8260 zcmeHNUvt~W5x)fv1SOJ^Xp6F}#;)W1Z4y|{KgV^GSW=TTGtEP1ns*f>k0LA(fN?-* zC6nnF>lbK0MLs|t^3>=24*z%{NY^vXbUGQn5Ww!<-tO&TvHLqRSI&qrMx6e}m}wB( zHVK5E9`BFBSri5$NSx#<5|5%de0F6pbM7TpcAx(;DCja`_K$r!-J&ytu6R2Necv7W zf|=0C)zg0DCeug9>UQyCF#`gXG@Z2#SU~mh6f@qHNi5u%BjPxWp;S%M3)3V@6DMbZ z$U*FSL5k3%^>h{})6B*M@W3G6GzLnSJ>m2n@5sbW zQt6Dsv09uKJvI54Uw{1<#w>ODE3RQO6){Q1TXHlNGbPrBXZ=`6ghL8P`R&H;42*5M zyrS5=HVT74j1VYqCct)PvOAb~u}qxdRU&lq;ZP)VA%ct{bq?Q+#nV(^Oc*5|W`h16 z--Wu1&uf4(DspKSr1!ws(-@gH(67($GAkH#FL3oG1eLjUnGJt zyYK>cr3K7NVs`|dh3Ji@wbhx4WEzg4exL7p0XA#RNK!^tWX;GM%1Dh-8hI1+!%3Q? zv2ZkYzUG+aH{iD>p76(NVQ%p@Ec1L3tEb!CR*n@9^ptnJ;2YQX#!edh2xYH~OSXSO z*ue{wgrm^UcQhz_X&|0Oh@lu)G;Wpq{bf3#V)EO>cxN1kky98$uTW@6Nztnivhljc zo{+D>rtLt?E1}mZl5}E}N_gPTgk*22sDebV zP*uc}-ddwgYO-z=iD1m=ZOuXU8s8~Y72Ys-GV>zk)RkkbopBdkUU`b_`$>r zJULwiu}Bbf45LZzR)M<*J4)ed*OtQf)nXPe#1RAs*^+A;Bi}dlt|oWAlB?7e8W_E& z$sMr)zp<>!DfTnHUz3!4(2!J_jL`@DpuvGr@fBEfxmDBh;fnc+>_QLtQA3ZL;@yh9 zB-5oW1iQlz8^Yz*r;q3f9kANO4_C+BEwU|G(Y!!Jz!G3;!Yd7-1WLKfkYvdFUZ3H0{qEZnv3!^{QW$*Bt zjj5d~Y@gMIAFdLvV)i*+BK;#~F9Or&gQdWfrhlQ&&_`5mH2f>W@+XMWevq1!LI17=LM92G0}Rp9@Kg-}OD2;4_$n&blFtzT%cDedJzrdGY8t zyUl+st23aSx4qz@ma+fcrqi8YZx!^)rV3JpC^Oln3i{tyLFU@m5f!`9C_NQ%xu{jN zwPhZiZK?g;T3N+rmA<{IO3rHi_H(O8PM0P!XIW8DS>d*r#amN17^7DrTbnnh#jj`C zrOK8C^>~?JZFSzJh5v=vVC7)bVD>+drFxqzRlLfZUac%sH@(^~(5wB2ETvUqSr4Hy zQnR_IvsRIcmgVv7DN<2$6nKW7X1aQ9YNDvBat+s-;99P!rYm#JGQn!AT(eBgbImf< z6t^D>V$9VFGt*xyBWv%R>UEI5W0?tXMR|w zj7NntJz#K=?*V|K{e=R>hiZEg#@IV>bx>M|O~#LEZs0?$n|V-4!jEg2A4?K9UI4J< z2(h^gSeh#VOKUY?*;)fwnlA*zTMdQaWF7YQdbJRFF@(e%jK#!FeH>Dj z=aTB&^hIHkPPPhFm!hpgvzID5u&&l9E!yPF)!ynuSp%hF1@t_x1Itc+bJHu6%GP0- zVD0eyygkRFvjh0!?3Xj wasmtime::Result>; + /// Return a cryptographically-secure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-random-bytes`, represented as a `u64`. + fn get_random_u64(&mut self) -> wasmtime::Result; + /// 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. + fn insecure_random(&mut self) -> wasmtime::Result<(u64, u64)>; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("random")?; + inst.func_wrap( + "get-random-bytes", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| { + let host = get(caller.data_mut()); + let r = host.get_random_bytes(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "get-random-u64", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { + let host = get(caller.data_mut()); + let r = host.get_random_u64(); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "insecure-random", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { + let host = get(caller.data_mut()); + let r = host.insecure_random(); + Ok((r?,)) + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod console { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + /// A log level, describing a kind of message. + #[component(enum)] + pub enum Level { + /// Describes messages about the values of variables and the flow of + /// control within a program. + #[component(name = "trace")] + Trace, + /// Describes messages likely to be of interest to someone debugging a + /// program. + #[component(name = "debug")] + Debug, + /// Describes messages likely to be of interest to someone monitoring a + /// program. + #[component(name = "info")] + Info, + /// Describes messages indicating hazardous situations. + #[component(name = "warn")] + Warn, + /// Describes messages indicating serious errors. + #[component(name = "error")] + Error, + } + #[automatically_derived] + impl ::core::clone::Clone for Level { + #[inline] + fn clone(&self) -> Level { + *self + } + } + #[automatically_derived] + impl ::core::marker::Copy for Level {} + #[automatically_derived] + impl ::core::marker::StructuralPartialEq for Level {} + #[automatically_derived] + impl ::core::cmp::PartialEq for Level { + #[inline] + fn eq(&self, other: &Level) -> bool { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + __self_tag == __arg1_tag + } + } + #[automatically_derived] + impl ::core::marker::StructuralEq for Level {} + #[automatically_derived] + impl ::core::cmp::Eq for Level { + #[inline] + #[doc(hidden)] + #[no_coverage] + fn assert_receiver_is_total_eq(&self) -> () {} + } + unsafe impl wasmtime::component::Lower for Level { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + match self { + Self::Trace => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(0u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Trace) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Debug => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(1u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Debug) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Info => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(2u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Info) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Warn => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(3u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Warn) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Error => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(4u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Error) + } + } + }, + |dst| Ok(()), + ) + } + } + } + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + match self { + Self::Trace => { + *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); + Ok(()) + } + Self::Debug => { + *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); + Ok(()) + } + Self::Info => { + *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); + Ok(()) + } + Self::Warn => { + *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); + Ok(()) + } + Self::Error => { + *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); + Ok(()) + } + } + } + } + unsafe impl wasmtime::component::Lift for Level { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok( + match src.tag.get_u32() { + 0u32 => Self::Trace, + 1u32 => Self::Debug, + 2u32 => Self::Info, + 3u32 => Self::Warn, + 4u32 => Self::Error, + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + let align = ::ALIGN32; + if true { + if !((bytes.as_ptr() as usize) % (align as usize) == 0) { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", + ) + } + } + let discrim = bytes[0]; + let payload_offset = ::PAYLOAD_OFFSET32; + let payload = &bytes[payload_offset..]; + Ok( + match discrim { + 0u8 => Self::Trace, + 1u8 => Self::Debug, + 2u8 => Self::Info, + 3u8 => Self::Warn, + 4u8 => Self::Error, + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerLevel { + tag: wasmtime::ValRaw, + payload: LowerPayloadLevel, + } + #[automatically_derived] + impl ::core::clone::Clone for LowerLevel { + #[inline] + fn clone(&self) -> LowerLevel { + let _: ::core::clone::AssertParamIsClone; + let _: ::core::clone::AssertParamIsClone; + *self + } + } + #[automatically_derived] + impl ::core::marker::Copy for LowerLevel {} + #[doc(hidden)] + #[allow(non_snake_case)] + #[repr(C)] + union LowerPayloadLevel { + Trace: [wasmtime::ValRaw; 0], + Debug: [wasmtime::ValRaw; 0], + Info: [wasmtime::ValRaw; 0], + Warn: [wasmtime::ValRaw; 0], + Error: [wasmtime::ValRaw; 0], + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::clone::Clone for LowerPayloadLevel { + #[inline] + fn clone(&self) -> LowerPayloadLevel { + let _: ::core::clone::AssertParamIsCopy; + *self + } + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::marker::Copy for LowerPayloadLevel {} + unsafe impl wasmtime::component::ComponentType for Level { + type Lower = LowerLevel; + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_enum( + ty, + types, + &["trace", "debug", "info", "warn", "error"], + ) + } + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( + &[None, None, None, None, None], + ); + } + unsafe impl wasmtime::component::__internal::ComponentVariant for Level { + const CASES: &'static [Option< + wasmtime::component::__internal::CanonicalAbiInfo, + >] = &[None, None, None, None, None]; + } + }; + impl core::fmt::Debug for Level { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Level::Trace => f.debug_tuple("Level::Trace").finish(), + Level::Debug => f.debug_tuple("Level::Debug").finish(), + Level::Info => f.debug_tuple("Level::Info").finish(), + Level::Warn => f.debug_tuple("Level::Warn").finish(), + Level::Error => f.debug_tuple("Level::Error").finish(), + } + } + } + pub trait Host: Sized { + /// Emit a log message. + /// + /// A log message has a `level` describing what kind of message is being + /// sent, a context, which is an uninterpreted string meant to help + /// consumers group similar messages, and a string containing the message + /// text. + fn log( + &mut self, + level: Level, + context: String, + message: String, + ) -> wasmtime::Result<()>; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("console")?; + inst.func_wrap( + "log", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1, arg2): (Level, String, String)| + { + let host = get(caller.data_mut()); + let r = host.log(arg0, arg1, arg2); + r + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod poll { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + /// A "pollable" handle. + /// + /// This is conceptually represents a `stream<_, _>`, or in other words, + /// a stream that one can wait on, repeatedly, but which does not itself + /// produce any data. It's temporary scaffolding until component-model's + /// async features are ready. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// `pollable` lifetimes are not automatically managed. Users must ensure + /// that they do not outlive the resource they reference. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type Pollable = u32; + pub trait Host: Sized { + /// Dispose of the specified `pollable`, after which it may no longer + /// be used. + fn drop_pollable(&mut self, this: Pollable) -> wasmtime::Result<()>; + /// Poll for completion on a set of pollables. + /// + /// The "oneoff" in the name refers to the fact that this function must do a + /// linear scan through the entire list of subscriptions, which may be + /// inefficient if the number is large and the same subscriptions are used + /// many times. In the future, this is expected to be obsoleted by the + /// component model async proposal, which will include a scalable waiting + /// facility. + /// + /// Note that the return type would ideally be `list`, but that would + /// be more difficult to polyfill given the current state of `wit-bindgen`. + /// See + /// for details. For now, we use zero to mean "not ready" and non-zero to + /// mean "ready". + fn poll_oneoff(&mut self, in_: Vec) -> wasmtime::Result>; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("poll")?; + inst.func_wrap( + "drop-pollable", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Pollable,)| { + let host = get(caller.data_mut()); + let r = host.drop_pollable(arg0); + r + }, + )?; + inst.func_wrap( + "poll-oneoff", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (Vec,)| + { + let host = get(caller.data_mut()); + let r = host.poll_oneoff(arg0); + Ok((r?,)) + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod streams { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + pub type Pollable = super::poll::Pollable; + /// An error type returned from a stream operation. Currently this + /// doesn't provide any additional information. + #[component(record)] + pub struct StreamError {} + #[automatically_derived] + impl ::core::marker::Copy for StreamError {} + #[automatically_derived] + impl ::core::clone::Clone for StreamError { + #[inline] + fn clone(&self) -> StreamError { + *self + } + } + unsafe impl wasmtime::component::Lower for StreamError { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + Ok(()) + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + Ok(()) + } + } + unsafe impl wasmtime::component::Lift for StreamError { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok(Self {}) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + if true { + if !((bytes.as_ptr() as usize) + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) %\\n (::ALIGN32 as usize) == 0", + ) + } + } + let mut offset = 0; + Ok(Self {}) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerStreamError { + _align: [wasmtime::ValRaw; 0], + } + #[automatically_derived] + impl ::core::clone::Clone for LowerStreamError { + #[inline] + fn clone(&self) -> LowerStreamError { + let _: ::core::clone::AssertParamIsClone<[wasmtime::ValRaw; 0]>; + *self + } + } + #[automatically_derived] + impl ::core::marker::Copy for LowerStreamError {} + unsafe impl wasmtime::component::ComponentType for StreamError { + type Lower = LowerStreamError; + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::record_static( + &[], + ); + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_record(ty, types, &[]) + } + } + }; + impl core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("StreamError").finish() + } + } + impl core::fmt::Display for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_fmt(format_args!("{0:?}", self)) + } + } + impl std::error::Error for StreamError {} + /// An output bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `output-stream`s are *non-blocking* to the extent practical on + /// underlying platforms. Except where specified otherwise, I/O operations also + /// always return promptly, after the number of bytes that can be written + /// promptly, which could even be zero. To wait for the stream to be ready to + /// accept data, the `subscribe-to-output-stream` function to obtain a + /// `pollable` which can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type OutputStream = u32; + /// An input bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `input-stream`s are *non-blocking* to the extent practical on underlying + /// platforms. I/O operations always return promptly; if fewer bytes are + /// promptly available than requested, they return the number of bytes promptly + /// available, which could even be zero. To wait for data to be available, + /// use the `subscribe-to-input-stream` function to obtain a `pollable` which + /// can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type InputStream = u32; + pub trait Host: Sized { + /// Read bytes from a stream. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool indicating whether the end of the stream + /// was reached. The returned list will contain up to `len` bytes; it + /// may return fewer than requested, but not more. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// If `len` is 0, it represents a request to read 0 bytes, which should + /// always succeed, assuming the stream hasn't reached its end yet, and + /// return an empty list. + /// + /// The len here is a `u64`, but some callees may not be able to allocate + /// a buffer as large as that would imply. + /// FIXME: describe what happens if allocation fails. + fn read( + &mut self, + this: InputStream, + len: u64, + ) -> wasmtime::Result, bool), StreamError>>; + /// Skip bytes from a stream. + /// + /// This is similar to the `read` function, but avoids copying the + /// bytes into the instance. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// This function returns the number of bytes skipped, along with a bool + /// indicating whether the end of the stream was reached. The returned + /// value will be at most `len`; it may be less. + fn skip( + &mut self, + this: InputStream, + len: u64, + ) -> wasmtime::Result>; + /// Create a `pollable` which will resolve once either the specified stream + /// has bytes available to read or the other end of the stream has been + /// closed. + fn subscribe_to_input_stream( + &mut self, + this: InputStream, + ) -> wasmtime::Result; + /// Dispose of the specified `input-stream`, after which it may no longer + /// be used. + fn drop_input_stream(&mut self, this: InputStream) -> wasmtime::Result<()>; + /// Write bytes to a stream. + /// + /// This function returns a `u64` indicating the number of bytes from + /// `buf` that were written; it may be less than the full list. + fn write( + &mut self, + this: OutputStream, + buf: Vec, + ) -> wasmtime::Result>; + /// Write multiple zero bytes to a stream. + /// + /// This function returns a `u64` indicating the number of zero bytes + /// that were written; it may be less than `len`. + fn write_zeroes( + &mut self, + this: OutputStream, + len: u64, + ) -> wasmtime::Result>; + /// Read from one stream and write to another. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + /// + /// Unlike other I/O functions, this function blocks until all the data + /// read from the input stream has been written to the output stream. + fn splice( + &mut self, + this: OutputStream, + src: InputStream, + len: u64, + ) -> wasmtime::Result>; + /// Forward the entire contents of an input stream to an output stream. + /// + /// This function repeatedly reads from the input stream and writes + /// the data to the output stream, until the end of the input stream + /// is reached, or an error is encountered. + /// + /// Unlike other I/O functions, this function blocks until the end + /// of the input stream is seen and all the data has been written to + /// the output stream. + /// + /// This function returns the number of bytes transferred. + fn forward( + &mut self, + this: OutputStream, + src: InputStream, + ) -> wasmtime::Result>; + /// Create a `pollable` which will resolve once either the specified stream + /// is ready to accept bytes or the other end of the stream has been closed. + fn subscribe_to_output_stream( + &mut self, + this: OutputStream, + ) -> wasmtime::Result; + /// Dispose of the specified `output-stream`, after which it may no longer + /// be used. + fn drop_output_stream(&mut self, this: OutputStream) -> wasmtime::Result<()>; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("streams")?; + inst.func_wrap( + "read", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (InputStream, u64)| + { + let host = get(caller.data_mut()); + let r = host.read(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "skip", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (InputStream, u64)| + { + let host = get(caller.data_mut()); + let r = host.skip(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "subscribe-to-input-stream", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (InputStream,)| { + let host = get(caller.data_mut()); + let r = host.subscribe_to_input_stream(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "drop-input-stream", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (InputStream,)| { + let host = get(caller.data_mut()); + let r = host.drop_input_stream(arg0); + r + }, + )?; + inst.func_wrap( + "write", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (OutputStream, Vec)| + { + let host = get(caller.data_mut()); + let r = host.write(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "write-zeroes", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (OutputStream, u64)| + { + let host = get(caller.data_mut()); + let r = host.write_zeroes(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "splice", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1, arg2): (OutputStream, InputStream, u64)| + { + let host = get(caller.data_mut()); + let r = host.splice(arg0, arg1, arg2); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "forward", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (OutputStream, InputStream)| + { + let host = get(caller.data_mut()); + let r = host.forward(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "subscribe-to-output-stream", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutputStream,)| + { + let host = get(caller.data_mut()); + let r = host.subscribe_to_output_stream(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "drop-output-stream", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutputStream,)| + { + let host = get(caller.data_mut()); + let r = host.drop_output_stream(arg0); + r + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod types { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + pub type InputStream = super::streams::InputStream; + pub type OutputStream = super::streams::OutputStream; + pub type Pollable = super::poll::Pollable; + pub type StatusCode = u16; + #[component(variant)] + pub enum Scheme { + #[component(name = "HTTP")] + Http, + #[component(name = "HTTPS")] + Https, + #[component(name = "other")] + Other(String), + } + #[automatically_derived] + impl ::core::clone::Clone for Scheme { + #[inline] + fn clone(&self) -> Scheme { + match self { + Scheme::Http => Scheme::Http, + Scheme::Https => Scheme::Https, + Scheme::Other(__self_0) => { + Scheme::Other(::core::clone::Clone::clone(__self_0)) + } + } + } + } + unsafe impl wasmtime::component::Lower for Scheme { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + match self { + Self::Http => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(0u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Http) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Https => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(1u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Https) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Other(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(2u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Other) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + } + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + match self { + Self::Http => { + *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); + Ok(()) + } + Self::Https => { + *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); + Ok(()) + } + Self::Other(value) => { + *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + } + } + } + unsafe impl wasmtime::component::Lift for Scheme { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok( + match src.tag.get_u32() { + 0u32 => Self::Http, + 1u32 => Self::Https, + 2u32 => { + Self::Other( + ::lift( + store, + options, + unsafe { &src.payload.Other }, + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + let align = ::ALIGN32; + if true { + if !((bytes.as_ptr() as usize) % (align as usize) == 0) { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", + ) + } + } + let discrim = bytes[0]; + let payload_offset = ::PAYLOAD_OFFSET32; + let payload = &bytes[payload_offset..]; + Ok( + match discrim { + 0u8 => Self::Http, + 1u8 => Self::Https, + 2u8 => { + Self::Other( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerScheme { + tag: wasmtime::ValRaw, + payload: LowerPayloadScheme, + } + #[automatically_derived] + impl ::core::clone::Clone for LowerScheme { + #[inline] + fn clone(&self) -> LowerScheme { + LowerScheme { + tag: ::core::clone::Clone::clone(&self.tag), + payload: ::core::clone::Clone::clone(&self.payload), + } + } + } + #[automatically_derived] + impl ::core::marker::Copy for LowerScheme {} + #[doc(hidden)] + #[allow(non_snake_case)] + #[repr(C)] + union LowerPayloadScheme { + Http: [wasmtime::ValRaw; 0], + Https: [wasmtime::ValRaw; 0], + Other: T2, + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::clone::Clone + for LowerPayloadScheme { + #[inline] + fn clone(&self) -> LowerPayloadScheme { + let _: ::core::clone::AssertParamIsCopy; + *self + } + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::marker::Copy + for LowerPayloadScheme {} + unsafe impl wasmtime::component::ComponentType for Scheme { + type Lower = LowerScheme< + ::Lower, + >; + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_variant( + ty, + types, + &[ + ("HTTP", None), + ("HTTPS", None), + ( + "other", + Some( + ::typecheck, + ), + ), + ], + ) + } + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( + &[None, None, Some(::ABI)], + ); + } + unsafe impl wasmtime::component::__internal::ComponentVariant for Scheme { + const CASES: &'static [Option< + wasmtime::component::__internal::CanonicalAbiInfo, + >] = &[ + None, + None, + Some(::ABI), + ]; + } + }; + impl core::fmt::Debug for Scheme { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Scheme::Http => f.debug_tuple("Scheme::Http").finish(), + Scheme::Https => f.debug_tuple("Scheme::Https").finish(), + Scheme::Other(e) => f.debug_tuple("Scheme::Other").field(e).finish(), + } + } + } + pub type ResponseOutparam = u32; + #[component(record)] + pub struct RequestOptions { + #[component(name = "connect-timeout-ms")] + pub connect_timeout_ms: Option, + #[component(name = "first-byte-timeout-ms")] + pub first_byte_timeout_ms: Option, + #[component(name = "between-bytes-timeout-ms")] + pub between_bytes_timeout_ms: Option, + } + #[automatically_derived] + impl ::core::marker::Copy for RequestOptions {} + #[automatically_derived] + impl ::core::clone::Clone for RequestOptions { + #[inline] + fn clone(&self) -> RequestOptions { + let _: ::core::clone::AssertParamIsClone>; + let _: ::core::clone::AssertParamIsClone>; + let _: ::core::clone::AssertParamIsClone>; + *self + } + } + unsafe impl wasmtime::component::Lower for RequestOptions { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::Lower::lower( + &self.connect_timeout_ms, + store, + options, + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).connect_timeout_ms) + } + } + }, + )?; + wasmtime::component::Lower::lower( + &self.first_byte_timeout_ms, + store, + options, + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).first_byte_timeout_ms) + } + } + }, + )?; + wasmtime::component::Lower::lower( + &self.between_bytes_timeout_ms, + store, + options, + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).between_bytes_timeout_ms) + } + } + }, + )?; + Ok(()) + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + wasmtime::component::Lower::store( + &self.connect_timeout_ms, + memory, + as wasmtime::component::ComponentType>::ABI + .next_field32_size(&mut offset), + )?; + wasmtime::component::Lower::store( + &self.first_byte_timeout_ms, + memory, + as wasmtime::component::ComponentType>::ABI + .next_field32_size(&mut offset), + )?; + wasmtime::component::Lower::store( + &self.between_bytes_timeout_ms, + memory, + as wasmtime::component::ComponentType>::ABI + .next_field32_size(&mut offset), + )?; + Ok(()) + } + } + unsafe impl wasmtime::component::Lift for RequestOptions { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok(Self { + connect_timeout_ms: as wasmtime::component::Lift>::lift( + store, + options, + &src.connect_timeout_ms, + )?, + first_byte_timeout_ms: as wasmtime::component::Lift>::lift( + store, + options, + &src.first_byte_timeout_ms, + )?, + between_bytes_timeout_ms: as wasmtime::component::Lift>::lift( + store, + options, + &src.between_bytes_timeout_ms, + )?, + }) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + if true { + if !((bytes.as_ptr() as usize) + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) %\\n (::ALIGN32 as usize) == 0", + ) + } + } + let mut offset = 0; + Ok(Self { + connect_timeout_ms: as wasmtime::component::Lift>::load( + memory, + &bytes[ as wasmtime::component::ComponentType>::ABI + .next_field32_size( + &mut offset, + )..][.. as wasmtime::component::ComponentType>::SIZE32], + )?, + first_byte_timeout_ms: as wasmtime::component::Lift>::load( + memory, + &bytes[ as wasmtime::component::ComponentType>::ABI + .next_field32_size( + &mut offset, + )..][.. as wasmtime::component::ComponentType>::SIZE32], + )?, + between_bytes_timeout_ms: as wasmtime::component::Lift>::load( + memory, + &bytes[ as wasmtime::component::ComponentType>::ABI + .next_field32_size( + &mut offset, + )..][.. as wasmtime::component::ComponentType>::SIZE32], + )?, + }) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerRequestOptions { + connect_timeout_ms: T0, + first_byte_timeout_ms: T1, + between_bytes_timeout_ms: T2, + _align: [wasmtime::ValRaw; 0], + } + #[automatically_derived] + impl< + T0: ::core::clone::Clone + Copy, + T1: ::core::clone::Clone + Copy, + T2: ::core::clone::Clone + Copy, + > ::core::clone::Clone for LowerRequestOptions { + #[inline] + fn clone(&self) -> LowerRequestOptions { + LowerRequestOptions { + connect_timeout_ms: ::core::clone::Clone::clone( + &self.connect_timeout_ms, + ), + first_byte_timeout_ms: ::core::clone::Clone::clone( + &self.first_byte_timeout_ms, + ), + between_bytes_timeout_ms: ::core::clone::Clone::clone( + &self.between_bytes_timeout_ms, + ), + _align: ::core::clone::Clone::clone(&self._align), + } + } + } + #[automatically_derived] + impl< + T0: ::core::marker::Copy + Copy, + T1: ::core::marker::Copy + Copy, + T2: ::core::marker::Copy + Copy, + > ::core::marker::Copy for LowerRequestOptions {} + unsafe impl wasmtime::component::ComponentType for RequestOptions { + type Lower = LowerRequestOptions< + as wasmtime::component::ComponentType>::Lower, + as wasmtime::component::ComponentType>::Lower, + as wasmtime::component::ComponentType>::Lower, + >; + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::record_static( + &[ + as wasmtime::component::ComponentType>::ABI, + as wasmtime::component::ComponentType>::ABI, + as wasmtime::component::ComponentType>::ABI, + ], + ); + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_record( + ty, + types, + &[ + ( + "connect-timeout-ms", + as wasmtime::component::ComponentType>::typecheck, + ), + ( + "first-byte-timeout-ms", + as wasmtime::component::ComponentType>::typecheck, + ), + ( + "between-bytes-timeout-ms", + as wasmtime::component::ComponentType>::typecheck, + ), + ], + ) + } + } + }; + impl core::fmt::Debug for RequestOptions { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("RequestOptions") + .field("connect-timeout-ms", &self.connect_timeout_ms) + .field("first-byte-timeout-ms", &self.first_byte_timeout_ms) + .field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms) + .finish() + } + } + pub type OutgoingStream = OutputStream; + pub type OutgoingResponse = u32; + pub type OutgoingRequest = u32; + #[component(variant)] + pub enum Method { + #[component(name = "get")] + Get, + #[component(name = "head")] + Head, + #[component(name = "post")] + Post, + #[component(name = "put")] + Put, + #[component(name = "delete")] + Delete, + #[component(name = "connect")] + Connect, + #[component(name = "options")] + Options, + #[component(name = "trace")] + Trace, + #[component(name = "patch")] + Patch, + #[component(name = "other")] + Other(String), + } + #[automatically_derived] + impl ::core::clone::Clone for Method { + #[inline] + fn clone(&self) -> Method { + match self { + Method::Get => Method::Get, + Method::Head => Method::Head, + Method::Post => Method::Post, + Method::Put => Method::Put, + Method::Delete => Method::Delete, + Method::Connect => Method::Connect, + Method::Options => Method::Options, + Method::Trace => Method::Trace, + Method::Patch => Method::Patch, + Method::Other(__self_0) => { + Method::Other(::core::clone::Clone::clone(__self_0)) + } + } + } + } + unsafe impl wasmtime::component::Lower for Method { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + match self { + Self::Get => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(0u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Get) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Head => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(1u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Head) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Post => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(2u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Post) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Put => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(3u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Put) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Delete => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(4u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Delete) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Connect => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(5u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Connect) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Options => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(6u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Options) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Trace => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(7u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Trace) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Patch => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(8u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Patch) + } + } + }, + |dst| Ok(()), + ) + } + } + Self::Other(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(9u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).Other) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + } + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + match self { + Self::Get => { + *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); + Ok(()) + } + Self::Head => { + *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); + Ok(()) + } + Self::Post => { + *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); + Ok(()) + } + Self::Put => { + *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); + Ok(()) + } + Self::Delete => { + *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); + Ok(()) + } + Self::Connect => { + *memory.get::<1usize>(offset) = 5u8.to_le_bytes(); + Ok(()) + } + Self::Options => { + *memory.get::<1usize>(offset) = 6u8.to_le_bytes(); + Ok(()) + } + Self::Trace => { + *memory.get::<1usize>(offset) = 7u8.to_le_bytes(); + Ok(()) + } + Self::Patch => { + *memory.get::<1usize>(offset) = 8u8.to_le_bytes(); + Ok(()) + } + Self::Other(value) => { + *memory.get::<1usize>(offset) = 9u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + } + } + } + unsafe impl wasmtime::component::Lift for Method { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok( + match src.tag.get_u32() { + 0u32 => Self::Get, + 1u32 => Self::Head, + 2u32 => Self::Post, + 3u32 => Self::Put, + 4u32 => Self::Delete, + 5u32 => Self::Connect, + 6u32 => Self::Options, + 7u32 => Self::Trace, + 8u32 => Self::Patch, + 9u32 => { + Self::Other( + ::lift( + store, + options, + unsafe { &src.payload.Other }, + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + let align = ::ALIGN32; + if true { + if !((bytes.as_ptr() as usize) % (align as usize) == 0) { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", + ) + } + } + let discrim = bytes[0]; + let payload_offset = ::PAYLOAD_OFFSET32; + let payload = &bytes[payload_offset..]; + Ok( + match discrim { + 0u8 => Self::Get, + 1u8 => Self::Head, + 2u8 => Self::Post, + 3u8 => Self::Put, + 4u8 => Self::Delete, + 5u8 => Self::Connect, + 6u8 => Self::Options, + 7u8 => Self::Trace, + 8u8 => Self::Patch, + 9u8 => { + Self::Other( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerMethod { + tag: wasmtime::ValRaw, + payload: LowerPayloadMethod, + } + #[automatically_derived] + impl ::core::clone::Clone for LowerMethod { + #[inline] + fn clone(&self) -> LowerMethod { + LowerMethod { + tag: ::core::clone::Clone::clone(&self.tag), + payload: ::core::clone::Clone::clone(&self.payload), + } + } + } + #[automatically_derived] + impl ::core::marker::Copy for LowerMethod {} + #[doc(hidden)] + #[allow(non_snake_case)] + #[repr(C)] + union LowerPayloadMethod { + Get: [wasmtime::ValRaw; 0], + Head: [wasmtime::ValRaw; 0], + Post: [wasmtime::ValRaw; 0], + Put: [wasmtime::ValRaw; 0], + Delete: [wasmtime::ValRaw; 0], + Connect: [wasmtime::ValRaw; 0], + Options: [wasmtime::ValRaw; 0], + Trace: [wasmtime::ValRaw; 0], + Patch: [wasmtime::ValRaw; 0], + Other: T9, + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::clone::Clone + for LowerPayloadMethod { + #[inline] + fn clone(&self) -> LowerPayloadMethod { + let _: ::core::clone::AssertParamIsCopy; + *self + } + } + #[automatically_derived] + #[allow(non_snake_case)] + impl ::core::marker::Copy + for LowerPayloadMethod {} + unsafe impl wasmtime::component::ComponentType for Method { + type Lower = LowerMethod< + ::Lower, + >; + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_variant( + ty, + types, + &[ + ("get", None), + ("head", None), + ("post", None), + ("put", None), + ("delete", None), + ("connect", None), + ("options", None), + ("trace", None), + ("patch", None), + ( + "other", + Some( + ::typecheck, + ), + ), + ], + ) + } + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( + &[ + None, + None, + None, + None, + None, + None, + None, + None, + None, + Some(::ABI), + ], + ); + } + unsafe impl wasmtime::component::__internal::ComponentVariant for Method { + const CASES: &'static [Option< + wasmtime::component::__internal::CanonicalAbiInfo, + >] = &[ + None, + None, + None, + None, + None, + None, + None, + None, + None, + Some(::ABI), + ]; + } + }; + impl core::fmt::Debug for Method { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Method::Get => f.debug_tuple("Method::Get").finish(), + Method::Head => f.debug_tuple("Method::Head").finish(), + Method::Post => f.debug_tuple("Method::Post").finish(), + Method::Put => f.debug_tuple("Method::Put").finish(), + Method::Delete => f.debug_tuple("Method::Delete").finish(), + Method::Connect => f.debug_tuple("Method::Connect").finish(), + Method::Options => f.debug_tuple("Method::Options").finish(), + Method::Trace => f.debug_tuple("Method::Trace").finish(), + Method::Patch => f.debug_tuple("Method::Patch").finish(), + Method::Other(e) => f.debug_tuple("Method::Other").field(e).finish(), + } + } + } + pub type IncomingStream = InputStream; + pub type IncomingResponse = u32; + pub type IncomingRequest = u32; + pub type FutureIncomingResponse = u32; + pub type Fields = u32; + pub type Trailers = Fields; + pub type Headers = Fields; + #[component(variant)] + pub enum Error { + #[component(name = "invalid-url")] + InvalidUrl(String), + #[component(name = "timeout-error")] + TimeoutError(String), + #[component(name = "protocol-error")] + ProtocolError(String), + #[component(name = "status-error")] + StatusError(u16), + #[component(name = "unexpected-error")] + UnexpectedError(String), + } + #[automatically_derived] + impl ::core::clone::Clone for Error { + #[inline] + fn clone(&self) -> Error { + match self { + Error::InvalidUrl(__self_0) => { + Error::InvalidUrl(::core::clone::Clone::clone(__self_0)) + } + Error::TimeoutError(__self_0) => { + Error::TimeoutError(::core::clone::Clone::clone(__self_0)) + } + Error::ProtocolError(__self_0) => { + Error::ProtocolError(::core::clone::Clone::clone(__self_0)) + } + Error::StatusError(__self_0) => { + Error::StatusError(::core::clone::Clone::clone(__self_0)) + } + Error::UnexpectedError(__self_0) => { + Error::UnexpectedError(::core::clone::Clone::clone(__self_0)) + } + } + } + } + unsafe impl wasmtime::component::Lower for Error { + #[inline] + fn lower( + &self, + store: &mut wasmtime::StoreContextMut, + options: &wasmtime::component::__internal::Options, + dst: &mut std::mem::MaybeUninit, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + match self { + Self::InvalidUrl(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(0u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).InvalidUrl) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + Self::TimeoutError(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(1u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).TimeoutError) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + Self::ProtocolError(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(2u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).ProtocolError) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + Self::StatusError(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(3u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).StatusError) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + Self::UnexpectedError(value) => { + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).tag) + } + } + } + .write(wasmtime::ValRaw::u32(4u32)); + unsafe { + wasmtime::component::__internal::lower_payload( + { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = dst; + m.map(|p| &raw mut (*p).payload) + } + } + }, + |payload| { + #[allow(unused_unsafe)] + { + unsafe { + use ::wasmtime::component::__internal::MaybeUninitExt; + let m: &mut std::mem::MaybeUninit<_> = payload; + m.map(|p| &raw mut (*p).UnexpectedError) + } + } + }, + |dst| value.lower(store, options, dst), + ) + } + } + } + } + #[inline] + fn store( + &self, + memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, + mut offset: usize, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + if true { + if !(offset + % (::ALIGN32 as usize) + == 0) + { + ::core::panicking::panic( + "assertion failed: offset % (::ALIGN32 as usize) == 0", + ) + } + } + match self { + Self::InvalidUrl(value) => { + *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + Self::TimeoutError(value) => { + *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + Self::ProtocolError(value) => { + *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + Self::StatusError(value) => { + *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + Self::UnexpectedError(value) => { + *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); + value + .store( + memory, + offset + + ::PAYLOAD_OFFSET32, + ) + } + } + } + } + unsafe impl wasmtime::component::Lift for Error { + #[inline] + fn lift( + store: &wasmtime::component::__internal::StoreOpaque, + options: &wasmtime::component::__internal::Options, + src: &Self::Lower, + ) -> wasmtime::component::__internal::anyhow::Result { + Ok( + match src.tag.get_u32() { + 0u32 => { + Self::InvalidUrl( + ::lift( + store, + options, + unsafe { &src.payload.InvalidUrl }, + )?, + ) + } + 1u32 => { + Self::TimeoutError( + ::lift( + store, + options, + unsafe { &src.payload.TimeoutError }, + )?, + ) + } + 2u32 => { + Self::ProtocolError( + ::lift( + store, + options, + unsafe { &src.payload.ProtocolError }, + )?, + ) + } + 3u32 => { + Self::StatusError( + ::lift( + store, + options, + unsafe { &src.payload.StatusError }, + )?, + ) + } + 4u32 => { + Self::UnexpectedError( + ::lift( + store, + options, + unsafe { &src.payload.UnexpectedError }, + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + #[inline] + fn load( + memory: &wasmtime::component::__internal::Memory, + bytes: &[u8], + ) -> wasmtime::component::__internal::anyhow::Result { + let align = ::ALIGN32; + if true { + if !((bytes.as_ptr() as usize) % (align as usize) == 0) { + ::core::panicking::panic( + "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", + ) + } + } + let discrim = bytes[0]; + let payload_offset = ::PAYLOAD_OFFSET32; + let payload = &bytes[payload_offset..]; + Ok( + match discrim { + 0u8 => { + Self::InvalidUrl( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + 1u8 => { + Self::TimeoutError( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + 2u8 => { + Self::ProtocolError( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + 3u8 => { + Self::StatusError( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + 4u8 => { + Self::UnexpectedError( + ::load( + memory, + &payload[..::SIZE32], + )?, + ) + } + discrim => { + return ::anyhow::__private::Err( + ::anyhow::Error::msg({ + let res = ::alloc::fmt::format( + format_args!("unexpected discriminant: {0}", discrim), + ); + res + }), + ); + } + }, + ) + } + } + const _: () = { + #[doc(hidden)] + #[repr(C)] + pub struct LowerError { + tag: wasmtime::ValRaw, + payload: LowerPayloadError, + } + #[automatically_derived] + impl< + T0: ::core::clone::Clone + Copy, + T1: ::core::clone::Clone + Copy, + T2: ::core::clone::Clone + Copy, + T3: ::core::clone::Clone + Copy, + T4: ::core::clone::Clone + Copy, + > ::core::clone::Clone for LowerError { + #[inline] + fn clone(&self) -> LowerError { + LowerError { + tag: ::core::clone::Clone::clone(&self.tag), + payload: ::core::clone::Clone::clone(&self.payload), + } + } + } + #[automatically_derived] + impl< + T0: ::core::marker::Copy + Copy, + T1: ::core::marker::Copy + Copy, + T2: ::core::marker::Copy + Copy, + T3: ::core::marker::Copy + Copy, + T4: ::core::marker::Copy + Copy, + > ::core::marker::Copy for LowerError {} + #[doc(hidden)] + #[allow(non_snake_case)] + #[repr(C)] + union LowerPayloadError { + InvalidUrl: T0, + TimeoutError: T1, + ProtocolError: T2, + StatusError: T3, + UnexpectedError: T4, + } + #[automatically_derived] + #[allow(non_snake_case)] + impl< + T0: ::core::marker::Copy + ::core::clone::Clone + Copy, + T1: ::core::marker::Copy + ::core::clone::Clone + Copy, + T2: ::core::marker::Copy + ::core::clone::Clone + Copy, + T3: ::core::marker::Copy + ::core::clone::Clone + Copy, + T4: ::core::marker::Copy + ::core::clone::Clone + Copy, + > ::core::clone::Clone for LowerPayloadError { + #[inline] + fn clone(&self) -> LowerPayloadError { + let _: ::core::clone::AssertParamIsCopy; + *self + } + } + #[automatically_derived] + #[allow(non_snake_case)] + impl< + T0: ::core::marker::Copy + Copy, + T1: ::core::marker::Copy + Copy, + T2: ::core::marker::Copy + Copy, + T3: ::core::marker::Copy + Copy, + T4: ::core::marker::Copy + Copy, + > ::core::marker::Copy for LowerPayloadError {} + unsafe impl wasmtime::component::ComponentType for Error { + type Lower = LowerError< + ::Lower, + ::Lower, + ::Lower, + ::Lower, + ::Lower, + >; + #[inline] + fn typecheck( + ty: &wasmtime::component::__internal::InterfaceType, + types: &wasmtime::component::__internal::ComponentTypes, + ) -> wasmtime::component::__internal::anyhow::Result<()> { + wasmtime::component::__internal::typecheck_variant( + ty, + types, + &[ + ( + "invalid-url", + Some( + ::typecheck, + ), + ), + ( + "timeout-error", + Some( + ::typecheck, + ), + ), + ( + "protocol-error", + Some( + ::typecheck, + ), + ), + ( + "status-error", + Some(::typecheck), + ), + ( + "unexpected-error", + Some( + ::typecheck, + ), + ), + ], + ) + } + const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( + &[ + Some(::ABI), + Some(::ABI), + Some(::ABI), + Some(::ABI), + Some(::ABI), + ], + ); + } + unsafe impl wasmtime::component::__internal::ComponentVariant for Error { + const CASES: &'static [Option< + wasmtime::component::__internal::CanonicalAbiInfo, + >] = &[ + Some(::ABI), + Some(::ABI), + Some(::ABI), + Some(::ABI), + Some(::ABI), + ]; + } + }; + impl core::fmt::Debug for Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Error::InvalidUrl(e) => { + f.debug_tuple("Error::InvalidUrl").field(e).finish() + } + Error::TimeoutError(e) => { + f.debug_tuple("Error::TimeoutError").field(e).finish() + } + Error::ProtocolError(e) => { + f.debug_tuple("Error::ProtocolError").field(e).finish() + } + Error::StatusError(e) => { + f.debug_tuple("Error::StatusError").field(e).finish() + } + Error::UnexpectedError(e) => { + f.debug_tuple("Error::UnexpectedError").field(e).finish() + } + } + } + } + pub trait Host: Sized { + fn drop_fields(&mut self, fields: Fields) -> wasmtime::Result<()>; + fn new_fields( + &mut self, + entries: Vec<(String, String)>, + ) -> wasmtime::Result; + fn fields_get( + &mut self, + fields: Fields, + name: String, + ) -> wasmtime::Result>; + fn fields_set( + &mut self, + fields: Fields, + name: String, + value: Vec, + ) -> wasmtime::Result<()>; + fn fields_delete( + &mut self, + fields: Fields, + name: String, + ) -> wasmtime::Result<()>; + fn fields_append( + &mut self, + fields: Fields, + name: String, + value: String, + ) -> wasmtime::Result<()>; + fn fields_entries( + &mut self, + fields: Fields, + ) -> wasmtime::Result>; + fn fields_clone(&mut self, fields: Fields) -> wasmtime::Result; + fn finish_incoming_stream( + &mut self, + s: IncomingStream, + ) -> wasmtime::Result>; + fn finish_outgoing_stream( + &mut self, + s: OutgoingStream, + trailers: Option, + ) -> wasmtime::Result<()>; + fn drop_incoming_request( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result<()>; + fn drop_outgoing_request( + &mut self, + request: OutgoingRequest, + ) -> wasmtime::Result<()>; + fn incoming_request_method( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result; + fn incoming_request_path( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result; + fn incoming_request_scheme( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result>; + fn incoming_request_authority( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result; + fn incoming_request_headers( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result; + fn incoming_request_consume( + &mut self, + request: IncomingRequest, + ) -> wasmtime::Result>; + fn new_outgoing_request( + &mut self, + method: Method, + path: String, + scheme: Option, + authority: String, + headers: Headers, + ) -> wasmtime::Result; + fn outgoing_request_write( + &mut self, + request: OutgoingRequest, + ) -> wasmtime::Result>; + fn drop_response_outparam( + &mut self, + response: ResponseOutparam, + ) -> wasmtime::Result<()>; + fn set_response_outparam( + &mut self, + response: Result, + ) -> wasmtime::Result>; + fn drop_incoming_response( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result<()>; + fn drop_outgoing_response( + &mut self, + response: OutgoingResponse, + ) -> wasmtime::Result<()>; + fn incoming_response_status( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result; + fn incoming_response_headers( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result; + fn incoming_response_consume( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result>; + fn new_outgoing_response( + &mut self, + status_code: StatusCode, + headers: Headers, + ) -> wasmtime::Result; + fn outgoing_response_write( + &mut self, + response: OutgoingResponse, + ) -> wasmtime::Result>; + fn drop_future_incoming_response( + &mut self, + f: FutureIncomingResponse, + ) -> wasmtime::Result<()>; + fn future_incoming_response_get( + &mut self, + f: FutureIncomingResponse, + ) -> wasmtime::Result>>; + fn listen_to_future_incoming_response( + &mut self, + f: FutureIncomingResponse, + ) -> wasmtime::Result; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("types")?; + inst.func_wrap( + "drop-fields", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { + let host = get(caller.data_mut()); + let r = host.drop_fields(arg0); + r + }, + )?; + inst.func_wrap( + "new-fields", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (Vec<(String, String)>,)| + { + let host = get(caller.data_mut()); + let r = host.new_fields(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "fields-get", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (Fields, String)| + { + let host = get(caller.data_mut()); + let r = host.fields_get(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "fields-set", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1, arg2): (Fields, String, Vec)| + { + let host = get(caller.data_mut()); + let r = host.fields_set(arg0, arg1, arg2); + r + }, + )?; + inst.func_wrap( + "fields-delete", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (Fields, String)| + { + let host = get(caller.data_mut()); + let r = host.fields_delete(arg0, arg1); + r + }, + )?; + inst.func_wrap( + "fields-append", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1, arg2): (Fields, String, String)| + { + let host = get(caller.data_mut()); + let r = host.fields_append(arg0, arg1, arg2); + r + }, + )?; + inst.func_wrap( + "fields-entries", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { + let host = get(caller.data_mut()); + let r = host.fields_entries(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "fields-clone", + move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { + let host = get(caller.data_mut()); + let r = host.fields_clone(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "finish-incoming-stream", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingStream,)| + { + let host = get(caller.data_mut()); + let r = host.finish_incoming_stream(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "finish-outgoing-stream", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (OutgoingStream, Option)| + { + let host = get(caller.data_mut()); + let r = host.finish_outgoing_stream(arg0, arg1); + r + }, + )?; + inst.func_wrap( + "drop-incoming-request", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.drop_incoming_request(arg0); + r + }, + )?; + inst.func_wrap( + "drop-outgoing-request", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutgoingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.drop_outgoing_request(arg0); + r + }, + )?; + inst.func_wrap( + "incoming-request-method", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_method(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-request-path", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_path(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-request-scheme", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_scheme(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-request-authority", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_authority(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-request-headers", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_headers(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-request-consume", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_request_consume(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "new-outgoing-request", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + ( + arg0, + arg1, + arg2, + arg3, + arg4, + ): (Method, String, Option, String, Headers)| + { + let host = get(caller.data_mut()); + let r = host.new_outgoing_request(arg0, arg1, arg2, arg3, arg4); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "outgoing-request-write", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutgoingRequest,)| + { + let host = get(caller.data_mut()); + let r = host.outgoing_request_write(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "drop-response-outparam", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (ResponseOutparam,)| + { + let host = get(caller.data_mut()); + let r = host.drop_response_outparam(arg0); + r + }, + )?; + inst.func_wrap( + "set-response-outparam", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (Result,)| + { + let host = get(caller.data_mut()); + let r = host.set_response_outparam(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "drop-incoming-response", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.drop_incoming_response(arg0); + r + }, + )?; + inst.func_wrap( + "drop-outgoing-response", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutgoingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.drop_outgoing_response(arg0); + r + }, + )?; + inst.func_wrap( + "incoming-response-status", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_response_status(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-response-headers", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_response_headers(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "incoming-response-consume", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (IncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.incoming_response_consume(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "new-outgoing-response", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (StatusCode, Headers)| + { + let host = get(caller.data_mut()); + let r = host.new_outgoing_response(arg0, arg1); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "outgoing-response-write", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (OutgoingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.outgoing_response_write(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "drop-future-incoming-response", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (FutureIncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.drop_future_incoming_response(arg0); + r + }, + )?; + inst.func_wrap( + "future-incoming-response-get", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (FutureIncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.future_incoming_response_get(arg0); + Ok((r?,)) + }, + )?; + inst.func_wrap( + "listen-to-future-incoming-response", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0,): (FutureIncomingResponse,)| + { + let host = get(caller.data_mut()); + let r = host.listen_to_future_incoming_response(arg0); + Ok((r?,)) + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod default_outgoing_http { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + pub type OutgoingRequest = super::types::OutgoingRequest; + pub type RequestOptions = super::types::RequestOptions; + pub type FutureIncomingResponse = super::types::FutureIncomingResponse; + pub trait Host: Sized { + fn handle( + &mut self, + request: OutgoingRequest, + options: Option, + ) -> wasmtime::Result; + } + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: Host, + { + let mut inst = linker.instance("default-outgoing-HTTP")?; + inst.func_wrap( + "handle", + move | + mut caller: wasmtime::StoreContextMut<'_, T>, + (arg0, arg1): (OutgoingRequest, Option)| + { + let host = get(caller.data_mut()); + let r = host.handle(arg0, arg1); + Ok((r?,)) + }, + )?; + Ok(()) + } +} +#[allow(clippy::all)] +pub mod http { + #[allow(unused_imports)] + use wasmtime::component::__internal::anyhow; + pub type IncomingRequest = super::types::IncomingRequest; + pub type ResponseOutparam = super::types::ResponseOutparam; + pub struct Http { + handle: wasmtime::component::Func, + } + impl Http { + pub fn new( + __exports: &mut wasmtime::component::ExportInstance<'_, '_>, + ) -> wasmtime::Result { + let handle = *__exports + .typed_func::<(IncomingRequest, ResponseOutparam), ()>("handle")? + .func(); + Ok(Http { handle }) + } + pub fn call_handle( + &self, + mut store: S, + arg0: IncomingRequest, + arg1: ResponseOutparam, + ) -> wasmtime::Result<()> { + let callee = unsafe { + wasmtime::component::TypedFunc::< + (IncomingRequest, ResponseOutparam), + (), + >::new_unchecked(self.handle) + }; + let () = callee.call(store.as_context_mut(), (arg0, arg1))?; + callee.post_return(store.as_context_mut())?; + Ok(()) + } + } +} +pub struct Proxy { + http: http::Http, +} +const _: () = { + use wasmtime::component::__internal::anyhow; + impl Proxy { + pub fn add_to_linker( + linker: &mut wasmtime::component::Linker, + get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, + ) -> wasmtime::Result<()> + where + U: random::Host + console::Host + poll::Host + streams::Host + types::Host + + default_outgoing_http::Host, + { + random::add_to_linker(linker, get)?; + console::add_to_linker(linker, get)?; + poll::add_to_linker(linker, get)?; + streams::add_to_linker(linker, get)?; + types::add_to_linker(linker, get)?; + default_outgoing_http::add_to_linker(linker, get)?; + Ok(()) + } + /// Instantiates the provided `module` using the specified + /// parameters, wrapping up the result in a structure that + /// translates between wasm and the host. + pub fn instantiate( + mut store: impl wasmtime::AsContextMut, + component: &wasmtime::component::Component, + linker: &wasmtime::component::Linker, + ) -> wasmtime::Result<(Self, wasmtime::component::Instance)> { + let instance = linker.instantiate(&mut store, component)?; + Ok((Self::new(store, &instance)?, instance)) + } + /// Instantiates a pre-instantiated module using the specified + /// parameters, wrapping up the result in a structure that + /// translates between wasm and the host. + pub fn instantiate_pre( + mut store: impl wasmtime::AsContextMut, + instance_pre: &wasmtime::component::InstancePre, + ) -> wasmtime::Result<(Self, wasmtime::component::Instance)> { + let instance = instance_pre.instantiate(&mut store)?; + Ok((Self::new(store, &instance)?, instance)) + } + /// Low-level creation wrapper for wrapping up the exports + /// of the `instance` provided in this structure of wasm + /// exports. + /// + /// This function will extract exports from the `instance` + /// defined within `store` and wrap them all up in the + /// returned structure which can be used to interact with + /// the wasm module. + pub fn new( + mut store: impl wasmtime::AsContextMut, + instance: &wasmtime::component::Instance, + ) -> wasmtime::Result { + let mut store = store.as_context_mut(); + let mut exports = instance.exports(&mut store); + let mut __exports = exports.root(); + let http = http::Http::new( + &mut __exports + .instance("HTTP") + .ok_or_else(|| ::anyhow::__private::must_use({ + let error = ::anyhow::__private::format_err( + format_args!("exported instance `HTTP` not present"), + ); + error + }))?, + )?; + Ok(Proxy { http }) + } + pub fn http(&self) -> &http::Http { + &self.http + } + } +}; +const _: &str = "/// WASI Random is a random data API.\n///\n/// It is intended to be portable at least between Unix-family platforms and\n/// Windows.\ndefault interface random {\n /// Return `len` cryptographically-secure pseudo-random bytes.\n ///\n /// This function must produce data from an adequately seeded\n /// cryptographically-secure pseudo-random number generator (CSPRNG), so it\n /// must not block, from the perspective of the calling program, and the\n /// returned data is always unpredictable.\n ///\n /// This function must always return fresh pseudo-random data. Deterministic\n /// environments must omit this function, rather than implementing it with\n /// deterministic data.\n get-random-bytes: func(len: u64) -> list\n\n /// Return a cryptographically-secure pseudo-random `u64` value.\n ///\n /// This function returns the same type of pseudo-random data as\n /// `get-random-bytes`, represented as a `u64`.\n get-random-u64: func() -> u64\n\n /// Return a 128-bit value that may contain a pseudo-random value.\n ///\n /// The returned value is not required to be computed from a CSPRNG, and may\n /// even be entirely deterministic. Host implementations are encouraged to\n /// provide pseudo-random values to any program exposed to\n /// attacker-controlled content, to enable DoS protection built into many\n /// languages\' hash-map implementations.\n ///\n /// This function is intended to only be called once, by a source language\n /// to initialize Denial Of Service (DoS) protection in its hash-map\n /// implementation.\n ///\n /// # Expected future evolution\n ///\n /// This will likely be changed to a value import, to prevent it from being\n /// called multiple times and potentially used for purposes other than DoS\n /// protection.\n insecure-random: func() -> tuple\n}\n"; +const _: &str = "/// WASI Logging is a logging API intended to let users emit log messages with\n/// simple priority levels and context values.\ndefault interface handler {\n /// A log level, describing a kind of message.\n enum level {\n /// Describes messages about the values of variables and the flow of\n /// control within a program.\n trace,\n\n /// Describes messages likely to be of interest to someone debugging a\n /// program.\n debug,\n\n /// Describes messages likely to be of interest to someone monitoring a\n /// program.\n info,\n\n /// Describes messages indicating hazardous situations.\n warn,\n\n /// Describes messages indicating serious errors.\n error,\n }\n\n /// Emit a log message.\n ///\n /// A log message has a `level` describing what kind of message is being\n /// sent, a context, which is an uninterpreted string meant to help\n /// consumers group similar messages, and a string containing the message\n /// text.\n log: func(level: level, context: string, message: string)\n}\n"; +const _: &str = "/// A poll API intended to let users wait for I/O events on multiple handles\n/// at once.\ndefault interface poll {\n /// A \"pollable\" handle.\n ///\n /// This is conceptually represents a `stream<_, _>`, or in other words,\n /// a stream that one can wait on, repeatedly, but which does not itself\n /// produce any data. It\'s temporary scaffolding until component-model\'s\n /// async features are ready.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// `pollable` lifetimes are not automatically managed. Users must ensure\n /// that they do not outlive the resource they reference.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type pollable = u32\n\n /// Dispose of the specified `pollable`, after which it may no longer\n /// be used.\n drop-pollable: func(this: pollable)\n\n /// Poll for completion on a set of pollables.\n ///\n /// The \"oneoff\" in the name refers to the fact that this function must do a\n /// linear scan through the entire list of subscriptions, which may be\n /// inefficient if the number is large and the same subscriptions are used\n /// many times. In the future, this is expected to be obsoleted by the\n /// component model async proposal, which will include a scalable waiting\n /// facility.\n ///\n /// Note that the return type would ideally be `list`, but that would\n /// be more difficult to polyfill given the current state of `wit-bindgen`.\n /// See \n /// for details. For now, we use zero to mean \"not ready\" and non-zero to\n /// mean \"ready\".\n poll-oneoff: func(in: list) -> list\n}\n"; +const _: &str = "/// WASI I/O is an I/O abstraction API which is currently focused on providing\n/// stream types.\n///\n/// In the future, the component model is expected to add built-in stream types;\n/// when it does, they are expected to subsume this API.\ndefault interface streams {\n use poll.poll.{pollable}\n\n /// An error type returned from a stream operation. Currently this\n /// doesn\'t provide any additional information.\n record stream-error {}\n\n /// An input bytestream. In the future, this will be replaced by handle\n /// types.\n ///\n /// This conceptually represents a `stream`. It\'s temporary\n /// scaffolding until component-model\'s async features are ready.\n ///\n /// `input-stream`s are *non-blocking* to the extent practical on underlying\n /// platforms. I/O operations always return promptly; if fewer bytes are\n /// promptly available than requested, they return the number of bytes promptly\n /// available, which could even be zero. To wait for data to be available,\n /// use the `subscribe-to-input-stream` function to obtain a `pollable` which\n /// can be polled for using `wasi_poll`.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type input-stream = u32\n\n /// Read bytes from a stream.\n ///\n /// This function returns a list of bytes containing the data that was\n /// read, along with a bool indicating whether the end of the stream\n /// was reached. The returned list will contain up to `len` bytes; it\n /// may return fewer than requested, but not more.\n ///\n /// Once a stream has reached the end, subsequent calls to read or\n /// `skip` will always report end-of-stream rather than producing more\n /// data.\n ///\n /// If `len` is 0, it represents a request to read 0 bytes, which should\n /// always succeed, assuming the stream hasn\'t reached its end yet, and\n /// return an empty list.\n ///\n /// The len here is a `u64`, but some callees may not be able to allocate\n /// a buffer as large as that would imply.\n /// FIXME: describe what happens if allocation fails.\n read: func(\n this: input-stream,\n /// The maximum number of bytes to read\n len: u64\n ) -> result, bool>, stream-error>\n\n /// Skip bytes from a stream.\n ///\n /// This is similar to the `read` function, but avoids copying the\n /// bytes into the instance.\n ///\n /// Once a stream has reached the end, subsequent calls to read or\n /// `skip` will always report end-of-stream rather than producing more\n /// data.\n ///\n /// This function returns the number of bytes skipped, along with a bool\n /// indicating whether the end of the stream was reached. The returned\n /// value will be at most `len`; it may be less.\n skip: func(\n this: input-stream,\n /// The maximum number of bytes to skip.\n len: u64,\n ) -> result, stream-error>\n\n /// Create a `pollable` which will resolve once either the specified stream\n /// has bytes available to read or the other end of the stream has been\n /// closed.\n subscribe-to-input-stream: func(this: input-stream) -> pollable\n\n /// Dispose of the specified `input-stream`, after which it may no longer\n /// be used.\n drop-input-stream: func(this: input-stream)\n\n /// An output bytestream. In the future, this will be replaced by handle\n /// types.\n ///\n /// This conceptually represents a `stream`. It\'s temporary\n /// scaffolding until component-model\'s async features are ready.\n ///\n /// `output-stream`s are *non-blocking* to the extent practical on\n /// underlying platforms. Except where specified otherwise, I/O operations also\n /// always return promptly, after the number of bytes that can be written\n /// promptly, which could even be zero. To wait for the stream to be ready to\n /// accept data, the `subscribe-to-output-stream` function to obtain a\n /// `pollable` which can be polled for using `wasi_poll`.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type output-stream = u32\n\n /// Write bytes to a stream.\n ///\n /// This function returns a `u64` indicating the number of bytes from\n /// `buf` that were written; it may be less than the full list.\n write: func(\n this: output-stream,\n /// Data to write\n buf: list\n ) -> result\n\n /// Write multiple zero bytes to a stream.\n ///\n /// This function returns a `u64` indicating the number of zero bytes\n /// that were written; it may be less than `len`.\n write-zeroes: func(\n this: output-stream,\n /// The number of zero bytes to write\n len: u64\n ) -> result\n\n /// Read from one stream and write to another.\n ///\n /// This function returns the number of bytes transferred; it may be less\n /// than `len`.\n ///\n /// Unlike other I/O functions, this function blocks until all the data\n /// read from the input stream has been written to the output stream.\n splice: func(\n this: output-stream,\n /// The stream to read from\n src: input-stream,\n /// The number of bytes to splice\n len: u64,\n ) -> result, stream-error>\n\n /// Forward the entire contents of an input stream to an output stream.\n ///\n /// This function repeatedly reads from the input stream and writes\n /// the data to the output stream, until the end of the input stream\n /// is reached, or an error is encountered.\n ///\n /// Unlike other I/O functions, this function blocks until the end\n /// of the input stream is seen and all the data has been written to\n /// the output stream.\n ///\n /// This function returns the number of bytes transferred.\n forward: func(\n this: output-stream,\n /// The stream to read from\n src: input-stream\n ) -> result\n\n /// Create a `pollable` which will resolve once either the specified stream\n /// is ready to accept bytes or the other end of the stream has been closed.\n subscribe-to-output-stream: func(this: output-stream) -> pollable\n\n /// Dispose of the specified `output-stream`, after which it may no longer\n /// be used.\n drop-output-stream: func(this: output-stream)\n}\n"; +const _: &str = "// The `wasi:http/outgoing-handler` interface is meant to be imported by\n// components and implemented by the host.\n//\n// NOTE: in Preview3, this interface will be merged with\n// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface\n// that takes a `request` parameter and returns a `response` result.\n//\ndefault interface outgoing-handler {\n use pkg.types.{outgoing-request, request-options, future-incoming-response}\n\n // The parameter and result types of the `handle` function allow the caller\n // to concurrently stream the bodies of the outgoing request and the incoming\n // response.\n handle: func(\n request: outgoing-request,\n options: option\n ) -> future-incoming-response\n}\n"; +const _: &str = "// The `wasi:http/incoming-handler` interface is meant to be exported by\n// components and called by the host in response to a new incoming HTTP\n// response.\n//\n// NOTE: in Preview3, this interface will be merged with\n// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface\n// that takes a `request` parameter and returns a `response` result.\n//\ndefault interface incoming-handler {\n use pkg.types.{incoming-request, response-outparam}\n\n // The `handle` function takes an outparam instead of returning its response\n // so that the component may stream its response while streaming any other\n // request or response bodies. The callee MUST write a response to the\n // `response-out` and then finish the response before returning. The `handle`\n // function is allowed to continue execution after finishing the response\'s\n // output stream. While this post-response execution is taken off the\n // critical path, since there is no return value, there is no way to report\n // its success or failure.\n handle: func(\n request: incoming-request,\n response-out: response-outparam\n )\n}\n"; +const _: &str = "// The `wasi:http/proxy` world captures a widely-implementable intersection of\n// hosts that includes HTTP forward and reverse proxies. Components targeting\n// this world may concurrently stream in and out any number of incoming and\n// outgoing HTTP requests.\ndefault world proxy {\n // HTTP proxies have access to time and randomness.\n import random: random.random\n // TODO: add `import wall-clock: clocks.wall-clock`\n // TODO: add `import monotonic-clock: clocks.monotonic-clock`\n\n // This is the default logging handler to use when user code simply wants to\n // log to a developer-facing console (e.g., via `console.log()`).\n import console: logging.handler\n\n // TODO: Once the underlying Wit template machinery is implemented, add:\n //\n // import loggers: interface {\n // *: logging.handler\n // }\n //\n // which will allow a component to import any number of non-default logging\n // backends that different categories of log messages can be sent to.\n\n // TODO: add `import metrics: metrics.counters`\n\n // This is the default handler to use when user code simply wants to make an\n // HTTP request (e.g., via `fetch()`) but doesn\'t otherwise specify a\n // particular handler.\n import default-outgoing-HTTP: pkg.outgoing-handler\n\n // TODO: Once the underlying Wit template machinery is implemented, add:\n //\n // import upstreams: interface {\n // *: pkg.outgoing-handler\n // }\n //\n // which will allow a component to import any number of non-default backends\n // that HTTP requests can be dispatched to.\n\n // The host delivers incoming HTTP requests to a component by calling the\n // `handle` function of this exported interface. A host may arbitrarily reuse\n // or not reuse component instance when delivering incoming HTTP requests and\n // thus a component must be able to handle 0..N calls to `handle`.\n export HTTP: pkg.incoming-handler\n}\n"; +const _: &str = "// The `wasi:http/types` interface is meant to be imported by components to\n// define the HTTP resource types and operations used by the component\'s\n// imported and exported interfaces.\ndefault interface types {\n use io.streams.{input-stream, output-stream}\n use poll.poll.{pollable}\n \n // This type corresponds to HTTP standard Methods.\n variant method {\n get,\n head,\n post,\n put,\n delete,\n connect,\n options,\n trace,\n patch,\n other(string)\n }\n\n // This type corresponds to HTTP standard Related Schemes.\n variant scheme {\n HTTP,\n HTTPS,\n other(string)\n }\n\n // TODO: perhaps better align with HTTP semantics?\n // This type enumerates the different kinds of errors that may occur when\n // initially returning a response.\n variant error {\n invalid-url(string),\n timeout-error(string),\n protocol-error(string),\n status-error(u16),\n unexpected-error(string)\n }\n\n // This following block defines the `fields` resource which corresponds to\n // HTTP standard Fields. Soon, when resource types are added, the `type\n // fields = u32` type alias can be replaced by a proper `resource fields`\n // definition containing all the functions using the method syntactic sugar.\n type fields = u32\n drop-fields: func(fields: fields)\n new-fields: func(entries: list>) -> fields\n fields-get: func(fields: fields, name: string) -> list\n fields-set: func(fields: fields, name: string, value: list)\n fields-delete: func(fields: fields, name: string)\n fields-append: func(fields: fields, name: string, value: string)\n fields-entries: func(fields: fields) -> list>\n fields-clone: func(fields: fields) -> fields\n\n type headers = fields\n type trailers = fields\n\n // The following block defines stream types which corresponds to the HTTP\n // standard Contents and Trailers. With Preview3, all of these fields can be\n // replaced by a stream>. In the interim, we need to\n // build on separate resource types defined by `wasi:io/streams`. The\n // `finish-` functions emulate the stream\'s result value and MUST be called\n // exactly once after the final read/write from/to the stream before dropping\n // the stream.\n type incoming-stream = input-stream\n type outgoing-stream = output-stream\n finish-incoming-stream: func(s: incoming-stream) -> option\n finish-outgoing-stream: func(s: outgoing-stream, trailers: option)\n\n // The following block defines the `incoming-request` and `outgoing-request`\n // resource types that correspond to HTTP standard Requests. Soon, when\n // resource types are added, the `u32` type aliases can be replaced by\n // proper `resource` type definitions containing all the functions as\n // methods. Later, Preview2 will allow both types to be merged together into\n // a single `request` type (that uses the single `stream` type mentioned\n // above). The `consume` and `write` methods may only be called once (and\n // return failure thereafter).\n type incoming-request = u32\n type outgoing-request = u32\n drop-incoming-request: func(request: incoming-request)\n drop-outgoing-request: func(request: outgoing-request)\n incoming-request-method: func(request: incoming-request) -> method\n incoming-request-path: func(request: incoming-request) -> string\n incoming-request-scheme: func(request: incoming-request) -> option\n incoming-request-authority: func(request: incoming-request) -> string\n incoming-request-headers: func(request: incoming-request) -> headers\n incoming-request-consume: func(request: incoming-request) -> result\n new-outgoing-request: func(\n method: method,\n path: string,\n scheme: option,\n authority: string,\n headers: headers\n ) -> outgoing-request\n outgoing-request-write: func(request: outgoing-request) -> result\n\n // Additional optional parameters that can be set when making a request.\n record request-options {\n // The following timeouts are specific to the HTTP protocol and work\n // independently of the overall timeouts passed to `io.poll.poll-oneoff`.\n\n // The timeout for the initial connect.\n connect-timeout-ms: option,\n\n // The timeout for receiving the first byte of the response body.\n first-byte-timeout-ms: option,\n\n // The timeout for receiving the next chunk of bytes in the response body\n // stream.\n between-bytes-timeout-ms: option\n }\n\n // The following block defines a special resource type used by the\n // `wasi:http/incoming-handler` interface. When resource types are added, this\n // block can be replaced by a proper `resource response-outparam { ... }`\n // definition. Later, with Preview3, the need for an outparam goes away entirely\n // (the `wasi:http/handler` interface used for both incoming and outgoing can\n // simply return a `stream`).\n type response-outparam = u32\n drop-response-outparam: func(response: response-outparam)\n set-response-outparam: func(response: result) -> result\n\n // This type corresponds to the HTTP standard Status Code.\n type status-code = u16\n\n // The following block defines the `incoming-response` and `outgoing-response`\n // resource types that correspond to HTTP standard Responses. Soon, when\n // resource types are added, the `u32` type aliases can be replaced by proper\n // `resource` type definitions containing all the functions as methods. Later,\n // Preview2 will allow both types to be merged together into a single `response`\n // type (that uses the single `stream` type mentioned above). The `consume` and\n // `write` methods may only be called once (and return failure thereafter).\n type incoming-response = u32\n type outgoing-response = u32\n drop-incoming-response: func(response: incoming-response)\n drop-outgoing-response: func(response: outgoing-response)\n incoming-response-status: func(response: incoming-response) -> status-code\n incoming-response-headers: func(response: incoming-response) -> headers\n incoming-response-consume: func(response: incoming-response) -> result\n new-outgoing-response: func(\n status-code: status-code,\n headers: headers\n ) -> outgoing-response\n outgoing-response-write: func(response: outgoing-response) -> result\n\n // The following block defines a special resource type used by the\n // `wasi:http/outgoing-handler` interface to emulate\n // `future>` in advance of Preview3. Given a\n // `future-incoming-response`, the client can call the non-blocking `get`\n // method to get the result if it is available. If the result is not available,\n // the client can call `listen` to get a `pollable` that can be passed to\n // `io.poll.poll-oneoff`.\n type future-incoming-response = u32\n drop-future-incoming-response: func(f: future-incoming-response)\n future-incoming-response-get: func(f: future-incoming-response) -> option>\n listen-to-future-incoming-response: func(f: future-incoming-response) -> pollable\n}\n"; +struct WasiHttp {} +impl default_outgoing_http::Host for WasiHttp {} diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs new file mode 100644 index 000000000000..702dfa41335c --- /dev/null +++ b/crates/wasi-http/src/component_impl.rs @@ -0,0 +1,433 @@ +use crate::default_outgoing_http::Host; +pub use crate::r#struct::WasiHttp; +use crate::streams::Host as StreamsHost; +use crate::types::Host as TypesHost; +use crate::types::Scheme; +use std::str; +use std::vec::Vec; +use wasmtime::AsContext; +use wasmtime::AsContextMut; +use wasmtime::Caller; +use wasmtime::Extern; +use wasmtime::Memory; + +const MEMORY: &str = "memory"; + +#[derive(Debug, thiserror::Error)] +enum HttpError { + #[error("Memory not found")] + MemoryNotFound, + #[error("Memory access error")] + MemoryAccessError(#[from] wasmtime::MemoryAccessError), + #[error("Buffer too small")] + BufferTooSmall, + #[error("UTF-8 error")] + Utf8Error(#[from] std::str::Utf8Error), +} + +impl From for u32 { + fn from(e: HttpError) -> u32 { + match e { + HttpError::MemoryNotFound => 2, + HttpError::MemoryAccessError(_) => 3, + HttpError::BufferTooSmall => 4, + _ => panic!("Unsupported"), + } + } +} + +fn memory_get(caller: &mut Caller<'_, T>) -> Result { + if let Some(Extern::Memory(mem)) = caller.get_export(MEMORY) { + Ok(mem) + } else { + Err(HttpError::MemoryNotFound) + } +} + +/// Get a slice of length `len` from `memory`, starting at `offset`. +/// This will return an `HttpError::BufferTooSmall` if the size of the +/// requested slice is larger than the memory size. +fn slice_from_memory( + memory: &Memory, + mut ctx: impl AsContextMut, + offset: u32, + len: u32, +) -> Result, HttpError> { + let required_memory_size = offset.checked_add(len).ok_or(HttpError::BufferTooSmall)? as usize; + + if required_memory_size > memory.data_size(&mut ctx) { + return Err(HttpError::BufferTooSmall); + } + + let mut buf = vec![0u8; len as usize]; + memory.read(&mut ctx, offset as usize, buf.as_mut_slice())?; + Ok(buf) +} + +fn u32_from_memory(memory: &Memory, ctx: impl AsContextMut, ptr: u32) -> Result { + let slice = slice_from_memory(memory, ctx, ptr, 4)?; + let mut dst = [0u8; 4]; + dst.clone_from_slice(&slice[0..4]); + Ok(u32::from_le_bytes(dst)) +} + +/// Read a string of byte length `len` from `memory`, starting at `offset`. +fn string_from_memory( + memory: &Memory, + ctx: impl AsContextMut, + offset: u32, + len: u32, +) -> Result { + let slice = slice_from_memory(memory, ctx, offset, len)?; + Ok(std::str::from_utf8(&slice)?.to_string()) +} + +fn allocate_guest_pointer(caller: &mut Caller<'_, T>, size: u32) -> u32 { + let realloc = caller.get_export("cabi_realloc").unwrap(); + let func = realloc.into_func().unwrap(); + let typed = func + .typed::<(u32, u32, u32, u32), u32>(caller.as_context()) + .unwrap(); + typed + .call(caller.as_context_mut(), (0, 0, 4, size)) + .unwrap() +} + +fn u32_array_to_u8(arr: &[u32]) -> Vec { + let mut result = std::vec::Vec::new(); + for val in arr.iter() { + let bytes = val.to_le_bytes(); + for b in bytes.iter() { + result.push(*b); + } + } + result +} + +pub fn add_component_to_linker( + linker: &mut wasmtime::Linker, + get_cx: impl Fn(&mut T) -> &mut WasiHttp + Send + Sync + Copy + 'static, +) -> anyhow::Result<()> { + linker.func_wrap( + "default-outgoing-HTTP", + "handle", + move |mut caller: Caller<'_, T>, + request: u32, + _b: i32, + _c: i32, + _d: i32, + _e: i32, + _f: i32, + _g: i32, + _h: i32| + -> u32 { + // TODO: use options here. + match get_cx(caller.data_mut()).handle(request, None) { + Ok(v) => v, + Err(_) => 0, + } + }, + )?; + linker.func_wrap( + "types", + "new-outgoing-request", + move |mut caller: Caller<'_, T>, + method: i32, + _b: i32, + _c: i32, + path_ptr: u32, + path_len: u32, + query_ptr: u32, + query_len: u32, + scheme_is_some: i32, + scheme: i32, + _h: i32, + _i: i32, + authority_ptr: u32, + authority_len: u32, + headers: u32| + -> u32 { + let memory = match memory_get(&mut caller) { + Ok(m) => m, + Err(_) => return 0, + }; + let path = + string_from_memory(&memory, caller.as_context_mut(), path_ptr, path_len).unwrap(); + let query = + string_from_memory(&memory, caller.as_context_mut(), query_ptr, query_len).unwrap(); + let authority = string_from_memory( + &memory, + caller.as_context_mut(), + authority_ptr, + authority_len, + ) + .unwrap(); + + let mut s = Scheme::Https; + if scheme_is_some == 1 { + s = match scheme { + 0 => Scheme::Http, + 1 => Scheme::Https, + _ => panic!("unsupported!"), + }; + } + let m = match method { + 0 => crate::types::Method::Get, + 1 => crate::types::Method::Head, + 2 => crate::types::Method::Post, + 3 => crate::types::Method::Put, + 4 => crate::types::Method::Delete, + 5 => crate::types::Method::Connect, + 6 => crate::types::Method::Options, + 7 => crate::types::Method::Trace, + 8 => crate::types::Method::Patch, + _ => panic!("unsupported method!"), + }; + + let ctx = get_cx(caller.data_mut()); + match ctx.new_outgoing_request(m, path, query, Some(s), authority, headers) { + Ok(v) => v, + Err(_) => 0, + } + }, + )?; + linker.func_wrap( + "types", + "incoming-response-status", + move |mut caller: Caller<'_, T>, id: u32| -> u32 { + let ctx = get_cx(caller.data_mut()); + ctx.incoming_response_status(id).unwrap().into() + }, + )?; + linker.func_wrap( + "types", + "future-incoming-response-get", + move |mut caller: Caller<'_, T>, future: u32, ptr: i32| { + let memory = memory_get(&mut caller).unwrap(); + + // First == is_some + // Second == is_err + // Third == {ok: is_err = false, tag: is_err = true} + // Fourth == string ptr + // Fifth == string len + let result: [u32; 5] = [1, 0, future, 0, 0]; + let raw = u32_array_to_u8(&result); + + memory + .write(caller.as_context_mut(), ptr as _, &raw) + .unwrap(); + }, + )?; + linker.func_wrap( + "types", + "incoming-response-consume", + move |mut caller: Caller<'_, T>, response: u32, ptr: i32| { + let memory = memory_get(&mut caller).unwrap(); + + // First == is_some + // Second == stream_id + let result: [u32; 2] = [0, response]; + let raw = u32_array_to_u8(&result); + + memory + .write(caller.as_context_mut(), ptr as _, &raw) + .unwrap(); + }, + )?; + linker.func_wrap( + "poll", + "drop-pollable", + move |_caller: Caller<'_, T>, _a: i32| {}, + )?; + linker.func_wrap( + "types", + "drop-fields", + move |mut caller: Caller<'_, T>, ptr: u32| { + let ctx = get_cx(caller.data_mut()); + ctx.drop_fields(ptr) + }, + )?; + linker.func_wrap( + "streams", + "drop-input-stream", + move |mut caller: Caller<'_, T>, id: u32| { + let ctx = get_cx(caller.data_mut()); + match ctx.drop_input_stream(id) { + Ok(_) => {} + Err(_) => {} + }; + }, + )?; + linker.func_wrap( + "types", + "outgoing-request-write", + move |mut caller: Caller<'_, T>, request: u32, ptr: u32| { + let ctx = get_cx(caller.data_mut()); + let stream = ctx.outgoing_request_write(request).unwrap().unwrap(); + + let memory = memory_get(&mut caller).unwrap(); + // First == is_some + // Second == stream_id + let result: [u32; 2] = [0, stream]; + let raw = u32_array_to_u8(&result); + + memory + .write(caller.as_context_mut(), ptr as _, &raw) + .unwrap(); + }, + )?; + linker.func_wrap( + "types", + "drop-outgoing-request", + move |mut caller: Caller<'_, T>, id: u32| { + let ctx = get_cx(caller.data_mut()); + ctx.drop_outgoing_request(id).unwrap(); + }, + )?; + linker.func_wrap( + "types", + "drop-incoming-response", + move |mut caller: Caller<'_, T>, id: u32| { + let ctx = get_cx(caller.data_mut()); + ctx.drop_incoming_response(id).unwrap() + }, + )?; + linker.func_wrap( + "types", + "new-fields", + move |mut caller: Caller<'_, T>, base_ptr: u32, len: u32| -> u32 { + let memory = memory_get(&mut caller).unwrap(); + + let mut vec = Vec::new(); + let mut i = 0; + // TODO: read this more efficiently as a single block. + while i < len { + let ptr = base_ptr + i * 16; + let name_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr).unwrap(); + let name_len = u32_from_memory(&memory, caller.as_context_mut(), ptr + 4).unwrap(); + let value_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr + 8).unwrap(); + let value_len = + u32_from_memory(&memory, caller.as_context_mut(), ptr + 12).unwrap(); + + let name = string_from_memory(&memory, caller.as_context_mut(), name_ptr, name_len) + .unwrap(); + let value = + string_from_memory(&memory, caller.as_context_mut(), value_ptr, value_len) + .unwrap(); + + vec.push((name, value)); + i = i + 1; + } + + let ctx = get_cx(caller.data_mut()); + match ctx.new_fields(vec) { + Ok(v) => v, + Err(_) => 0, + } + }, + )?; + linker.func_wrap( + "streams", + "read", + move |mut caller: Caller<'_, T>, stream: u32, len: u64, ptr: u32| { + let ctx = get_cx(caller.data_mut()); + let bytes_tuple = ctx.read(stream, len).unwrap().unwrap(); + let bytes = bytes_tuple.0; + let done = match bytes_tuple.1 { + true => 1, + false => 0, + }; + let body_len: u32 = bytes.len().try_into().unwrap(); + let out_ptr = allocate_guest_pointer(&mut caller, body_len); + let result: [u32; 4] = [0, out_ptr, body_len, done]; + let raw = u32_array_to_u8(&result); + + let memory = memory_get(&mut caller).unwrap(); + memory + .write(caller.as_context_mut(), out_ptr as _, &bytes) + .unwrap(); + memory + .write(caller.as_context_mut(), ptr as _, &raw) + .unwrap(); + }, + )?; + linker.func_wrap( + "streams", + "write", + move |mut caller: Caller<'_, T>, stream: u32, body_ptr: u32, body_len: u32, ptr: u32| { + let memory = memory_get(&mut caller).unwrap(); + let body = + string_from_memory(&memory, caller.as_context_mut(), body_ptr, body_len).unwrap(); + + let result: [u32; 3] = [0, 0, body_len]; + let raw = u32_array_to_u8(&result); + + let memory = memory_get(&mut caller).unwrap(); + memory + .write(caller.as_context_mut(), ptr as _, &raw) + .unwrap(); + + let ctx = get_cx(caller.data_mut()); + ctx.write(stream, body.as_bytes().to_vec()) + .unwrap() + .unwrap(); + }, + )?; + linker.func_wrap( + "types", + "fields-entries", + move |mut caller: Caller<'_, T>, fields: u32, out_ptr: u32| { + let ctx = get_cx(caller.data_mut()); + let entries = ctx.fields_entries(fields).unwrap(); + + let header_len = entries.len(); + let tuple_ptr = + allocate_guest_pointer(&mut caller, (16 * header_len).try_into().unwrap()); + let mut ptr = tuple_ptr; + for item in entries.iter() { + let name = &item.0; + let value = &item.1; + let name_len: u32 = name.len().try_into().unwrap(); + let value_len: u32 = value.len().try_into().unwrap(); + + let name_ptr = allocate_guest_pointer(&mut caller, name_len); + let value_ptr = allocate_guest_pointer(&mut caller, value_len); + + let memory = memory_get(&mut caller).unwrap(); + memory + .write(caller.as_context_mut(), name_ptr as _, &name.as_bytes()) + .unwrap(); + memory + .write(caller.as_context_mut(), value_ptr as _, &value.as_bytes()) + .unwrap(); + + let pair: [u32; 4] = [name_ptr, name_len, value_ptr, value_len]; + let raw_pair = u32_array_to_u8(&pair); + memory + .write(caller.as_context_mut(), ptr as _, &raw_pair) + .unwrap(); + + ptr = ptr + 16; + } + + let memory = memory_get(&mut caller).unwrap(); + let result: [u32; 2] = [tuple_ptr, header_len.try_into().unwrap()]; + let raw = u32_array_to_u8(&result); + memory + .write(caller.as_context_mut(), out_ptr as _, &raw) + .unwrap(); + }, + )?; + linker.func_wrap( + "types", + "incoming-response-headers", + move |mut caller: Caller<'_, T>, handle: u32| -> u32 { + let ctx = get_cx(caller.data_mut()); + match ctx.incoming_response_headers(handle) { + Ok(h) => h, + Err(_) => 0, + } + }, + )?; + Ok(()) +} diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs new file mode 100644 index 000000000000..cc83d50a9372 --- /dev/null +++ b/crates/wasi-http/src/http_impl.rs @@ -0,0 +1,145 @@ +use crate::r#struct::ActiveResponse; +pub use crate::r#struct::WasiHttp; +use crate::types::Scheme; +use bytes::{BufMut, Bytes, BytesMut}; +use futures::executor; +use http_body_util::{BodyExt, Full}; +use hyper::Method; +use hyper::Request; +use tokio::net::TcpStream; +use tokio::runtime::Runtime; + +impl crate::default_outgoing_http::Host for WasiHttp { + fn handle( + &mut self, + request_id: crate::default_outgoing_http::OutgoingRequest, + options: Option, + ) -> wasmtime::Result { + // TODO: Initialize this once? + let rt = Runtime::new().unwrap(); + let _enter = rt.enter(); + + let f = self.handle_async(request_id, options); + match executor::block_on(f) { + Ok(r) => { + println!("{} OK", r); + Ok(r) + } + Err(e) => { + println!("{} ERR", e); + Err(e) + } + } + } +} + +fn port_for_scheme(scheme: &Option) -> &str { + match scheme { + Some(s) => match s { + Scheme::Http => ":80", + Scheme::Https => ":443", + // This should never happen. + _ => panic!("unsupported scheme!"), + }, + None => ":443", + } +} + +impl WasiHttp { + async fn handle_async( + &mut self, + request_id: crate::default_outgoing_http::OutgoingRequest, + _options: Option, + ) -> wasmtime::Result { + let request = match self.requests.get(&request_id) { + Some(r) => r, + None => return Err(anyhow::anyhow!("not found!")), + }; + + let method = match request.method { + crate::types::Method::Get => Method::GET, + crate::types::Method::Head => Method::HEAD, + crate::types::Method::Post => Method::POST, + crate::types::Method::Put => Method::PUT, + crate::types::Method::Delete => Method::DELETE, + crate::types::Method::Connect => Method::CONNECT, + crate::types::Method::Options => Method::OPTIONS, + crate::types::Method::Trace => Method::TRACE, + crate::types::Method::Patch => Method::PATCH, + _ => return Err(anyhow::anyhow!("unknown method!")), + }; + + let scheme = match request.scheme.as_ref().unwrap_or(&Scheme::Https) { + Scheme::Http => "http://", + Scheme::Https => "https://", + // TODO: this is wrong, fix this. + _ => panic!("Unsupported scheme!"), + }; + + // Largely adapted from https://hyper.rs/guides/1/client/basic/ + let authority = match request.authority.find(":") { + Some(_) => request.authority.clone(), + None => request.authority.clone() + port_for_scheme(&request.scheme), + }; + + let mut sender = if scheme == "https://" { + let stream = TcpStream::connect(authority).await?; + let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; + let connector = tokio_native_tls::TlsConnector::from(connector); + let stream = connector.connect(&request.authority, stream).await?; + let (s, conn) = hyper::client::conn::http1::handshake(stream).await?; + tokio::task::spawn(async move { + if let Err(err) = conn.await { + println!("Connection failed: {:?}", err); + } + }); + s + } else { + let tcp = TcpStream::connect(authority).await?; + let (s, conn) = hyper::client::conn::http1::handshake(tcp).await?; + tokio::task::spawn(async move { + if let Err(err) = conn.await { + println!("Connection failed: {:?}", err); + } + }); + s + }; + + let url = scheme.to_owned() + &request.authority + &request.path + &request.query; + + let mut call = Request::builder() + .method(method) + .uri(url) + .header(hyper::header::HOST, request.authority.as_str()); + + for (key, val) in request.headers.iter() { + for item in val { + call = call.header(key, item.clone()); + } + } + + let response_id = self.response_id_base; + self.response_id_base = self.response_id_base + 1; + let mut response = ActiveResponse::new(response_id); + let body = Full::::new(request.body.clone()); + let mut res = sender.send_request(call.body(body)?).await?; + response.status = res.status().try_into()?; + for (key, value) in res.headers().iter() { + let mut vec = std::vec::Vec::new(); + vec.push(value.to_str()?.to_string()); + response + .response_headers + .insert(key.as_str().to_string(), vec); + } + let mut buf = BytesMut::new(); + while let Some(next) = res.frame().await { + let frame = next?; + if let Some(chunk) = frame.data_ref() { + buf.put(chunk.clone()); + } + } + response.body = buf.freeze(); + self.responses.insert(response_id, response); + Ok(response_id) + } +} diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs new file mode 100644 index 000000000000..eef1cc57aa54 --- /dev/null +++ b/crates/wasi-http/src/lib.rs @@ -0,0 +1,27 @@ +use crate::component_impl::add_component_to_linker; +pub use crate::r#struct::WasiHttp; + +wasmtime::component::bindgen!("proxy"); + +pub mod component_impl; +pub mod http_impl; +pub mod streams_impl; +pub mod r#struct; +pub mod types_impl; + +pub fn add_to_component_linker( + linker: &mut wasmtime::component::Linker, + get_cx: impl Fn(&mut T) -> &mut WasiHttp + Send + Sync + Copy + 'static, +) -> anyhow::Result<()> { + default_outgoing_http::add_to_linker(linker, get_cx)?; + types::add_to_linker(linker, get_cx)?; + streams::add_to_linker(linker, get_cx)?; + Ok(()) +} + +pub fn add_to_linker( + linker: &mut wasmtime::Linker, + get_cx: impl Fn(&mut T) -> &mut WasiHttp + Send + Sync + Copy + 'static, +) -> anyhow::Result<()> { + add_component_to_linker(linker, get_cx) +} diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs new file mode 100644 index 000000000000..7e186c057b18 --- /dev/null +++ b/crates/wasi-http/src/streams_impl.rs @@ -0,0 +1,86 @@ +use crate::poll::Pollable; +use crate::streams::{InputStream, OutputStream, StreamError}; +use crate::WasiHttp; +use std::vec::Vec; + +impl crate::streams::Host for WasiHttp { + fn read( + &mut self, + stream: InputStream, + _len: u64, + ) -> wasmtime::Result, bool), StreamError>> { + let response = match self.responses.get(&stream) { + Some(r) => r, + None => return Err(anyhow::anyhow!("not found")), + }; + let bytes = response.body.clone(); + Ok(Ok((bytes.to_vec(), true))) + } + + fn skip( + &mut self, + _this: InputStream, + _len: u64, + ) -> wasmtime::Result> { + todo!(); + } + + fn subscribe_to_input_stream(&mut self, _this: InputStream) -> wasmtime::Result { + todo!(); + } + + fn drop_input_stream(&mut self, stream: InputStream) -> wasmtime::Result<()> { + match self.responses.get_mut(&stream) { + Some(r) => r.body.truncate(0), + None => {} + } + Ok(()) + } + + fn write( + &mut self, + this: OutputStream, + buf: Vec, + ) -> wasmtime::Result> { + match self.requests.get_mut(&this) { + Some(r) => { + r.body = bytes::Bytes::from(buf.clone()); + } + None => return Err(anyhow::anyhow!("not found")), + }; + Ok(Ok(buf.len().try_into().unwrap())) + } + + fn write_zeroes( + &mut self, + _this: OutputStream, + _len: u64, + ) -> wasmtime::Result> { + todo!(); + } + + fn splice( + &mut self, + _this: OutputStream, + _src: InputStream, + _len: u64, + ) -> wasmtime::Result> { + todo!(); + } + + fn forward( + &mut self, + _this: OutputStream, + _src: InputStream, + ) -> wasmtime::Result> { + todo!(); + } + + fn subscribe_to_output_stream(&mut self, _this: OutputStream) -> wasmtime::Result { + todo!(); + } + + fn drop_output_stream(&mut self, _this: OutputStream) -> wasmtime::Result<()> { + todo!(); + } +} diff --git a/crates/wasi-http/src/struct.rs b/crates/wasi-http/src/struct.rs new file mode 100644 index 000000000000..8d1d30a183f0 --- /dev/null +++ b/crates/wasi-http/src/struct.rs @@ -0,0 +1,76 @@ +use crate::types::{Method, Scheme}; +use bytes::Bytes; +use std::collections::HashMap; + +#[derive(Clone)] +pub struct WasiHttp { + pub request_id_base: u32, + pub response_id_base: u32, + pub fields_id_base: u32, + pub requests: HashMap, + pub responses: HashMap, + pub fields: HashMap>>, +} + +#[derive(Clone)] +pub struct ActiveRequest { + pub id: u32, + pub active_request: bool, + pub method: Method, + pub scheme: Option, + pub path: String, + pub query: String, + pub authority: String, + pub headers: HashMap>, + pub body: Bytes, +} + +#[derive(Clone)] +pub struct ActiveResponse { + pub id: u32, + pub active_response: bool, + pub status: u16, + pub body: Bytes, + pub response_headers: HashMap>, +} + +impl ActiveRequest { + pub fn new(id: u32) -> Self { + Self { + id: id, + active_request: false, + method: Method::Get, + scheme: Some(Scheme::Http), + path: "".to_string(), + query: "".to_string(), + authority: "".to_string(), + headers: HashMap::new(), + body: Bytes::new(), + } + } +} + +impl ActiveResponse { + pub fn new(id: u32) -> Self { + Self { + id: id, + active_response: false, + status: 0, + body: bytes::Bytes::new(), + response_headers: HashMap::new(), + } + } +} + +impl WasiHttp { + pub fn new() -> Self { + Self { + request_id_base: 1, + response_id_base: 1, + fields_id_base: 1, + requests: HashMap::new(), + responses: HashMap::new(), + fields: HashMap::new(), + } + } +} diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs new file mode 100644 index 000000000000..a3e828e6a5ac --- /dev/null +++ b/crates/wasi-http/src/types_impl.rs @@ -0,0 +1,260 @@ +use crate::poll::Pollable; +use crate::r#struct::ActiveRequest; +use crate::types::{ + Error, Fields, FutureIncomingResponse, Headers, IncomingRequest, IncomingResponse, + IncomingStream, Method, OutgoingRequest, OutgoingResponse, OutgoingStream, ResponseOutparam, + Scheme, StatusCode, Trailers, +}; +use crate::WasiHttp; +use std::collections::HashMap; + +impl crate::types::Host for WasiHttp { + fn drop_fields(&mut self, fields: Fields) -> wasmtime::Result<()> { + self.fields.remove(&fields); + Ok(()) + } + fn new_fields(&mut self, entries: Vec<(String, String)>) -> wasmtime::Result { + let mut map = HashMap::new(); + for item in entries.iter() { + let mut vec = std::vec::Vec::new(); + vec.push(item.1.clone()); + map.insert(item.0.clone(), vec); + } + + let id = self.fields_id_base; + self.fields_id_base = id + 1; + self.fields.insert(id, map); + + Ok(id) + } + fn fields_get(&mut self, fields: Fields, name: String) -> wasmtime::Result> { + let res = match self.fields.get(&fields) { + Some(m) => match m.get(&name) { + Some(v) => v.clone(), + None => return Err(anyhow::anyhow!("key not found")), + }, + None => return Err(anyhow::anyhow!("fields not found")), + }; + Ok(res) + } + fn fields_set( + &mut self, + fields: Fields, + name: String, + value: Vec, + ) -> wasmtime::Result<()> { + match self.fields.get_mut(&fields) { + Some(m) => { + m.insert(name, value.clone()); + Ok(()) + } + None => Err(anyhow::anyhow!("fields not found")), + } + } + fn fields_delete(&mut self, fields: Fields, name: String) -> wasmtime::Result<()> { + match self.fields.get_mut(&fields) { + Some(m) => m.remove(&name), + None => None, + }; + Ok(()) + } + fn fields_append( + &mut self, + fields: Fields, + name: String, + value: String, + ) -> wasmtime::Result<()> { + match self.fields.get_mut(&fields) { + Some(m) => { + match m.get_mut(&name) { + Some(v) => v.push(value), + None => { + let mut vec = std::vec::Vec::new(); + vec.push(value); + m.insert(name, vec); + } + }; + Ok(()) + } + None => Err(anyhow::anyhow!("Unknown fields!")), + } + } + fn fields_entries(&mut self, fields: Fields) -> wasmtime::Result> { + let field_map = match self.fields.get(&fields) { + Some(m) => m, + None => return Err(anyhow::anyhow!("fields not found.")), + }; + let mut result = Vec::new(); + for (name, value) in field_map { + result.push((name.clone(), value[0].clone())); + } + Ok(result) + } + fn fields_clone(&mut self, fields: Fields) -> wasmtime::Result { + let id = self.fields_id_base; + self.fields_id_base = self.fields_id_base + 1; + + match self.fields.get(&fields) { + Some(m) => { + self.fields.insert(id, m.clone()); + } + None => {} + } + Ok(id) + } + fn finish_incoming_stream(&mut self, _s: IncomingStream) -> wasmtime::Result> { + todo!() + } + fn finish_outgoing_stream( + &mut self, + _s: OutgoingStream, + _trailers: Option, + ) -> wasmtime::Result<()> { + todo!() + } + fn drop_incoming_request(&mut self, _request: IncomingRequest) -> wasmtime::Result<()> { + todo!() + } + fn drop_outgoing_request(&mut self, request: OutgoingRequest) -> wasmtime::Result<()> { + self.requests.remove(&request); + Ok(()) + } + fn incoming_request_method(&mut self, _request: IncomingRequest) -> wasmtime::Result { + todo!() + } + fn incoming_request_path(&mut self, _request: IncomingRequest) -> wasmtime::Result { + todo!() + } + fn incoming_request_scheme( + &mut self, + _request: IncomingRequest, + ) -> wasmtime::Result> { + todo!() + } + fn incoming_request_authority( + &mut self, + _request: IncomingRequest, + ) -> wasmtime::Result { + todo!() + } + fn incoming_request_headers(&mut self, _request: IncomingRequest) -> wasmtime::Result { + todo!() + } + fn incoming_request_consume( + &mut self, + _request: IncomingRequest, + ) -> wasmtime::Result> { + todo!() + } + fn incoming_request_query(&mut self, _request: IncomingRequest) -> wasmtime::Result { + todo!() + } + fn new_outgoing_request( + &mut self, + method: Method, + path: String, + query: String, + scheme: Option, + authority: String, + headers: Headers, + ) -> wasmtime::Result { + let id = self.request_id_base; + self.request_id_base = self.request_id_base + 1; + + let mut req = ActiveRequest::new(id); + req.path = path; + req.query = query; + req.authority = authority; + req.method = method; + req.headers = match self.fields.get(&headers) { + Some(h) => h.clone(), + None => return Err(anyhow::anyhow!("headers not found.")), + }; + req.scheme = scheme; + self.requests.insert(id, req); + Ok(id) + } + fn outgoing_request_write( + &mut self, + request: OutgoingRequest, + ) -> wasmtime::Result> { + Ok(Ok(request)) + } + fn drop_response_outparam(&mut self, _response: ResponseOutparam) -> wasmtime::Result<()> { + todo!() + } + fn set_response_outparam( + &mut self, + _response: Result, + ) -> wasmtime::Result> { + todo!() + } + fn drop_incoming_response(&mut self, response: IncomingResponse) -> wasmtime::Result<()> { + self.responses.remove(&response); + Ok(()) + } + fn drop_outgoing_response(&mut self, _response: OutgoingResponse) -> wasmtime::Result<()> { + todo!() + } + fn incoming_response_status( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result { + match self.responses.get(&response) { + Some(r) => Ok(r.status), + None => Err(anyhow::anyhow!("response not found")), + } + } + fn incoming_response_headers( + &mut self, + response: IncomingResponse, + ) -> wasmtime::Result { + match self.responses.get(&response) { + Some(r) => { + let id = self.fields_id_base; + self.fields_id_base = self.fields_id_base + 1; + + self.fields.insert(id, r.response_headers.clone()); + Ok(id) + } + None => Err(anyhow::anyhow!("response not found")), + } + } + fn incoming_response_consume( + &mut self, + _response: IncomingResponse, + ) -> wasmtime::Result> { + todo!() + } + fn new_outgoing_response( + &mut self, + _status_code: StatusCode, + _headers: Headers, + ) -> wasmtime::Result { + todo!() + } + fn outgoing_response_write( + &mut self, + _response: OutgoingResponse, + ) -> wasmtime::Result> { + todo!() + } + fn drop_future_incoming_response( + &mut self, + _f: FutureIncomingResponse, + ) -> wasmtime::Result<()> { + todo!() + } + fn future_incoming_response_get( + &mut self, + _f: FutureIncomingResponse, + ) -> wasmtime::Result>> { + todo!() + } + fn listen_to_future_incoming_response( + &mut self, + _f: FutureIncomingResponse, + ) -> wasmtime::Result { + todo!() + } +} diff --git a/crates/wasi-http/wasi-http b/crates/wasi-http/wasi-http new file mode 160000 index 000000000000..1185b0a0224b --- /dev/null +++ b/crates/wasi-http/wasi-http @@ -0,0 +1 @@ +Subproject commit 1185b0a0224bc3e11274ad6298fd065cae472651 diff --git a/crates/wasi-http/wit b/crates/wasi-http/wit new file mode 120000 index 000000000000..a4267f5b0445 --- /dev/null +++ b/crates/wasi-http/wit @@ -0,0 +1 @@ +wasi-http/wit \ No newline at end of file diff --git a/src/commands/run.rs b/src/commands/run.rs index cea3ef741021..f9aaca631d99 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -26,6 +26,8 @@ use wasmtime_wasi_crypto::WasiCryptoCtx; #[cfg(feature = "wasi-threads")] use wasmtime_wasi_threads::WasiThreadsCtx; +use wasi_http::WasiHttp; + fn parse_module(s: &OsStr) -> anyhow::Result { // Do not accept wasmtime subcommand names as the module name match s.to_str() { @@ -459,6 +461,7 @@ struct Host { wasi_nn: Option>, #[cfg(feature = "wasi-threads")] wasi_threads: Option>>, + wasi_http: Option, } /// Populates the given `Linker` with WASI APIs. @@ -558,6 +561,12 @@ fn populate_with_wasi( } } + if wasi_modules.wasi_http { + let w_http = WasiHttp::new(); + wasi_http::add_to_linker(linker, |host: &mut Host| host.wasi_http.as_mut().unwrap())?; + store.data_mut().wasi_http = Some(w_http); + } + Ok(()) } From 63887e0743a518ca4600c4993cae1959a32c26df Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Sat, 18 Mar 2023 05:27:52 +0000 Subject: [PATCH 02/46] Reset Cargo.lock --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2a065982780..cfea7a51699c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2211,9 +2211,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.46" +version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", "cfg-if", @@ -2243,9 +2243,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.81" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg 1.1.0", "cc", @@ -2331,7 +2331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.6", ] [[package]] @@ -2350,15 +2350,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-sys 0.42.0", ] [[package]] @@ -3008,9 +3008,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ "libc", ] From 8ecc77e4e2358f9c64134187409c68f27c5b3d86 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Sat, 18 Mar 2023 15:45:25 +0000 Subject: [PATCH 03/46] Switch to bail!, plumb options partially. --- crates/wasi-http/src/component_impl.rs | 40 ++++++++++++++++++++------ crates/wasi-http/src/http_impl.rs | 17 +++++++---- crates/wasi-http/src/streams_impl.rs | 5 ++-- crates/wasi-http/src/types_impl.rs | 17 +++++------ 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs index 702dfa41335c..b3948c3f8f47 100644 --- a/crates/wasi-http/src/component_impl.rs +++ b/crates/wasi-http/src/component_impl.rs @@ -2,6 +2,7 @@ use crate::default_outgoing_http::Host; pub use crate::r#struct::WasiHttp; use crate::streams::Host as StreamsHost; use crate::types::Host as TypesHost; +use crate::types::RequestOptions; use crate::types::Scheme; use std::str; use std::vec::Vec; @@ -113,16 +114,37 @@ pub fn add_component_to_linker( "handle", move |mut caller: Caller<'_, T>, request: u32, - _b: i32, - _c: i32, - _d: i32, - _e: i32, - _f: i32, - _g: i32, - _h: i32| + has_options: i32, + has_timeout: i32, + timeout_ms: u32, + has_first_byte_timeout: i32, + first_byte_timeout_ms: u32, + has_between_bytes_timeout: i32, + between_bytes_timeout_ms: u32| -> u32 { - // TODO: use options here. - match get_cx(caller.data_mut()).handle(request, None) { + let options = if has_options == 1 { + Some(RequestOptions { + connect_timeout_ms: if has_timeout == 1 { + Some(timeout_ms) + } else { + None + }, + first_byte_timeout_ms: if has_first_byte_timeout == 1 { + Some(first_byte_timeout_ms) + } else { + None + }, + between_bytes_timeout_ms: if has_between_bytes_timeout == 1 { + Some(between_bytes_timeout_ms) + } else { + None + }, + }) + } else { + None + }; + + match get_cx(caller.data_mut()).handle(request, options) { Ok(v) => v, Err(_) => 0, } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index cc83d50a9372..93c76d862378 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -1,6 +1,7 @@ use crate::r#struct::ActiveResponse; pub use crate::r#struct::WasiHttp; use crate::types::Scheme; +use anyhow::bail; use bytes::{BufMut, Bytes, BytesMut}; use futures::executor; use http_body_util::{BodyExt, Full}; @@ -49,11 +50,16 @@ impl WasiHttp { async fn handle_async( &mut self, request_id: crate::default_outgoing_http::OutgoingRequest, - _options: Option, + options: Option, ) -> wasmtime::Result { + if options.is_some() { + // Hyper 1.0.x does not appear to support timeouts, we probably have + // to implement them ourselves :( + bail!("Options are not supported (for now)") + } let request = match self.requests.get(&request_id) { Some(r) => r, - None => return Err(anyhow::anyhow!("not found!")), + None => bail!("not found!"), }; let method = match request.method { @@ -66,7 +72,7 @@ impl WasiHttp { crate::types::Method::Options => Method::OPTIONS, crate::types::Method::Trace => Method::TRACE, crate::types::Method::Patch => Method::PATCH, - _ => return Err(anyhow::anyhow!("unknown method!")), + _ => bail!("unknown method!"), }; let scheme = match request.scheme.as_ref().unwrap_or(&Scheme::Https) { @@ -83,10 +89,11 @@ impl WasiHttp { }; let mut sender = if scheme == "https://" { - let stream = TcpStream::connect(authority).await?; + let stream = TcpStream::connect(authority.clone()).await?; let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; let connector = tokio_native_tls::TlsConnector::from(connector); - let stream = connector.connect(&request.authority, stream).await?; + let host = authority.split(":").next().unwrap_or(&authority); + let stream = connector.connect(&host, stream).await?; let (s, conn) = hyper::client::conn::http1::handshake(stream).await?; tokio::task::spawn(async move { if let Err(err) = conn.await { diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs index 7e186c057b18..b66742d151bd 100644 --- a/crates/wasi-http/src/streams_impl.rs +++ b/crates/wasi-http/src/streams_impl.rs @@ -1,6 +1,7 @@ use crate::poll::Pollable; use crate::streams::{InputStream, OutputStream, StreamError}; use crate::WasiHttp; +use anyhow::bail; use std::vec::Vec; impl crate::streams::Host for WasiHttp { @@ -11,7 +12,7 @@ impl crate::streams::Host for WasiHttp { ) -> wasmtime::Result, bool), StreamError>> { let response = match self.responses.get(&stream) { Some(r) => r, - None => return Err(anyhow::anyhow!("not found")), + None => bail!("not found"), }; let bytes = response.body.clone(); Ok(Ok((bytes.to_vec(), true))) @@ -46,7 +47,7 @@ impl crate::streams::Host for WasiHttp { Some(r) => { r.body = bytes::Bytes::from(buf.clone()); } - None => return Err(anyhow::anyhow!("not found")), + None => bail!("not found"), }; Ok(Ok(buf.len().try_into().unwrap())) } diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index a3e828e6a5ac..05aef0116906 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -6,6 +6,7 @@ use crate::types::{ Scheme, StatusCode, Trailers, }; use crate::WasiHttp; +use anyhow::bail; use std::collections::HashMap; impl crate::types::Host for WasiHttp { @@ -31,9 +32,9 @@ impl crate::types::Host for WasiHttp { let res = match self.fields.get(&fields) { Some(m) => match m.get(&name) { Some(v) => v.clone(), - None => return Err(anyhow::anyhow!("key not found")), + None => bail!("key not found"), }, - None => return Err(anyhow::anyhow!("fields not found")), + None => bail!("fields not found"), }; Ok(res) } @@ -48,7 +49,7 @@ impl crate::types::Host for WasiHttp { m.insert(name, value.clone()); Ok(()) } - None => Err(anyhow::anyhow!("fields not found")), + None => bail!("fields not found"), } } fn fields_delete(&mut self, fields: Fields, name: String) -> wasmtime::Result<()> { @@ -76,13 +77,13 @@ impl crate::types::Host for WasiHttp { }; Ok(()) } - None => Err(anyhow::anyhow!("Unknown fields!")), + None => bail!("Unknown fields!"), } } fn fields_entries(&mut self, fields: Fields) -> wasmtime::Result> { let field_map = match self.fields.get(&fields) { Some(m) => m, - None => return Err(anyhow::anyhow!("fields not found.")), + None => bail!("fields not found."), }; let mut result = Vec::new(); for (name, value) in field_map { @@ -168,7 +169,7 @@ impl crate::types::Host for WasiHttp { req.method = method; req.headers = match self.fields.get(&headers) { Some(h) => h.clone(), - None => return Err(anyhow::anyhow!("headers not found.")), + None => bail!("headers not found."), }; req.scheme = scheme; self.requests.insert(id, req); @@ -202,7 +203,7 @@ impl crate::types::Host for WasiHttp { ) -> wasmtime::Result { match self.responses.get(&response) { Some(r) => Ok(r.status), - None => Err(anyhow::anyhow!("response not found")), + None => bail!("response not found"), } } fn incoming_response_headers( @@ -217,7 +218,7 @@ impl crate::types::Host for WasiHttp { self.fields.insert(id, r.response_headers.clone()); Ok(id) } - None => Err(anyhow::anyhow!("response not found")), + None => bail!("response not found"), } } fn incoming_response_consume( From 8657c7c74276b0d8c4963171c40174aed0627207 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 21 Mar 2023 03:31:22 +0000 Subject: [PATCH 04/46] Implement timeouts. --- crates/wasi-http/src/http_impl.rs | 40 +++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 93c76d862378..5fcc432abe26 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -1,14 +1,16 @@ use crate::r#struct::ActiveResponse; pub use crate::r#struct::WasiHttp; -use crate::types::Scheme; +use crate::types::{RequestOptions, Scheme}; use anyhow::bail; use bytes::{BufMut, Bytes, BytesMut}; use futures::executor; use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; +use std::time::Duration; use tokio::net::TcpStream; use tokio::runtime::Runtime; +use tokio::time::timeout; impl crate::default_outgoing_http::Host for WasiHttp { fn handle( @@ -52,11 +54,22 @@ impl WasiHttp { request_id: crate::default_outgoing_http::OutgoingRequest, options: Option, ) -> wasmtime::Result { - if options.is_some() { - // Hyper 1.0.x does not appear to support timeouts, we probably have - // to implement them ourselves :( - bail!("Options are not supported (for now)") - } + let opts = match options { + Some(o) => o, + // TODO: Configurable defaults here? + None => RequestOptions { + connect_timeout_ms: Some(600 * 1000), + first_byte_timeout_ms: Some(600 * 1000), + between_bytes_timeout_ms: Some(600 * 1000), + }, + }; + let connect_timeout = + Duration::from_millis(opts.connect_timeout_ms.unwrap_or(600 * 1000).into()); + let first_bytes_timeout = + Duration::from_millis(opts.first_byte_timeout_ms.unwrap_or(600 * 1000).into()); + let between_bytes_timeout = + Duration::from_millis(opts.between_bytes_timeout_ms.unwrap_or(600 * 1000).into()); + let request = match self.requests.get(&request_id) { Some(r) => r, None => bail!("not found!"), @@ -94,7 +107,12 @@ impl WasiHttp { let connector = tokio_native_tls::TlsConnector::from(connector); let host = authority.split(":").next().unwrap_or(&authority); let stream = connector.connect(&host, stream).await?; - let (s, conn) = hyper::client::conn::http1::handshake(stream).await?; + let t = timeout( + connect_timeout, + hyper::client::conn::http1::handshake(stream), + ) + .await?; + let (s, conn) = t?; tokio::task::spawn(async move { if let Err(err) = conn.await { println!("Connection failed: {:?}", err); @@ -103,7 +121,8 @@ impl WasiHttp { s } else { let tcp = TcpStream::connect(authority).await?; - let (s, conn) = hyper::client::conn::http1::handshake(tcp).await?; + let t = timeout(connect_timeout, hyper::client::conn::http1::handshake(tcp)).await?; + let (s, conn) = t?; tokio::task::spawn(async move { if let Err(err) = conn.await { println!("Connection failed: {:?}", err); @@ -129,7 +148,8 @@ impl WasiHttp { self.response_id_base = self.response_id_base + 1; let mut response = ActiveResponse::new(response_id); let body = Full::::new(request.body.clone()); - let mut res = sender.send_request(call.body(body)?).await?; + let t = timeout(first_bytes_timeout, sender.send_request(call.body(body)?)).await?; + let mut res = t?; response.status = res.status().try_into()?; for (key, value) in res.headers().iter() { let mut vec = std::vec::Vec::new(); @@ -139,7 +159,7 @@ impl WasiHttp { .insert(key.as_str().to_string(), vec); } let mut buf = BytesMut::new(); - while let Some(next) = res.frame().await { + while let Some(next) = timeout(between_bytes_timeout, res.frame()).await? { let frame = next?; if let Some(chunk) = frame.data_ref() { buf.put(chunk.clone()); From c983d73bd376fa5144ecd25c61e1094893cc2531 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 21 Mar 2023 03:40:59 +0000 Subject: [PATCH 05/46] Remove generated files & wasm, add Makefile --- crates/wasi-http/example/.gitignore | 4 + crates/wasi-http/example/Makefile | 17 + crates/wasi-http/example/main.wasm | Bin 50300 -> 0 bytes crates/wasi-http/example/proxy.c | 1211 ----------------- crates/wasi-http/example/proxy.h | 335 ----- .../wasi-http/example/proxy_component_type.o | Bin 8260 -> 0 bytes 6 files changed, 21 insertions(+), 1546 deletions(-) create mode 100644 crates/wasi-http/example/.gitignore create mode 100644 crates/wasi-http/example/Makefile delete mode 100755 crates/wasi-http/example/main.wasm delete mode 100644 crates/wasi-http/example/proxy.c delete mode 100644 crates/wasi-http/example/proxy.h delete mode 100644 crates/wasi-http/example/proxy_component_type.o diff --git a/crates/wasi-http/example/.gitignore b/crates/wasi-http/example/.gitignore new file mode 100644 index 000000000000..27e2d0e75003 --- /dev/null +++ b/crates/wasi-http/example/.gitignore @@ -0,0 +1,4 @@ +proxy.c +proxy.h +proxy_component_type.o +main.wasm diff --git a/crates/wasi-http/example/Makefile b/crates/wasi-http/example/Makefile new file mode 100644 index 000000000000..e6274d3cdf1c --- /dev/null +++ b/crates/wasi-http/example/Makefile @@ -0,0 +1,17 @@ +cc := /wasi-sdk-19.0/bin/clang + +.phony: gen clean run + +default: main.wasm + +gen: + wit-bindgen c ../wit + +main.wasm: gen + ${cc} proxy.c proxy_component_type.o main.c -o main.wasm + +clean: + rm -f proxy.c proxy_component_type.o proxy.h main.wasm + +run: main.wasm + ../../../target/debug/wasmtime --wasi-modules=experimental-wasi-http main.wasm \ No newline at end of file diff --git a/crates/wasi-http/example/main.wasm b/crates/wasi-http/example/main.wasm deleted file mode 100755 index c565b511dbf979ecafc609940ea4846f5a4b3697..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50300 zcmeI53!Gh7UGMkWd!Lyzb7nFpnMY?5TTnOB4 zaDPlW5235&cX0m(l{EjOlTpuNUc`M26qUKoT!Y~LHeam=ehTi18x0#|kBsu*1@mC| ziMTJGpPQNKo?M)pAJyIXiJ58;w%3;ytK+BZF~28+D1Y4OnoZ5lFE5Sy7R{!Gvx`$p z)gUe`ou9APJ7=qBM^8>wXC~`G!53}tkE7MurNyagJ!tdA{SM~b^3nryQ?n0@E>;(o ztM#QI^tFA0v!=4$R}QSM81*=0kOwksC+1Fj$o2WT**dfHy$7deSJg15@ulT@Q1lIk z);2f=IjW0K)nbAnmQPpn*=;?!ytKSn9bF6Rf$CDw)<0Q2Ilerz)STk6d+xcb?bP_} zBy8vyI6GdS8mrHa&(}}QEsf1DR?kdT&t6kJIXN~lGsjelmuS&Vi<6U@&X~q2T%uV! z&Fah24d)SS%C@ZEf8f zieXr2D;7FSVOO!Ms}PimXoD#PJ>`vE8@h`8hk6wFQHNktTrl&7yT}A#TM?;GFTOu6 zweO4DPFGLQEuIg9wlSu+xD@nvO^lzI8beTLX67b>fs!b=Go#?{j!qM#rWC*6@R2(^ zKk(M@SQwOUHs(TjI6RyNBjICjzj!g|4pJKJ_YdVaU8Jb|e*I2@@{j3igKpDP3WAai z%0H}vp!5gE^j_G>J+0!@CIuVY!gSJR+jhA^+h&9P;UE_P_i+jLhh;9&{;F~`uZHMhFf6xs?jVnS~A zOiw;Jla`av8XHb0k&Uu8ktWw=Bh4eW@kkga1+Zzeg{0lKF_(5*yglgv8;AZvQUaUO zEzH$*>9SoTp^)z`e?aJ!7-NHt?1mZ>>G5Oql#ZLWF9(V8w+j@I3P38cyhBlfO;@Na!Kb=^-Dr!1K@l%t7pSG|+418g`Z7=_h2eB2ta2o zDcRD$7JmR=0{;)h?QN_TgZymZr@@;zeLT2?-EjLBNiR(8-Vg>REW!L90QVdU z%FsfBUaldD8}v>6a(UEyZCSyY$43_?#|IAn)LgRW#t z`bCor+bwo@A=%16+w9h4yWN)Tu-om9TN4XTiM2LaNGf!%9175n-BFP2w0(BxfiOsm z$u4ep)soAo=W@BdT;g|yz06(#251~0MyMMBeN3q43&%uiRYLUH=orKIj4$e=^laY5?#aY5>?N(Wa- zos)!v-ojmn)OCt1C0*jgS;szXLx(NdE-b`rb1CdY^fpKedmusC_SkYm3VRw-xREh8 z9txaT^(C9^rrl8y0mSSbh>D)mvc`QhaRd#LexME5emk&`Y<8U9EKaK%(l`?COAtdl zcpwtLw(yfnB2cy-3U2iL+C~L3X}2#RmTh(i6%PE3E5uWT+e!7#8WOoH<5#7pv}j5> zai5;K75$wh#XgB>?Y4kvdPI~$vm@CgF4CwDXPTlFrpb2nlzzZO-7q!G#|=|^3A?xz z!v;?W0pu1rXIU9Bw(VL2Fq2yu(^*T5q3tMtjbj)EgEES;q8LSSn8vm%Gp1d#{z82N zg&U;uv2?Zv!_y<(v2ZxfjEE=HmoL^|dr7hW$Bt+-vpTt{!N5Z=xb-;u>B*;t^;k~tKFBh0uQReZWZ(F7< z3pE0|(VNFxS&R*~vCsA|Bm)@M0anZOV6vHRn`?;TU^0ZI*@7%?sUd@I#I1I#49+$? zY`1xXvz^=RHDqwBE?7m;J+V7%0^LjMbstu;A}!jPb|ky(PP;4DB5%=~zwOQqo!Is$ zF0{25J33{SE(4p(&~I)p=k{`RoZBn7#gJar)!_|k(T?~wyQ$di+g!=*m1wTLWxV=GbSObg6b9s8MZ}U8EpXb}$$nA}4V=@jL2KCe)wrMRnLfw)5;RwvQ ziQAj#EG~^CH`|-VyIUx{1u(wws68s3xs}3O0SLI!;9znL$vJM1+2aezZO($-CfSLT z+mRoM=<{pI3+xN*?Tg7BJl!FGlp*?(JMEnkgu7tK3+-L@g-t=QcWsEodhz^4^m!4^ zE4O!ZdpAnYtrX!Ntc>Puk{9#zV&CQ^+`h!Oc`3IqRU1F=zT{qzdYQe~zO0tKoVu6G za|)AJaQg~*#~>9a_u2b2?^jazO4%1z_$vD<)s0a&20#sYKlk_V4|l0SIT`0^e1B;5 z)Rmmz=>%@Bo{Gr?PZJn0Z>cAFnxr3dsB&AS6SpV1JxLF4AK>-@nmb-ymz)xieaVzA zS0y!F?oFocw2++fPp9o^VK=L%dy+Xjr@DFnv|txhx2UIGNnID4Ea|c}S=MDRIit(- zle6}$`knJn=k0m*`zk#hOI~eH*(qDIGj`U_+eKTqOLp0wvFGep*;kjp&e{D3!TUj3 zS9%1=L$YWOQ}l2xxnM737VV*)(uYH{JvV!oHu{4YU#wnV+SN4rcx75voMFfOi?q(s zFTXA~_$)WJLn74)gD``(l#7(@Y^>0370?RpAgo#i#3O^PjAbh^Sh1k3jB2or#5L+I z&yq_Yo@JlHnt-mYt2t0M9}0GOz7JB#I&Oy+Fru;DLWKjrBN?VuXy>`~GnpeUpUkP}{Zfbr<(-X$_h;()O*v`r|1#9`nAgN^z;+)B zj(K<+u-`7zP{TVbOEn4cYG_-jVmb^TFIgw`D`@Jd_fFt^CxjHJqVs$#(E`(V<)*he2W! zEesXfRJ2UE!ku=f){b2i?$Szv2WoL~ti23pN{jvoUQTQ;ui@cbk&FOzw;i#&YXpX_ z{~o(XK(C?=9tYA) z-danLh27DJcQ|MW-)^(V>}@sNjS<|9ICnQFxx?O}wdhWJyS-EXXZmrx4O-k)!{K;g z@*;rVZC_;XuHjAq^dNr3J@&;O=u5bLNiBIPc-%{uduwt*2JHLon7zM-Z!j(|`GmdCp75|IxSgmalXhH}s;#R2q@A=U zsh7MROCDfRIAtHOrxubaDPj%KwVD?G%*0OhlzzXxT~UOzRzJ7p_BKqP3@)L$Gk`&J zPYLN$Yjb9|uE?3uwv_4Ksi%|elh+3oSQLG_rH|E6i56np8p`E{B#_W#hwNrMBx00V z4LAFcVo;a$LW<3PJsiwJ3iWp(g{Qu#Re@SNZN=_fNOn2J+?C;S8Ms{LGA_v#;4)&b zup>3pC{|p6YRl8T(q1Wj-vf-R>>hj7LNe-Li~_^AxSFne?bUW~&FhXFHG}gX%lSud zlgj&c*6IWv-fOn@%^onml5=9|7cKLk$`c7KBqD0Atc+SU}~!r zN^ZSek{f}DTkrI~jBXv)_$h@cD(c72bZe0DZ=wS4zAqae_g-nHTYz)a-eQj~B)7Wp zZ*7c!4Bj}ezLwm^{BO6n+1qPg!Q?j^eEQhFz$va=p@y!-(lwXr$dt`H<1eK33#pKQ z^&;+Z>CtaFrFZj$SC4U!Z;B?$vA;o2gD7My#~#BYKkFqt;oC!1S(BIYgnN%QlW})S z>Vq6+`!ecY#t7WLoLfBo!`!}tTRi<6xV?|t`;?K)wAKerucGu-K4==_7GIwj2kgFF9&@=4J?63xJ?3&1Zv6eI_X#_JT378!`#|}doriO1-r`X3z8L4<917m6Yq&prm#(BP9@UlH z#oKfxdGY2L7T~t;jy{49CfEISF}{1zmTF`%x@;$zFV%j~)pn;Bm9i;jse0R;)xO8o z62jT?f#~yiqr0O=UC~C0HXewcjM66~vK>XcsfK~-#TO{b7x-*M0NBrc|NiiaDE(}N zxhi^dwOL7z@^?9=4N*9>Kl}`ttx;x%%__=+|74VYQf@)f4m-<*{~r4^94U|^0gL|* zYh}{u_1+kxRkX>W;NwyH@d#I-Xe%|W*3M)Xy)Lu6oS~xE74~v_h3ho}wOIEbi?CQ^ zGPLktN$z5g9Vx%XIaP#O?~2I?eNa~^1_^6)yM6wx$qTS4caUMYV=S<^j#5aebK(K zhShlyw&pH-cln(ToqOoz7W{?eCG>g;c)W*jCt%GFFefjy_vU!CV^4~*C*Tq0cw`xb zH@n$@*DLHRvdtN#?656wb2W_r%Jj_n|Ey1Bbipiz~&lQJOX_c)}p?7({*?Ds^;DKI|;=6~-fI7RE4BJ~{e0v~aJ2 zXaLkRbU#aC;Os(jj_&8g+|Lo(1<85(f0aFNzbfw^l2s_$S2y~PgrN4IeX#siAtL@g z5+x7Whsy7Ah`C(C_2yqfTina<+O?hwU)6ky~cj8gYj-Rf%nkC zzK8PvX6%16$$O3E|9A8JJ_EVlZ|wVweLo9BpbXLXsqyzw`2k};V3O~5gE8s{^HD#f zQGdYL4;lLdjQU|?sroP-e$dz-WYl8vLwTPc&inj``h3LLA2IeL^!ZU^srpg+{Ft#n zMxUzd+^3js3Vue$herB^CY>g}-d z3Xrq5fSn43+C@LUc*4&m;8as{(v%@{+vVnQzo^^e^=>$XY@Zb_EX0GVFSoT z7W6+-4YHT?{5{><1vGs&MD?P>jm z3jcz_&l>w#ll-NzK=@N*|J>NWH0AGb6Z{{V;9nX0KaBk=CisLV_=G0-I_D?+wI=vK zjs0t5|7QcYw&ZUF`EOb$cr1BRWlvI8PT%Av__s=M{hdnx4jlfMv43mq|7rjM>CdU| zbJYF4v43xpe=znRO!>`1OY_9a|8Haew<$lGm)w_p-q_EZ^4szPnD~#z{-Y^>w@SeD z{|Ms$ad`QaB2NCv$Qk>BD!#x_|7`3(n=DrRCr*$2P-rg8-8MOf#s=0*bF?D#jR5M- zC3tUL{(T|+6q!{{Riqzt*Y@;p-L**54(*AvyJkB%TcP_dTd-XVY^s&mp2r^qi;nX9 zgzXkQtPOzc$-tG<4>>R!)3-UwZ%Qw^=U##7;~Yuf0&yev18lKsQQcJXtN zQKFb;CmF@ zKx1z-El*c6iiU@Ec;{0(yi*Cg1Nkv3cpK~qDv=gFo*vaxBF`laj$AkpzDLj8UcC4S zba^Z|;9I2dAuZO@`Gxe8@BQuf7U~teWCtmw_5SdKzMF0@x?5=syGB70rWYYyz|o{f zkfgYlUZ?>qo?h_f!@gp=Qb>O_`gH{`XCxSJeg z*7xH3! zf2f{jzCZl5a1!bEhmU8sL@bWI9-NJ8DT%MRBu=mQ&j#re=5|Sf!2Ya&RNB)r#l7Mz z*V6G}7!jSR@PC{}3kZn-F?q9Kqs7$JD{X1CREcsj#x}|*%$iYXH zqotISN=x7iZKf9&vYQ12trCNI*O|0TA#+L#XVT(ArOn2R8dg&b&!q7}C0YbIH)V4s z4Ocyz#xsa%@=X~6x)(1^o=~}137V6S&Ms8g{C8y5^xG7=7A?mn-1MPFHf7OJG_8SD zVY=ewiNjeHnmRd%nQ)N_+hTfdA)~y~Vk6-vMUy0QJZev|s_<^9(y`zY==@GOiGM_n&9gO;1;AD{o#hj{kY>rC*Gj#q_z`n z{>oE34VTi-5tIcrk(W_prmypZk;UH2kA*Ir>?l`aXw#PVxpqhf(GSeXTElL5ZKLCr zwqbh4V!&{Ms3dL9`vC5sJ9)=VSEa)SM*+rt5k7NqcINmND2CLM6A+Cc0y>7e^wlbi z59@sw5V@rr_z&2u#e)Iw=%C%P} zWPZUjxVkZLX$|K-M7T6W?dBU(t<#ZT{WB@*`~ zh|-4r?QtateA`mmb4EI_XxkQ@`B{>lru{WyrG>?mEdz35m}Q8cTNZ?E1%ujhCN^jq zi#8bxXFR;ISn-Up$ewE}sKZ()n`I;wEwahPk0+Q|m6a>t49%SwBR|X&S@JTASPnxN zh~Xz@J7f+b38+&`7$X8ARD($fIBvQyA03iq?pMh&qj*_H@VYpUq7Ex%)Cs3#*-NXJ zWwLaYRWk2o87!O*g0h$8A|M;MA&&*Ou&*>%lw#}BGF37_E!GY>%gqh9xe=lfOQbW7 zH20=cCQWO4zI3pVBK(b|L(6Bwgz47NDqnffIFF@UP0@(L3qU0lDo|P2Mc(>?1oZL? zt#deB2er%w4xPbt@H|B47{MXY;9Xk1lL%D5w1d@EYdTn8+Pz}$4JCtlqQ@`b;}jtx z$VStZ_600i0gC_$I0*EE!l5zWFOXTnX1Ntq7=F$@!|Ph5(?%i!J~PX#1HTeL8jwJ7 zj##|V&CqV)2{lvao+YuV9Hn0cBEFh!hi;T{)?>QCb(VC; z4lJ%mQ?!kffZ@b758VTC#|Ka_S4pS#X#@9tRVbMhDh9Y^nkhS{BLB{ML7A_fY?cj^ghS0HbCu;zuJK}n7{RL}$`FK+$} z`FRNs^8#n8+!K@Y|J2ckA1>Nxh=@j#h`K;SfHeE%u#V%V5gUD-tq=oI3fm)vVo&~;5KJYMtrm(-iN3N zCR?EiW)`(!ms_l zd*%lq(4IfIZ-l?{EIlA;8ga%#YJen$b1F*2br6u`AzpBFix81V zflKDl(AX}nAja!x#&`%A#_{MDe#3uWFmO?Z7HN8O&e;v;05O_OryG)m2mczB)P?@? zNt}SR%O@ca#89X$zDDE8SwH7YMRJS0TheIi9B?3IK9$U%xXM{ORuhkehTe)SH#}Ge z+EKX=C<``w;oWtV61lPmklab%LQ z`?3nAsEIRsfzWYE*oK!!Y6=m8X9=q&!jnEsB#q0IGqouv3>0S^lslb=ht5rJ@JU)r zGX;k%+|o64pb;EKF8||?&1t#G!@(?E2S0_1$Wl@3&kltE8nZR#a1ll`=Ex(AX3WvH zRKaw&#vFl*IS`da8xV6u`0WfGwZ<3Me6TNq~_-^x%QQ&RA|uso-Pd$>7&u6gBvY;Y2)*D!I9og%7=jC(3MCc%kp@rSvI1&|+hbySz~?O>4M$ z#PX;HiJOje=cUYXZeActo-=Z;eH!czU$2!=JGp4dZohsW2uYvvT*SV+YM$0#W)WJq zlG1n=avMo7Xc=&E&bSsCmu`^X1g@f{7iEX|bVZ6O;cp~5f=rm9R704tpq|-2XC+|{ zoG=HuFb54`R$Px3%AHUU z#idJ*BJB`nRse)K_QFgkBVq1;#n#@eRY{+2eG_ z4JYDhROt?oi7X}CypNPAmMpE*j2^ksP>MqtCAq6v7a{CfgUR<@+?)hmb_U-rTO0-7 zxt9%BQUMy)O95K8)CTP?Mi9)ThieKES;N)}Vsvs{zt3u`% zxK#n;?^2r;?0jQE;FU=hgis4Y$C?EJozsGV^t%+1EE5QGY%w$XioQj3#bhv%HG%4E z&_Ph7ZHfsvb*lYuh7+BkTA)t4iXuNmv8 znY;n=N4c6Q(Dn&M7N&-pAqsxo_7hT$6a2flI7z`1^J<2tk*OIBd3tJw9mE0cCms;hT()vhP%ikk)U2ey9!E1+CoFW zA|F+uUrM57`c+t=Uj?sU&iu6wD5_~(4VWnlk5U$ojaL@eLrtMG8CzLuw}yxQ1!5;L zz*+6%G^Lp=Cc-2iCzs|HS>{b+WSO_o*cy;5`^L_>;eA6d%g(uS^6E09l4Y9Vz({-> zvMj;QW!Y7?$}-~7D$7h}tt_*WIzK&=WkuUQ*@Ing$nsO=#=T58GUG(}&i(P$^b)yo zC%oR_VOq|-x!JiCD6)|!#gXnTqoiO>DL(dCYr9BmTx2q(PB>8hem#`_q??m+FemT| zeyihBQREP#vf|~QHLb9!BdFZxYjOCw58M37(gP4WG#|hFyvLOjpixH`C2;ork z9A?WW9c7z=bVfTm4R5~9dGk6OKm-%7@#YInZyv2C;KQ4zofH9J2%?-Adh@cXW2FPc z>#XwT-H5evWoClF!(;lmjRbay zy}&a>xuT`QPp<4iBk)x8slvDvwTP4rt9Pl~Mi#q!#9ayik@(R2KPVov@If20P}376 zL@J!s?g6e(ifbnf0H(1Q7qUa;SRIM=ZmDx@)RE~mp(R;C0Q)er0lYSBt8k(mbITwJ|kgYyEM@CvV!9oIGmg1I8FdXc4H^DGqeiICx zTVmv})wz)I)972R@y-Rx*zn;S?voEm6{Rq&d?#!tn4@Q~Nz0cHNpVBuXPA6enxke- zJNyiW$BPfW7Y|ZcPQU3%y2JTeQ(l__IQ_4AYV6syOMyC$ITec}vAPnCuuDL1nk&u8MQbRVO$71C5yHo=W(X^sIafB%WR3;lK>W1J15QwYebe^ z&N<;*Kv}BM_i^5MQD2H^q#8M#3ouO%4LgiC79vt0K^I^REa|=#h#opt? zckZ0aEH4XF2p1&@Ety3t8=X0l0Sz525`0f zwK&JbG%Zetiw1M&SP7uq>0owQs@vt;lF!M=hI$j&4STdUpG0i1XzRx8j($6%LNw5>P>&PSo zUWZaLmB7wLmD?_s%TS`~hWt{Z8p{638>vLQW|@{bu}eNm+%+m%@@s?Gt;jOY47BL6s-SZCSt4Vwm^#c?md zGQ1{_(qVm`ePdT8JltR<(JU6&`Ny(qz{fLVQFeT`QDWQ*j*KMm)5t$l?v#r%R?-L! z$dmJr0j(i3|Cock9EL>fS`LY^ck(p-V+^79k1@APjJ$fo#*N-czO`=H;2&#xP4AdN zo!@}-gI!>X$RSho-Z2xFcZ}xyIcbKF7D}((uaS(cagNDJ2s`H-3s=l!i*pROGv}CP zNLHzJJP}XBG9I9DAM_;OScS3<9y1Wk$y_S+(53t>TCX5$;_HY?hV;?c4Mml;VJ2cLd>Kxz;zbxw+(AML&*KnDoN)T|$7WGl$uS(vc95Y&zT* zn27I}f9VhxWkXQ@Q4LW3CH*d4&j%lOatHn#ArE)CTRFf?GW|Gj7&`3BKdTlAwi?CH z+L+R3jVa*zgQ3?hjn1AzSpH?Th7BraCzA$v-_owj14m_yu%jYfsG% zr@=7?iltOXJ(4Iwjup#`u~p>o2H3O8!zl;z>#q_q}2I> zyf#kEl0&E@HCpEL64#fp3)0-Y&1JfqJS{;hpGsbatdG}M1g{%0EbL#cr5C%eg-W|0S2R}9D=Qz-odO7d$11A=#S;8WKM~x{CuNq>$9cmf zsO>dD`j}p{z{)ac`IC~H(t^pqye5&1ytr{nHuj>HUbszkPq*d=++3c~$rBvzs+E68 zP+ZQAK?z{oF*xcBQfb%CA%0FW9dIR8m1S-Ye-51 zwD~91!ZdC<>}*0J;Tm(mbclW^ifkwZA~nItLaBfF5-KW`VGAD&uR2DK%J2~m(dby{gyMY=BEJ?09E63jBIp(cKLsf$f^Mp zFZXj@As_l21gz64KY}F7E~rOYN1iSyk&;^>=eJx6Ey8*R=3OHuU<(Qz8HRZPDL0p# z%F)OmpdfpsfrqRGLwa$A;OeV;E3i01n$rP#!lmufR4aJ#n-!d?9?; zJXqxW+S#J>BxlPCS&KsYvmEy9a)u8WPX@JVUf?gJPw=4<9d|!aW8=CYLZ=VcdBe-M z=Usf6LzNa6^{$t@?O5akgJ*n`Y2M2BZTSdo54Q*TMi2Dc$j>HzdOiK4!&WbO@kLho zOkZrT-^QB3Q%&CsUj5JZVRkFMB4A%)q}uvt^`h8-r`FlqLlU^pD zyVvV9U*xJ$PkG2IWxc6FYd!%m;2IGs;rJx|C0;V?o31qRs`TI1O~xbJRss*mEj&Or zDF1|nZ%fJccFSu5d@s_$$2+aLDlnD7^sZWEAnnkmvSHM8m#jJtr@lNu3%$Fh&m<2d zn#;kb+bj43YA4#+p~Ym#4pe%tf-+eztD~h^vzE>> zH4gNZ4DSgCcEZhg+(Z$N8~!gjlv>&;8`djCA(R?NOY8-v7a!7Yn)~?ZM%nj`oc8tO zi9lK?9GkcBO+*7!?4+_ebfiJaZjo8W*RWfr`GCSudhxM<$>^vEO&q2kHy!2e zO$M?G$J8z9C*JbmKMzEn3&81|sSMyZK#qY-jBXzWq)<*gDJlb^wV!OKR%LKF*1bXJ zBz!9vMhC~cmUcl`x8wm4a^0c4@o%zpi$ z_y#z*bi$zf2IVykx?F=OZ!ox~LD@Bk^9FWJgFe@wkT)1v(}4999NO{*`_?qr>Ke4? z4GykpU|j=N3_pv<|oyJ+TQOlr)UXe3ZlTpeXH>4?@v*G#9^ zoi>qrgMtH6ysM?m11?`W3<4_lYSs{Jp2HTwrdPC%U=J`D;^7*v5Nx-bxDj7q0OR0{ zwijwwo(Z%%OFIT6&}3f*@$%9gXA)sVKS>IRIo02qcIa3QU+QHp*;gO8S(6Mzhmktv z6t}gC^EQdI;nQKfkm@2ytRmt(D1r>Tsq#@Ijeyx2u!DSHY^&zFHASvbap;M%$gW^2 z)34zb(4&%fXO?7I2hu|`weUPw@bnzW$_j%vOpq6EXvTJlZ`sBLzE0W8`qi{QR$ zh({Cgh&RM{uMR{9v6(dVB-+%qK??&S)0+!~vQL|(>Pl{-Mr_P;j$#N!ef2_R8!zEH z&1db}E*3xaKc;b^=4Upxz!1GUz|H=g<~3Z|k$&_-ZNtIxrtVGUa(Pqpzb@TI`Ez+w zv7q__1sx_1H*M1-`IA7+36FS|7_vpH8Xmkk>JwC&Z#p;Y**j?-tP>y;3om9A&Zb)XP{ks3XhVZn-U@6_FP61Lx|%n5E>e?zt8V=S z7!6lp>o6;=c*%4z%@@lr2eeHRM>W)UCAnzSd9jil>3sO1cQ@uFXXWii6Qi3WSIH*t zc1}o>43f{zS(g6Jndz)&FH5Z!Y&s4}Tft#i{NnBPW8IrXbEyR%k{=#UwlxTRBzO_i z(pS<3J*h#lS0>aG&GG>|Toq5XAy>z$#U2#$a6@pQRjQ%Q5K&2=Yot#okN8ln{8L(^ z5E`a0LBuS)|LZBSy~7Eg2-62m2mR8TU)eJF4fUxE$=zvH98BSD-R*L)Q1y0JPzRAQ z2bKK>aTiMC?Yh&t;P^Z;Jvx1+Gq4BUH9=No@nkRfYFv02qVkpgpu$(EWmh@iRkH)- z-*X7y3>~XLO}^F$38v*{@tryOc!L!2ZfEc9ymutWZm1iYf$Xtvy^sd6FFwXQn(E5h zPhtnSIKZjZ<8-B;eNZ5=8Cn?_ER!IM4OUI5=lzqy9!zb886y-kPBAM#=@q{6)}(^W?u0tK(ziIBzHE)Q``WiP zYSXtnjeo0tdyU^YoLpvi-jeLn(3Q8`9Jv3Uyf6V-cFMm+#GE+jfCPy4XTrcY6eJA& zL;?~9{dyY0K(7_TKsSUzVG6RjS{UG8O9%lPid$*yBnzY)ymb{xuV&zD(@(l-zR~Ha zEPbVSIQ?r^_FpsIwR~Is#BdrlfHcKk?zWeT|Fp>>rO?)HX-I`q_QV7kmv&TVn%D+V&(GmkKNmacovQ4quuQ(f4;-n)?r*H^~x+96r5l! zr2C2%`8Xd;-{H@PYJz3NfDGjK~17U!&;Qg=;QbjLq_^3}n^HEo$O=5;vzxwz#zoGp@YLa5_{= zJ7(n-@5bo`Raw^#u)Q&c2t(NlnKlr+CD9_tR~_@uZ$#2@seZ*y(sWi8NN+=i~L-setG)m zmG7H(q zes}MT7Soi|KKLInU9^-;Fbl_T`IWAM?;XNory1Ma>^0Zf%H_6SLkqU;WlMocGwsXW zA%aYS4&THAz+e(kUK8d|mpEzLh8$|0)tOAgU&?ZJTWw2Ozfa$oYhZr!`5WCR!&y0x zg8(*XD!Yjj2JLQ6K<#1lU0`#WK#$4_?s;pn$7-=DF*3Ar;v8T;_dIGVGCC^N5{&rJ zIYU&`;!jQ3EBO+y7H_#7TEkouJ0OYhisTAq1f)0!fs`en`GfRBl)m_F%vx)MgOCtT z{3`^BD3ah=;)0|SDj?rDVKqB4EddaAXhts)*T4&4g<)7Xx+q-XbJ$*=9b>kFx19fE zx6ICvBHIgyrNJr13Jl#w(W`G;sPq$d@uxpX13zrJ-=RPAp>CDk2-sO=_?)|{0VE59 z-pRpFO*`jlfqbFPBr3E%%P1nm`s$yz=5Ui|IDm7!$Ny9Z7n1||H?!!J4`;d15J5-IBH z@K7AXA~@D-p<|u#RsoYSfRQKRj;1hc{%(YlH2ox~((qWf`*2HtTI7tm#J@v{Av=T} zl@qh?P;js9auVu6fTjn9_#lM6S!pjXHufSr6GH_J()aQyx8CWdFNr2&aR%*X z(pzH1E-kT*=IMLogkm*XA{~eMHkr*_V`NvfrupZbY}ONv@@~k{?foAvdR(JBtY8h@ z84v+kjD48h2LTmkGbJ}+ePkiOCv1`vvM(pb`cv))zYhHz8*a{nXN-~znVbGL<=bg; zn>dG`iTKOO2Q+Bl_wW^nUyv{B64=cxR2}kdrZ6lKz1>bSkH4!Vs{!X(F}WGUw()Jc zhISSt*?eCZdDvnHoZ(|@f+M`xe;3YfgKE@?sChVx>$W1C-QJ?C==N7SoNb5zIL6(eIO`NY-G9nuSjmT9L5rs>5p!l|O!4Pm=@Fw`3TeVC%{cOCchX?X2x-l)e*x+pRvbmMKmg-jQT)FnzTTL+I4f zy4mmFa>tmxiei-B)?k~pw0Zv@=ilym$D>35nu7ED_q>B}zzLztHw;N$wOi42=P=-2 z{@FukMNdl&`ESknw#t9&qVDBC>&gy%Q~vL?CAsfAd2IrbQfkMoX?S+qc+x zE1Wy$vU7?^UV>jH{Vsbm;q~csLW5S`>wHrjr;8WQX|J1rVaD8kv|Q8wFa*7|ZAll4eOh{9tSr8_H1b>i!;+oSKgjC*{v6y2EWc0K|q3Bx|efk|qUqQ|ZI8GmkPFPyLUL%(Jx(n>GgQ zKStT#v+U~L&{GEFsv{GDHP?mgv-8gFfC3{`7vg*r1X4Uk+WZy5@pm9>=%Od+)uzRB5IbvD);}Q)*khNST zE`-{p(s!BWX}*iRJXi4Igl=+vSur;+Q?gGb{j^49`hw3zy}_Z~h&Z!uNk|9YOIc;! zLbYt_6@6GmvKJrZnKbkdcrESp&C^V*OIw5VkMv#h^l|MOmw!eR+LE7cE(YnR++ow# z>eyd+xcrN%R>-S_l1D~oTPYfpBS-dz)t)Dt9TeUoOUW}wXLKo6-1`wwpI6%6pSrSL z8^78Sk?nI@T<5<2LoaP!ep+L@p*)nQ9O!8e<6(cqeR)^Y_{zh6OsBlR;&_+ta|bjv z&l?cr3mm%PXzL9g{XqKdHYOmhKl7Tp)9M^93^{MFUY9dwk=;u7d9Zk;nWW|AYGqO#NWS4LnULmE2p~<_|znN(G)i; zl+fgsSLo+9H!NLGP5K&v;!g|+xJ3Ffw~^T$XhY=x*Xq6vRY3X%Q80ilh zp=xQOw1lhtLWvu9@ZWuefHFB;sF5^BM0Jm8lyx{1P^ChHNoD#Dt!?1%u9dj?cVI-%$|C?Z+2<- zoWht%oXe_1eDJ*CP@|!~7DPjQL|w}M(nYuVMz@*9-KoaiWDbheE?!6n7yV~4tl&o9 zcSOore%PIK#?cESh-upnM1%g~zTUv!I`>bI5#A*_>D4&lC^J<0i*^&c_Zl28EO7=+ z{M&`@gAY8yS5J6SJlHBlayqC8S$K^Q!N!8=muu;`!S^40OVDyh8rN$XihUt`b1>No zR?BF;meHXgq9s{#jm}1gT5>7qKm()N@C%)RlN=kWiR#^p2~0_^R_A{i02wH2YanvM zO=SfAVQpC^o|v4!XQyw3xw|6Y2ct7@9x7Ppf;i|qb+mTWcjR8TkKmN`Avae$c!0Cz zu}CjCT!14EgzmLe7Yv1&b!bAn}LYT;r34`N8J^gvUNb45{L_-3ph(!pcUur^{)cQk{Cw%Ts| zj*zz{2(b~Zf-WZAAc;&js3jlv-oQtcpqmFHF;Y*C9R`5m)q5TawcR)(q2{~MgW+P* zZU?4YEdkR5n2>pb9b9w_(}@0@BT%v_X_&z54;F^FSqydNBrY)k|g>MBMB=t0@zWToZV#CS0;6p4F6PtPaI$HR0l> z<36RLVLV-==v&+ph0!zR-4>HO^7dnpMy8_WlW zhjYB{7J6s5uoyeY%tdu3uZeRO5amU&u+BPzUE$z#oiV=n&;N9`#@`2F!8wQM$p=&f z5Q)jF2X{M^z|l@DV5k;_WRn>y9|!@9WSP~O3w#x!VUF7>NB<*OU+~)t*^7Iu#=j{^ z;2nt4--mdS^novtWI+E!LdO`b#(HE}ptDZOS&*643>mn|Q>Gz~%IfO^s=jiEIWYC0^z7WE#ErddA3!T*ftyd!y%*+<$iyw4;BR7X>`om-a$Nuo_)Un2Mau-0*^nBSzQu&*VdFkD^OKeE$aSxKH#5~2*1y;TNkV5@`JLx~ zU0#ooodr?uAg_4xrgy?5cb+Q&HD`d*!#>qOGr7&LIp-cjcUp<<^{=~l;kE8;E)0C~ z#z#KtKSojd<;@(QxL7Pb-v8>#$+@}8AzL{yzF2uE7~Ny7-FNT4bHV7od-v?Sm;2Fu z=l1M7XDQk{zr4h+x%yJ@;(B#)bo_zpECml#mxA&6`I)JS@ujJ`*}b*;+-xvAJ{zdz z>G9do>cpwJt0(482UD{rgB$B}r>oB$Uwq*52j;5v=boxAR)d@7W|sgpx^#ZN8r+fI z5gfncXzI_bfPt8;(?b4hDBYS3iW|=?lNXw~N#$M6VL#S70Cs!0-RzGAft9J&I<4fcArO*h>y&(F^-E;&5F<@C7k zKQjm7lXJ@_W~v_1x;jrRFD^ocne%pXsysp@2K=X`b1 ziIwZe!|AD|CCcxZv-RbPQ}!f0w=j8fYOy-8G`D!ZQ8T|d=P)~}7S(f8^`(075+@W( zbNppaB+!e8`_Ynu(@Mu)xk&tBWn9TbeozdI;^x#wVBS zQ1TdBDyA>bBFqz~9CGR8B(M<5SxcMX$l}~|b=J;Lp`OS0-kI?;XF-NGOh7!KdJY8G(pfR>o)RAdsZeqH1gobcU!hcoTvvbP;pPRrq zU}whBF0Vinb7#;Dsn1=D$j#hx-Oinztx6MCs0~J9qKYXAjxNu7DN+Ba)AKV`(bB8Z zX}E?pmy|O#gbXt(TYMZXT$(yL1=vNT{|v34FY9t@ylziap=V0Q!e5s$4^T&1))*tR4AKKkT+a8#vRqAvvZ5nQk+TX9^}uhTC|>K&ia0> zia36P6~f_%0-QVvt-Td$PUvn&JdHKsm7UgEnXqaWHm&9OjMlF6(qIJh0jHMD+SXEp z3L$l3eTo$WfqLQc91CFe+(flHDYjs>r%uhyTNW>w9ExrlpC3OlH8Zs|<+P^`+EWu# zQq3S(4(|wl$NWkBqw%2m=E7fx1M%Ml-yWIhVB!1CYs{U|-gtZPTZMN9o1*Q}$IKr_ z#o+ygz)XgJYpR9o!qGkN>pr_VDxZ)9Ko&)YSwT1NB#dUfM|b@*a_x7O$F{8bBY{+|}*Sigb}U(D~;`n;XL zZfbelsC)OT!x!_L|F=-OWs82V|KEywN4)jhHA?#$cR{dO_wHARFXne^eM?hr2U;Hc zb?<(4_+ozZ|GsOkeb#l)-hbfWbJ8O>-F(YYc2~BQo-i42U4PR8CBF^1iTL@Hn}1#^ z&iVgzG__g!rSBfk*!-o&#cOioeqQ71A^R`KQLfgP^WQOX{>dBraQATOP(bHHA428N zoezWP?9@`h-TU9cc>Q!&V1o81Hj?)?M?!NxF3!)*c#i~nM6sUw=Es*#9m3I{nQ8ti z1R)I?t<8~Q7!ePy>~9u>xXU}7qt4r8vKpk@JItfLio%$}uBlm^=w?}4)b8u+gC2pY zxxHCIel3I`VODfh!AkJv$gEI{)(pT5LKCk=2B52F5}Q}Yr8>*)a(#4SZn6r>ZDt{g z6^~#!bh(@B9RBvAsRwaeec}}BDb0$^Y$N8@dDx?x_xR%YX(~F+^m(%wZOW|msGKsY zM^D$g`cFa-f!`hX0PcY~LYgK`BVp4h z&e5WEnTm2tg^Qsm-((g#BSmyUe2N8xi;MSyNU>kgHi;{-R1JdmY!=+*7zBl-MVx1- z0{13Pt)R~7>e8vXNx=8TJ$X3RMA8V!MsW+0n}uXcMULbU<%1`emzEc+qb=2*=8Q5- zeH&iO%%ljjEiQr?p4g(Ew#V(7SoUBR;?k7CDGXJBP_&KD=Y6l_3&oNwbLnv(MJ zZ1vncK6iDpQ5F|+c~8t?lMTMz1aWC{ac+JzL&oehb78%1=6BJk9d%t~0lf^II%lhA z8;veE^L2AL%z?ymVC%sZai@neD)yKWb2wVrqToW_D;P6xNHh?b-D^P6qB{eX@zY#+ z3260}w#4{E%z@d{GQr@octZv%n@wP@YOUWMcV+bxgsRoRjGE~kG%)pn;Ocnbw{=fz?8Yz{Z1X8t0;K4w#x52v)Q|xK4Z2yiUv&;7c8DYxC3Yk2R@!!A+o^ zS-xj?H1MeB3TA`exKDz;mc)k`zNdBg-r)LpV0F9Ev&@UZZvf9?ZWl@t1;^pMq-kZ% zbAh|ju*Dk)c%#qrf*a$0v|)6eE{9ti4mN(7uAQ z+0x)wm%!Y#vaOAW)(kz`VB5_r8y{S+af4^KphT^USbLK(8{_^}jLA_y+B(8UxUzZ8 z{BpM3N>g)kD}>nQjohUyvN;A@24TzeFN!Vn34SSvw_eJEdjofS*0K;+6y~!GF3pWz zs!L#=9~TrJ*30wL4;dNzoHXS|^Q zcrPfrq&niUhihC<6|Qz_Rdz`?&m8HHe7CLZ#X3*FeLXMP`TE7D^d4g~9bq|hkHX|0 zZd*`@+p-i1S%&5meA(jV&bl+p@#&EfaXspK2s*<8psOKYaXXjOCbX!mUGjALyQ z1g0dGsZH0KHr;VtpPrfz%!Zr@B*x>R`tk{Fkewi3HAnQ`lE*VWjfPNbV-||HHYhXD z+2%lnh+U6jurV%V(cY#U&4NdBW8CFxM!%}M$dQ4-^ulpBk3v*moX95AO%6_H5C|9h zngCP}=yvuKksYSmpJRuR#amWPgN3>k&4ETs=CR4mV^xdIPa|Q;YbimrI$;^Do3Jdb zpRjDZM8Yy!k$Qb5VfjqLQpY=+Cqr`SR7RE|DXs-2zf!Jd#~OgtxCp!R(qL)w^fDw-|77*#IEP1?`G4)3 zKHW4)$x)#ZrL<6CZ7h{VU|lVNQZr0;Q|(@VQ#Qm^Y$SS~DgtvmzaI4lN_pt8x}dNj z_WSKV7wtCS_qyNg_>XpQH@Q5)2BhiYR%aC1M?7)fbhBH}W^=ZYU)Xo`{;T&Xb?tik z)U~^f+JfLmd)%&|`G%hR0y{Q#mW}-}&UA5*XiVY9nA}x&rxRjk%gPqnruvwi|L}_S z>l^^**pK<<(eU~WoogO%Us>tW?_=yRjQP#KLS?;rUpJO*9JcLVuZ_baPoaUaTh7`? z)@!QaR<|r(xn9fFt;XCWI@WEQ5yBrK1_8fM(s|W-aC1RuG=p|JLQoogdabi1mUCrqL(+8c zuzL2Iv6GWy?C#d9<-Jd!FLd~odKVzoM$odU0qEiH4V^4hVy z^2FTSjB7Dec4{jN8ci{E`ha;lHBd zAv~41k8FJ^0pC58@t-ptvY#!oe`TrVVNbqJT-7r+#)doDqw$$Boo^p4PR^WmB64*s zk=WZdIiu@7dbr|ix;fC#IhyL&#Hr=k>1zStG%44cXZ1A;n#ytAhGwZW;MpzR9P9U& zvjz=WK2UInNe{;L6N}T&DNHV(K7Ibs3i+Otd|%(@ULZJmL&wB`IXbW`CZ$&>oc#WN>8>|09yIyN!4SUuW4 z&w9ie=v$-t@yTODdTU|KzqK&N3D&X3$=l&r``L*_-Mpdzx6jSDZ!!TaLb4~O zS$layqq^9!ksX|?S@3zK#1yX9CAj>O9su(ipM9Y1nrHLE%Yk5f4>kxRId+maUC5!< R&7RVU<(X-MIlYMRe*q~y-1`6k diff --git a/crates/wasi-http/example/proxy.c b/crates/wasi-http/example/proxy.c deleted file mode 100644 index a6555102af98..000000000000 --- a/crates/wasi-http/example/proxy.c +++ /dev/null @@ -1,1211 +0,0 @@ -#include "proxy.h" - - -typedef struct { - bool is_err; - union { - streams_tuple2_list_u8_bool_t ok; - } val; -} streams_result_tuple2_list_u8_bool_stream_error_t; - -typedef struct { - bool is_err; - union { - streams_tuple2_u64_bool_t ok; - } val; -} streams_result_tuple2_u64_bool_stream_error_t; - -typedef struct { - bool is_err; - union { - uint64_t ok; - } val; -} streams_result_u64_stream_error_t; - -typedef struct { - bool is_some; - types_trailers_t val; -} types_option_trailers_t; - -typedef struct { - bool is_some; - types_scheme_t val; -} types_option_scheme_t; - -typedef struct { - bool is_err; - union { - types_incoming_stream_t ok; - } val; -} types_result_incoming_stream_void_t; - -typedef struct { - bool is_err; - union { - types_outgoing_stream_t ok; - } val; -} types_result_outgoing_stream_void_t; - -typedef struct { - bool is_err; - union { - } val; -} types_result_void_void_t; - -typedef struct { - bool is_some; - types_result_incoming_response_error_t val; -} types_option_result_incoming_response_error_t; - -typedef struct { - bool is_some; - default_outgoing_http_request_options_t val; -} default_outgoing_http_option_request_options_t; - -__attribute__((import_module("random"), import_name("get-random-bytes"))) -void __wasm_import_random_get_random_bytes(int64_t, int32_t); - -__attribute__((import_module("random"), import_name("get-random-u64"))) -int64_t __wasm_import_random_get_random_u64(void); - -__attribute__((import_module("random"), import_name("insecure-random"))) -void __wasm_import_random_insecure_random(int32_t); - -__attribute__((import_module("console"), import_name("log"))) -void __wasm_import_console_log(int32_t, int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("poll"), import_name("drop-pollable"))) -void __wasm_import_poll_drop_pollable(int32_t); - -__attribute__((import_module("poll"), import_name("poll-oneoff"))) -void __wasm_import_poll_poll_oneoff(int32_t, int32_t, int32_t); - -__attribute__((import_module("streams"), import_name("read"))) -void __wasm_import_streams_read(int32_t, int64_t, int32_t); - -__attribute__((import_module("streams"), import_name("skip"))) -void __wasm_import_streams_skip(int32_t, int64_t, int32_t); - -__attribute__((import_module("streams"), import_name("subscribe-to-input-stream"))) -int32_t __wasm_import_streams_subscribe_to_input_stream(int32_t); - -__attribute__((import_module("streams"), import_name("drop-input-stream"))) -void __wasm_import_streams_drop_input_stream(int32_t); - -__attribute__((import_module("streams"), import_name("write"))) -void __wasm_import_streams_write(int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("streams"), import_name("write-zeroes"))) -void __wasm_import_streams_write_zeroes(int32_t, int64_t, int32_t); - -__attribute__((import_module("streams"), import_name("splice"))) -void __wasm_import_streams_splice(int32_t, int32_t, int64_t, int32_t); - -__attribute__((import_module("streams"), import_name("forward"))) -void __wasm_import_streams_forward(int32_t, int32_t, int32_t); - -__attribute__((import_module("streams"), import_name("subscribe-to-output-stream"))) -int32_t __wasm_import_streams_subscribe_to_output_stream(int32_t); - -__attribute__((import_module("streams"), import_name("drop-output-stream"))) -void __wasm_import_streams_drop_output_stream(int32_t); - -__attribute__((import_module("types"), import_name("drop-fields"))) -void __wasm_import_types_drop_fields(int32_t); - -__attribute__((import_module("types"), import_name("new-fields"))) -int32_t __wasm_import_types_new_fields(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-get"))) -void __wasm_import_types_fields_get(int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-set"))) -void __wasm_import_types_fields_set(int32_t, int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-delete"))) -void __wasm_import_types_fields_delete(int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-append"))) -void __wasm_import_types_fields_append(int32_t, int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-entries"))) -void __wasm_import_types_fields_entries(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("fields-clone"))) -int32_t __wasm_import_types_fields_clone(int32_t); - -__attribute__((import_module("types"), import_name("finish-incoming-stream"))) -void __wasm_import_types_finish_incoming_stream(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("finish-outgoing-stream"))) -void __wasm_import_types_finish_outgoing_stream(int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("drop-incoming-request"))) -void __wasm_import_types_drop_incoming_request(int32_t); - -__attribute__((import_module("types"), import_name("drop-outgoing-request"))) -void __wasm_import_types_drop_outgoing_request(int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-method"))) -void __wasm_import_types_incoming_request_method(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-path"))) -void __wasm_import_types_incoming_request_path(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-query"))) -void __wasm_import_types_incoming_request_query(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-scheme"))) -void __wasm_import_types_incoming_request_scheme(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-authority"))) -void __wasm_import_types_incoming_request_authority(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-headers"))) -int32_t __wasm_import_types_incoming_request_headers(int32_t); - -__attribute__((import_module("types"), import_name("incoming-request-consume"))) -void __wasm_import_types_incoming_request_consume(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("new-outgoing-request"))) -int32_t __wasm_import_types_new_outgoing_request(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); - -__attribute__((import_module("types"), import_name("outgoing-request-write"))) -void __wasm_import_types_outgoing_request_write(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("drop-response-outparam"))) -void __wasm_import_types_drop_response_outparam(int32_t); - -__attribute__((import_module("types"), import_name("set-response-outparam"))) -int32_t __wasm_import_types_set_response_outparam(int32_t, int32_t, int32_t, int32_t); - -__attribute__((import_module("types"), import_name("drop-incoming-response"))) -void __wasm_import_types_drop_incoming_response(int32_t); - -__attribute__((import_module("types"), import_name("drop-outgoing-response"))) -void __wasm_import_types_drop_outgoing_response(int32_t); - -__attribute__((import_module("types"), import_name("incoming-response-status"))) -int32_t __wasm_import_types_incoming_response_status(int32_t); - -__attribute__((import_module("types"), import_name("incoming-response-headers"))) -int32_t __wasm_import_types_incoming_response_headers(int32_t); - -__attribute__((import_module("types"), import_name("incoming-response-consume"))) -void __wasm_import_types_incoming_response_consume(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("new-outgoing-response"))) -int32_t __wasm_import_types_new_outgoing_response(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("outgoing-response-write"))) -void __wasm_import_types_outgoing_response_write(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("drop-future-incoming-response"))) -void __wasm_import_types_drop_future_incoming_response(int32_t); - -__attribute__((import_module("types"), import_name("future-incoming-response-get"))) -void __wasm_import_types_future_incoming_response_get(int32_t, int32_t); - -__attribute__((import_module("types"), import_name("listen-to-future-incoming-response"))) -int32_t __wasm_import_types_listen_to_future_incoming_response(int32_t); - -__attribute__((import_module("default-outgoing-HTTP"), import_name("handle"))) -int32_t __wasm_import_default_outgoing_http_handle(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t); - -__attribute__((weak, export_name("cabi_realloc"))) -void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { - if (new_size == 0) return (void*) align; - void *ret = realloc(ptr, new_size); - if (!ret) abort(); - return ret; -} - -// Helper Functions - -void random_list_u8_free(random_list_u8_t *ptr) { - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void poll_list_pollable_free(poll_list_pollable_t *ptr) { - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void poll_list_u8_free(poll_list_u8_t *ptr) { - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void streams_list_u8_free(streams_list_u8_t *ptr) { - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void streams_tuple2_list_u8_bool_free(streams_tuple2_list_u8_bool_t *ptr) { - streams_list_u8_free(&ptr->f0); -} - -void types_scheme_free(types_scheme_t *ptr) { - switch ((int32_t) ptr->tag) { - case 2: { - proxy_string_free(&ptr->val.other); - break; - } - } -} - -void types_method_free(types_method_t *ptr) { - switch ((int32_t) ptr->tag) { - case 9: { - proxy_string_free(&ptr->val.other); - break; - } - } -} - -void types_error_free(types_error_t *ptr) { - switch ((int32_t) ptr->tag) { - case 0: { - proxy_string_free(&ptr->val.invalid_url); - break; - } - case 1: { - proxy_string_free(&ptr->val.timeout_error); - break; - } - case 2: { - proxy_string_free(&ptr->val.protocol_error); - break; - } - case 3: { - proxy_string_free(&ptr->val.unexpected_error); - break; - } - } -} - -void types_tuple2_string_string_free(types_tuple2_string_string_t *ptr) { - proxy_string_free(&ptr->f0); - proxy_string_free(&ptr->f1); -} - -void types_list_tuple2_string_string_free(types_list_tuple2_string_string_t *ptr) { - for (size_t i = 0; i < ptr->len; i++) { - types_tuple2_string_string_free(&ptr->ptr[i]); - } - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void types_list_string_free(types_list_string_t *ptr) { - for (size_t i = 0; i < ptr->len; i++) { - proxy_string_free(&ptr->ptr[i]); - } - if (ptr->len > 0) { - free(ptr->ptr); - } -} - -void types_result_outgoing_response_error_free(types_result_outgoing_response_error_t *ptr) { - if (!ptr->is_err) { - } else { - types_error_free(&ptr->val.err); - } -} - -void types_result_incoming_response_error_free(types_result_incoming_response_error_t *ptr) { - if (!ptr->is_err) { - } else { - types_error_free(&ptr->val.err); - } -} - -void proxy_string_set(proxy_string_t *ret, const char*s) { - ret->ptr = (char*) s; - ret->len = strlen(s); -} - -void proxy_string_dup(proxy_string_t *ret, const char*s) { - ret->len = strlen(s); - ret->ptr = cabi_realloc(NULL, 0, 1, ret->len * 1); - memcpy(ret->ptr, s, ret->len * 1); -} - -void proxy_string_free(proxy_string_t *ret) { - if (ret->len > 0) { - free(ret->ptr); - } - ret->ptr = NULL; - ret->len = 0; -} - -// Component Adapters - -void random_get_random_bytes(uint64_t len, random_list_u8_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_random_get_random_bytes((int64_t) (len), ptr); - *ret = (random_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -uint64_t random_get_random_u64(void) { - int64_t ret = __wasm_import_random_get_random_u64(); - return (uint64_t) (ret); -} - -void random_insecure_random(random_tuple2_u64_u64_t *ret) { - __attribute__((aligned(8))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_random_insecure_random(ptr); - *ret = (random_tuple2_u64_u64_t) { - (uint64_t) (*((int64_t*) (ptr + 0))), - (uint64_t) (*((int64_t*) (ptr + 8))), - }; -} - -void console_log(console_level_t level, proxy_string_t *context, proxy_string_t *message) { - __wasm_import_console_log((int32_t) level, (int32_t) (*context).ptr, (int32_t) (*context).len, (int32_t) (*message).ptr, (int32_t) (*message).len); -} - -void poll_drop_pollable(poll_pollable_t this) { - __wasm_import_poll_drop_pollable((int32_t) (this)); -} - -void poll_poll_oneoff(poll_list_pollable_t *in, poll_list_u8_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_poll_poll_oneoff((int32_t) (*in).ptr, (int32_t) (*in).len, ptr); - *ret = (poll_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -bool streams_read(streams_input_stream_t this, uint64_t len, streams_tuple2_list_u8_bool_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(4))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_read((int32_t) (this), (int64_t) (len), ptr); - streams_result_tuple2_list_u8_bool_stream_error_t result; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - result.is_err = false; - result.val.ok = (streams_tuple2_list_u8_bool_t) { - (streams_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }, - (int32_t) (*((uint8_t*) (ptr + 12))), - }; - break; - } - case 1: { - result.is_err = true; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -bool streams_skip(streams_input_stream_t this, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(8))) - uint8_t ret_area[24]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_skip((int32_t) (this), (int64_t) (len), ptr); - streams_result_tuple2_u64_bool_stream_error_t result; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - result.is_err = false; - result.val.ok = (streams_tuple2_u64_bool_t) { - (uint64_t) (*((int64_t*) (ptr + 8))), - (int32_t) (*((uint8_t*) (ptr + 16))), - }; - break; - } - case 1: { - result.is_err = true; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -streams_pollable_t streams_subscribe_to_input_stream(streams_input_stream_t this) { - int32_t ret = __wasm_import_streams_subscribe_to_input_stream((int32_t) (this)); - return (uint32_t) (ret); -} - -void streams_drop_input_stream(streams_input_stream_t this) { - __wasm_import_streams_drop_input_stream((int32_t) (this)); -} - -bool streams_write(streams_output_stream_t this, streams_list_u8_t *buf, uint64_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(8))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_write((int32_t) (this), (int32_t) (*buf).ptr, (int32_t) (*buf).len, ptr); - 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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -bool streams_write_zeroes(streams_output_stream_t this, uint64_t len, uint64_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(8))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_write_zeroes((int32_t) (this), (int64_t) (len), ptr); - 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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -bool streams_splice(streams_output_stream_t this, streams_input_stream_t src, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(8))) - uint8_t ret_area[24]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_splice((int32_t) (this), (int32_t) (src), (int64_t) (len), ptr); - streams_result_tuple2_u64_bool_stream_error_t result; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - result.is_err = false; - result.val.ok = (streams_tuple2_u64_bool_t) { - (uint64_t) (*((int64_t*) (ptr + 8))), - (int32_t) (*((uint8_t*) (ptr + 16))), - }; - break; - } - case 1: { - result.is_err = true; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -bool streams_forward(streams_output_stream_t this, streams_input_stream_t src, uint64_t *ret, streams_stream_error_t *err) { - __attribute__((aligned(8))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_streams_forward((int32_t) (this), (int32_t) (src), ptr); - 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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -streams_pollable_t streams_subscribe_to_output_stream(streams_output_stream_t this) { - int32_t ret = __wasm_import_streams_subscribe_to_output_stream((int32_t) (this)); - return (uint32_t) (ret); -} - -void streams_drop_output_stream(streams_output_stream_t this) { - __wasm_import_streams_drop_output_stream((int32_t) (this)); -} - -void types_drop_fields(types_fields_t fields) { - __wasm_import_types_drop_fields((int32_t) (fields)); -} - -types_fields_t types_new_fields(types_list_tuple2_string_string_t *entries) { - int32_t ret = __wasm_import_types_new_fields((int32_t) (*entries).ptr, (int32_t) (*entries).len); - return (uint32_t) (ret); -} - -void types_fields_get(types_fields_t fields, proxy_string_t *name, types_list_string_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_fields_get((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, ptr); - *ret = (types_list_string_t) { (proxy_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -void types_fields_set(types_fields_t fields, proxy_string_t *name, types_list_string_t *value) { - __wasm_import_types_fields_set((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, (int32_t) (*value).ptr, (int32_t) (*value).len); -} - -void types_fields_delete(types_fields_t fields, proxy_string_t *name) { - __wasm_import_types_fields_delete((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len); -} - -void types_fields_append(types_fields_t fields, proxy_string_t *name, proxy_string_t *value) { - __wasm_import_types_fields_append((int32_t) (fields), (int32_t) (*name).ptr, (int32_t) (*name).len, (int32_t) (*value).ptr, (int32_t) (*value).len); -} - -void types_fields_entries(types_fields_t fields, types_list_tuple2_string_string_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_fields_entries((int32_t) (fields), ptr); - *ret = (types_list_tuple2_string_string_t) { (types_tuple2_string_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -types_fields_t types_fields_clone(types_fields_t fields) { - int32_t ret = __wasm_import_types_fields_clone((int32_t) (fields)); - return (uint32_t) (ret); -} - -bool types_finish_incoming_stream(types_incoming_stream_t s, types_trailers_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_finish_incoming_stream((int32_t) (s), ptr); - types_option_trailers_t option; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - option.val = (uint32_t) (*((int32_t*) (ptr + 4))); - break; - } - } - *ret = option.val; - return option.is_some; -} - -void types_finish_outgoing_stream(types_outgoing_stream_t s, types_trailers_t *maybe_trailers) { - types_option_trailers_t trailers; - trailers.is_some = maybe_trailers != NULL;if (maybe_trailers) { - trailers.val = *maybe_trailers; - } - int32_t option; - int32_t option1; - if ((trailers).is_some) { - const types_trailers_t *payload0 = &(trailers).val; - option = 1; - option1 = (int32_t) (*payload0); - } else { - option = 0; - option1 = 0; - } - __wasm_import_types_finish_outgoing_stream((int32_t) (s), option, option1); -} - -void types_drop_incoming_request(types_incoming_request_t request) { - __wasm_import_types_drop_incoming_request((int32_t) (request)); -} - -void types_drop_outgoing_request(types_outgoing_request_t request) { - __wasm_import_types_drop_outgoing_request((int32_t) (request)); -} - -void types_incoming_request_method(types_incoming_request_t request, types_method_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[12]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_method((int32_t) (request), ptr); - types_method_t variant; - variant.tag = (int32_t) (*((uint8_t*) (ptr + 0))); - 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: { - variant.val.other = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; - break; - } - } - *ret = variant; -} - -void types_incoming_request_path(types_incoming_request_t request, proxy_string_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_path((int32_t) (request), ptr); - *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -void types_incoming_request_query(types_incoming_request_t request, proxy_string_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_query((int32_t) (request), ptr); - *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -bool types_incoming_request_scheme(types_incoming_request_t request, types_scheme_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[16]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_scheme((int32_t) (request), ptr); - types_option_scheme_t option; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - types_scheme_t variant; - variant.tag = (int32_t) (*((uint8_t*) (ptr + 4))); - switch ((int32_t) variant.tag) { - case 0: { - break; - } - case 1: { - break; - } - case 2: { - variant.val.other = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 8))), (size_t)(*((int32_t*) (ptr + 12))) }; - break; - } - } - - option.val = variant; - break; - } - } - *ret = option.val; - return option.is_some; -} - -void types_incoming_request_authority(types_incoming_request_t request, proxy_string_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_authority((int32_t) (request), ptr); - *ret = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; -} - -types_headers_t types_incoming_request_headers(types_incoming_request_t request) { - int32_t ret = __wasm_import_types_incoming_request_headers((int32_t) (request)); - return (uint32_t) (ret); -} - -bool types_incoming_request_consume(types_incoming_request_t request, types_incoming_stream_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_request_consume((int32_t) (request), ptr); - types_result_incoming_stream_void_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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -types_outgoing_request_t types_new_outgoing_request(types_method_t *method, proxy_string_t *path, proxy_string_t *query, types_scheme_t *maybe_scheme, proxy_string_t *authority, types_headers_t headers) { - types_option_scheme_t scheme; - scheme.is_some = maybe_scheme != NULL;if (maybe_scheme) { - scheme.val = *maybe_scheme; - } - int32_t variant; - int32_t variant9; - int32_t variant10; - switch ((int32_t) (*method).tag) { - case 0: { - variant = 0; - variant9 = 0; - variant10 = 0; - break; - } - case 1: { - variant = 1; - variant9 = 0; - variant10 = 0; - break; - } - case 2: { - variant = 2; - variant9 = 0; - variant10 = 0; - break; - } - case 3: { - variant = 3; - variant9 = 0; - variant10 = 0; - break; - } - case 4: { - variant = 4; - variant9 = 0; - variant10 = 0; - break; - } - case 5: { - variant = 5; - variant9 = 0; - variant10 = 0; - break; - } - case 6: { - variant = 6; - variant9 = 0; - variant10 = 0; - break; - } - case 7: { - variant = 7; - variant9 = 0; - variant10 = 0; - break; - } - case 8: { - variant = 8; - variant9 = 0; - variant10 = 0; - break; - } - case 9: { - const proxy_string_t *payload8 = &(*method).val.other; - variant = 9; - variant9 = (int32_t) (*payload8).ptr; - variant10 = (int32_t) (*payload8).len; - break; - } - } - int32_t option; - int32_t option19; - int32_t option20; - int32_t option21; - if ((scheme).is_some) { - const types_scheme_t *payload12 = &(scheme).val; - int32_t variant16; - int32_t variant17; - int32_t variant18; - switch ((int32_t) (*payload12).tag) { - case 0: { - variant16 = 0; - variant17 = 0; - variant18 = 0; - break; - } - case 1: { - variant16 = 1; - variant17 = 0; - variant18 = 0; - break; - } - case 2: { - const proxy_string_t *payload15 = &(*payload12).val.other; - variant16 = 2; - variant17 = (int32_t) (*payload15).ptr; - variant18 = (int32_t) (*payload15).len; - break; - } - } - option = 1; - option19 = variant16; - option20 = variant17; - option21 = variant18; - } else { - option = 0; - option19 = 0; - option20 = 0; - option21 = 0; - } - int32_t ret = __wasm_import_types_new_outgoing_request(variant, variant9, variant10, (int32_t) (*path).ptr, (int32_t) (*path).len, (int32_t) (*query).ptr, (int32_t) (*query).len, option, option19, option20, option21, (int32_t) (*authority).ptr, (int32_t) (*authority).len, (int32_t) (headers)); - return (uint32_t) (ret); -} - -bool types_outgoing_request_write(types_outgoing_request_t request, types_outgoing_stream_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_outgoing_request_write((int32_t) (request), ptr); - types_result_outgoing_stream_void_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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -void types_drop_response_outparam(types_response_outparam_t response) { - __wasm_import_types_drop_response_outparam((int32_t) (response)); -} - -bool types_set_response_outparam(types_result_outgoing_response_error_t *response) { - int32_t result; - int32_t result7; - int32_t result8; - int32_t result9; - if ((*response).is_err) { - const types_error_t *payload0 = &(*response).val.err;int32_t variant; - int32_t variant5; - int32_t variant6; - switch ((int32_t) (*payload0).tag) { - case 0: { - const proxy_string_t *payload1 = &(*payload0).val.invalid_url; - variant = 0; - variant5 = (int32_t) (*payload1).ptr; - variant6 = (int32_t) (*payload1).len; - break; - } - case 1: { - const proxy_string_t *payload2 = &(*payload0).val.timeout_error; - variant = 1; - variant5 = (int32_t) (*payload2).ptr; - variant6 = (int32_t) (*payload2).len; - break; - } - case 2: { - const proxy_string_t *payload3 = &(*payload0).val.protocol_error; - variant = 2; - variant5 = (int32_t) (*payload3).ptr; - variant6 = (int32_t) (*payload3).len; - break; - } - case 3: { - const proxy_string_t *payload4 = &(*payload0).val.unexpected_error; - variant = 3; - variant5 = (int32_t) (*payload4).ptr; - variant6 = (int32_t) (*payload4).len; - break; - } - } - result = 1; - result7 = variant; - result8 = variant5; - result9 = variant6; - } else { - const types_outgoing_response_t *payload = &(*response).val.ok;result = 0; - result7 = (int32_t) (*payload); - result8 = 0; - result9 = 0; - } - int32_t ret = __wasm_import_types_set_response_outparam(result, result7, result8, result9); - types_result_void_void_t result10; - switch (ret) { - case 0: { - result10.is_err = false; - break; - } - case 1: { - result10.is_err = true; - break; - } - } - if (!result10.is_err) { - return 1; - } else { - return 0; - } -} - -void types_drop_incoming_response(types_incoming_response_t response) { - __wasm_import_types_drop_incoming_response((int32_t) (response)); -} - -void types_drop_outgoing_response(types_outgoing_response_t response) { - __wasm_import_types_drop_outgoing_response((int32_t) (response)); -} - -types_status_code_t types_incoming_response_status(types_incoming_response_t response) { - int32_t ret = __wasm_import_types_incoming_response_status((int32_t) (response)); - return (uint16_t) (ret); -} - -types_headers_t types_incoming_response_headers(types_incoming_response_t response) { - int32_t ret = __wasm_import_types_incoming_response_headers((int32_t) (response)); - return (uint32_t) (ret); -} - -bool types_incoming_response_consume(types_incoming_response_t response, types_incoming_stream_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_incoming_response_consume((int32_t) (response), ptr); - types_result_incoming_stream_void_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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -types_outgoing_response_t types_new_outgoing_response(types_status_code_t status_code, types_headers_t headers) { - int32_t ret = __wasm_import_types_new_outgoing_response((int32_t) (status_code), (int32_t) (headers)); - return (uint32_t) (ret); -} - -bool types_outgoing_response_write(types_outgoing_response_t response, types_outgoing_stream_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[8]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_outgoing_response_write((int32_t) (response), ptr); - types_result_outgoing_stream_void_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; - break; - } - } - if (!result.is_err) { - *ret = result.val.ok; - return 1; - } else { - return 0; - } -} - -void types_drop_future_incoming_response(types_future_incoming_response_t f) { - __wasm_import_types_drop_future_incoming_response((int32_t) (f)); -} - -bool types_future_incoming_response_get(types_future_incoming_response_t f, types_result_incoming_response_error_t *ret) { - __attribute__((aligned(4))) - uint8_t ret_area[20]; - int32_t ptr = (int32_t) &ret_area; - __wasm_import_types_future_incoming_response_get((int32_t) (f), ptr); - types_option_result_incoming_response_error_t option; - switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { - case 0: { - option.is_some = false; - break; - } - case 1: { - option.is_some = true; - types_result_incoming_response_error_t result; - switch ((int32_t) (*((uint8_t*) (ptr + 4)))) { - case 0: { - result.is_err = false; - result.val.ok = (uint32_t) (*((int32_t*) (ptr + 8))); - break; - } - case 1: { - result.is_err = true; - types_error_t variant; - variant.tag = (int32_t) (*((uint8_t*) (ptr + 8))); - switch ((int32_t) variant.tag) { - case 0: { - variant.val.invalid_url = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; - break; - } - case 1: { - variant.val.timeout_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; - break; - } - case 2: { - variant.val.protocol_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; - break; - } - case 3: { - variant.val.unexpected_error = (proxy_string_t) { (char*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }; - break; - } - } - - result.val.err = variant; - break; - } - } - - option.val = result; - break; - } - } - *ret = option.val; - return option.is_some; -} - -types_pollable_t types_listen_to_future_incoming_response(types_future_incoming_response_t f) { - int32_t ret = __wasm_import_types_listen_to_future_incoming_response((int32_t) (f)); - return (uint32_t) (ret); -} - -default_outgoing_http_future_incoming_response_t default_outgoing_http_handle(default_outgoing_http_outgoing_request_t request, default_outgoing_http_request_options_t *maybe_options) { - default_outgoing_http_option_request_options_t options; - options.is_some = maybe_options != NULL;if (maybe_options) { - options.val = *maybe_options; - } - int32_t option12; - int32_t option13; - int32_t option14; - int32_t option15; - int32_t option16; - int32_t option17; - int32_t option18; - if ((options).is_some) { - const default_outgoing_http_request_options_t *payload0 = &(options).val; - int32_t option; - int32_t option3; - if (((*payload0).connect_timeout_ms).is_some) { - const uint32_t *payload2 = &((*payload0).connect_timeout_ms).val; - option = 1; - option3 = (int32_t) (*payload2); - } else { - option = 0; - option3 = 0; - } - int32_t option6; - int32_t option7; - if (((*payload0).first_byte_timeout_ms).is_some) { - const uint32_t *payload5 = &((*payload0).first_byte_timeout_ms).val; - option6 = 1; - option7 = (int32_t) (*payload5); - } else { - option6 = 0; - option7 = 0; - } - int32_t option10; - int32_t option11; - if (((*payload0).between_bytes_timeout_ms).is_some) { - const uint32_t *payload9 = &((*payload0).between_bytes_timeout_ms).val; - option10 = 1; - option11 = (int32_t) (*payload9); - } else { - option10 = 0; - option11 = 0; - } - option12 = 1; - option13 = option; - option14 = option3; - option15 = option6; - option16 = option7; - option17 = option10; - option18 = option11; - } else { - option12 = 0; - option13 = 0; - option14 = 0; - option15 = 0; - option16 = 0; - option17 = 0; - option18 = 0; - } - int32_t ret = __wasm_import_default_outgoing_http_handle((int32_t) (request), option12, option13, option14, option15, option16, option17, option18); - return (uint32_t) (ret); -} - -__attribute__((export_name("HTTP#handle"))) -void __wasm_export_http_handle(int32_t arg, int32_t arg0) { - http_handle((uint32_t) (arg), (uint32_t) (arg0)); -} - -extern void __component_type_object_force_link_proxy(void); -void __component_type_object_force_link_proxy_public_use_in_this_compilation_unit(void) { - __component_type_object_force_link_proxy(); -} diff --git a/crates/wasi-http/example/proxy.h b/crates/wasi-http/example/proxy.h deleted file mode 100644 index 17030384af30..000000000000 --- a/crates/wasi-http/example/proxy.h +++ /dev/null @@ -1,335 +0,0 @@ -#ifndef __BINDINGS_PROXY_H -#define __BINDINGS_PROXY_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -typedef struct { - char*ptr; - size_t len; -} proxy_string_t; - -typedef struct { - uint8_t *ptr; - size_t len; -} random_list_u8_t; - -typedef struct { - uint64_t f0; - uint64_t f1; -} random_tuple2_u64_u64_t; - -// A log level, describing a kind of message. -typedef uint8_t console_level_t; - -#define CONSOLE_LEVEL_TRACE 0 -#define CONSOLE_LEVEL_DEBUG 1 -#define CONSOLE_LEVEL_INFO 2 -#define CONSOLE_LEVEL_WARN 3 -#define CONSOLE_LEVEL_ERROR 4 - -// A "pollable" handle. -// -// This is conceptually represents a `stream<_, _>`, or in other words, -// a stream that one can wait on, repeatedly, but which does not itself -// produce any data. It's temporary scaffolding until component-model's -// async features are ready. -// -// And at present, it is a `u32` instead of being an actual handle, until -// the wit-bindgen implementation of handles and resources is ready. -// -// `pollable` lifetimes are not automatically managed. Users must ensure -// that they do not outlive the resource they reference. -// -// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). -typedef uint32_t poll_pollable_t; - -typedef struct { - poll_pollable_t *ptr; - size_t len; -} poll_list_pollable_t; - -typedef struct { - uint8_t *ptr; - size_t len; -} poll_list_u8_t; - -typedef poll_pollable_t streams_pollable_t; - -// An error type returned from a stream operation. Currently this -// doesn't provide any additional information. -typedef struct { -} streams_stream_error_t; - -// An output bytestream. In the future, this will be replaced by handle -// types. -// -// This conceptually represents a `stream`. It's temporary -// scaffolding until component-model's async features are ready. -// -// `output-stream`s are *non-blocking* to the extent practical on -// underlying platforms. Except where specified otherwise, I/O operations also -// always return promptly, after the number of bytes that can be written -// promptly, which could even be zero. To wait for the stream to be ready to -// accept data, the `subscribe-to-output-stream` function to obtain a -// `pollable` which can be polled for using `wasi_poll`. -// -// And at present, it is a `u32` instead of being an actual handle, until -// the wit-bindgen implementation of handles and resources is ready. -// -// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). -typedef uint32_t streams_output_stream_t; - -// An input bytestream. In the future, this will be replaced by handle -// types. -// -// This conceptually represents a `stream`. It's temporary -// scaffolding until component-model's async features are ready. -// -// `input-stream`s are *non-blocking* to the extent practical on underlying -// platforms. I/O operations always return promptly; if fewer bytes are -// promptly available than requested, they return the number of bytes promptly -// available, which could even be zero. To wait for data to be available, -// use the `subscribe-to-input-stream` function to obtain a `pollable` which -// can be polled for using `wasi_poll`. -// -// And at present, it is a `u32` instead of being an actual handle, until -// the wit-bindgen implementation of handles and resources is ready. -// -// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). -typedef uint32_t streams_input_stream_t; - -typedef struct { - uint8_t *ptr; - size_t len; -} streams_list_u8_t; - -typedef struct { - streams_list_u8_t f0; - bool f1; -} streams_tuple2_list_u8_bool_t; - -typedef struct { - uint64_t f0; - bool f1; -} streams_tuple2_u64_bool_t; - -typedef streams_input_stream_t types_input_stream_t; - -typedef streams_output_stream_t types_output_stream_t; - -typedef poll_pollable_t types_pollable_t; - -typedef uint16_t types_status_code_t; - -typedef struct { - uint8_t tag; - union { - proxy_string_t other; - } val; -} types_scheme_t; - -#define TYPES_SCHEME_HTTP 0 -#define TYPES_SCHEME_HTTPS 1 -#define TYPES_SCHEME_OTHER 2 - -typedef uint32_t types_response_outparam_t; - -typedef struct { - bool is_some; - uint32_t val; -} types_option_u32_t; - -typedef struct { - types_option_u32_t connect_timeout_ms; - types_option_u32_t first_byte_timeout_ms; - types_option_u32_t between_bytes_timeout_ms; -} types_request_options_t; - -typedef types_output_stream_t types_outgoing_stream_t; - -typedef uint32_t types_outgoing_response_t; - -typedef uint32_t types_outgoing_request_t; - -typedef struct { - uint8_t tag; - union { - proxy_string_t other; - } val; -} types_method_t; - -#define TYPES_METHOD_GET 0 -#define TYPES_METHOD_HEAD 1 -#define TYPES_METHOD_POST 2 -#define TYPES_METHOD_PUT 3 -#define TYPES_METHOD_DELETE 4 -#define TYPES_METHOD_CONNECT 5 -#define TYPES_METHOD_OPTIONS 6 -#define TYPES_METHOD_TRACE 7 -#define TYPES_METHOD_PATCH 8 -#define TYPES_METHOD_OTHER 9 - -typedef types_input_stream_t types_incoming_stream_t; - -typedef uint32_t types_incoming_response_t; - -typedef uint32_t types_incoming_request_t; - -typedef uint32_t types_future_incoming_response_t; - -typedef uint32_t types_fields_t; - -typedef types_fields_t types_trailers_t; - -typedef types_fields_t types_headers_t; - -typedef struct { - uint8_t tag; - union { - proxy_string_t invalid_url; - proxy_string_t timeout_error; - proxy_string_t protocol_error; - proxy_string_t unexpected_error; - } val; -} types_error_t; - -#define TYPES_ERROR_INVALID_URL 0 -#define TYPES_ERROR_TIMEOUT_ERROR 1 -#define TYPES_ERROR_PROTOCOL_ERROR 2 -#define TYPES_ERROR_UNEXPECTED_ERROR 3 - -typedef struct { - proxy_string_t f0; - proxy_string_t f1; -} types_tuple2_string_string_t; - -typedef struct { - types_tuple2_string_string_t *ptr; - size_t len; -} types_list_tuple2_string_string_t; - -typedef struct { - proxy_string_t *ptr; - size_t len; -} types_list_string_t; - -typedef struct { - bool is_err; - union { - types_outgoing_response_t ok; - types_error_t err; - } val; -} types_result_outgoing_response_error_t; - -typedef struct { - bool is_err; - union { - types_incoming_response_t ok; - types_error_t err; - } val; -} types_result_incoming_response_error_t; - -typedef types_outgoing_request_t default_outgoing_http_outgoing_request_t; - -typedef types_request_options_t default_outgoing_http_request_options_t; - -typedef types_future_incoming_response_t default_outgoing_http_future_incoming_response_t; - -typedef types_incoming_request_t http_incoming_request_t; - -typedef types_response_outparam_t http_response_outparam_t; - -// Imported Functions from `random` -void random_get_random_bytes(uint64_t len, random_list_u8_t *ret); -uint64_t random_get_random_u64(void); -void random_insecure_random(random_tuple2_u64_u64_t *ret); - -// Imported Functions from `console` -void console_log(console_level_t level, proxy_string_t *context, proxy_string_t *message); - -// Imported Functions from `poll` -void poll_drop_pollable(poll_pollable_t this); -void poll_poll_oneoff(poll_list_pollable_t *in, poll_list_u8_t *ret); - -// Imported Functions from `streams` -bool streams_read(streams_input_stream_t this, uint64_t len, streams_tuple2_list_u8_bool_t *ret, streams_stream_error_t *err); -bool streams_skip(streams_input_stream_t this, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err); -streams_pollable_t streams_subscribe_to_input_stream(streams_input_stream_t this); -void streams_drop_input_stream(streams_input_stream_t this); -bool streams_write(streams_output_stream_t this, streams_list_u8_t *buf, uint64_t *ret, streams_stream_error_t *err); -bool streams_write_zeroes(streams_output_stream_t this, uint64_t len, uint64_t *ret, streams_stream_error_t *err); -bool streams_splice(streams_output_stream_t this, streams_input_stream_t src, uint64_t len, streams_tuple2_u64_bool_t *ret, streams_stream_error_t *err); -bool streams_forward(streams_output_stream_t this, streams_input_stream_t src, uint64_t *ret, streams_stream_error_t *err); -streams_pollable_t streams_subscribe_to_output_stream(streams_output_stream_t this); -void streams_drop_output_stream(streams_output_stream_t this); - -// Imported Functions from `types` -void types_drop_fields(types_fields_t fields); -types_fields_t types_new_fields(types_list_tuple2_string_string_t *entries); -void types_fields_get(types_fields_t fields, proxy_string_t *name, types_list_string_t *ret); -void types_fields_set(types_fields_t fields, proxy_string_t *name, types_list_string_t *value); -void types_fields_delete(types_fields_t fields, proxy_string_t *name); -void types_fields_append(types_fields_t fields, proxy_string_t *name, proxy_string_t *value); -void types_fields_entries(types_fields_t fields, types_list_tuple2_string_string_t *ret); -types_fields_t types_fields_clone(types_fields_t fields); -bool types_finish_incoming_stream(types_incoming_stream_t s, types_trailers_t *ret); -void types_finish_outgoing_stream(types_outgoing_stream_t s, types_trailers_t *maybe_trailers); -void types_drop_incoming_request(types_incoming_request_t request); -void types_drop_outgoing_request(types_outgoing_request_t request); -void types_incoming_request_method(types_incoming_request_t request, types_method_t *ret); -void types_incoming_request_path(types_incoming_request_t request, proxy_string_t *ret); -void types_incoming_request_query(types_incoming_request_t request, proxy_string_t *ret); -bool types_incoming_request_scheme(types_incoming_request_t request, types_scheme_t *ret); -void types_incoming_request_authority(types_incoming_request_t request, proxy_string_t *ret); -types_headers_t types_incoming_request_headers(types_incoming_request_t request); -bool types_incoming_request_consume(types_incoming_request_t request, types_incoming_stream_t *ret); -types_outgoing_request_t types_new_outgoing_request(types_method_t *method, proxy_string_t *path, proxy_string_t *query, types_scheme_t *maybe_scheme, proxy_string_t *authority, types_headers_t headers); -bool types_outgoing_request_write(types_outgoing_request_t request, types_outgoing_stream_t *ret); -void types_drop_response_outparam(types_response_outparam_t response); -bool types_set_response_outparam(types_result_outgoing_response_error_t *response); -void types_drop_incoming_response(types_incoming_response_t response); -void types_drop_outgoing_response(types_outgoing_response_t response); -types_status_code_t types_incoming_response_status(types_incoming_response_t response); -types_headers_t types_incoming_response_headers(types_incoming_response_t response); -bool types_incoming_response_consume(types_incoming_response_t response, types_incoming_stream_t *ret); -types_outgoing_response_t types_new_outgoing_response(types_status_code_t status_code, types_headers_t headers); -bool types_outgoing_response_write(types_outgoing_response_t response, types_outgoing_stream_t *ret); -void types_drop_future_incoming_response(types_future_incoming_response_t f); -bool types_future_incoming_response_get(types_future_incoming_response_t f, types_result_incoming_response_error_t *ret); -types_pollable_t types_listen_to_future_incoming_response(types_future_incoming_response_t f); - -// Imported Functions from `default-outgoing-HTTP` -default_outgoing_http_future_incoming_response_t default_outgoing_http_handle(default_outgoing_http_outgoing_request_t request, default_outgoing_http_request_options_t *maybe_options); - -// Exported Functions from `HTTP` -void http_handle(http_incoming_request_t request, http_response_outparam_t response_out); - -// Helper Functions - -void random_list_u8_free(random_list_u8_t *ptr); -void poll_list_pollable_free(poll_list_pollable_t *ptr); -void poll_list_u8_free(poll_list_u8_t *ptr); -void streams_list_u8_free(streams_list_u8_t *ptr); -void streams_tuple2_list_u8_bool_free(streams_tuple2_list_u8_bool_t *ptr); -void types_scheme_free(types_scheme_t *ptr); -void types_method_free(types_method_t *ptr); -void types_error_free(types_error_t *ptr); -void types_tuple2_string_string_free(types_tuple2_string_string_t *ptr); -void types_list_tuple2_string_string_free(types_list_tuple2_string_string_t *ptr); -void types_list_string_free(types_list_string_t *ptr); -void types_result_outgoing_response_error_free(types_result_outgoing_response_error_t *ptr); -void types_result_incoming_response_error_free(types_result_incoming_response_error_t *ptr); -void proxy_string_set(proxy_string_t *ret, const char*s); -void proxy_string_dup(proxy_string_t *ret, const char*s); -void proxy_string_free(proxy_string_t *ret); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/crates/wasi-http/example/proxy_component_type.o b/crates/wasi-http/example/proxy_component_type.o deleted file mode 100644 index c584bd3ba5417a4dd5db963c0aba743d9b589219..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8260 zcmeHNUvt~W5x)fv1SOJ^Xp6F}#;)W1Z4y|{KgV^GSW=TTGtEP1ns*f>k0LA(fN?-* zC6nnF>lbK0MLs|t^3>=24*z%{NY^vXbUGQn5Ww!<-tO&TvHLqRSI&qrMx6e}m}wB( zHVK5E9`BFBSri5$NSx#<5|5%de0F6pbM7TpcAx(;DCja`_K$r!-J&ytu6R2Necv7W zf|=0C)zg0DCeug9>UQyCF#`gXG@Z2#SU~mh6f@qHNi5u%BjPxWp;S%M3)3V@6DMbZ z$U*FSL5k3%^>h{})6B*M@W3G6GzLnSJ>m2n@5sbW zQt6Dsv09uKJvI54Uw{1<#w>ODE3RQO6){Q1TXHlNGbPrBXZ=`6ghL8P`R&H;42*5M zyrS5=HVT74j1VYqCct)PvOAb~u}qxdRU&lq;ZP)VA%ct{bq?Q+#nV(^Oc*5|W`h16 z--Wu1&uf4(DspKSr1!ws(-@gH(67($GAkH#FL3oG1eLjUnGJt zyYK>cr3K7NVs`|dh3Ji@wbhx4WEzg4exL7p0XA#RNK!^tWX;GM%1Dh-8hI1+!%3Q? zv2ZkYzUG+aH{iD>p76(NVQ%p@Ec1L3tEb!CR*n@9^ptnJ;2YQX#!edh2xYH~OSXSO z*ue{wgrm^UcQhz_X&|0Oh@lu)G;Wpq{bf3#V)EO>cxN1kky98$uTW@6Nztnivhljc zo{+D>rtLt?E1}mZl5}E}N_gPTgk*22sDebV zP*uc}-ddwgYO-z=iD1m=ZOuXU8s8~Y72Ys-GV>zk)RkkbopBdkUU`b_`$>r zJULwiu}Bbf45LZzR)M<*J4)ed*OtQf)nXPe#1RAs*^+A;Bi}dlt|oWAlB?7e8W_E& z$sMr)zp<>!DfTnHUz3!4(2!J_jL`@DpuvGr@fBEfxmDBh;fnc+>_QLtQA3ZL;@yh9 zB-5oW1iQlz8^Yz*r;q3f9kANO4_C+BEwU|G(Y!!Jz!G3;!Yd7-1WLKfkYvdFUZ3H0{qEZnv3!^{QW$*Bt zjj5d~Y@gMIAFdLvV)i*+BK;#~F9Or&gQdWfrhlQ&&_`5mH2f>W@+XMWevq1!LI17=LM92G0}Rp9@Kg-}OD2;4_$n&blFtzT%cDedJzrdGY8t zyUl+st23aSx4qz@ma+fcrqi8YZx!^)rV3JpC^Oln3i{tyLFU@m5f!`9C_NQ%xu{jN zwPhZiZK?g;T3N+rmA<{IO3rHi_H(O8PM0P!XIW8DS>d*r#amN17^7DrTbnnh#jj`C zrOK8C^>~?JZFSzJh5v=vVC7)bVD>+drFxqzRlLfZUac%sH@(^~(5wB2ETvUqSr4Hy zQnR_IvsRIcmgVv7DN<2$6nKW7X1aQ9YNDvBat+s-;99P!rYm#JGQn!AT(eBgbImf< z6t^D>V$9VFGt*xyBWv%R>UEI5W0?tXMR|w zj7NntJz#K=?*V|K{e=R>hiZEg#@IV>bx>M|O~#LEZs0?$n|V-4!jEg2A4?K9UI4J< z2(h^gSeh#VOKUY?*;)fwnlA*zTMdQaWF7YQdbJRFF@(e%jK#!FeH>Dj z=aTB&^hIHkPPPhFm!hpgvzID5u&&l9E!yPF)!ynuSp%hF1@t_x1Itc+bJHu6%GP0- zVD0eyygkRFvjh0!?3Xj Date: Tue, 21 Mar 2023 03:44:56 +0000 Subject: [PATCH 06/46] Remove generated code textfile --- crates/wasi-http/expansion.txt | 3613 -------------------------------- 1 file changed, 3613 deletions(-) delete mode 100644 crates/wasi-http/expansion.txt diff --git a/crates/wasi-http/expansion.txt b/crates/wasi-http/expansion.txt deleted file mode 100644 index 54847681e0ce..000000000000 --- a/crates/wasi-http/expansion.txt +++ /dev/null @@ -1,3613 +0,0 @@ -#![feature(prelude_import)]get_cx -#[prelude_import] -use std::prelude::rust_2021::*; -#[macro_use] -extern crate std; -#[allow(clippy::all)] -pub mod random { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - pub trait Host: Sized { - /// Return `len` cryptographically-secure pseudo-random bytes. - /// - /// This function must produce data from an adequately seeded - /// cryptographically-secure pseudo-random number generator (CSPRNG), so it - /// must not block, from the perspective of the calling program, and the - /// returned data is always unpredictable. - /// - /// This function must always return fresh pseudo-random data. Deterministic - /// environments must omit this function, rather than implementing it with - /// deterministic data. - fn get_random_bytes(&mut self, len: u64) -> wasmtime::Result>; - /// Return a cryptographically-secure pseudo-random `u64` value. - /// - /// This function returns the same type of pseudo-random data as - /// `get-random-bytes`, represented as a `u64`. - fn get_random_u64(&mut self) -> wasmtime::Result; - /// 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. - fn insecure_random(&mut self) -> wasmtime::Result<(u64, u64)>; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("random")?; - inst.func_wrap( - "get-random-bytes", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| { - let host = get(caller.data_mut()); - let r = host.get_random_bytes(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "get-random-u64", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { - let host = get(caller.data_mut()); - let r = host.get_random_u64(); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "insecure-random", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { - let host = get(caller.data_mut()); - let r = host.insecure_random(); - Ok((r?,)) - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod console { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - /// A log level, describing a kind of message. - #[component(enum)] - pub enum Level { - /// Describes messages about the values of variables and the flow of - /// control within a program. - #[component(name = "trace")] - Trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. - #[component(name = "debug")] - Debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. - #[component(name = "info")] - Info, - /// Describes messages indicating hazardous situations. - #[component(name = "warn")] - Warn, - /// Describes messages indicating serious errors. - #[component(name = "error")] - Error, - } - #[automatically_derived] - impl ::core::clone::Clone for Level { - #[inline] - fn clone(&self) -> Level { - *self - } - } - #[automatically_derived] - impl ::core::marker::Copy for Level {} - #[automatically_derived] - impl ::core::marker::StructuralPartialEq for Level {} - #[automatically_derived] - impl ::core::cmp::PartialEq for Level { - #[inline] - fn eq(&self, other: &Level) -> bool { - let __self_tag = ::core::intrinsics::discriminant_value(self); - let __arg1_tag = ::core::intrinsics::discriminant_value(other); - __self_tag == __arg1_tag - } - } - #[automatically_derived] - impl ::core::marker::StructuralEq for Level {} - #[automatically_derived] - impl ::core::cmp::Eq for Level { - #[inline] - #[doc(hidden)] - #[no_coverage] - fn assert_receiver_is_total_eq(&self) -> () {} - } - unsafe impl wasmtime::component::Lower for Level { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - match self { - Self::Trace => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(0u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Trace) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Debug => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(1u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Debug) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Info => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(2u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Info) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Warn => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(3u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Warn) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Error => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(4u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Error) - } - } - }, - |dst| Ok(()), - ) - } - } - } - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - match self { - Self::Trace => { - *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); - Ok(()) - } - Self::Debug => { - *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); - Ok(()) - } - Self::Info => { - *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); - Ok(()) - } - Self::Warn => { - *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); - Ok(()) - } - Self::Error => { - *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); - Ok(()) - } - } - } - } - unsafe impl wasmtime::component::Lift for Level { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok( - match src.tag.get_u32() { - 0u32 => Self::Trace, - 1u32 => Self::Debug, - 2u32 => Self::Info, - 3u32 => Self::Warn, - 4u32 => Self::Error, - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - let align = ::ALIGN32; - if true { - if !((bytes.as_ptr() as usize) % (align as usize) == 0) { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", - ) - } - } - let discrim = bytes[0]; - let payload_offset = ::PAYLOAD_OFFSET32; - let payload = &bytes[payload_offset..]; - Ok( - match discrim { - 0u8 => Self::Trace, - 1u8 => Self::Debug, - 2u8 => Self::Info, - 3u8 => Self::Warn, - 4u8 => Self::Error, - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerLevel { - tag: wasmtime::ValRaw, - payload: LowerPayloadLevel, - } - #[automatically_derived] - impl ::core::clone::Clone for LowerLevel { - #[inline] - fn clone(&self) -> LowerLevel { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - #[automatically_derived] - impl ::core::marker::Copy for LowerLevel {} - #[doc(hidden)] - #[allow(non_snake_case)] - #[repr(C)] - union LowerPayloadLevel { - Trace: [wasmtime::ValRaw; 0], - Debug: [wasmtime::ValRaw; 0], - Info: [wasmtime::ValRaw; 0], - Warn: [wasmtime::ValRaw; 0], - Error: [wasmtime::ValRaw; 0], - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::clone::Clone for LowerPayloadLevel { - #[inline] - fn clone(&self) -> LowerPayloadLevel { - let _: ::core::clone::AssertParamIsCopy; - *self - } - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::marker::Copy for LowerPayloadLevel {} - unsafe impl wasmtime::component::ComponentType for Level { - type Lower = LowerLevel; - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_enum( - ty, - types, - &["trace", "debug", "info", "warn", "error"], - ) - } - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( - &[None, None, None, None, None], - ); - } - unsafe impl wasmtime::component::__internal::ComponentVariant for Level { - const CASES: &'static [Option< - wasmtime::component::__internal::CanonicalAbiInfo, - >] = &[None, None, None, None, None]; - } - }; - impl core::fmt::Debug for Level { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Level::Trace => f.debug_tuple("Level::Trace").finish(), - Level::Debug => f.debug_tuple("Level::Debug").finish(), - Level::Info => f.debug_tuple("Level::Info").finish(), - Level::Warn => f.debug_tuple("Level::Warn").finish(), - Level::Error => f.debug_tuple("Level::Error").finish(), - } - } - } - pub trait Host: Sized { - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. - fn log( - &mut self, - level: Level, - context: String, - message: String, - ) -> wasmtime::Result<()>; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("console")?; - inst.func_wrap( - "log", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1, arg2): (Level, String, String)| - { - let host = get(caller.data_mut()); - let r = host.log(arg0, arg1, arg2); - r - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod poll { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - /// A "pollable" handle. - /// - /// This is conceptually represents a `stream<_, _>`, or in other words, - /// a stream that one can wait on, repeatedly, but which does not itself - /// produce any data. It's temporary scaffolding until component-model's - /// async features are ready. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// `pollable` lifetimes are not automatically managed. Users must ensure - /// that they do not outlive the resource they reference. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type Pollable = u32; - pub trait Host: Sized { - /// Dispose of the specified `pollable`, after which it may no longer - /// be used. - fn drop_pollable(&mut self, this: Pollable) -> wasmtime::Result<()>; - /// Poll for completion on a set of pollables. - /// - /// The "oneoff" in the name refers to the fact that this function must do a - /// linear scan through the entire list of subscriptions, which may be - /// inefficient if the number is large and the same subscriptions are used - /// many times. In the future, this is expected to be obsoleted by the - /// component model async proposal, which will include a scalable waiting - /// facility. - /// - /// Note that the return type would ideally be `list`, but that would - /// be more difficult to polyfill given the current state of `wit-bindgen`. - /// See - /// for details. For now, we use zero to mean "not ready" and non-zero to - /// mean "ready". - fn poll_oneoff(&mut self, in_: Vec) -> wasmtime::Result>; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("poll")?; - inst.func_wrap( - "drop-pollable", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Pollable,)| { - let host = get(caller.data_mut()); - let r = host.drop_pollable(arg0); - r - }, - )?; - inst.func_wrap( - "poll-oneoff", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (Vec,)| - { - let host = get(caller.data_mut()); - let r = host.poll_oneoff(arg0); - Ok((r?,)) - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod streams { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - pub type Pollable = super::poll::Pollable; - /// An error type returned from a stream operation. Currently this - /// doesn't provide any additional information. - #[component(record)] - pub struct StreamError {} - #[automatically_derived] - impl ::core::marker::Copy for StreamError {} - #[automatically_derived] - impl ::core::clone::Clone for StreamError { - #[inline] - fn clone(&self) -> StreamError { - *self - } - } - unsafe impl wasmtime::component::Lower for StreamError { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - Ok(()) - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - Ok(()) - } - } - unsafe impl wasmtime::component::Lift for StreamError { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok(Self {}) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - if true { - if !((bytes.as_ptr() as usize) - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) %\\n (::ALIGN32 as usize) == 0", - ) - } - } - let mut offset = 0; - Ok(Self {}) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerStreamError { - _align: [wasmtime::ValRaw; 0], - } - #[automatically_derived] - impl ::core::clone::Clone for LowerStreamError { - #[inline] - fn clone(&self) -> LowerStreamError { - let _: ::core::clone::AssertParamIsClone<[wasmtime::ValRaw; 0]>; - *self - } - } - #[automatically_derived] - impl ::core::marker::Copy for LowerStreamError {} - unsafe impl wasmtime::component::ComponentType for StreamError { - type Lower = LowerStreamError; - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::record_static( - &[], - ); - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_record(ty, types, &[]) - } - } - }; - impl core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("StreamError").finish() - } - } - impl core::fmt::Display for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.write_fmt(format_args!("{0:?}", self)) - } - } - impl std::error::Error for StreamError {} - /// An output bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `output-stream`s are *non-blocking* to the extent practical on - /// underlying platforms. Except where specified otherwise, I/O operations also - /// always return promptly, after the number of bytes that can be written - /// promptly, which could even be zero. To wait for the stream to be ready to - /// accept data, the `subscribe-to-output-stream` function to obtain a - /// `pollable` which can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type OutputStream = u32; - /// An input bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `input-stream`s are *non-blocking* to the extent practical on underlying - /// platforms. I/O operations always return promptly; if fewer bytes are - /// promptly available than requested, they return the number of bytes promptly - /// available, which could even be zero. To wait for data to be available, - /// use the `subscribe-to-input-stream` function to obtain a `pollable` which - /// can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type InputStream = u32; - pub trait Host: Sized { - /// Read bytes from a stream. - /// - /// This function returns a list of bytes containing the data that was - /// read, along with a bool indicating whether the end of the stream - /// was reached. The returned list will contain up to `len` bytes; it - /// may return fewer than requested, but not more. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// If `len` is 0, it represents a request to read 0 bytes, which should - /// always succeed, assuming the stream hasn't reached its end yet, and - /// return an empty list. - /// - /// The len here is a `u64`, but some callees may not be able to allocate - /// a buffer as large as that would imply. - /// FIXME: describe what happens if allocation fails. - fn read( - &mut self, - this: InputStream, - len: u64, - ) -> wasmtime::Result, bool), StreamError>>; - /// Skip bytes from a stream. - /// - /// This is similar to the `read` function, but avoids copying the - /// bytes into the instance. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// This function returns the number of bytes skipped, along with a bool - /// indicating whether the end of the stream was reached. The returned - /// value will be at most `len`; it may be less. - fn skip( - &mut self, - this: InputStream, - len: u64, - ) -> wasmtime::Result>; - /// Create a `pollable` which will resolve once either the specified stream - /// has bytes available to read or the other end of the stream has been - /// closed. - fn subscribe_to_input_stream( - &mut self, - this: InputStream, - ) -> wasmtime::Result; - /// Dispose of the specified `input-stream`, after which it may no longer - /// be used. - fn drop_input_stream(&mut self, this: InputStream) -> wasmtime::Result<()>; - /// Write bytes to a stream. - /// - /// This function returns a `u64` indicating the number of bytes from - /// `buf` that were written; it may be less than the full list. - fn write( - &mut self, - this: OutputStream, - buf: Vec, - ) -> wasmtime::Result>; - /// Write multiple zero bytes to a stream. - /// - /// This function returns a `u64` indicating the number of zero bytes - /// that were written; it may be less than `len`. - fn write_zeroes( - &mut self, - this: OutputStream, - len: u64, - ) -> wasmtime::Result>; - /// Read from one stream and write to another. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - /// - /// Unlike other I/O functions, this function blocks until all the data - /// read from the input stream has been written to the output stream. - fn splice( - &mut self, - this: OutputStream, - src: InputStream, - len: u64, - ) -> wasmtime::Result>; - /// Forward the entire contents of an input stream to an output stream. - /// - /// This function repeatedly reads from the input stream and writes - /// the data to the output stream, until the end of the input stream - /// is reached, or an error is encountered. - /// - /// Unlike other I/O functions, this function blocks until the end - /// of the input stream is seen and all the data has been written to - /// the output stream. - /// - /// This function returns the number of bytes transferred. - fn forward( - &mut self, - this: OutputStream, - src: InputStream, - ) -> wasmtime::Result>; - /// Create a `pollable` which will resolve once either the specified stream - /// is ready to accept bytes or the other end of the stream has been closed. - fn subscribe_to_output_stream( - &mut self, - this: OutputStream, - ) -> wasmtime::Result; - /// Dispose of the specified `output-stream`, after which it may no longer - /// be used. - fn drop_output_stream(&mut self, this: OutputStream) -> wasmtime::Result<()>; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("streams")?; - inst.func_wrap( - "read", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (InputStream, u64)| - { - let host = get(caller.data_mut()); - let r = host.read(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "skip", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (InputStream, u64)| - { - let host = get(caller.data_mut()); - let r = host.skip(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "subscribe-to-input-stream", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (InputStream,)| { - let host = get(caller.data_mut()); - let r = host.subscribe_to_input_stream(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "drop-input-stream", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (InputStream,)| { - let host = get(caller.data_mut()); - let r = host.drop_input_stream(arg0); - r - }, - )?; - inst.func_wrap( - "write", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (OutputStream, Vec)| - { - let host = get(caller.data_mut()); - let r = host.write(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "write-zeroes", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (OutputStream, u64)| - { - let host = get(caller.data_mut()); - let r = host.write_zeroes(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "splice", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1, arg2): (OutputStream, InputStream, u64)| - { - let host = get(caller.data_mut()); - let r = host.splice(arg0, arg1, arg2); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "forward", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (OutputStream, InputStream)| - { - let host = get(caller.data_mut()); - let r = host.forward(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "subscribe-to-output-stream", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutputStream,)| - { - let host = get(caller.data_mut()); - let r = host.subscribe_to_output_stream(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "drop-output-stream", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutputStream,)| - { - let host = get(caller.data_mut()); - let r = host.drop_output_stream(arg0); - r - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod types { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - pub type InputStream = super::streams::InputStream; - pub type OutputStream = super::streams::OutputStream; - pub type Pollable = super::poll::Pollable; - pub type StatusCode = u16; - #[component(variant)] - pub enum Scheme { - #[component(name = "HTTP")] - Http, - #[component(name = "HTTPS")] - Https, - #[component(name = "other")] - Other(String), - } - #[automatically_derived] - impl ::core::clone::Clone for Scheme { - #[inline] - fn clone(&self) -> Scheme { - match self { - Scheme::Http => Scheme::Http, - Scheme::Https => Scheme::Https, - Scheme::Other(__self_0) => { - Scheme::Other(::core::clone::Clone::clone(__self_0)) - } - } - } - } - unsafe impl wasmtime::component::Lower for Scheme { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - match self { - Self::Http => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(0u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Http) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Https => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(1u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Https) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Other(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(2u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Other) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - } - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - match self { - Self::Http => { - *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); - Ok(()) - } - Self::Https => { - *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); - Ok(()) - } - Self::Other(value) => { - *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - } - } - } - unsafe impl wasmtime::component::Lift for Scheme { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok( - match src.tag.get_u32() { - 0u32 => Self::Http, - 1u32 => Self::Https, - 2u32 => { - Self::Other( - ::lift( - store, - options, - unsafe { &src.payload.Other }, - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - let align = ::ALIGN32; - if true { - if !((bytes.as_ptr() as usize) % (align as usize) == 0) { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", - ) - } - } - let discrim = bytes[0]; - let payload_offset = ::PAYLOAD_OFFSET32; - let payload = &bytes[payload_offset..]; - Ok( - match discrim { - 0u8 => Self::Http, - 1u8 => Self::Https, - 2u8 => { - Self::Other( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerScheme { - tag: wasmtime::ValRaw, - payload: LowerPayloadScheme, - } - #[automatically_derived] - impl ::core::clone::Clone for LowerScheme { - #[inline] - fn clone(&self) -> LowerScheme { - LowerScheme { - tag: ::core::clone::Clone::clone(&self.tag), - payload: ::core::clone::Clone::clone(&self.payload), - } - } - } - #[automatically_derived] - impl ::core::marker::Copy for LowerScheme {} - #[doc(hidden)] - #[allow(non_snake_case)] - #[repr(C)] - union LowerPayloadScheme { - Http: [wasmtime::ValRaw; 0], - Https: [wasmtime::ValRaw; 0], - Other: T2, - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::clone::Clone - for LowerPayloadScheme { - #[inline] - fn clone(&self) -> LowerPayloadScheme { - let _: ::core::clone::AssertParamIsCopy; - *self - } - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::marker::Copy - for LowerPayloadScheme {} - unsafe impl wasmtime::component::ComponentType for Scheme { - type Lower = LowerScheme< - ::Lower, - >; - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_variant( - ty, - types, - &[ - ("HTTP", None), - ("HTTPS", None), - ( - "other", - Some( - ::typecheck, - ), - ), - ], - ) - } - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( - &[None, None, Some(::ABI)], - ); - } - unsafe impl wasmtime::component::__internal::ComponentVariant for Scheme { - const CASES: &'static [Option< - wasmtime::component::__internal::CanonicalAbiInfo, - >] = &[ - None, - None, - Some(::ABI), - ]; - } - }; - impl core::fmt::Debug for Scheme { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Scheme::Http => f.debug_tuple("Scheme::Http").finish(), - Scheme::Https => f.debug_tuple("Scheme::Https").finish(), - Scheme::Other(e) => f.debug_tuple("Scheme::Other").field(e).finish(), - } - } - } - pub type ResponseOutparam = u32; - #[component(record)] - pub struct RequestOptions { - #[component(name = "connect-timeout-ms")] - pub connect_timeout_ms: Option, - #[component(name = "first-byte-timeout-ms")] - pub first_byte_timeout_ms: Option, - #[component(name = "between-bytes-timeout-ms")] - pub between_bytes_timeout_ms: Option, - } - #[automatically_derived] - impl ::core::marker::Copy for RequestOptions {} - #[automatically_derived] - impl ::core::clone::Clone for RequestOptions { - #[inline] - fn clone(&self) -> RequestOptions { - let _: ::core::clone::AssertParamIsClone>; - let _: ::core::clone::AssertParamIsClone>; - let _: ::core::clone::AssertParamIsClone>; - *self - } - } - unsafe impl wasmtime::component::Lower for RequestOptions { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::Lower::lower( - &self.connect_timeout_ms, - store, - options, - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).connect_timeout_ms) - } - } - }, - )?; - wasmtime::component::Lower::lower( - &self.first_byte_timeout_ms, - store, - options, - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).first_byte_timeout_ms) - } - } - }, - )?; - wasmtime::component::Lower::lower( - &self.between_bytes_timeout_ms, - store, - options, - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).between_bytes_timeout_ms) - } - } - }, - )?; - Ok(()) - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - wasmtime::component::Lower::store( - &self.connect_timeout_ms, - memory, - as wasmtime::component::ComponentType>::ABI - .next_field32_size(&mut offset), - )?; - wasmtime::component::Lower::store( - &self.first_byte_timeout_ms, - memory, - as wasmtime::component::ComponentType>::ABI - .next_field32_size(&mut offset), - )?; - wasmtime::component::Lower::store( - &self.between_bytes_timeout_ms, - memory, - as wasmtime::component::ComponentType>::ABI - .next_field32_size(&mut offset), - )?; - Ok(()) - } - } - unsafe impl wasmtime::component::Lift for RequestOptions { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok(Self { - connect_timeout_ms: as wasmtime::component::Lift>::lift( - store, - options, - &src.connect_timeout_ms, - )?, - first_byte_timeout_ms: as wasmtime::component::Lift>::lift( - store, - options, - &src.first_byte_timeout_ms, - )?, - between_bytes_timeout_ms: as wasmtime::component::Lift>::lift( - store, - options, - &src.between_bytes_timeout_ms, - )?, - }) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - if true { - if !((bytes.as_ptr() as usize) - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) %\\n (::ALIGN32 as usize) == 0", - ) - } - } - let mut offset = 0; - Ok(Self { - connect_timeout_ms: as wasmtime::component::Lift>::load( - memory, - &bytes[ as wasmtime::component::ComponentType>::ABI - .next_field32_size( - &mut offset, - )..][.. as wasmtime::component::ComponentType>::SIZE32], - )?, - first_byte_timeout_ms: as wasmtime::component::Lift>::load( - memory, - &bytes[ as wasmtime::component::ComponentType>::ABI - .next_field32_size( - &mut offset, - )..][.. as wasmtime::component::ComponentType>::SIZE32], - )?, - between_bytes_timeout_ms: as wasmtime::component::Lift>::load( - memory, - &bytes[ as wasmtime::component::ComponentType>::ABI - .next_field32_size( - &mut offset, - )..][.. as wasmtime::component::ComponentType>::SIZE32], - )?, - }) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerRequestOptions { - connect_timeout_ms: T0, - first_byte_timeout_ms: T1, - between_bytes_timeout_ms: T2, - _align: [wasmtime::ValRaw; 0], - } - #[automatically_derived] - impl< - T0: ::core::clone::Clone + Copy, - T1: ::core::clone::Clone + Copy, - T2: ::core::clone::Clone + Copy, - > ::core::clone::Clone for LowerRequestOptions { - #[inline] - fn clone(&self) -> LowerRequestOptions { - LowerRequestOptions { - connect_timeout_ms: ::core::clone::Clone::clone( - &self.connect_timeout_ms, - ), - first_byte_timeout_ms: ::core::clone::Clone::clone( - &self.first_byte_timeout_ms, - ), - between_bytes_timeout_ms: ::core::clone::Clone::clone( - &self.between_bytes_timeout_ms, - ), - _align: ::core::clone::Clone::clone(&self._align), - } - } - } - #[automatically_derived] - impl< - T0: ::core::marker::Copy + Copy, - T1: ::core::marker::Copy + Copy, - T2: ::core::marker::Copy + Copy, - > ::core::marker::Copy for LowerRequestOptions {} - unsafe impl wasmtime::component::ComponentType for RequestOptions { - type Lower = LowerRequestOptions< - as wasmtime::component::ComponentType>::Lower, - as wasmtime::component::ComponentType>::Lower, - as wasmtime::component::ComponentType>::Lower, - >; - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::record_static( - &[ - as wasmtime::component::ComponentType>::ABI, - as wasmtime::component::ComponentType>::ABI, - as wasmtime::component::ComponentType>::ABI, - ], - ); - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_record( - ty, - types, - &[ - ( - "connect-timeout-ms", - as wasmtime::component::ComponentType>::typecheck, - ), - ( - "first-byte-timeout-ms", - as wasmtime::component::ComponentType>::typecheck, - ), - ( - "between-bytes-timeout-ms", - as wasmtime::component::ComponentType>::typecheck, - ), - ], - ) - } - } - }; - impl core::fmt::Debug for RequestOptions { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("RequestOptions") - .field("connect-timeout-ms", &self.connect_timeout_ms) - .field("first-byte-timeout-ms", &self.first_byte_timeout_ms) - .field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms) - .finish() - } - } - pub type OutgoingStream = OutputStream; - pub type OutgoingResponse = u32; - pub type OutgoingRequest = u32; - #[component(variant)] - pub enum Method { - #[component(name = "get")] - Get, - #[component(name = "head")] - Head, - #[component(name = "post")] - Post, - #[component(name = "put")] - Put, - #[component(name = "delete")] - Delete, - #[component(name = "connect")] - Connect, - #[component(name = "options")] - Options, - #[component(name = "trace")] - Trace, - #[component(name = "patch")] - Patch, - #[component(name = "other")] - Other(String), - } - #[automatically_derived] - impl ::core::clone::Clone for Method { - #[inline] - fn clone(&self) -> Method { - match self { - Method::Get => Method::Get, - Method::Head => Method::Head, - Method::Post => Method::Post, - Method::Put => Method::Put, - Method::Delete => Method::Delete, - Method::Connect => Method::Connect, - Method::Options => Method::Options, - Method::Trace => Method::Trace, - Method::Patch => Method::Patch, - Method::Other(__self_0) => { - Method::Other(::core::clone::Clone::clone(__self_0)) - } - } - } - } - unsafe impl wasmtime::component::Lower for Method { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - match self { - Self::Get => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(0u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Get) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Head => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(1u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Head) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Post => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(2u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Post) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Put => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(3u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Put) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Delete => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(4u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Delete) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Connect => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(5u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Connect) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Options => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(6u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Options) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Trace => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(7u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Trace) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Patch => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(8u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Patch) - } - } - }, - |dst| Ok(()), - ) - } - } - Self::Other(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(9u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).Other) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - } - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - match self { - Self::Get => { - *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); - Ok(()) - } - Self::Head => { - *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); - Ok(()) - } - Self::Post => { - *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); - Ok(()) - } - Self::Put => { - *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); - Ok(()) - } - Self::Delete => { - *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); - Ok(()) - } - Self::Connect => { - *memory.get::<1usize>(offset) = 5u8.to_le_bytes(); - Ok(()) - } - Self::Options => { - *memory.get::<1usize>(offset) = 6u8.to_le_bytes(); - Ok(()) - } - Self::Trace => { - *memory.get::<1usize>(offset) = 7u8.to_le_bytes(); - Ok(()) - } - Self::Patch => { - *memory.get::<1usize>(offset) = 8u8.to_le_bytes(); - Ok(()) - } - Self::Other(value) => { - *memory.get::<1usize>(offset) = 9u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - } - } - } - unsafe impl wasmtime::component::Lift for Method { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok( - match src.tag.get_u32() { - 0u32 => Self::Get, - 1u32 => Self::Head, - 2u32 => Self::Post, - 3u32 => Self::Put, - 4u32 => Self::Delete, - 5u32 => Self::Connect, - 6u32 => Self::Options, - 7u32 => Self::Trace, - 8u32 => Self::Patch, - 9u32 => { - Self::Other( - ::lift( - store, - options, - unsafe { &src.payload.Other }, - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - let align = ::ALIGN32; - if true { - if !((bytes.as_ptr() as usize) % (align as usize) == 0) { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", - ) - } - } - let discrim = bytes[0]; - let payload_offset = ::PAYLOAD_OFFSET32; - let payload = &bytes[payload_offset..]; - Ok( - match discrim { - 0u8 => Self::Get, - 1u8 => Self::Head, - 2u8 => Self::Post, - 3u8 => Self::Put, - 4u8 => Self::Delete, - 5u8 => Self::Connect, - 6u8 => Self::Options, - 7u8 => Self::Trace, - 8u8 => Self::Patch, - 9u8 => { - Self::Other( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerMethod { - tag: wasmtime::ValRaw, - payload: LowerPayloadMethod, - } - #[automatically_derived] - impl ::core::clone::Clone for LowerMethod { - #[inline] - fn clone(&self) -> LowerMethod { - LowerMethod { - tag: ::core::clone::Clone::clone(&self.tag), - payload: ::core::clone::Clone::clone(&self.payload), - } - } - } - #[automatically_derived] - impl ::core::marker::Copy for LowerMethod {} - #[doc(hidden)] - #[allow(non_snake_case)] - #[repr(C)] - union LowerPayloadMethod { - Get: [wasmtime::ValRaw; 0], - Head: [wasmtime::ValRaw; 0], - Post: [wasmtime::ValRaw; 0], - Put: [wasmtime::ValRaw; 0], - Delete: [wasmtime::ValRaw; 0], - Connect: [wasmtime::ValRaw; 0], - Options: [wasmtime::ValRaw; 0], - Trace: [wasmtime::ValRaw; 0], - Patch: [wasmtime::ValRaw; 0], - Other: T9, - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::clone::Clone - for LowerPayloadMethod { - #[inline] - fn clone(&self) -> LowerPayloadMethod { - let _: ::core::clone::AssertParamIsCopy; - *self - } - } - #[automatically_derived] - #[allow(non_snake_case)] - impl ::core::marker::Copy - for LowerPayloadMethod {} - unsafe impl wasmtime::component::ComponentType for Method { - type Lower = LowerMethod< - ::Lower, - >; - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_variant( - ty, - types, - &[ - ("get", None), - ("head", None), - ("post", None), - ("put", None), - ("delete", None), - ("connect", None), - ("options", None), - ("trace", None), - ("patch", None), - ( - "other", - Some( - ::typecheck, - ), - ), - ], - ) - } - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( - &[ - None, - None, - None, - None, - None, - None, - None, - None, - None, - Some(::ABI), - ], - ); - } - unsafe impl wasmtime::component::__internal::ComponentVariant for Method { - const CASES: &'static [Option< - wasmtime::component::__internal::CanonicalAbiInfo, - >] = &[ - None, - None, - None, - None, - None, - None, - None, - None, - None, - Some(::ABI), - ]; - } - }; - impl core::fmt::Debug for Method { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Method::Get => f.debug_tuple("Method::Get").finish(), - Method::Head => f.debug_tuple("Method::Head").finish(), - Method::Post => f.debug_tuple("Method::Post").finish(), - Method::Put => f.debug_tuple("Method::Put").finish(), - Method::Delete => f.debug_tuple("Method::Delete").finish(), - Method::Connect => f.debug_tuple("Method::Connect").finish(), - Method::Options => f.debug_tuple("Method::Options").finish(), - Method::Trace => f.debug_tuple("Method::Trace").finish(), - Method::Patch => f.debug_tuple("Method::Patch").finish(), - Method::Other(e) => f.debug_tuple("Method::Other").field(e).finish(), - } - } - } - pub type IncomingStream = InputStream; - pub type IncomingResponse = u32; - pub type IncomingRequest = u32; - pub type FutureIncomingResponse = u32; - pub type Fields = u32; - pub type Trailers = Fields; - pub type Headers = Fields; - #[component(variant)] - pub enum Error { - #[component(name = "invalid-url")] - InvalidUrl(String), - #[component(name = "timeout-error")] - TimeoutError(String), - #[component(name = "protocol-error")] - ProtocolError(String), - #[component(name = "status-error")] - StatusError(u16), - #[component(name = "unexpected-error")] - UnexpectedError(String), - } - #[automatically_derived] - impl ::core::clone::Clone for Error { - #[inline] - fn clone(&self) -> Error { - match self { - Error::InvalidUrl(__self_0) => { - Error::InvalidUrl(::core::clone::Clone::clone(__self_0)) - } - Error::TimeoutError(__self_0) => { - Error::TimeoutError(::core::clone::Clone::clone(__self_0)) - } - Error::ProtocolError(__self_0) => { - Error::ProtocolError(::core::clone::Clone::clone(__self_0)) - } - Error::StatusError(__self_0) => { - Error::StatusError(::core::clone::Clone::clone(__self_0)) - } - Error::UnexpectedError(__self_0) => { - Error::UnexpectedError(::core::clone::Clone::clone(__self_0)) - } - } - } - } - unsafe impl wasmtime::component::Lower for Error { - #[inline] - fn lower( - &self, - store: &mut wasmtime::StoreContextMut, - options: &wasmtime::component::__internal::Options, - dst: &mut std::mem::MaybeUninit, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - match self { - Self::InvalidUrl(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(0u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).InvalidUrl) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - Self::TimeoutError(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(1u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).TimeoutError) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - Self::ProtocolError(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(2u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).ProtocolError) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - Self::StatusError(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(3u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).StatusError) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - Self::UnexpectedError(value) => { - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).tag) - } - } - } - .write(wasmtime::ValRaw::u32(4u32)); - unsafe { - wasmtime::component::__internal::lower_payload( - { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = dst; - m.map(|p| &raw mut (*p).payload) - } - } - }, - |payload| { - #[allow(unused_unsafe)] - { - unsafe { - use ::wasmtime::component::__internal::MaybeUninitExt; - let m: &mut std::mem::MaybeUninit<_> = payload; - m.map(|p| &raw mut (*p).UnexpectedError) - } - } - }, - |dst| value.lower(store, options, dst), - ) - } - } - } - } - #[inline] - fn store( - &self, - memory: &mut wasmtime::component::__internal::MemoryMut<'_, T>, - mut offset: usize, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - if true { - if !(offset - % (::ALIGN32 as usize) - == 0) - { - ::core::panicking::panic( - "assertion failed: offset % (::ALIGN32 as usize) == 0", - ) - } - } - match self { - Self::InvalidUrl(value) => { - *memory.get::<1usize>(offset) = 0u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - Self::TimeoutError(value) => { - *memory.get::<1usize>(offset) = 1u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - Self::ProtocolError(value) => { - *memory.get::<1usize>(offset) = 2u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - Self::StatusError(value) => { - *memory.get::<1usize>(offset) = 3u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - Self::UnexpectedError(value) => { - *memory.get::<1usize>(offset) = 4u8.to_le_bytes(); - value - .store( - memory, - offset - + ::PAYLOAD_OFFSET32, - ) - } - } - } - } - unsafe impl wasmtime::component::Lift for Error { - #[inline] - fn lift( - store: &wasmtime::component::__internal::StoreOpaque, - options: &wasmtime::component::__internal::Options, - src: &Self::Lower, - ) -> wasmtime::component::__internal::anyhow::Result { - Ok( - match src.tag.get_u32() { - 0u32 => { - Self::InvalidUrl( - ::lift( - store, - options, - unsafe { &src.payload.InvalidUrl }, - )?, - ) - } - 1u32 => { - Self::TimeoutError( - ::lift( - store, - options, - unsafe { &src.payload.TimeoutError }, - )?, - ) - } - 2u32 => { - Self::ProtocolError( - ::lift( - store, - options, - unsafe { &src.payload.ProtocolError }, - )?, - ) - } - 3u32 => { - Self::StatusError( - ::lift( - store, - options, - unsafe { &src.payload.StatusError }, - )?, - ) - } - 4u32 => { - Self::UnexpectedError( - ::lift( - store, - options, - unsafe { &src.payload.UnexpectedError }, - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - #[inline] - fn load( - memory: &wasmtime::component::__internal::Memory, - bytes: &[u8], - ) -> wasmtime::component::__internal::anyhow::Result { - let align = ::ALIGN32; - if true { - if !((bytes.as_ptr() as usize) % (align as usize) == 0) { - ::core::panicking::panic( - "assertion failed: (bytes.as_ptr() as usize) % (align as usize) == 0", - ) - } - } - let discrim = bytes[0]; - let payload_offset = ::PAYLOAD_OFFSET32; - let payload = &bytes[payload_offset..]; - Ok( - match discrim { - 0u8 => { - Self::InvalidUrl( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - 1u8 => { - Self::TimeoutError( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - 2u8 => { - Self::ProtocolError( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - 3u8 => { - Self::StatusError( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - 4u8 => { - Self::UnexpectedError( - ::load( - memory, - &payload[..::SIZE32], - )?, - ) - } - discrim => { - return ::anyhow::__private::Err( - ::anyhow::Error::msg({ - let res = ::alloc::fmt::format( - format_args!("unexpected discriminant: {0}", discrim), - ); - res - }), - ); - } - }, - ) - } - } - const _: () = { - #[doc(hidden)] - #[repr(C)] - pub struct LowerError { - tag: wasmtime::ValRaw, - payload: LowerPayloadError, - } - #[automatically_derived] - impl< - T0: ::core::clone::Clone + Copy, - T1: ::core::clone::Clone + Copy, - T2: ::core::clone::Clone + Copy, - T3: ::core::clone::Clone + Copy, - T4: ::core::clone::Clone + Copy, - > ::core::clone::Clone for LowerError { - #[inline] - fn clone(&self) -> LowerError { - LowerError { - tag: ::core::clone::Clone::clone(&self.tag), - payload: ::core::clone::Clone::clone(&self.payload), - } - } - } - #[automatically_derived] - impl< - T0: ::core::marker::Copy + Copy, - T1: ::core::marker::Copy + Copy, - T2: ::core::marker::Copy + Copy, - T3: ::core::marker::Copy + Copy, - T4: ::core::marker::Copy + Copy, - > ::core::marker::Copy for LowerError {} - #[doc(hidden)] - #[allow(non_snake_case)] - #[repr(C)] - union LowerPayloadError { - InvalidUrl: T0, - TimeoutError: T1, - ProtocolError: T2, - StatusError: T3, - UnexpectedError: T4, - } - #[automatically_derived] - #[allow(non_snake_case)] - impl< - T0: ::core::marker::Copy + ::core::clone::Clone + Copy, - T1: ::core::marker::Copy + ::core::clone::Clone + Copy, - T2: ::core::marker::Copy + ::core::clone::Clone + Copy, - T3: ::core::marker::Copy + ::core::clone::Clone + Copy, - T4: ::core::marker::Copy + ::core::clone::Clone + Copy, - > ::core::clone::Clone for LowerPayloadError { - #[inline] - fn clone(&self) -> LowerPayloadError { - let _: ::core::clone::AssertParamIsCopy; - *self - } - } - #[automatically_derived] - #[allow(non_snake_case)] - impl< - T0: ::core::marker::Copy + Copy, - T1: ::core::marker::Copy + Copy, - T2: ::core::marker::Copy + Copy, - T3: ::core::marker::Copy + Copy, - T4: ::core::marker::Copy + Copy, - > ::core::marker::Copy for LowerPayloadError {} - unsafe impl wasmtime::component::ComponentType for Error { - type Lower = LowerError< - ::Lower, - ::Lower, - ::Lower, - ::Lower, - ::Lower, - >; - #[inline] - fn typecheck( - ty: &wasmtime::component::__internal::InterfaceType, - types: &wasmtime::component::__internal::ComponentTypes, - ) -> wasmtime::component::__internal::anyhow::Result<()> { - wasmtime::component::__internal::typecheck_variant( - ty, - types, - &[ - ( - "invalid-url", - Some( - ::typecheck, - ), - ), - ( - "timeout-error", - Some( - ::typecheck, - ), - ), - ( - "protocol-error", - Some( - ::typecheck, - ), - ), - ( - "status-error", - Some(::typecheck), - ), - ( - "unexpected-error", - Some( - ::typecheck, - ), - ), - ], - ) - } - const ABI: wasmtime::component::__internal::CanonicalAbiInfo = wasmtime::component::__internal::CanonicalAbiInfo::variant_static( - &[ - Some(::ABI), - Some(::ABI), - Some(::ABI), - Some(::ABI), - Some(::ABI), - ], - ); - } - unsafe impl wasmtime::component::__internal::ComponentVariant for Error { - const CASES: &'static [Option< - wasmtime::component::__internal::CanonicalAbiInfo, - >] = &[ - Some(::ABI), - Some(::ABI), - Some(::ABI), - Some(::ABI), - Some(::ABI), - ]; - } - }; - impl core::fmt::Debug for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Error::InvalidUrl(e) => { - f.debug_tuple("Error::InvalidUrl").field(e).finish() - } - Error::TimeoutError(e) => { - f.debug_tuple("Error::TimeoutError").field(e).finish() - } - Error::ProtocolError(e) => { - f.debug_tuple("Error::ProtocolError").field(e).finish() - } - Error::StatusError(e) => { - f.debug_tuple("Error::StatusError").field(e).finish() - } - Error::UnexpectedError(e) => { - f.debug_tuple("Error::UnexpectedError").field(e).finish() - } - } - } - } - pub trait Host: Sized { - fn drop_fields(&mut self, fields: Fields) -> wasmtime::Result<()>; - fn new_fields( - &mut self, - entries: Vec<(String, String)>, - ) -> wasmtime::Result; - fn fields_get( - &mut self, - fields: Fields, - name: String, - ) -> wasmtime::Result>; - fn fields_set( - &mut self, - fields: Fields, - name: String, - value: Vec, - ) -> wasmtime::Result<()>; - fn fields_delete( - &mut self, - fields: Fields, - name: String, - ) -> wasmtime::Result<()>; - fn fields_append( - &mut self, - fields: Fields, - name: String, - value: String, - ) -> wasmtime::Result<()>; - fn fields_entries( - &mut self, - fields: Fields, - ) -> wasmtime::Result>; - fn fields_clone(&mut self, fields: Fields) -> wasmtime::Result; - fn finish_incoming_stream( - &mut self, - s: IncomingStream, - ) -> wasmtime::Result>; - fn finish_outgoing_stream( - &mut self, - s: OutgoingStream, - trailers: Option, - ) -> wasmtime::Result<()>; - fn drop_incoming_request( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result<()>; - fn drop_outgoing_request( - &mut self, - request: OutgoingRequest, - ) -> wasmtime::Result<()>; - fn incoming_request_method( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result; - fn incoming_request_path( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result; - fn incoming_request_scheme( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result>; - fn incoming_request_authority( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result; - fn incoming_request_headers( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result; - fn incoming_request_consume( - &mut self, - request: IncomingRequest, - ) -> wasmtime::Result>; - fn new_outgoing_request( - &mut self, - method: Method, - path: String, - scheme: Option, - authority: String, - headers: Headers, - ) -> wasmtime::Result; - fn outgoing_request_write( - &mut self, - request: OutgoingRequest, - ) -> wasmtime::Result>; - fn drop_response_outparam( - &mut self, - response: ResponseOutparam, - ) -> wasmtime::Result<()>; - fn set_response_outparam( - &mut self, - response: Result, - ) -> wasmtime::Result>; - fn drop_incoming_response( - &mut self, - response: IncomingResponse, - ) -> wasmtime::Result<()>; - fn drop_outgoing_response( - &mut self, - response: OutgoingResponse, - ) -> wasmtime::Result<()>; - fn incoming_response_status( - &mut self, - response: IncomingResponse, - ) -> wasmtime::Result; - fn incoming_response_headers( - &mut self, - response: IncomingResponse, - ) -> wasmtime::Result; - fn incoming_response_consume( - &mut self, - response: IncomingResponse, - ) -> wasmtime::Result>; - fn new_outgoing_response( - &mut self, - status_code: StatusCode, - headers: Headers, - ) -> wasmtime::Result; - fn outgoing_response_write( - &mut self, - response: OutgoingResponse, - ) -> wasmtime::Result>; - fn drop_future_incoming_response( - &mut self, - f: FutureIncomingResponse, - ) -> wasmtime::Result<()>; - fn future_incoming_response_get( - &mut self, - f: FutureIncomingResponse, - ) -> wasmtime::Result>>; - fn listen_to_future_incoming_response( - &mut self, - f: FutureIncomingResponse, - ) -> wasmtime::Result; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("types")?; - inst.func_wrap( - "drop-fields", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { - let host = get(caller.data_mut()); - let r = host.drop_fields(arg0); - r - }, - )?; - inst.func_wrap( - "new-fields", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (Vec<(String, String)>,)| - { - let host = get(caller.data_mut()); - let r = host.new_fields(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "fields-get", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (Fields, String)| - { - let host = get(caller.data_mut()); - let r = host.fields_get(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "fields-set", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1, arg2): (Fields, String, Vec)| - { - let host = get(caller.data_mut()); - let r = host.fields_set(arg0, arg1, arg2); - r - }, - )?; - inst.func_wrap( - "fields-delete", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (Fields, String)| - { - let host = get(caller.data_mut()); - let r = host.fields_delete(arg0, arg1); - r - }, - )?; - inst.func_wrap( - "fields-append", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1, arg2): (Fields, String, String)| - { - let host = get(caller.data_mut()); - let r = host.fields_append(arg0, arg1, arg2); - r - }, - )?; - inst.func_wrap( - "fields-entries", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { - let host = get(caller.data_mut()); - let r = host.fields_entries(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "fields-clone", - move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Fields,)| { - let host = get(caller.data_mut()); - let r = host.fields_clone(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "finish-incoming-stream", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingStream,)| - { - let host = get(caller.data_mut()); - let r = host.finish_incoming_stream(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "finish-outgoing-stream", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (OutgoingStream, Option)| - { - let host = get(caller.data_mut()); - let r = host.finish_outgoing_stream(arg0, arg1); - r - }, - )?; - inst.func_wrap( - "drop-incoming-request", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.drop_incoming_request(arg0); - r - }, - )?; - inst.func_wrap( - "drop-outgoing-request", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutgoingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.drop_outgoing_request(arg0); - r - }, - )?; - inst.func_wrap( - "incoming-request-method", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_method(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-request-path", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_path(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-request-scheme", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_scheme(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-request-authority", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_authority(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-request-headers", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_headers(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-request-consume", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_request_consume(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "new-outgoing-request", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - ( - arg0, - arg1, - arg2, - arg3, - arg4, - ): (Method, String, Option, String, Headers)| - { - let host = get(caller.data_mut()); - let r = host.new_outgoing_request(arg0, arg1, arg2, arg3, arg4); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "outgoing-request-write", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutgoingRequest,)| - { - let host = get(caller.data_mut()); - let r = host.outgoing_request_write(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "drop-response-outparam", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (ResponseOutparam,)| - { - let host = get(caller.data_mut()); - let r = host.drop_response_outparam(arg0); - r - }, - )?; - inst.func_wrap( - "set-response-outparam", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (Result,)| - { - let host = get(caller.data_mut()); - let r = host.set_response_outparam(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "drop-incoming-response", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.drop_incoming_response(arg0); - r - }, - )?; - inst.func_wrap( - "drop-outgoing-response", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutgoingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.drop_outgoing_response(arg0); - r - }, - )?; - inst.func_wrap( - "incoming-response-status", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_response_status(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-response-headers", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_response_headers(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "incoming-response-consume", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (IncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.incoming_response_consume(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "new-outgoing-response", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (StatusCode, Headers)| - { - let host = get(caller.data_mut()); - let r = host.new_outgoing_response(arg0, arg1); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "outgoing-response-write", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (OutgoingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.outgoing_response_write(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "drop-future-incoming-response", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (FutureIncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.drop_future_incoming_response(arg0); - r - }, - )?; - inst.func_wrap( - "future-incoming-response-get", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (FutureIncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.future_incoming_response_get(arg0); - Ok((r?,)) - }, - )?; - inst.func_wrap( - "listen-to-future-incoming-response", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0,): (FutureIncomingResponse,)| - { - let host = get(caller.data_mut()); - let r = host.listen_to_future_incoming_response(arg0); - Ok((r?,)) - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod default_outgoing_http { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - pub type OutgoingRequest = super::types::OutgoingRequest; - pub type RequestOptions = super::types::RequestOptions; - pub type FutureIncomingResponse = super::types::FutureIncomingResponse; - pub trait Host: Sized { - fn handle( - &mut self, - request: OutgoingRequest, - options: Option, - ) -> wasmtime::Result; - } - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: Host, - { - let mut inst = linker.instance("default-outgoing-HTTP")?; - inst.func_wrap( - "handle", - move | - mut caller: wasmtime::StoreContextMut<'_, T>, - (arg0, arg1): (OutgoingRequest, Option)| - { - let host = get(caller.data_mut()); - let r = host.handle(arg0, arg1); - Ok((r?,)) - }, - )?; - Ok(()) - } -} -#[allow(clippy::all)] -pub mod http { - #[allow(unused_imports)] - use wasmtime::component::__internal::anyhow; - pub type IncomingRequest = super::types::IncomingRequest; - pub type ResponseOutparam = super::types::ResponseOutparam; - pub struct Http { - handle: wasmtime::component::Func, - } - impl Http { - pub fn new( - __exports: &mut wasmtime::component::ExportInstance<'_, '_>, - ) -> wasmtime::Result { - let handle = *__exports - .typed_func::<(IncomingRequest, ResponseOutparam), ()>("handle")? - .func(); - Ok(Http { handle }) - } - pub fn call_handle( - &self, - mut store: S, - arg0: IncomingRequest, - arg1: ResponseOutparam, - ) -> wasmtime::Result<()> { - let callee = unsafe { - wasmtime::component::TypedFunc::< - (IncomingRequest, ResponseOutparam), - (), - >::new_unchecked(self.handle) - }; - let () = callee.call(store.as_context_mut(), (arg0, arg1))?; - callee.post_return(store.as_context_mut())?; - Ok(()) - } - } -} -pub struct Proxy { - http: http::Http, -} -const _: () = { - use wasmtime::component::__internal::anyhow; - impl Proxy { - pub fn add_to_linker( - linker: &mut wasmtime::component::Linker, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, - ) -> wasmtime::Result<()> - where - U: random::Host + console::Host + poll::Host + streams::Host + types::Host - + default_outgoing_http::Host, - { - random::add_to_linker(linker, get)?; - console::add_to_linker(linker, get)?; - poll::add_to_linker(linker, get)?; - streams::add_to_linker(linker, get)?; - types::add_to_linker(linker, get)?; - default_outgoing_http::add_to_linker(linker, get)?; - Ok(()) - } - /// Instantiates the provided `module` using the specified - /// parameters, wrapping up the result in a structure that - /// translates between wasm and the host. - pub fn instantiate( - mut store: impl wasmtime::AsContextMut, - component: &wasmtime::component::Component, - linker: &wasmtime::component::Linker, - ) -> wasmtime::Result<(Self, wasmtime::component::Instance)> { - let instance = linker.instantiate(&mut store, component)?; - Ok((Self::new(store, &instance)?, instance)) - } - /// Instantiates a pre-instantiated module using the specified - /// parameters, wrapping up the result in a structure that - /// translates between wasm and the host. - pub fn instantiate_pre( - mut store: impl wasmtime::AsContextMut, - instance_pre: &wasmtime::component::InstancePre, - ) -> wasmtime::Result<(Self, wasmtime::component::Instance)> { - let instance = instance_pre.instantiate(&mut store)?; - Ok((Self::new(store, &instance)?, instance)) - } - /// Low-level creation wrapper for wrapping up the exports - /// of the `instance` provided in this structure of wasm - /// exports. - /// - /// This function will extract exports from the `instance` - /// defined within `store` and wrap them all up in the - /// returned structure which can be used to interact with - /// the wasm module. - pub fn new( - mut store: impl wasmtime::AsContextMut, - instance: &wasmtime::component::Instance, - ) -> wasmtime::Result { - let mut store = store.as_context_mut(); - let mut exports = instance.exports(&mut store); - let mut __exports = exports.root(); - let http = http::Http::new( - &mut __exports - .instance("HTTP") - .ok_or_else(|| ::anyhow::__private::must_use({ - let error = ::anyhow::__private::format_err( - format_args!("exported instance `HTTP` not present"), - ); - error - }))?, - )?; - Ok(Proxy { http }) - } - pub fn http(&self) -> &http::Http { - &self.http - } - } -}; -const _: &str = "/// WASI Random is a random data API.\n///\n/// It is intended to be portable at least between Unix-family platforms and\n/// Windows.\ndefault interface random {\n /// Return `len` cryptographically-secure pseudo-random bytes.\n ///\n /// This function must produce data from an adequately seeded\n /// cryptographically-secure pseudo-random number generator (CSPRNG), so it\n /// must not block, from the perspective of the calling program, and the\n /// returned data is always unpredictable.\n ///\n /// This function must always return fresh pseudo-random data. Deterministic\n /// environments must omit this function, rather than implementing it with\n /// deterministic data.\n get-random-bytes: func(len: u64) -> list\n\n /// Return a cryptographically-secure pseudo-random `u64` value.\n ///\n /// This function returns the same type of pseudo-random data as\n /// `get-random-bytes`, represented as a `u64`.\n get-random-u64: func() -> u64\n\n /// Return a 128-bit value that may contain a pseudo-random value.\n ///\n /// The returned value is not required to be computed from a CSPRNG, and may\n /// even be entirely deterministic. Host implementations are encouraged to\n /// provide pseudo-random values to any program exposed to\n /// attacker-controlled content, to enable DoS protection built into many\n /// languages\' hash-map implementations.\n ///\n /// This function is intended to only be called once, by a source language\n /// to initialize Denial Of Service (DoS) protection in its hash-map\n /// implementation.\n ///\n /// # Expected future evolution\n ///\n /// This will likely be changed to a value import, to prevent it from being\n /// called multiple times and potentially used for purposes other than DoS\n /// protection.\n insecure-random: func() -> tuple\n}\n"; -const _: &str = "/// WASI Logging is a logging API intended to let users emit log messages with\n/// simple priority levels and context values.\ndefault interface handler {\n /// A log level, describing a kind of message.\n enum level {\n /// Describes messages about the values of variables and the flow of\n /// control within a program.\n trace,\n\n /// Describes messages likely to be of interest to someone debugging a\n /// program.\n debug,\n\n /// Describes messages likely to be of interest to someone monitoring a\n /// program.\n info,\n\n /// Describes messages indicating hazardous situations.\n warn,\n\n /// Describes messages indicating serious errors.\n error,\n }\n\n /// Emit a log message.\n ///\n /// A log message has a `level` describing what kind of message is being\n /// sent, a context, which is an uninterpreted string meant to help\n /// consumers group similar messages, and a string containing the message\n /// text.\n log: func(level: level, context: string, message: string)\n}\n"; -const _: &str = "/// A poll API intended to let users wait for I/O events on multiple handles\n/// at once.\ndefault interface poll {\n /// A \"pollable\" handle.\n ///\n /// This is conceptually represents a `stream<_, _>`, or in other words,\n /// a stream that one can wait on, repeatedly, but which does not itself\n /// produce any data. It\'s temporary scaffolding until component-model\'s\n /// async features are ready.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// `pollable` lifetimes are not automatically managed. Users must ensure\n /// that they do not outlive the resource they reference.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type pollable = u32\n\n /// Dispose of the specified `pollable`, after which it may no longer\n /// be used.\n drop-pollable: func(this: pollable)\n\n /// Poll for completion on a set of pollables.\n ///\n /// The \"oneoff\" in the name refers to the fact that this function must do a\n /// linear scan through the entire list of subscriptions, which may be\n /// inefficient if the number is large and the same subscriptions are used\n /// many times. In the future, this is expected to be obsoleted by the\n /// component model async proposal, which will include a scalable waiting\n /// facility.\n ///\n /// Note that the return type would ideally be `list`, but that would\n /// be more difficult to polyfill given the current state of `wit-bindgen`.\n /// See \n /// for details. For now, we use zero to mean \"not ready\" and non-zero to\n /// mean \"ready\".\n poll-oneoff: func(in: list) -> list\n}\n"; -const _: &str = "/// WASI I/O is an I/O abstraction API which is currently focused on providing\n/// stream types.\n///\n/// In the future, the component model is expected to add built-in stream types;\n/// when it does, they are expected to subsume this API.\ndefault interface streams {\n use poll.poll.{pollable}\n\n /// An error type returned from a stream operation. Currently this\n /// doesn\'t provide any additional information.\n record stream-error {}\n\n /// An input bytestream. In the future, this will be replaced by handle\n /// types.\n ///\n /// This conceptually represents a `stream`. It\'s temporary\n /// scaffolding until component-model\'s async features are ready.\n ///\n /// `input-stream`s are *non-blocking* to the extent practical on underlying\n /// platforms. I/O operations always return promptly; if fewer bytes are\n /// promptly available than requested, they return the number of bytes promptly\n /// available, which could even be zero. To wait for data to be available,\n /// use the `subscribe-to-input-stream` function to obtain a `pollable` which\n /// can be polled for using `wasi_poll`.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type input-stream = u32\n\n /// Read bytes from a stream.\n ///\n /// This function returns a list of bytes containing the data that was\n /// read, along with a bool indicating whether the end of the stream\n /// was reached. The returned list will contain up to `len` bytes; it\n /// may return fewer than requested, but not more.\n ///\n /// Once a stream has reached the end, subsequent calls to read or\n /// `skip` will always report end-of-stream rather than producing more\n /// data.\n ///\n /// If `len` is 0, it represents a request to read 0 bytes, which should\n /// always succeed, assuming the stream hasn\'t reached its end yet, and\n /// return an empty list.\n ///\n /// The len here is a `u64`, but some callees may not be able to allocate\n /// a buffer as large as that would imply.\n /// FIXME: describe what happens if allocation fails.\n read: func(\n this: input-stream,\n /// The maximum number of bytes to read\n len: u64\n ) -> result, bool>, stream-error>\n\n /// Skip bytes from a stream.\n ///\n /// This is similar to the `read` function, but avoids copying the\n /// bytes into the instance.\n ///\n /// Once a stream has reached the end, subsequent calls to read or\n /// `skip` will always report end-of-stream rather than producing more\n /// data.\n ///\n /// This function returns the number of bytes skipped, along with a bool\n /// indicating whether the end of the stream was reached. The returned\n /// value will be at most `len`; it may be less.\n skip: func(\n this: input-stream,\n /// The maximum number of bytes to skip.\n len: u64,\n ) -> result, stream-error>\n\n /// Create a `pollable` which will resolve once either the specified stream\n /// has bytes available to read or the other end of the stream has been\n /// closed.\n subscribe-to-input-stream: func(this: input-stream) -> pollable\n\n /// Dispose of the specified `input-stream`, after which it may no longer\n /// be used.\n drop-input-stream: func(this: input-stream)\n\n /// An output bytestream. In the future, this will be replaced by handle\n /// types.\n ///\n /// This conceptually represents a `stream`. It\'s temporary\n /// scaffolding until component-model\'s async features are ready.\n ///\n /// `output-stream`s are *non-blocking* to the extent practical on\n /// underlying platforms. Except where specified otherwise, I/O operations also\n /// always return promptly, after the number of bytes that can be written\n /// promptly, which could even be zero. To wait for the stream to be ready to\n /// accept data, the `subscribe-to-output-stream` function to obtain a\n /// `pollable` which can be polled for using `wasi_poll`.\n ///\n /// And at present, it is a `u32` instead of being an actual handle, until\n /// the wit-bindgen implementation of handles and resources is ready.\n ///\n /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).\n type output-stream = u32\n\n /// Write bytes to a stream.\n ///\n /// This function returns a `u64` indicating the number of bytes from\n /// `buf` that were written; it may be less than the full list.\n write: func(\n this: output-stream,\n /// Data to write\n buf: list\n ) -> result\n\n /// Write multiple zero bytes to a stream.\n ///\n /// This function returns a `u64` indicating the number of zero bytes\n /// that were written; it may be less than `len`.\n write-zeroes: func(\n this: output-stream,\n /// The number of zero bytes to write\n len: u64\n ) -> result\n\n /// Read from one stream and write to another.\n ///\n /// This function returns the number of bytes transferred; it may be less\n /// than `len`.\n ///\n /// Unlike other I/O functions, this function blocks until all the data\n /// read from the input stream has been written to the output stream.\n splice: func(\n this: output-stream,\n /// The stream to read from\n src: input-stream,\n /// The number of bytes to splice\n len: u64,\n ) -> result, stream-error>\n\n /// Forward the entire contents of an input stream to an output stream.\n ///\n /// This function repeatedly reads from the input stream and writes\n /// the data to the output stream, until the end of the input stream\n /// is reached, or an error is encountered.\n ///\n /// Unlike other I/O functions, this function blocks until the end\n /// of the input stream is seen and all the data has been written to\n /// the output stream.\n ///\n /// This function returns the number of bytes transferred.\n forward: func(\n this: output-stream,\n /// The stream to read from\n src: input-stream\n ) -> result\n\n /// Create a `pollable` which will resolve once either the specified stream\n /// is ready to accept bytes or the other end of the stream has been closed.\n subscribe-to-output-stream: func(this: output-stream) -> pollable\n\n /// Dispose of the specified `output-stream`, after which it may no longer\n /// be used.\n drop-output-stream: func(this: output-stream)\n}\n"; -const _: &str = "// The `wasi:http/outgoing-handler` interface is meant to be imported by\n// components and implemented by the host.\n//\n// NOTE: in Preview3, this interface will be merged with\n// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface\n// that takes a `request` parameter and returns a `response` result.\n//\ndefault interface outgoing-handler {\n use pkg.types.{outgoing-request, request-options, future-incoming-response}\n\n // The parameter and result types of the `handle` function allow the caller\n // to concurrently stream the bodies of the outgoing request and the incoming\n // response.\n handle: func(\n request: outgoing-request,\n options: option\n ) -> future-incoming-response\n}\n"; -const _: &str = "// The `wasi:http/incoming-handler` interface is meant to be exported by\n// components and called by the host in response to a new incoming HTTP\n// response.\n//\n// NOTE: in Preview3, this interface will be merged with\n// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface\n// that takes a `request` parameter and returns a `response` result.\n//\ndefault interface incoming-handler {\n use pkg.types.{incoming-request, response-outparam}\n\n // The `handle` function takes an outparam instead of returning its response\n // so that the component may stream its response while streaming any other\n // request or response bodies. The callee MUST write a response to the\n // `response-out` and then finish the response before returning. The `handle`\n // function is allowed to continue execution after finishing the response\'s\n // output stream. While this post-response execution is taken off the\n // critical path, since there is no return value, there is no way to report\n // its success or failure.\n handle: func(\n request: incoming-request,\n response-out: response-outparam\n )\n}\n"; -const _: &str = "// The `wasi:http/proxy` world captures a widely-implementable intersection of\n// hosts that includes HTTP forward and reverse proxies. Components targeting\n// this world may concurrently stream in and out any number of incoming and\n// outgoing HTTP requests.\ndefault world proxy {\n // HTTP proxies have access to time and randomness.\n import random: random.random\n // TODO: add `import wall-clock: clocks.wall-clock`\n // TODO: add `import monotonic-clock: clocks.monotonic-clock`\n\n // This is the default logging handler to use when user code simply wants to\n // log to a developer-facing console (e.g., via `console.log()`).\n import console: logging.handler\n\n // TODO: Once the underlying Wit template machinery is implemented, add:\n //\n // import loggers: interface {\n // *: logging.handler\n // }\n //\n // which will allow a component to import any number of non-default logging\n // backends that different categories of log messages can be sent to.\n\n // TODO: add `import metrics: metrics.counters`\n\n // This is the default handler to use when user code simply wants to make an\n // HTTP request (e.g., via `fetch()`) but doesn\'t otherwise specify a\n // particular handler.\n import default-outgoing-HTTP: pkg.outgoing-handler\n\n // TODO: Once the underlying Wit template machinery is implemented, add:\n //\n // import upstreams: interface {\n // *: pkg.outgoing-handler\n // }\n //\n // which will allow a component to import any number of non-default backends\n // that HTTP requests can be dispatched to.\n\n // The host delivers incoming HTTP requests to a component by calling the\n // `handle` function of this exported interface. A host may arbitrarily reuse\n // or not reuse component instance when delivering incoming HTTP requests and\n // thus a component must be able to handle 0..N calls to `handle`.\n export HTTP: pkg.incoming-handler\n}\n"; -const _: &str = "// The `wasi:http/types` interface is meant to be imported by components to\n// define the HTTP resource types and operations used by the component\'s\n// imported and exported interfaces.\ndefault interface types {\n use io.streams.{input-stream, output-stream}\n use poll.poll.{pollable}\n \n // This type corresponds to HTTP standard Methods.\n variant method {\n get,\n head,\n post,\n put,\n delete,\n connect,\n options,\n trace,\n patch,\n other(string)\n }\n\n // This type corresponds to HTTP standard Related Schemes.\n variant scheme {\n HTTP,\n HTTPS,\n other(string)\n }\n\n // TODO: perhaps better align with HTTP semantics?\n // This type enumerates the different kinds of errors that may occur when\n // initially returning a response.\n variant error {\n invalid-url(string),\n timeout-error(string),\n protocol-error(string),\n status-error(u16),\n unexpected-error(string)\n }\n\n // This following block defines the `fields` resource which corresponds to\n // HTTP standard Fields. Soon, when resource types are added, the `type\n // fields = u32` type alias can be replaced by a proper `resource fields`\n // definition containing all the functions using the method syntactic sugar.\n type fields = u32\n drop-fields: func(fields: fields)\n new-fields: func(entries: list>) -> fields\n fields-get: func(fields: fields, name: string) -> list\n fields-set: func(fields: fields, name: string, value: list)\n fields-delete: func(fields: fields, name: string)\n fields-append: func(fields: fields, name: string, value: string)\n fields-entries: func(fields: fields) -> list>\n fields-clone: func(fields: fields) -> fields\n\n type headers = fields\n type trailers = fields\n\n // The following block defines stream types which corresponds to the HTTP\n // standard Contents and Trailers. With Preview3, all of these fields can be\n // replaced by a stream>. In the interim, we need to\n // build on separate resource types defined by `wasi:io/streams`. The\n // `finish-` functions emulate the stream\'s result value and MUST be called\n // exactly once after the final read/write from/to the stream before dropping\n // the stream.\n type incoming-stream = input-stream\n type outgoing-stream = output-stream\n finish-incoming-stream: func(s: incoming-stream) -> option\n finish-outgoing-stream: func(s: outgoing-stream, trailers: option)\n\n // The following block defines the `incoming-request` and `outgoing-request`\n // resource types that correspond to HTTP standard Requests. Soon, when\n // resource types are added, the `u32` type aliases can be replaced by\n // proper `resource` type definitions containing all the functions as\n // methods. Later, Preview2 will allow both types to be merged together into\n // a single `request` type (that uses the single `stream` type mentioned\n // above). The `consume` and `write` methods may only be called once (and\n // return failure thereafter).\n type incoming-request = u32\n type outgoing-request = u32\n drop-incoming-request: func(request: incoming-request)\n drop-outgoing-request: func(request: outgoing-request)\n incoming-request-method: func(request: incoming-request) -> method\n incoming-request-path: func(request: incoming-request) -> string\n incoming-request-scheme: func(request: incoming-request) -> option\n incoming-request-authority: func(request: incoming-request) -> string\n incoming-request-headers: func(request: incoming-request) -> headers\n incoming-request-consume: func(request: incoming-request) -> result\n new-outgoing-request: func(\n method: method,\n path: string,\n scheme: option,\n authority: string,\n headers: headers\n ) -> outgoing-request\n outgoing-request-write: func(request: outgoing-request) -> result\n\n // Additional optional parameters that can be set when making a request.\n record request-options {\n // The following timeouts are specific to the HTTP protocol and work\n // independently of the overall timeouts passed to `io.poll.poll-oneoff`.\n\n // The timeout for the initial connect.\n connect-timeout-ms: option,\n\n // The timeout for receiving the first byte of the response body.\n first-byte-timeout-ms: option,\n\n // The timeout for receiving the next chunk of bytes in the response body\n // stream.\n between-bytes-timeout-ms: option\n }\n\n // The following block defines a special resource type used by the\n // `wasi:http/incoming-handler` interface. When resource types are added, this\n // block can be replaced by a proper `resource response-outparam { ... }`\n // definition. Later, with Preview3, the need for an outparam goes away entirely\n // (the `wasi:http/handler` interface used for both incoming and outgoing can\n // simply return a `stream`).\n type response-outparam = u32\n drop-response-outparam: func(response: response-outparam)\n set-response-outparam: func(response: result) -> result\n\n // This type corresponds to the HTTP standard Status Code.\n type status-code = u16\n\n // The following block defines the `incoming-response` and `outgoing-response`\n // resource types that correspond to HTTP standard Responses. Soon, when\n // resource types are added, the `u32` type aliases can be replaced by proper\n // `resource` type definitions containing all the functions as methods. Later,\n // Preview2 will allow both types to be merged together into a single `response`\n // type (that uses the single `stream` type mentioned above). The `consume` and\n // `write` methods may only be called once (and return failure thereafter).\n type incoming-response = u32\n type outgoing-response = u32\n drop-incoming-response: func(response: incoming-response)\n drop-outgoing-response: func(response: outgoing-response)\n incoming-response-status: func(response: incoming-response) -> status-code\n incoming-response-headers: func(response: incoming-response) -> headers\n incoming-response-consume: func(response: incoming-response) -> result\n new-outgoing-response: func(\n status-code: status-code,\n headers: headers\n ) -> outgoing-response\n outgoing-response-write: func(response: outgoing-response) -> result\n\n // The following block defines a special resource type used by the\n // `wasi:http/outgoing-handler` interface to emulate\n // `future>` in advance of Preview3. Given a\n // `future-incoming-response`, the client can call the non-blocking `get`\n // method to get the result if it is available. If the result is not available,\n // the client can call `listen` to get a `pollable` that can be passed to\n // `io.poll.poll-oneoff`.\n type future-incoming-response = u32\n drop-future-incoming-response: func(f: future-incoming-response)\n future-incoming-response-get: func(f: future-incoming-response) -> option>\n listen-to-future-incoming-response: func(f: future-incoming-response) -> pollable\n}\n"; -struct WasiHttp {} -impl default_outgoing_http::Host for WasiHttp {} From 320d6201ed1d59b2998e711f0a6e24475aa4a0b5 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 23 Mar 2023 16:48:51 -0700 Subject: [PATCH 07/46] Update crates/wasi-http/Cargo.toml Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com> --- crates/wasi-http/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index cd0c315f1e55..87d3554911d2 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -15,7 +15,7 @@ tokio = { version = "1", features = ["full"] } tokio-native-tls = { version = "0.3.1" } futures = { version = "0.3.27" } - http-body = "0.1.0-rc.2" + http-body = "1.0.0-rc.2" http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } wasmtime = { workspace = true, features = ['component-model'] } From 356ffa6f3e099b098756816fd935b163a0581be1 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 23 Mar 2023 16:49:02 -0700 Subject: [PATCH 08/46] Update crates/wasi-http/Cargo.toml Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com> --- crates/wasi-http/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 87d3554911d2..5f16bd97be87 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -12,7 +12,7 @@ anyhow = { workspace = true } bytes = "1.1.0" hyper = { version = "1.0.0-rc.3", features = ["full"] } - tokio = { version = "1", features = ["full"] } + tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } tokio-native-tls = { version = "0.3.1" } futures = { version = "0.3.27" } http-body = "1.0.0-rc.2" From 7ed508ccc66d64e41b631631f3effadd446d02ef Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 21 Mar 2023 20:15:41 +0000 Subject: [PATCH 09/46] Extract streams from request/response. --- crates/wasi-http/src/component_impl.rs | 8 +++++++- crates/wasi-http/src/http_impl.rs | 6 ++++-- crates/wasi-http/src/streams_impl.rs | 12 ++++-------- crates/wasi-http/src/struct.rs | 12 ++++++++---- crates/wasi-http/src/types_impl.rs | 16 +++++++++++++--- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs index b3948c3f8f47..bc3869e5dbeb 100644 --- a/crates/wasi-http/src/component_impl.rs +++ b/crates/wasi-http/src/component_impl.rs @@ -244,11 +244,17 @@ pub fn add_component_to_linker( "types", "incoming-response-consume", move |mut caller: Caller<'_, T>, response: u32, ptr: i32| { + let ctx = get_cx(caller.data_mut()); + let stream = match ctx.incoming_response_consume(response) { + Ok(s) => s.unwrap_or(0), + Err(_) => 0, + }; + let memory = memory_get(&mut caller).unwrap(); // First == is_some // Second == stream_id - let result: [u32; 2] = [0, response]; + let result: [u32; 2] = [0, stream]; let raw = u32_array_to_u8(&result); memory diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 5fcc432abe26..aca74bcf2ac2 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -147,7 +147,7 @@ impl WasiHttp { let response_id = self.response_id_base; self.response_id_base = self.response_id_base + 1; let mut response = ActiveResponse::new(response_id); - let body = Full::::new(request.body.clone()); + let body = Full::::new(self.streams.get(&request.body).unwrap_or(&Bytes::new()).clone()); let t = timeout(first_bytes_timeout, sender.send_request(call.body(body)?)).await?; let mut res = t?; response.status = res.status().try_into()?; @@ -165,7 +165,9 @@ impl WasiHttp { buf.put(chunk.clone()); } } - response.body = buf.freeze(); + response.body = self.streams_id_base; + self.streams_id_base = self.streams_id_base + 1; + self.streams.insert(response.body, buf.freeze()); self.responses.insert(response_id, response); Ok(response_id) } diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs index b66742d151bd..3a7c4937ab26 100644 --- a/crates/wasi-http/src/streams_impl.rs +++ b/crates/wasi-http/src/streams_impl.rs @@ -31,8 +31,8 @@ impl crate::streams::Host for WasiHttp { } fn drop_input_stream(&mut self, stream: InputStream) -> wasmtime::Result<()> { - match self.responses.get_mut(&stream) { - Some(r) => r.body.truncate(0), + match self.streams.get_mut(&stream) { + Some(r) => r.truncate(0), None => {} } Ok(()) @@ -43,12 +43,8 @@ impl crate::streams::Host for WasiHttp { this: OutputStream, buf: Vec, ) -> wasmtime::Result> { - match self.requests.get_mut(&this) { - Some(r) => { - r.body = bytes::Bytes::from(buf.clone()); - } - None => bail!("not found"), - }; + // TODO: Make this a real write not a replace. + self.streams.insert(this, bytes::Bytes::from(buf.clone())); Ok(Ok(buf.len().try_into().unwrap())) } diff --git a/crates/wasi-http/src/struct.rs b/crates/wasi-http/src/struct.rs index 8d1d30a183f0..b1c02ad1a21e 100644 --- a/crates/wasi-http/src/struct.rs +++ b/crates/wasi-http/src/struct.rs @@ -7,9 +7,11 @@ pub struct WasiHttp { pub request_id_base: u32, pub response_id_base: u32, pub fields_id_base: u32, + pub streams_id_base: u32, pub requests: HashMap, pub responses: HashMap, pub fields: HashMap>>, + pub streams: HashMap, } #[derive(Clone)] @@ -22,7 +24,7 @@ pub struct ActiveRequest { pub query: String, pub authority: String, pub headers: HashMap>, - pub body: Bytes, + pub body: u32, } #[derive(Clone)] @@ -30,7 +32,7 @@ pub struct ActiveResponse { pub id: u32, pub active_response: bool, pub status: u16, - pub body: Bytes, + pub body: u32, pub response_headers: HashMap>, } @@ -45,7 +47,7 @@ impl ActiveRequest { query: "".to_string(), authority: "".to_string(), headers: HashMap::new(), - body: Bytes::new(), + body: 0, } } } @@ -56,7 +58,7 @@ impl ActiveResponse { id: id, active_response: false, status: 0, - body: bytes::Bytes::new(), + body: 0, response_headers: HashMap::new(), } } @@ -68,9 +70,11 @@ impl WasiHttp { request_id_base: 1, response_id_base: 1, fields_id_base: 1, + streams_id_base: 1, requests: HashMap::new(), responses: HashMap::new(), fields: HashMap::new(), + streams: HashMap::new(), } } } diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index 05aef0116906..947687c8f5e9 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -179,7 +179,14 @@ impl crate::types::Host for WasiHttp { &mut self, request: OutgoingRequest, ) -> wasmtime::Result> { - Ok(Ok(request)) + match self.requests.get_mut(&request) { + Some(req) => { + req.body = self.streams_id_base; + self.streams_id_base = self.streams_id_base + 1; + Ok(Ok(req.body)) + }, + None => bail!("unknown request!") + } } fn drop_response_outparam(&mut self, _response: ResponseOutparam) -> wasmtime::Result<()> { todo!() @@ -223,9 +230,12 @@ impl crate::types::Host for WasiHttp { } fn incoming_response_consume( &mut self, - _response: IncomingResponse, + response: IncomingResponse, ) -> wasmtime::Result> { - todo!() + match self.responses.get(&response) { + Some(r) => Ok(Ok(r.body)), + None => bail!("response not found"), + } } fn new_outgoing_response( &mut self, From 4bfde02004cb02ddf0b55b310978fdda506c3f63 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 24 Mar 2023 20:01:44 +0000 Subject: [PATCH 10/46] Fix read for len < buffer length. --- Cargo.lock | 142 +++++---------------------- crates/wasi-http/src/streams_impl.rs | 20 ++-- 2 files changed, 36 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfea7a51699c..40b74b371958 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,16 +234,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "1.1.0" @@ -1343,12 +1333,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.27" @@ -1523,12 +1507,12 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.8", + "http", "indexmap", "slab", "tokio", @@ -1607,38 +1591,15 @@ dependencies = [ "digest 0.9.0", ] -[[package]] -name = "http" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes 0.4.12", - "fnv", - "itoa 0.4.8", -] - [[package]] name = "http" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", - "itoa 1.0.1", -] - -[[package]] -name = "http-body" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "http 0.1.21", - "tokio-buf", + "itoa", ] [[package]] @@ -1647,8 +1608,8 @@ version = "1.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "951dfc2e32ac02d67c90c0d65bd27009a635dc9b381a2cc7d284ab01e3a0150d" dependencies = [ - "bytes 1.1.0", - "http 0.2.8", + "bytes", + "http", ] [[package]] @@ -1657,10 +1618,10 @@ version = "0.1.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92445bc9cc14bfa0a3ce56817dc3b5bcc227a168781a356b702410789cec0d10" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-util", - "http 0.2.8", - "http-body 1.0.0-rc.2", + "http", + "http-body", "pin-project-lite", ] @@ -1697,16 +1658,16 @@ version = "1.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b75264b2003a3913f118d35c586e535293b3e22e41f074930762929d071e092" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-channel", "futures-core", "futures-util", "h2", - "http 0.2.8", - "http-body 1.0.0-rc.2", + "http", + "http-body", "httparse", "httpdate", - "itoa 1.0.1", + "itoa", "pin-project-lite", "tokio", "tracing", @@ -1787,15 +1748,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "ipnet" version = "2.5.0" @@ -1842,12 +1794,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.1" @@ -2321,17 +2267,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.6", + "parking_lot_core", ] [[package]] @@ -2348,19 +2284,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot_core" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys 0.42.0", -] - [[package]] name = "paste" version = "1.0.7" @@ -2849,7 +2772,7 @@ dependencies = [ "bitflags", "errno", "io-lifetimes", - "itoa 1.0.1", + "itoa", "libc", "linux-raw-sys", "once_cell", @@ -2947,7 +2870,7 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944" dependencies = [ - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -3006,15 +2929,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - [[package]] name = "signature" version = "1.3.2" @@ -3289,29 +3203,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg 1.1.0", - "bytes 1.1.0", + "bytes", "libc", "memchr", "mio", "num_cpus", - "parking_lot 0.12.1", "pin-project-lite", - "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.42.0", ] -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", -] - [[package]] name = "tokio-macros" version = "1.7.0" @@ -3339,7 +3241,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-core", "futures-sink", "pin-project-lite", @@ -3615,7 +3517,7 @@ dependencies = [ "hmac", "k256", "p256", - "parking_lot 0.11.2", + "parking_lot", "pqcrypto", "rand_core 0.5.1", "rand_core 0.6.3", @@ -3633,9 +3535,9 @@ name = "wasi-http" version = "0.0.1" dependencies = [ "anyhow", - "bytes 1.1.0", - "futures 0.3.27", - "http-body 0.1.0", + "bytes", + "futures", + "http-body", "http-body-util", "hyper", "thiserror", diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs index 3a7c4937ab26..4aa175c92672 100644 --- a/crates/wasi-http/src/streams_impl.rs +++ b/crates/wasi-http/src/streams_impl.rs @@ -8,14 +8,22 @@ impl crate::streams::Host for WasiHttp { fn read( &mut self, stream: InputStream, - _len: u64, + len: u64, ) -> wasmtime::Result, bool), StreamError>> { - let response = match self.responses.get(&stream) { - Some(r) => r, + match self.streams.get_mut(&stream) { + Some(s) => { + if len == 0 { + Ok(Ok((bytes::Bytes::new().to_vec(), s.len() > 0))) + } else if s.len() > len.try_into()? { + let result = s.split_to(len.try_into()?); + Ok(Ok((result.to_vec(), false))) + } else { + s.truncate(s.len()); + Ok(Ok((s.clone().to_vec(), true))) + } + } None => bail!("not found"), - }; - let bytes = response.body.clone(); - Ok(Ok((bytes.to_vec(), true))) + } } fn skip( From dff5986f128e0a3d494ed33b9d6cc1f4ca3a69c1 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 24 Mar 2023 20:35:18 +0000 Subject: [PATCH 11/46] Formatting. --- crates/wasi-http/src/http_impl.rs | 7 ++++++- crates/wasi-http/src/types_impl.rs | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index aca74bcf2ac2..11fe0db9c49f 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -147,7 +147,12 @@ impl WasiHttp { let response_id = self.response_id_base; self.response_id_base = self.response_id_base + 1; let mut response = ActiveResponse::new(response_id); - let body = Full::::new(self.streams.get(&request.body).unwrap_or(&Bytes::new()).clone()); + let body = Full::::new( + self.streams + .get(&request.body) + .unwrap_or(&Bytes::new()) + .clone(), + ); let t = timeout(first_bytes_timeout, sender.send_request(call.body(body)?)).await?; let mut res = t?; response.status = res.status().try_into()?; diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index 947687c8f5e9..cdbc0abfbdd1 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -184,8 +184,8 @@ impl crate::types::Host for WasiHttp { req.body = self.streams_id_base; self.streams_id_base = self.streams_id_base + 1; Ok(Ok(req.body)) - }, - None => bail!("unknown request!") + } + None => bail!("unknown request!"), } } fn drop_response_outparam(&mut self, _response: ResponseOutparam) -> wasmtime::Result<()> { From aee848be4b5643c9f04a78902deeb2a9d9d2301c Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 23 Mar 2023 19:45:22 -0700 Subject: [PATCH 12/46] types impl: swap todos for traps --- crates/wasi-http/src/types_impl.rs | 139 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 70 deletions(-) diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index cdbc0abfbdd1..0ca4e34f975b 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -6,7 +6,7 @@ use crate::types::{ Scheme, StatusCode, Trailers, }; use crate::WasiHttp; -use anyhow::bail; +use anyhow::{anyhow, bail}; use std::collections::HashMap; impl crate::types::Host for WasiHttp { @@ -29,13 +29,13 @@ impl crate::types::Host for WasiHttp { Ok(id) } fn fields_get(&mut self, fields: Fields, name: String) -> wasmtime::Result> { - let res = match self.fields.get(&fields) { - Some(m) => match m.get(&name) { - Some(v) => v.clone(), - None => bail!("key not found"), - }, - None => bail!("fields not found"), - }; + let res = self + .fields + .get(&fields) + .ok_or_else(|| anyhow!("fields not found: {fields}"))? + .get(&name) + .ok_or_else(|| anyhow!("key not found: {name}"))? + .clone(); Ok(res) } fn fields_set( @@ -65,20 +65,19 @@ impl crate::types::Host for WasiHttp { name: String, value: String, ) -> wasmtime::Result<()> { - match self.fields.get_mut(&fields) { - Some(m) => { - match m.get_mut(&name) { - Some(v) => v.push(value), - None => { - let mut vec = std::vec::Vec::new(); - vec.push(value); - m.insert(name, vec); - } - }; - Ok(()) + let mut m = self + .fields + .get_mut(&fields) + .ok_or_else(|| anyhow!("unknown fields: {fields}"))?; + match m.get_mut(&name) { + Some(v) => v.push(value), + None => { + let mut vec = std::vec::Vec::new(); + vec.push(value); + m.insert(name, vec); } - None => bail!("Unknown fields!"), - } + }; + Ok(()) } fn fields_entries(&mut self, fields: Fields) -> wasmtime::Result> { let field_map = match self.fields.get(&fields) { @@ -95,60 +94,59 @@ impl crate::types::Host for WasiHttp { let id = self.fields_id_base; self.fields_id_base = self.fields_id_base + 1; - match self.fields.get(&fields) { - Some(m) => { - self.fields.insert(id, m.clone()); - } - None => {} - } + let m = self + .fields + .get(&fields) + .ok_or_else(|| anyhow!("fields not found: {fields}"))?; + self.fields.insert(id, m.clone()); Ok(id) } fn finish_incoming_stream(&mut self, _s: IncomingStream) -> wasmtime::Result> { - todo!() + bail!("unimplemented: finish_incoming_stream") } fn finish_outgoing_stream( &mut self, _s: OutgoingStream, _trailers: Option, ) -> wasmtime::Result<()> { - todo!() + bail!("unimplemented: finish_outgoing_stream") } fn drop_incoming_request(&mut self, _request: IncomingRequest) -> wasmtime::Result<()> { - todo!() + bail!("unimplemented: drop_incoming_request") } fn drop_outgoing_request(&mut self, request: OutgoingRequest) -> wasmtime::Result<()> { self.requests.remove(&request); Ok(()) } fn incoming_request_method(&mut self, _request: IncomingRequest) -> wasmtime::Result { - todo!() + bail!("unimplemented: incoming_request_method") } fn incoming_request_path(&mut self, _request: IncomingRequest) -> wasmtime::Result { - todo!() + bail!("unimplemented: incoming_request_path") } fn incoming_request_scheme( &mut self, _request: IncomingRequest, ) -> wasmtime::Result> { - todo!() + bail!("unimplemented: incoming_request_scheme") } fn incoming_request_authority( &mut self, _request: IncomingRequest, ) -> wasmtime::Result { - todo!() + bail!("unimplemented: incoming_request_authority") } fn incoming_request_headers(&mut self, _request: IncomingRequest) -> wasmtime::Result { - todo!() + bail!("unimplemented: incoming_request_headers") } fn incoming_request_consume( &mut self, _request: IncomingRequest, ) -> wasmtime::Result> { - todo!() + bail!("unimplemented: incoming_request_consume") } fn incoming_request_query(&mut self, _request: IncomingRequest) -> wasmtime::Result { - todo!() + bail!("unimplemented: incoming_request_query") } fn new_outgoing_request( &mut self, @@ -179,93 +177,94 @@ impl crate::types::Host for WasiHttp { &mut self, request: OutgoingRequest, ) -> wasmtime::Result> { - match self.requests.get_mut(&request) { - Some(req) => { - req.body = self.streams_id_base; - self.streams_id_base = self.streams_id_base + 1; - Ok(Ok(req.body)) - } - None => bail!("unknown request!"), - } + let mut req = self + .requests + .get_mut(&request) + .ok_or_else(|| anyhow!("unknown request: {request}"))?; + req.body = self.streams_id_base; + self.streams_id_base = self.streams_id_base + 1; + Ok(Ok(req.body)) } fn drop_response_outparam(&mut self, _response: ResponseOutparam) -> wasmtime::Result<()> { - todo!() + bail!("unimplemented: drop_response_outparam") } fn set_response_outparam( &mut self, _response: Result, ) -> wasmtime::Result> { - todo!() + bail!("unimplemented: set_response_outparam") } fn drop_incoming_response(&mut self, response: IncomingResponse) -> wasmtime::Result<()> { self.responses.remove(&response); Ok(()) } fn drop_outgoing_response(&mut self, _response: OutgoingResponse) -> wasmtime::Result<()> { - todo!() + bail!("unimplemented: drop_outgoing_response") } fn incoming_response_status( &mut self, response: IncomingResponse, ) -> wasmtime::Result { - match self.responses.get(&response) { - Some(r) => Ok(r.status), - None => bail!("response not found"), - } + let r = self + .responses + .get(&response) + .ok_or_else(|| anyhow!("response not found: {response}"))?; + Ok(r.status) } fn incoming_response_headers( &mut self, response: IncomingResponse, ) -> wasmtime::Result { - match self.responses.get(&response) { - Some(r) => { - let id = self.fields_id_base; - self.fields_id_base = self.fields_id_base + 1; + let r = self + .responses + .get(&response) + .ok_or_else(|| anyhow!("response not found: {response}"))?; + let id = self.fields_id_base; + self.fields_id_base = self.fields_id_base + 1; - self.fields.insert(id, r.response_headers.clone()); - Ok(id) - } - None => bail!("response not found"), - } + self.fields.insert(id, r.response_headers.clone()); + Ok(id) } fn incoming_response_consume( &mut self, response: IncomingResponse, ) -> wasmtime::Result> { - match self.responses.get(&response) { - Some(r) => Ok(Ok(r.body)), - None => bail!("response not found"), - } + let r = self + .responses + .get(&response) + .ok_or_else(|| anyhow!("response not found: {response}"))?; + + Ok(Ok(r.body)) } fn new_outgoing_response( &mut self, _status_code: StatusCode, _headers: Headers, ) -> wasmtime::Result { - todo!() + bail!("unimplemented: new_outgoing_response") } fn outgoing_response_write( &mut self, _response: OutgoingResponse, ) -> wasmtime::Result> { - todo!() + bail!("unimplemented: outgoing_response_write") } fn drop_future_incoming_response( &mut self, _f: FutureIncomingResponse, ) -> wasmtime::Result<()> { - todo!() + bail!("unimplemented: drop_future_incoming_response") } fn future_incoming_response_get( &mut self, _f: FutureIncomingResponse, ) -> wasmtime::Result>> { - todo!() + bail!("unimplemented: future_incoming_response_get") } fn listen_to_future_incoming_response( &mut self, _f: FutureIncomingResponse, ) -> wasmtime::Result { - todo!() + bail!("unimplemented: listen_to_future_incoming_response") } } From 41a922fc106d407ad046d0ac788a877201931e59 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 23 Mar 2023 19:45:52 -0700 Subject: [PATCH 13/46] streams_impl: idioms, and swap todos for traps --- crates/wasi-http/src/streams_impl.rs | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs index 4aa175c92672..457bbea9452e 100644 --- a/crates/wasi-http/src/streams_impl.rs +++ b/crates/wasi-http/src/streams_impl.rs @@ -1,7 +1,7 @@ use crate::poll::Pollable; use crate::streams::{InputStream, OutputStream, StreamError}; use crate::WasiHttp; -use anyhow::bail; +use anyhow::{anyhow, bail}; use std::vec::Vec; impl crate::streams::Host for WasiHttp { @@ -10,19 +10,18 @@ impl crate::streams::Host for WasiHttp { stream: InputStream, len: u64, ) -> wasmtime::Result, bool), StreamError>> { - match self.streams.get_mut(&stream) { - Some(s) => { - if len == 0 { - Ok(Ok((bytes::Bytes::new().to_vec(), s.len() > 0))) - } else if s.len() > len.try_into()? { - let result = s.split_to(len.try_into()?); - Ok(Ok((result.to_vec(), false))) - } else { - s.truncate(s.len()); - Ok(Ok((s.clone().to_vec(), true))) - } - } - None => bail!("not found"), + let s = self + .streams + .get_mut(&stream) + .ok_or_else(|| anyhow!("stream not found: {stream}"))?; + if len == 0 { + Ok(Ok((bytes::Bytes::new().to_vec(), s.len() > 0))) + } else if s.len() > len.try_into()? { + let result = s.split_to(len.try_into()?); + Ok(Ok((result.to_vec(), false))) + } else { + s.truncate(s.len()); + Ok(Ok((s.clone().to_vec(), true))) } } @@ -31,18 +30,19 @@ impl crate::streams::Host for WasiHttp { _this: InputStream, _len: u64, ) -> wasmtime::Result> { - todo!(); + bail!("unimplemented: skip"); } fn subscribe_to_input_stream(&mut self, _this: InputStream) -> wasmtime::Result { - todo!(); + bail!("unimplemented: subscribe_to_input_stream"); } fn drop_input_stream(&mut self, stream: InputStream) -> wasmtime::Result<()> { - match self.streams.get_mut(&stream) { - Some(r) => r.truncate(0), - None => {} - } + let r = self + .streams + .get_mut(&stream) + .ok_or_else(|| anyhow!("no such input-stream {stream}"))?; + r.truncate(0); Ok(()) } @@ -53,7 +53,7 @@ impl crate::streams::Host for WasiHttp { ) -> wasmtime::Result> { // TODO: Make this a real write not a replace. self.streams.insert(this, bytes::Bytes::from(buf.clone())); - Ok(Ok(buf.len().try_into().unwrap())) + Ok(Ok(buf.len().try_into()?)) } fn write_zeroes( @@ -61,7 +61,7 @@ impl crate::streams::Host for WasiHttp { _this: OutputStream, _len: u64, ) -> wasmtime::Result> { - todo!(); + bail!("unimplemented: write_zeroes"); } fn splice( @@ -70,7 +70,7 @@ impl crate::streams::Host for WasiHttp { _src: InputStream, _len: u64, ) -> wasmtime::Result> { - todo!(); + bail!("unimplemented: splice"); } fn forward( @@ -78,14 +78,14 @@ impl crate::streams::Host for WasiHttp { _this: OutputStream, _src: InputStream, ) -> wasmtime::Result> { - todo!(); + bail!("unimplemented: forward"); } fn subscribe_to_output_stream(&mut self, _this: OutputStream) -> wasmtime::Result { - todo!(); + bail!("unimplemented: subscribe_to_output_stream"); } fn drop_output_stream(&mut self, _this: OutputStream) -> wasmtime::Result<()> { - todo!(); + bail!("unimplemented: drop_output_stream"); } } From 4dbade613fd2e726ab621e1f126b658f862db68a Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 23 Mar 2023 19:46:41 -0700 Subject: [PATCH 14/46] component impl: idioms, swap all unwraps for traps, swap all todos for traps --- crates/wasi-http/src/component_impl.rs | 251 ++++++++++--------------- 1 file changed, 102 insertions(+), 149 deletions(-) diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs index bc3869e5dbeb..2972ef77a05f 100644 --- a/crates/wasi-http/src/component_impl.rs +++ b/crates/wasi-http/src/component_impl.rs @@ -1,16 +1,11 @@ use crate::default_outgoing_http::Host; pub use crate::r#struct::WasiHttp; use crate::streams::Host as StreamsHost; -use crate::types::Host as TypesHost; -use crate::types::RequestOptions; -use crate::types::Scheme; +use crate::types::{Host as TypesHost, RequestOptions, Scheme}; +use anyhow::anyhow; use std::str; use std::vec::Vec; -use wasmtime::AsContext; -use wasmtime::AsContextMut; -use wasmtime::Caller; -use wasmtime::Extern; -use wasmtime::Memory; +use wasmtime::{AsContext, AsContextMut, Caller, Extern, Memory}; const MEMORY: &str = "memory"; @@ -26,17 +21,6 @@ enum HttpError { Utf8Error(#[from] std::str::Utf8Error), } -impl From for u32 { - fn from(e: HttpError) -> u32 { - match e { - HttpError::MemoryNotFound => 2, - HttpError::MemoryAccessError(_) => 3, - HttpError::BufferTooSmall => 4, - _ => panic!("Unsupported"), - } - } -} - fn memory_get(caller: &mut Caller<'_, T>) -> Result { if let Some(Extern::Memory(mem)) = caller.get_export(MEMORY) { Ok(mem) @@ -83,15 +67,15 @@ fn string_from_memory( Ok(std::str::from_utf8(&slice)?.to_string()) } -fn allocate_guest_pointer(caller: &mut Caller<'_, T>, size: u32) -> u32 { - let realloc = caller.get_export("cabi_realloc").unwrap(); - let func = realloc.into_func().unwrap(); - let typed = func - .typed::<(u32, u32, u32, u32), u32>(caller.as_context()) - .unwrap(); - typed - .call(caller.as_context_mut(), (0, 0, 4, size)) - .unwrap() +fn allocate_guest_pointer(caller: &mut Caller<'_, T>, size: u32) -> anyhow::Result { + let realloc = caller + .get_export("cabi_realloc") + .ok_or_else(|| anyhow!("missing required export cabi_realloc"))?; + let func = realloc + .into_func() + .ok_or_else(|| anyhow!("cabi_realloc must be a func"))?; + let typed = func.typed::<(u32, u32, u32, u32), u32>(caller.as_context())?; + Ok(typed.call(caller.as_context_mut(), (0, 0, 4, size))?) } fn u32_array_to_u8(arr: &[u32]) -> Vec { @@ -121,7 +105,7 @@ pub fn add_component_to_linker( first_byte_timeout_ms: u32, has_between_bytes_timeout: i32, between_bytes_timeout_ms: u32| - -> u32 { + -> anyhow::Result { let options = if has_options == 1 { Some(RequestOptions { connect_timeout_ms: if has_timeout == 1 { @@ -144,10 +128,7 @@ pub fn add_component_to_linker( None }; - match get_cx(caller.data_mut()).handle(request, options) { - Ok(v) => v, - Err(_) => 0, - } + Ok(get_cx(caller.data_mut()).handle(request, options)?) }, )?; linker.func_wrap( @@ -168,29 +149,23 @@ pub fn add_component_to_linker( authority_ptr: u32, authority_len: u32, headers: u32| - -> u32 { - let memory = match memory_get(&mut caller) { - Ok(m) => m, - Err(_) => return 0, - }; - let path = - string_from_memory(&memory, caller.as_context_mut(), path_ptr, path_len).unwrap(); - let query = - string_from_memory(&memory, caller.as_context_mut(), query_ptr, query_len).unwrap(); + -> anyhow::Result { + let memory = memory_get(&mut caller)?; + let path = string_from_memory(&memory, caller.as_context_mut(), path_ptr, path_len)?; + let query = string_from_memory(&memory, caller.as_context_mut(), query_ptr, query_len)?; let authority = string_from_memory( &memory, caller.as_context_mut(), authority_ptr, authority_len, - ) - .unwrap(); + )?; let mut s = Scheme::Https; if scheme_is_some == 1 { s = match scheme { 0 => Scheme::Http, 1 => Scheme::Https, - _ => panic!("unsupported!"), + _ => anyhow::bail!("unsupported scheme {scheme}"), }; } let m = match method { @@ -203,29 +178,26 @@ pub fn add_component_to_linker( 6 => crate::types::Method::Options, 7 => crate::types::Method::Trace, 8 => crate::types::Method::Patch, - _ => panic!("unsupported method!"), + _ => anyhow::bail!("unsupported method {method}"), }; let ctx = get_cx(caller.data_mut()); - match ctx.new_outgoing_request(m, path, query, Some(s), authority, headers) { - Ok(v) => v, - Err(_) => 0, - } + Ok(ctx.new_outgoing_request(m, path, query, Some(s), authority, headers)?) }, )?; linker.func_wrap( "types", "incoming-response-status", - move |mut caller: Caller<'_, T>, id: u32| -> u32 { + move |mut caller: Caller<'_, T>, id: u32| -> anyhow::Result { let ctx = get_cx(caller.data_mut()); - ctx.incoming_response_status(id).unwrap().into() + Ok(ctx.incoming_response_status(id)?.into()) }, )?; linker.func_wrap( "types", "future-incoming-response-get", - move |mut caller: Caller<'_, T>, future: u32, ptr: i32| { - let memory = memory_get(&mut caller).unwrap(); + move |mut caller: Caller<'_, T>, future: u32, ptr: i32| -> anyhow::Result<()> { + let memory = memory_get(&mut caller)?; // First == is_some // Second == is_err @@ -235,20 +207,16 @@ pub fn add_component_to_linker( let result: [u32; 5] = [1, 0, future, 0, 0]; let raw = u32_array_to_u8(&result); - memory - .write(caller.as_context_mut(), ptr as _, &raw) - .unwrap(); + memory.write(caller.as_context_mut(), ptr as _, &raw)?; + Ok(()) }, )?; linker.func_wrap( "types", "incoming-response-consume", - move |mut caller: Caller<'_, T>, response: u32, ptr: i32| { + move |mut caller: Caller<'_, T>, response: u32, ptr: i32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - let stream = match ctx.incoming_response_consume(response) { - Ok(s) => s.unwrap_or(0), - Err(_) => 0, - }; + let stream = ctx.incoming_response_consume(response)?.unwrap_or(0); let memory = memory_get(&mut caller).unwrap(); @@ -257,204 +225,189 @@ pub fn add_component_to_linker( let result: [u32; 2] = [0, stream]; let raw = u32_array_to_u8(&result); - memory - .write(caller.as_context_mut(), ptr as _, &raw) - .unwrap(); + memory.write(caller.as_context_mut(), ptr as _, &raw)?; + Ok(()) }, )?; linker.func_wrap( "poll", "drop-pollable", - move |_caller: Caller<'_, T>, _a: i32| {}, + move |_caller: Caller<'_, T>, _a: i32| -> anyhow::Result<()> { + anyhow::bail!("unimplemented") + }, )?; linker.func_wrap( "types", "drop-fields", - move |mut caller: Caller<'_, T>, ptr: u32| { + move |mut caller: Caller<'_, T>, ptr: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - ctx.drop_fields(ptr) + ctx.drop_fields(ptr)?; + Ok(()) }, )?; linker.func_wrap( "streams", "drop-input-stream", - move |mut caller: Caller<'_, T>, id: u32| { + move |mut caller: Caller<'_, T>, id: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - match ctx.drop_input_stream(id) { - Ok(_) => {} - Err(_) => {} - }; + ctx.drop_input_stream(id)?; + Ok(()) }, )?; linker.func_wrap( "types", "outgoing-request-write", - move |mut caller: Caller<'_, T>, request: u32, ptr: u32| { + move |mut caller: Caller<'_, T>, request: u32, ptr: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - let stream = ctx.outgoing_request_write(request).unwrap().unwrap(); + let stream = ctx + .outgoing_request_write(request)? + .map_err(|_| anyhow!("no outgoing stream present"))?; - let memory = memory_get(&mut caller).unwrap(); + let memory = memory_get(&mut caller)?; // First == is_some // Second == stream_id let result: [u32; 2] = [0, stream]; let raw = u32_array_to_u8(&result); - memory - .write(caller.as_context_mut(), ptr as _, &raw) - .unwrap(); + memory.write(caller.as_context_mut(), ptr as _, &raw)?; + Ok(()) }, )?; linker.func_wrap( "types", "drop-outgoing-request", - move |mut caller: Caller<'_, T>, id: u32| { + move |mut caller: Caller<'_, T>, id: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - ctx.drop_outgoing_request(id).unwrap(); + ctx.drop_outgoing_request(id)?; + Ok(()) }, )?; linker.func_wrap( "types", "drop-incoming-response", - move |mut caller: Caller<'_, T>, id: u32| { + move |mut caller: Caller<'_, T>, id: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - ctx.drop_incoming_response(id).unwrap() + ctx.drop_incoming_response(id)?; + Ok(()) }, )?; linker.func_wrap( "types", "new-fields", - move |mut caller: Caller<'_, T>, base_ptr: u32, len: u32| -> u32 { - let memory = memory_get(&mut caller).unwrap(); + move |mut caller: Caller<'_, T>, base_ptr: u32, len: u32| -> anyhow::Result { + let memory = memory_get(&mut caller)?; let mut vec = Vec::new(); let mut i = 0; // TODO: read this more efficiently as a single block. while i < len { let ptr = base_ptr + i * 16; - let name_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr).unwrap(); - let name_len = u32_from_memory(&memory, caller.as_context_mut(), ptr + 4).unwrap(); - let value_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr + 8).unwrap(); - let value_len = - u32_from_memory(&memory, caller.as_context_mut(), ptr + 12).unwrap(); - - let name = string_from_memory(&memory, caller.as_context_mut(), name_ptr, name_len) - .unwrap(); + let name_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr)?; + let name_len = u32_from_memory(&memory, caller.as_context_mut(), ptr + 4)?; + let value_ptr = u32_from_memory(&memory, caller.as_context_mut(), ptr + 8)?; + let value_len = u32_from_memory(&memory, caller.as_context_mut(), ptr + 12)?; + + let name = + string_from_memory(&memory, caller.as_context_mut(), name_ptr, name_len)?; let value = - string_from_memory(&memory, caller.as_context_mut(), value_ptr, value_len) - .unwrap(); + string_from_memory(&memory, caller.as_context_mut(), value_ptr, value_len)?; vec.push((name, value)); i = i + 1; } let ctx = get_cx(caller.data_mut()); - match ctx.new_fields(vec) { - Ok(v) => v, - Err(_) => 0, - } + Ok(ctx.new_fields(vec)?) }, )?; linker.func_wrap( "streams", "read", - move |mut caller: Caller<'_, T>, stream: u32, len: u64, ptr: u32| { + move |mut caller: Caller<'_, T>, stream: u32, len: u64, ptr: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - let bytes_tuple = ctx.read(stream, len).unwrap().unwrap(); + let bytes_tuple = ctx.read(stream, len)??; let bytes = bytes_tuple.0; let done = match bytes_tuple.1 { true => 1, false => 0, }; - let body_len: u32 = bytes.len().try_into().unwrap(); - let out_ptr = allocate_guest_pointer(&mut caller, body_len); + let body_len: u32 = bytes.len().try_into()?; + let out_ptr = allocate_guest_pointer(&mut caller, body_len)?; let result: [u32; 4] = [0, out_ptr, body_len, done]; let raw = u32_array_to_u8(&result); - let memory = memory_get(&mut caller).unwrap(); - memory - .write(caller.as_context_mut(), out_ptr as _, &bytes) - .unwrap(); - memory - .write(caller.as_context_mut(), ptr as _, &raw) - .unwrap(); + let memory = memory_get(&mut caller)?; + memory.write(caller.as_context_mut(), out_ptr as _, &bytes)?; + memory.write(caller.as_context_mut(), ptr as _, &raw)?; + Ok(()) }, )?; linker.func_wrap( "streams", "write", - move |mut caller: Caller<'_, T>, stream: u32, body_ptr: u32, body_len: u32, ptr: u32| { - let memory = memory_get(&mut caller).unwrap(); - let body = - string_from_memory(&memory, caller.as_context_mut(), body_ptr, body_len).unwrap(); + move |mut caller: Caller<'_, T>, + stream: u32, + body_ptr: u32, + body_len: u32, + ptr: u32| + -> anyhow::Result<()> { + let memory = memory_get(&mut caller)?; + let body = string_from_memory(&memory, caller.as_context_mut(), body_ptr, body_len)?; let result: [u32; 3] = [0, 0, body_len]; let raw = u32_array_to_u8(&result); - let memory = memory_get(&mut caller).unwrap(); - memory - .write(caller.as_context_mut(), ptr as _, &raw) - .unwrap(); + let memory = memory_get(&mut caller)?; + memory.write(caller.as_context_mut(), ptr as _, &raw)?; let ctx = get_cx(caller.data_mut()); - ctx.write(stream, body.as_bytes().to_vec()) - .unwrap() - .unwrap(); + ctx.write(stream, body.as_bytes().to_vec())??; + Ok(()) }, )?; linker.func_wrap( "types", "fields-entries", - move |mut caller: Caller<'_, T>, fields: u32, out_ptr: u32| { + move |mut caller: Caller<'_, T>, fields: u32, out_ptr: u32| -> anyhow::Result<()> { let ctx = get_cx(caller.data_mut()); - let entries = ctx.fields_entries(fields).unwrap(); + let entries = ctx.fields_entries(fields)?; let header_len = entries.len(); - let tuple_ptr = - allocate_guest_pointer(&mut caller, (16 * header_len).try_into().unwrap()); + let tuple_ptr = allocate_guest_pointer(&mut caller, (16 * header_len).try_into()?)?; let mut ptr = tuple_ptr; for item in entries.iter() { let name = &item.0; let value = &item.1; - let name_len: u32 = name.len().try_into().unwrap(); - let value_len: u32 = value.len().try_into().unwrap(); + let name_len: u32 = name.len().try_into()?; + let value_len: u32 = value.len().try_into()?; - let name_ptr = allocate_guest_pointer(&mut caller, name_len); - let value_ptr = allocate_guest_pointer(&mut caller, value_len); + let name_ptr = allocate_guest_pointer(&mut caller, name_len)?; + let value_ptr = allocate_guest_pointer(&mut caller, value_len)?; - let memory = memory_get(&mut caller).unwrap(); - memory - .write(caller.as_context_mut(), name_ptr as _, &name.as_bytes()) - .unwrap(); - memory - .write(caller.as_context_mut(), value_ptr as _, &value.as_bytes()) - .unwrap(); + let memory = memory_get(&mut caller)?; + memory.write(caller.as_context_mut(), name_ptr as _, &name.as_bytes())?; + memory.write(caller.as_context_mut(), value_ptr as _, &value.as_bytes())?; let pair: [u32; 4] = [name_ptr, name_len, value_ptr, value_len]; let raw_pair = u32_array_to_u8(&pair); - memory - .write(caller.as_context_mut(), ptr as _, &raw_pair) - .unwrap(); + memory.write(caller.as_context_mut(), ptr as _, &raw_pair)?; ptr = ptr + 16; } - let memory = memory_get(&mut caller).unwrap(); - let result: [u32; 2] = [tuple_ptr, header_len.try_into().unwrap()]; + let memory = memory_get(&mut caller)?; + let result: [u32; 2] = [tuple_ptr, header_len.try_into()?]; let raw = u32_array_to_u8(&result); - memory - .write(caller.as_context_mut(), out_ptr as _, &raw) - .unwrap(); + memory.write(caller.as_context_mut(), out_ptr as _, &raw)?; + Ok(()) }, )?; linker.func_wrap( "types", "incoming-response-headers", - move |mut caller: Caller<'_, T>, handle: u32| -> u32 { + move |mut caller: Caller<'_, T>, handle: u32| -> anyhow::Result { let ctx = get_cx(caller.data_mut()); - match ctx.incoming_response_headers(handle) { - Ok(h) => h, - Err(_) => 0, - } + Ok(ctx.incoming_response_headers(handle)?) }, )?; Ok(()) From 8e1b4816068ce3810499002460416f90fd4c8d4c Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 23 Mar 2023 19:47:01 -0700 Subject: [PATCH 15/46] http impl: idiom --- crates/wasi-http/src/http_impl.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 11fe0db9c49f..0fa469707bb2 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -54,15 +54,14 @@ impl WasiHttp { request_id: crate::default_outgoing_http::OutgoingRequest, options: Option, ) -> wasmtime::Result { - let opts = match options { - Some(o) => o, + let opts = options.unwrap_or( // TODO: Configurable defaults here? - None => RequestOptions { + RequestOptions { connect_timeout_ms: Some(600 * 1000), first_byte_timeout_ms: Some(600 * 1000), between_bytes_timeout_ms: Some(600 * 1000), }, - }; + ); let connect_timeout = Duration::from_millis(opts.connect_timeout_ms.unwrap_or(600 * 1000).into()); let first_bytes_timeout = From 2a815e0d51073a83baa64b796a2e2b557a921efc Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 28 Mar 2023 03:18:10 +0000 Subject: [PATCH 16/46] Remove an unnecessary mut. --- crates/wasi-http/src/types_impl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index 0ca4e34f975b..da735c78b1db 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -65,7 +65,7 @@ impl crate::types::Host for WasiHttp { name: String, value: String, ) -> wasmtime::Result<()> { - let mut m = self + let m = self .fields .get_mut(&fields) .ok_or_else(|| anyhow!("unknown fields: {fields}"))?; From 9913785be002b2d41ac4513fc169d834d9d2c621 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 28 Mar 2023 03:18:30 +0000 Subject: [PATCH 17/46] Remove an unsupported function. --- crates/wasi-http/example/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-http/example/main.c b/crates/wasi-http/example/main.c index 5085b0c0f56e..87ae9133eb0f 100644 --- a/crates/wasi-http/example/main.c +++ b/crates/wasi-http/example/main.c @@ -63,7 +63,7 @@ int request(uint8_t method_tag, uint8_t scheme_tag, const char * authority_str, printf("response is error!\n"); return 2; } - poll_drop_pollable(res); + // poll_drop_pollable(res); types_status_code_t code = types_incoming_response_status(result.val.ok); printf("STATUS: %d\n", code); From 96279bfe826a8685df40c3590761cb72423c9630 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 28 Mar 2023 03:19:04 +0000 Subject: [PATCH 18/46] Switch to the tokio runtime for the HTTP request. --- crates/wasi-http/src/http_impl.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 0fa469707bb2..832b4314e162 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -3,7 +3,6 @@ pub use crate::r#struct::WasiHttp; use crate::types::{RequestOptions, Scheme}; use anyhow::bail; use bytes::{BufMut, Bytes, BytesMut}; -use futures::executor; use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; @@ -23,7 +22,7 @@ impl crate::default_outgoing_http::Host for WasiHttp { let _enter = rt.enter(); let f = self.handle_async(request_id, options); - match executor::block_on(f) { + match rt.block_on(f) { Ok(r) => { println!("{} OK", r); Ok(r) From 1e23a06efdf708fb1732d3bdfddf57641871be35 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 28 Mar 2023 04:34:12 +0000 Subject: [PATCH 19/46] Add a rust example. --- Cargo.toml | 2 + crates/wasi-http/example/.gitignore | 3 +- crates/wasi-http/example/rust/Cargo.lock | 379 ++++ crates/wasi-http/example/rust/Cargo.toml | 7 + crates/wasi-http/example/rust/Makefile | 17 + crates/wasi-http/example/rust/proxy.rs | 1901 ++++++++++++++++ crates/wasi-http/example/rust/src/main.rs | 52 + crates/wasi-http/example/rust/src/proxy.rs | 2296 ++++++++++++++++++++ 8 files changed, 4656 insertions(+), 1 deletion(-) create mode 100644 crates/wasi-http/example/rust/Cargo.lock create mode 100644 crates/wasi-http/example/rust/Cargo.toml create mode 100644 crates/wasi-http/example/rust/Makefile create mode 100644 crates/wasi-http/example/rust/proxy.rs create mode 100644 crates/wasi-http/example/rust/src/main.rs create mode 100644 crates/wasi-http/example/rust/src/proxy.rs diff --git a/Cargo.toml b/Cargo.toml index e76ec19ae87a..581c687eed31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,6 +107,7 @@ members = [ ] exclude = [ 'crates/wasi-common/WASI/tools/witx-cli', + 'crates/wasi-http/example/rust', 'docs/rust_wasi_markdown_parser' ] @@ -264,3 +265,4 @@ harness = false [[bench]] name = "wasi" harness = false + diff --git a/crates/wasi-http/example/.gitignore b/crates/wasi-http/example/.gitignore index 27e2d0e75003..8aedca81004c 100644 --- a/crates/wasi-http/example/.gitignore +++ b/crates/wasi-http/example/.gitignore @@ -1,4 +1,5 @@ proxy.c proxy.h proxy_component_type.o -main.wasm +**/*.wasm +rust/target/** diff --git a/crates/wasi-http/example/rust/Cargo.lock b/crates/wasi-http/example/rust/Cargo.lock new file mode 100644 index 000000000000..b24cfb109d75 --- /dev/null +++ b/crates/wasi-http/example/rust/Cargo.lock @@ -0,0 +1,379 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "proc-macro2" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rust" +version = "0.1.0" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "serde" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.10", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasm-encoder" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6956efd8a1a2c48a707e9a1b2da729834a0f8e4c58117493b0d9d089cee468" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wit-bindgen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7cf57f8786216c5652e1228b25203af2ff523808b5e9d3671894eee2bf7264" +dependencies = [ + "bitflags", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef177b73007d86c720931d0e2ea7e30eb8c9776e58361717743fc1e83cfacfe5" +dependencies = [ + "anyhow", + "wit-component", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efdf5b00935b7b52d0e56cae1960f8ac13019a285f5aa762ff6bd7139a5c28a2" +dependencies = [ + "heck", + "wasm-metadata", + "wit-bindgen-core", + "wit-bindgen-rust-lib", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-lib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0a8f4b5fb1820b9d232beb122936425f72ec8fe6acb56e5d8782cfe55083da" +dependencies = [ + "heck", + "wit-bindgen-core", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadf1adf12ed25629b06272c16b335ef8c5a240d0ca64ab508a955ac3b46172c" +dependencies = [ + "anyhow", + "proc-macro2", + "syn 1.0.109", + "wit-bindgen-core", + "wit-bindgen-rust", + "wit-component", +] + +[[package]] +name = "wit-component" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed04310239706efc71cc8b995cb0226089c5b5fd260c3bd800a71486bd3cec97" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "url", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "unicode-xid", + "url", +] diff --git a/crates/wasi-http/example/rust/Cargo.toml b/crates/wasi-http/example/rust/Cargo.toml new file mode 100644 index 000000000000..b22a2aef9b55 --- /dev/null +++ b/crates/wasi-http/example/rust/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +[dependencies] +wit-bindgen = { features = ["macros", "realloc"] } \ No newline at end of file diff --git a/crates/wasi-http/example/rust/Makefile b/crates/wasi-http/example/rust/Makefile new file mode 100644 index 000000000000..14eb26e6e30d --- /dev/null +++ b/crates/wasi-http/example/rust/Makefile @@ -0,0 +1,17 @@ +cc := /wasi-sdk-19.0/bin/clang + +.phony: gen clean run + +default: target/debug/rust.wasm + +gen: + wit-bindgen rust ../../wit + +target/wasm32-wasi/debug/rust.wasm: gen + cargo build --target=wasm32-wasi + +clean: + rm -rf proxy.rs target + +run: target/wasm32-wasi/debug/rust.wasm + ../../../../target/debug/wasmtime --wasi-modules=experimental-wasi-http target/wasm32-wasi/debug/rust.wasm \ No newline at end of file diff --git a/crates/wasi-http/example/rust/proxy.rs b/crates/wasi-http/example/rust/proxy.rs new file mode 100644 index 000000000000..5e65d25da6bc --- /dev/null +++ b/crates/wasi-http/example/rust/proxy.rs @@ -0,0 +1,1901 @@ + +#[allow(clippy::all)] +pub mod random{ + #[allow(clippy::all)] + /// Return `len` cryptographically-secure pseudo-random bytes. + /// + /// This function must produce data from an adequately seeded + /// cryptographically-secure pseudo-random number generator (CSPRNG), so it + /// must not block, from the perspective of the calling program, and the + /// returned data is always unpredictable. + /// + /// This function must always return fresh pseudo-random data. Deterministic + /// environments must omit this function, rather than implementing it with + /// deterministic data. + pub fn get_random_bytes(len: u64,) -> wit_bindgen::rt::vec::Vec::{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "get-random-bytes")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-bytes")] + fn wit_import( + _: i64, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i64(len), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1) + } + } + #[allow(clippy::all)] + /// Return a cryptographically-secure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-random-bytes`, represented as a `u64`. + pub fn get_random_u64() -> u64{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "get-random-u64")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-u64")] + fn wit_import( + ) -> i64; + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(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. + pub fn insecure_random() -> (u64,u64,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "insecure-random")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_insecure-random")] + fn wit_import( + _: i32, ); + } + wit_import(ptr0); + (*((ptr0 + 0) as *const i64) as u64, *((ptr0 + 8) as *const i64) as u64) + } + } + +} + + +#[allow(clippy::all)] +pub mod console{ + /// A log level, describing a kind of message. + #[repr(u8)] + #[derive(Clone, Copy, PartialEq, Eq)] + pub enum Level { + /// Describes messages about the values of variables and the flow of + /// control within a program. + Trace, + /// Describes messages likely to be of interest to someone debugging a + /// program. + Debug, + /// Describes messages likely to be of interest to someone monitoring a + /// program. + Info, + /// Describes messages indicating hazardous situations. + Warn, + /// Describes messages indicating serious errors. + Error, + } + impl core::fmt::Debug for Level { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Level::Trace => { + f.debug_tuple("Level::Trace").finish() + } + Level::Debug => { + f.debug_tuple("Level::Debug").finish() + } + Level::Info => { + f.debug_tuple("Level::Info").finish() + } + Level::Warn => { + f.debug_tuple("Level::Warn").finish() + } + Level::Error => { + f.debug_tuple("Level::Error").finish() + } + } + } + } + #[allow(clippy::all)] + /// Emit a log message. + /// + /// A log message has a `level` describing what kind of message is being + /// sent, a context, which is an uninterpreted string meant to help + /// consumers group similar messages, and a string containing the message + /// text. + pub fn log(level: Level,context: &str,message: &str,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let vec0 = context; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec1 = message; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + #[link(wasm_import_module = "console")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "log")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "console_log")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, _: i32, ); + } + wit_import(match level { + Level::Trace => 0, + Level::Debug => 1, + Level::Info => 2, + Level::Warn => 3, + Level::Error => 4, + }, ptr0, len0, ptr1, len1); + } + } + +} + + +#[allow(clippy::all)] +pub mod poll{ + /// A "pollable" handle. + /// + /// This is conceptually represents a `stream<_, _>`, or in other words, + /// a stream that one can wait on, repeatedly, but which does not itself + /// produce any data. It's temporary scaffolding until component-model's + /// async features are ready. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// `pollable` lifetimes are not automatically managed. Users must ensure + /// that they do not outlive the resource they reference. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type Pollable = u32; + #[allow(clippy::all)] + /// Dispose of the specified `pollable`, after which it may no longer + /// be used. + pub fn drop_pollable(this: Pollable,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "poll")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-pollable")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_drop-pollable")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } + #[allow(clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// The "oneoff" in the name refers to the fact that this function must do a + /// linear scan through the entire list of subscriptions, which may be + /// inefficient if the number is large and the same subscriptions are used + /// many times. In the future, this is expected to be obsoleted by the + /// component model async proposal, which will include a scalable waiting + /// facility. + /// + /// Note that the return type would ideally be `list`, but that would + /// be more difficult to polyfill given the current state of `wit-bindgen`. + /// See + /// for details. For now, we use zero to mean "not ready" and non-zero to + /// mean "ready". + pub fn poll_oneoff(in_: &[Pollable],) -> wit_bindgen::rt::vec::Vec::{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = in_; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "poll")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "poll-oneoff")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_poll-oneoff")] + fn wit_import( + _: i32, _: i32, _: i32, ); + } + wit_import(ptr0, len0, ptr1); + let len2 = *((ptr1 + 4) as *const i32) as usize; + Vec::from_raw_parts(*((ptr1 + 0) as *const i32) as *mut _, len2, len2) + } + } + +} + + +#[allow(clippy::all)] +pub mod streams{ + pub type Pollable = super::poll::Pollable; + /// An error type returned from a stream operation. Currently this + /// doesn't provide any additional information. + #[repr(C)] + #[derive(Copy, Clone)] + pub struct StreamError { + } + impl core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("StreamError").finish() + } + } + impl core::fmt::Display for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for StreamError{} + /// An output bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `output-stream`s are *non-blocking* to the extent practical on + /// underlying platforms. Except where specified otherwise, I/O operations also + /// always return promptly, after the number of bytes that can be written + /// promptly, which could even be zero. To wait for the stream to be ready to + /// accept data, the `subscribe-to-output-stream` function to obtain a + /// `pollable` which can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type OutputStream = u32; + /// An input bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `input-stream`s are *non-blocking* to the extent practical on underlying + /// platforms. I/O operations always return promptly; if fewer bytes are + /// promptly available than requested, they return the number of bytes promptly + /// available, which could even be zero. To wait for data to be available, + /// use the `subscribe-to-input-stream` function to obtain a `pollable` which + /// can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type InputStream = u32; + #[allow(clippy::all)] + /// Read bytes from a stream. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool indicating whether the end of the stream + /// was reached. The returned list will contain up to `len` bytes; it + /// may return fewer than requested, but not more. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// If `len` is 0, it represents a request to read 0 bytes, which should + /// always succeed, assuming the stream hasn't reached its end yet, and + /// return an empty list. + /// + /// The len here is a `u64`, but some callees may not be able to allocate + /// a buffer as large as that would imply. + /// FIXME: describe what happens if allocation fails. + pub fn read(this: InputStream,len: u64,) -> Result<(wit_bindgen::rt::vec::Vec::,bool,),StreamError>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "read")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_read")] + fn wit_import( + _: i32, _: i64, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok({ + let len1 = *((ptr0 + 8) as *const i32) as usize; + + (Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1), match i32::from(*((ptr0 + 12) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + }) + }), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Skip bytes from a stream. + /// + /// This is similar to the `read` function, but avoids copying the + /// bytes into the instance. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// This function returns the number of bytes skipped, along with a bool + /// indicating whether the end of the stream was reached. The returned + /// value will be at most `len`; it may be less. + pub fn skip(this: InputStream,len: u64,) -> Result<(u64,bool,),StreamError>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 24]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "skip")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_skip")] + fn wit_import( + _: i32, _: i64, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok((*((ptr0 + 8) as *const i64) as u64, match i32::from(*((ptr0 + 16) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + })), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Create a `pollable` which will resolve once either the specified stream + /// has bytes available to read or the other end of the stream has been + /// closed. + pub fn subscribe_to_input_stream(this: InputStream,) -> Pollable{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-input-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_subscribe-to-input-stream")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(this)); + ret as u32 + } + } + #[allow(clippy::all)] + /// Dispose of the specified `input-stream`, after which it may no longer + /// be used. + pub fn drop_input_stream(this: InputStream,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-input-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-input-stream")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } + #[allow(clippy::all)] + /// Write bytes to a stream. + /// + /// This function returns a `u64` indicating the number of bytes from + /// `buf` that were written; it may be less than the full list. + pub fn write(this: OutputStream,buf: &[u8],) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = buf; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "write")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), ptr0, len0, ptr1); + match i32::from(*((ptr1 + 0) as *const u8)) { + 0 => Ok(*((ptr1 + 8) as *const i64) as u64), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Write multiple zero bytes to a stream. + /// + /// This function returns a `u64` indicating the number of zero bytes + /// that were written; it may be less than `len`. + pub fn write_zeroes(this: OutputStream,len: u64,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "write-zeroes")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write-zeroes")] + fn wit_import( + _: i32, _: i64, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i64) as u64), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Read from one stream and write to another. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + /// + /// Unlike other I/O functions, this function blocks until all the data + /// read from the input stream has been written to the output stream. + pub fn splice(this: OutputStream,src: InputStream,len: u64,) -> Result<(u64,bool,),StreamError>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 24]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "splice")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_splice")] + fn wit_import( + _: i32, _: i32, _: i64, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i32(src), wit_bindgen::rt::as_i64(len), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok((*((ptr0 + 8) as *const i64) as u64, match i32::from(*((ptr0 + 16) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + })), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Forward the entire contents of an input stream to an output stream. + /// + /// This function repeatedly reads from the input stream and writes + /// the data to the output stream, until the end of the input stream + /// is reached, or an error is encountered. + /// + /// Unlike other I/O functions, this function blocks until the end + /// of the input stream is seen and all the data has been written to + /// the output stream. + /// + /// This function returns the number of bytes transferred. + pub fn forward(this: OutputStream,src: InputStream,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "forward")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_forward")] + fn wit_import( + _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i32(src), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i64) as u64), + 1 => Err(StreamError{}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Create a `pollable` which will resolve once either the specified stream + /// is ready to accept bytes or the other end of the stream has been closed. + pub fn subscribe_to_output_stream(this: OutputStream,) -> Pollable{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-output-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_subscribe-to-output-stream")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(this)); + ret as u32 + } + } + #[allow(clippy::all)] + /// Dispose of the specified `output-stream`, after which it may no longer + /// be used. + pub fn drop_output_stream(this: OutputStream,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-output-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-output-stream")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } + +} + + +#[allow(clippy::all)] +pub mod types{ + pub type InputStream = super::streams::InputStream; + pub type OutputStream = super::streams::OutputStream; + pub type Pollable = super::poll::Pollable; + pub type StatusCode = u16; + #[derive(Clone)] + pub enum SchemeParam<'a,>{ + Http, + Https, + Other(&'a str), + } + impl<'a,> core::fmt::Debug for SchemeParam<'a,> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + SchemeParam::Http => { + f.debug_tuple("SchemeParam::Http").finish() + } + SchemeParam::Https => { + f.debug_tuple("SchemeParam::Https").finish() + } + SchemeParam::Other(e) => { + f.debug_tuple("SchemeParam::Other").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub enum SchemeResult{ + Http, + Https, + Other(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for SchemeResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + SchemeResult::Http => { + f.debug_tuple("SchemeResult::Http").finish() + } + SchemeResult::Https => { + f.debug_tuple("SchemeResult::Https").finish() + } + SchemeResult::Other(e) => { + f.debug_tuple("SchemeResult::Other").field(e).finish() + } + } + } + } + pub type ResponseOutparam = u32; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct RequestOptions { + pub connect_timeout_ms: Option, + pub first_byte_timeout_ms: Option, + pub between_bytes_timeout_ms: Option, + } + impl core::fmt::Debug for RequestOptions { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("RequestOptions").field("connect-timeout-ms", &self.connect_timeout_ms).field("first-byte-timeout-ms", &self.first_byte_timeout_ms).field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms).finish() + } + } + pub type OutgoingStream = OutputStream; + pub type OutgoingResponse = u32; + pub type OutgoingRequest = u32; + #[derive(Clone)] + pub enum MethodParam<'a,>{ + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(&'a str), + } + impl<'a,> core::fmt::Debug for MethodParam<'a,> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MethodParam::Get => { + f.debug_tuple("MethodParam::Get").finish() + } + MethodParam::Head => { + f.debug_tuple("MethodParam::Head").finish() + } + MethodParam::Post => { + f.debug_tuple("MethodParam::Post").finish() + } + MethodParam::Put => { + f.debug_tuple("MethodParam::Put").finish() + } + MethodParam::Delete => { + f.debug_tuple("MethodParam::Delete").finish() + } + MethodParam::Connect => { + f.debug_tuple("MethodParam::Connect").finish() + } + MethodParam::Options => { + f.debug_tuple("MethodParam::Options").finish() + } + MethodParam::Trace => { + f.debug_tuple("MethodParam::Trace").finish() + } + MethodParam::Patch => { + f.debug_tuple("MethodParam::Patch").finish() + } + MethodParam::Other(e) => { + f.debug_tuple("MethodParam::Other").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub enum MethodResult{ + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for MethodResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MethodResult::Get => { + f.debug_tuple("MethodResult::Get").finish() + } + MethodResult::Head => { + f.debug_tuple("MethodResult::Head").finish() + } + MethodResult::Post => { + f.debug_tuple("MethodResult::Post").finish() + } + MethodResult::Put => { + f.debug_tuple("MethodResult::Put").finish() + } + MethodResult::Delete => { + f.debug_tuple("MethodResult::Delete").finish() + } + MethodResult::Connect => { + f.debug_tuple("MethodResult::Connect").finish() + } + MethodResult::Options => { + f.debug_tuple("MethodResult::Options").finish() + } + MethodResult::Trace => { + f.debug_tuple("MethodResult::Trace").finish() + } + MethodResult::Patch => { + f.debug_tuple("MethodResult::Patch").finish() + } + MethodResult::Other(e) => { + f.debug_tuple("MethodResult::Other").field(e).finish() + } + } + } + } + pub type IncomingStream = InputStream; + pub type IncomingResponse = u32; + pub type IncomingRequest = u32; + pub type FutureIncomingResponse = u32; + pub type Fields = u32; + pub type Trailers = Fields; + pub type Headers = Fields; + #[derive(Clone)] + pub enum ErrorParam<'a,>{ + InvalidUrl(&'a str), + TimeoutError(&'a str), + ProtocolError(&'a str), + UnexpectedError(&'a str), + } + impl<'a,> core::fmt::Debug for ErrorParam<'a,> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + ErrorParam::InvalidUrl(e) => { + f.debug_tuple("ErrorParam::InvalidUrl").field(e).finish() + } + ErrorParam::TimeoutError(e) => { + f.debug_tuple("ErrorParam::TimeoutError").field(e).finish() + } + ErrorParam::ProtocolError(e) => { + f.debug_tuple("ErrorParam::ProtocolError").field(e).finish() + } + ErrorParam::UnexpectedError(e) => { + f.debug_tuple("ErrorParam::UnexpectedError").field(e).finish() + } + } + } + } + impl<'a,> core::fmt::Display for ErrorParam<'a,> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self)} + } + + impl<'a,> std::error::Error for ErrorParam<'a,> {} + #[derive(Clone)] + pub enum ErrorResult{ + InvalidUrl(wit_bindgen::rt::string::String), + TimeoutError(wit_bindgen::rt::string::String), + ProtocolError(wit_bindgen::rt::string::String), + UnexpectedError(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for ErrorResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + ErrorResult::InvalidUrl(e) => { + f.debug_tuple("ErrorResult::InvalidUrl").field(e).finish() + } + ErrorResult::TimeoutError(e) => { + f.debug_tuple("ErrorResult::TimeoutError").field(e).finish() + } + ErrorResult::ProtocolError(e) => { + f.debug_tuple("ErrorResult::ProtocolError").field(e).finish() + } + ErrorResult::UnexpectedError(e) => { + f.debug_tuple("ErrorResult::UnexpectedError").field(e).finish() + } + } + } + } + impl core::fmt::Display for ErrorResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self)} + } + + impl std::error::Error for ErrorResult {} + #[allow(clippy::all)] + pub fn drop_fields(fields: Fields,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-fields")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-fields")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields)); + } + } + #[allow(clippy::all)] + pub fn new_fields(entries: &[(&str,&str,)],) -> Fields{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let vec3 = entries; + let len3 = vec3.len() as i32; + let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); + let result3 = if layout3.size() != 0 + { + let ptr = alloc::alloc(layout3); + if ptr.is_null() + { + alloc::handle_alloc_error(layout3); + } + ptr + }else { + core::ptr::null_mut() + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3 as i32 + (i as i32) * 16; + { + let (t0_0, t0_1, ) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + *((base + 4) as *mut i32) = len1; + *((base + 0) as *mut i32) = ptr1; + let vec2 = t0_1; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + *((base + 12) as *mut i32) = len2; + *((base + 8) as *mut i32) = ptr2; + + }} + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-fields")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-fields")] + fn wit_import( + _: i32, _: i32, ) -> i32; + } + let ret = wit_import(result3 as i32, len3); + if layout3.size() != 0 { + alloc::dealloc(result3, layout3); + } + ret as u32 + } + } + #[allow(clippy::all)] + pub fn fields_get(fields: Fields,name: &str,) -> wit_bindgen::rt::vec::Vec::{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-get")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-get")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1); + let base3 = *((ptr1 + 0) as *const i32); + let len3 = *((ptr1 + 4) as *const i32); + let mut result3 = Vec::with_capacity(len3 as usize); + for i in 0..len3 { + let base = base3 + i *8; + result3.push({ + let len2 = *((base + 4) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((base + 0) as *const i32) as *mut _, len2, len2)).unwrap() + }); + } + wit_bindgen::rt::dealloc(base3, (len3 as usize) * 8, 4); + result3 + } + } + #[allow(clippy::all)] + pub fn fields_set(fields: Fields,name: &str,value: &[&str],) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec2 = value; + let len2 = vec2.len() as i32; + let layout2 = alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 + { + let ptr = alloc::alloc(layout2); + if ptr.is_null() + { + alloc::handle_alloc_error(layout2); + } + ptr + }else { + core::ptr::null_mut() + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2 as i32 + (i as i32) * 8; + { + let vec1 = e; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + *((base + 4) as *mut i32) = len1; + *((base + 0) as *mut i32) = ptr1; + + }} + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-set")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-set")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, result2 as i32, len2); + if layout2.size() != 0 { + alloc::dealloc(result2, layout2); + } + } + } + #[allow(clippy::all)] + pub fn fields_delete(fields: Fields,name: &str,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-delete")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-delete")] + fn wit_import( + _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0); + } + } + #[allow(clippy::all)] + pub fn fields_append(fields: Fields,name: &str,value: &str,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec1 = value; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-append")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-append")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1, len1); + } + } + #[allow(clippy::all)] + pub fn fields_entries(fields: Fields,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-entries")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-entries")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0); + let base3 = *((ptr0 + 0) as *const i32); + let len3 = *((ptr0 + 4) as *const i32); + let mut result3 = Vec::with_capacity(len3 as usize); + for i in 0..len3 { + let base = base3 + i *16; + result3.push({ + let len1 = *((base + 4) as *const i32) as usize; + let len2 = *((base + 12) as *const i32) as usize; + + (String::from_utf8(Vec::from_raw_parts(*((base + 0) as *const i32) as *mut _, len1, len1)).unwrap(), String::from_utf8(Vec::from_raw_parts(*((base + 8) as *const i32) as *mut _, len2, len2)).unwrap()) + }); + } + wit_bindgen::rt::dealloc(base3, (len3 as usize) * 16, 4); + result3 + } + } + #[allow(clippy::all)] + pub fn fields_clone(fields: Fields,) -> Fields{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-clone")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-clone")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(fields)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn finish_incoming_stream(s: IncomingStream,) -> Option{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "finish-incoming-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_finish-incoming-stream")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(s), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(*((ptr0 + 4) as *const i32) as u32), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn finish_outgoing_stream(s: OutgoingStream,trailers: Option,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let (result0_0,result0_1,) = match trailers { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "finish-outgoing-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_finish-outgoing-stream")] + fn wit_import( + _: i32, _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(s), result0_0, result0_1); + } + } + #[allow(clippy::all)] + pub fn drop_incoming_request(request: IncomingRequest,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-request")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request)); + } + } + #[allow(clippy::all)] + pub fn drop_outgoing_request(request: OutgoingRequest,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-request")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request)); + } + } + #[allow(clippy::all)] + pub fn incoming_request_method(request: IncomingRequest,) -> MethodResult{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 12]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-method")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-method")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => MethodResult::Get, + 1 => MethodResult::Head, + 2 => MethodResult::Post, + 3 => MethodResult::Put, + 4 => MethodResult::Delete, + 5 => MethodResult::Connect, + 6 => MethodResult::Options, + 7 => MethodResult::Trace, + 8 => MethodResult::Patch, + 9 => MethodResult::Other({ + let len1 = *((ptr0 + 8) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1)).unwrap() + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn incoming_request_path(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-path")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-path")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_query(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-query")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-query")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_scheme(request: IncomingRequest,) -> Option{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-scheme")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-scheme")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { + 0 => SchemeResult::Http, + 1 => SchemeResult::Https, + 2 => SchemeResult::Other({ + let len1 = *((ptr0 + 12) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 8) as *const i32) as *mut _, len1, len1)).unwrap() + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn incoming_request_authority(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-authority")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-authority")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_headers(request: IncomingRequest,) -> Headers{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-headers")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-headers")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(request)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn incoming_request_consume(request: IncomingRequest,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-consume")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-consume")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn new_outgoing_request(method: MethodParam<'_,>,path: &str,query: &str,scheme: Option>,authority: &str,headers: Headers,) -> OutgoingRequest{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let (result1_0,result1_1,result1_2,) = match method { + MethodParam::Get=> { + (0i32, 0i32, 0i32) + } + MethodParam::Head=> { + (1i32, 0i32, 0i32) + } + MethodParam::Post=> { + (2i32, 0i32, 0i32) + } + MethodParam::Put=> { + (3i32, 0i32, 0i32) + } + MethodParam::Delete=> { + (4i32, 0i32, 0i32) + } + MethodParam::Connect=> { + (5i32, 0i32, 0i32) + } + MethodParam::Options=> { + (6i32, 0i32, 0i32) + } + MethodParam::Trace=> { + (7i32, 0i32, 0i32) + } + MethodParam::Patch=> { + (8i32, 0i32, 0i32) + } + MethodParam::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + (9i32, ptr0, len0) + }, + }; + let vec2 = path; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + let vec3 = query; + let ptr3 = vec3.as_ptr() as i32; + let len3 = vec3.len() as i32; + let (result6_0,result6_1,result6_2,result6_3,) = match scheme { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + SchemeParam::Http=> { + (0i32, 0i32, 0i32) + } + SchemeParam::Https=> { + (1i32, 0i32, 0i32) + } + SchemeParam::Other(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr() as i32; + let len4 = vec4.len() as i32; + + (2i32, ptr4, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, 0i32, 0i32) + }, + };let vec7 = authority; + let ptr7 = vec7.as_ptr() as i32; + let len7 = vec7.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-request")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; + } + let ret = wit_import(result1_0, result1_1, result1_2, ptr2, len2, ptr3, len3, result6_0, result6_1, result6_2, result6_3, ptr7, len7, wit_bindgen::rt::as_i32(headers)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn outgoing_request_write(request: OutgoingRequest,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-request-write")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_outgoing-request-write")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_response_outparam(response: ResponseOutparam,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-response-outparam")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-response-outparam")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn set_response_outparam(response: Result>,) -> Result<(),()>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let (result5_0,result5_1,result5_2,result5_3,) = match response { + Ok(e) => { (0i32, wit_bindgen::rt::as_i32(e), 0i32, 0i32) }, + Err(e) => { { + let (result4_0,result4_1,result4_2,) = match e { + ErrorParam::InvalidUrl(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + (0i32, ptr0, len0) + }, + ErrorParam::TimeoutError(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + (1i32, ptr1, len1) + }, + ErrorParam::ProtocolError(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + + (2i32, ptr2, len2) + }, + ErrorParam::UnexpectedError(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr() as i32; + let len3 = vec3.len() as i32; + + (3i32, ptr3, len3) + }, + }; + + (1i32, result4_0, result4_1, result4_2) + } }, + }; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "set-response-outparam")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_set-response-outparam")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, ) -> i32; + } + let ret = wit_import(result5_0, result5_1, result5_2, result5_3); + match ret { + 0 => Ok(()), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_incoming_response(response: IncomingResponse,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-response")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn drop_outgoing_response(response: OutgoingResponse,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-response")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn incoming_response_status(response: IncomingResponse,) -> StatusCode{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-status")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-status")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(response)); + ret as u16 + } + } + #[allow(clippy::all)] + pub fn incoming_response_headers(response: IncomingResponse,) -> Headers{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-headers")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-headers")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(response)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn incoming_response_consume(response: IncomingResponse,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-consume")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-consume")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(response), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn new_outgoing_response(status_code: StatusCode,headers: Headers,) -> OutgoingResponse{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-response")] + fn wit_import( + _: i32, _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(status_code), wit_bindgen::rt::as_i32(headers)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn outgoing_response_write(response: OutgoingResponse,) -> Result{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-response-write")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_outgoing-response-write")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(response), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_future_incoming_response(f: FutureIncomingResponse,) -> (){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-future-incoming-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-future-incoming-response")] + fn wit_import( + _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(f)); + } + } + #[allow(clippy::all)] + pub fn future_incoming_response_get(f: FutureIncomingResponse,) -> Option>{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 20]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "future-incoming-response-get")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_future-incoming-response-get")] + fn wit_import( + _: i32, _: i32, ); + } + wit_import(wit_bindgen::rt::as_i32(f), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i32) as u32), + 1 => Err(match i32::from(*((ptr0 + 8) as *const u8)) { + 0 => ErrorResult::InvalidUrl({ + let len1 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len1, len1)).unwrap() + }), + 1 => ErrorResult::TimeoutError({ + let len2 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len2, len2)).unwrap() + }), + 2 => ErrorResult::ProtocolError({ + let len3 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len3, len3)).unwrap() + }), + 3 => ErrorResult::UnexpectedError({ + let len4 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len4, len4)).unwrap() + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn listen_to_future_incoming_response(f: FutureIncomingResponse,) -> Pollable{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "listen-to-future-incoming-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_listen-to-future-incoming-response")] + fn wit_import( + _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(f)); + ret as u32 + } + } + + } + + + #[allow(clippy::all)] + pub mod default_outgoing_http{ + pub type OutgoingRequest = super::types::OutgoingRequest; + pub type RequestOptions = super::types::RequestOptions; + pub type FutureIncomingResponse = super::types::FutureIncomingResponse; + #[allow(clippy::all)] + pub fn handle(request: OutgoingRequest,options: Option,) -> FutureIncomingResponse{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; + unsafe { + let (result4_0,result4_1,result4_2,result4_3,result4_4,result4_5,result4_6,) = match options { + Some(e) => { + let RequestOptions{ connect_timeout_ms:connect_timeout_ms0, first_byte_timeout_ms:first_byte_timeout_ms0, between_bytes_timeout_ms:between_bytes_timeout_ms0, } = e; + let (result1_0,result1_1,) = match connect_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let (result2_0,result2_1,) = match first_byte_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let (result3_0,result3_1,) = match between_bytes_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (1i32, result1_0, result1_1, result2_0, result2_1, result3_0, result3_1) + }, + None => { + (0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32) + }, + }; + #[link(wasm_import_module = "default-outgoing-HTTP")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "handle")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "default-outgoing-HTTP_handle")] + fn wit_import( + _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(request), result4_0, result4_1, result4_2, result4_3, result4_4, result4_5, result4_6); + ret as u32 + } + } + + } + + + #[allow(clippy::all)] + pub mod http{ + pub type IncomingRequest = super::types::IncomingRequest; + pub type ResponseOutparam = super::types::ResponseOutparam; + pub trait Http { + fn handle(request: IncomingRequest,response_out: ResponseOutparam,) -> (); + } + + #[doc(hidden)] + pub unsafe fn call_handle(arg0: i32,arg1: i32,) { + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + T::handle(arg0 as u32, arg1 as u32); + } + + } + + + /// Declares the export of the component's world for the + /// given type. + + macro_rules! export_proxy(($t:ident) => { + const _: () = { + + #[doc(hidden)] + #[export_name = "HTTP#handle"] + #[allow(non_snake_case)] + unsafe extern "C" fn __export_http_handle(arg0: i32,arg1: i32,) { + http::call_handle::<$t>(arg0,arg1,) + } + + }; + + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = __force_section_ref; + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + fn __force_section_ref() { + __link_section() + } + }); + + #[cfg(target_arch = "wasm32")] + #[link_section = "component-type:proxy"] + pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8155] = [2, 0, 3, 119, 105, 116, 5, 112, 114, 111, 120, 121, 5, 112, 114, 111, 120, 121, 0, 97, 115, 109, 12, 0, 1, 0, 7, 236, 17, 1, 65, 9, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 76, 4, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 11, 21, 1, 5, 116, 121, 112, 101, 115, 10, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 3, 0, 0, 7, 246, 8, 1, 65, 14, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 2, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 6, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 8, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 9, 11, 43, 1, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 2, 0, 7, 188, 8, 1, 65, 13, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 6, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 8, 11, 43, 1, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 4, 0, 7, 224, 26, 1, 65, 2, 1, 65, 22, 1, 66, 8, 1, 112, 125, 1, 64, 1, 3, 108, 101, 110, 119, 0, 0, 4, 16, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 98, 121, 116, 101, 115, 0, 1, 1, 1, 64, 0, 0, 119, 4, 14, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 117, 54, 52, 0, 1, 2, 1, 111, 2, 119, 119, 1, 64, 0, 0, 3, 4, 15, 105, 110, 115, 101, 99, 117, 114, 101, 45, 114, 97, 110, 100, 111, 109, 0, 1, 4, 3, 6, 114, 97, 110, 100, 111, 109, 26, 112, 97, 116, 104, 58, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 5, 0, 1, 66, 4, 1, 109, 5, 5, 116, 114, 97, 99, 101, 5, 100, 101, 98, 117, 103, 4, 105, 110, 102, 111, 4, 119, 97, 114, 110, 5, 101, 114, 114, 111, 114, 4, 5, 108, 101, 118, 101, 108, 0, 3, 0, 0, 1, 64, 3, 5, 108, 101, 118, 101, 108, 1, 7, 99, 111, 110, 116, 101, 120, 116, 115, 7, 109, 101, 115, 115, 97, 103, 101, 115, 1, 0, 4, 3, 108, 111, 103, 0, 1, 2, 3, 7, 99, 111, 110, 115, 111, 108, 101, 29, 112, 97, 116, 104, 58, 47, 108, 111, 103, 103, 105, 110, 103, 47, 104, 97, 110, 100, 108, 101, 114, 47, 104, 97, 110, 100, 108, 101, 114, 5, 1, 1, 66, 8, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 64, 1, 4, 116, 104, 105, 115, 1, 1, 0, 4, 13, 100, 114, 111, 112, 45, 112, 111, 108, 108, 97, 98, 108, 101, 0, 1, 2, 1, 112, 1, 1, 112, 125, 1, 64, 1, 2, 105, 110, 3, 0, 4, 4, 11, 112, 111, 108, 108, 45, 111, 110, 101, 111, 102, 102, 0, 1, 5, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 2, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 34, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 1, 112, 125, 1, 111, 2, 8, 127, 1, 106, 1, 9, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 10, 4, 4, 114, 101, 97, 100, 0, 1, 11, 1, 111, 2, 119, 127, 1, 106, 1, 12, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 13, 4, 4, 115, 107, 105, 112, 0, 1, 14, 1, 64, 1, 4, 116, 104, 105, 115, 7, 0, 1, 4, 25, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 15, 1, 64, 1, 4, 116, 104, 105, 115, 7, 1, 0, 4, 17, 100, 114, 111, 112, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 16, 1, 106, 1, 119, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 98, 117, 102, 8, 0, 17, 4, 5, 119, 114, 105, 116, 101, 0, 1, 18, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 108, 101, 110, 119, 0, 17, 4, 12, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 0, 1, 19, 1, 64, 3, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 3, 108, 101, 110, 119, 0, 13, 4, 6, 115, 112, 108, 105, 99, 101, 0, 1, 20, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 0, 17, 4, 7, 102, 111, 114, 119, 97, 114, 100, 0, 1, 21, 1, 64, 1, 4, 116, 104, 105, 115, 5, 0, 1, 4, 26, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 22, 1, 64, 1, 4, 116, 104, 105, 115, 5, 1, 0, 4, 18, 100, 114, 111, 112, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 23, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 4, 2, 3, 0, 3, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 3, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 5, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 6, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 76, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 7, 2, 3, 0, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 8, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 9, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 10, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 3, 21, 100, 101, 102, 97, 117, 108, 116, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 11, 2, 3, 0, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 12, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 13, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, 4, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 14, 4, 5, 112, 114, 111, 120, 121, 16, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, 47, 112, 114, 111, 120, 121, 4, 0, 0, 45, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 1, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 48, 46, 54, 46, 48, 11, 21, 1, 5, 112, 114, 111, 120, 121, 10, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, 3, 6, 0]; + + #[inline(never)] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + pub fn __link_section() {} + \ No newline at end of file diff --git a/crates/wasi-http/example/rust/src/main.rs b/crates/wasi-http/example/rust/src/main.rs new file mode 100644 index 000000000000..2339641e3b3a --- /dev/null +++ b/crates/wasi-http/example/rust/src/main.rs @@ -0,0 +1,52 @@ +use crate::proxy::types::new_fields; +use crate::proxy::types::new_outgoing_request; +use crate::proxy::types::MethodParam; +use crate::proxy::types::SchemeParam; + +pub mod proxy; + +fn request(method: MethodParam, scheme: Option, host: &str, path: &str) { + let headers = new_fields(&[ + ("Content-type", "text/plain"), + ("User-agent", "wasm32-wasi-rust"), + ]); + + let req = new_outgoing_request(method, path, "", scheme, host, headers); + let fut = crate::proxy::default_outgoing_http::handle(req, None); + let res = crate::proxy::types::future_incoming_response_get(fut) + .unwrap() + .unwrap(); + let code = crate::proxy::types::incoming_response_status(res); + let response_headers = crate::proxy::types::incoming_response_headers(res); + let stream = crate::proxy::types::incoming_response_consume(res).unwrap(); + let body = crate::proxy::streams::read(stream, 60 * 1024).unwrap().0; + + println!("Status is {}", code); + println!("Headers are:"); + let entries = crate::proxy::types::fields_entries(response_headers); + for tuple in entries.iter() { + println!("{}: {}", tuple.0, tuple.1); + } + println!("{}", String::from_utf8(body).unwrap()); +} + +fn main() { + request( + MethodParam::Get, + Some(SchemeParam::Https), + "postman-echo.com", + "/get", + ); + request( + MethodParam::Post, + Some(SchemeParam::Https), + "postman-echo.com", + "/post", + ); + request( + MethodParam::Put, + Some(SchemeParam::Http), + "postman-echo.com", + "/put", + ); +} diff --git a/crates/wasi-http/example/rust/src/proxy.rs b/crates/wasi-http/example/rust/src/proxy.rs new file mode 100644 index 000000000000..54b50aa79aa8 --- /dev/null +++ b/crates/wasi-http/example/rust/src/proxy.rs @@ -0,0 +1,2296 @@ +#[allow(clippy::all)] +pub mod random { + #[allow(clippy::all)] + /// Return `len` cryptographically-secure pseudo-random bytes. + /// + /// This function must produce data from an adequately seeded + /// cryptographically-secure pseudo-random number generator (CSPRNG), so it + /// must not block, from the perspective of the calling program, and the + /// returned data is always unpredictable. + /// + /// This function must always return fresh pseudo-random data. Deterministic + /// environments must omit this function, rather than implementing it with + /// deterministic data. + pub fn get_random_bytes(len: u64) -> wit_bindgen::rt::vec::Vec { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "get-random-bytes")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-bytes")] + fn wit_import(_: i64, _: i32); + } + wit_import(wit_bindgen::rt::as_i64(len), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1) + } + } + #[allow(clippy::all)] + /// Return a cryptographically-secure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-random-bytes`, represented as a `u64`. + pub fn get_random_u64() -> u64 { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "get-random-u64")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-u64")] + fn wit_import() -> i64; + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(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. + pub fn insecure_random() -> (u64, u64) { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "random")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "insecure-random")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_insecure-random")] + fn wit_import(_: i32); + } + wit_import(ptr0); + ( + *((ptr0 + 0) as *const i64) as u64, + *((ptr0 + 8) as *const i64) as u64, + ) + } + } +} + +#[allow(clippy::all)] +pub mod console { + /// A log level, describing a kind of message. + #[repr(u8)] + #[derive(Clone, Copy, PartialEq, Eq)] + pub enum Level { + /// Describes messages about the values of variables and the flow of + /// control within a program. + Trace, + /// Describes messages likely to be of interest to someone debugging a + /// program. + Debug, + /// Describes messages likely to be of interest to someone monitoring a + /// program. + Info, + /// Describes messages indicating hazardous situations. + Warn, + /// Describes messages indicating serious errors. + Error, + } + impl core::fmt::Debug for Level { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Level::Trace => f.debug_tuple("Level::Trace").finish(), + Level::Debug => f.debug_tuple("Level::Debug").finish(), + Level::Info => f.debug_tuple("Level::Info").finish(), + Level::Warn => f.debug_tuple("Level::Warn").finish(), + Level::Error => f.debug_tuple("Level::Error").finish(), + } + } + } + #[allow(clippy::all)] + /// Emit a log message. + /// + /// A log message has a `level` describing what kind of message is being + /// sent, a context, which is an uninterpreted string meant to help + /// consumers group similar messages, and a string containing the message + /// text. + pub fn log(level: Level, context: &str, message: &str) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let vec0 = context; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec1 = message; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + #[link(wasm_import_module = "console")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "log")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "console_log")] + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); + } + wit_import( + match level { + Level::Trace => 0, + Level::Debug => 1, + Level::Info => 2, + Level::Warn => 3, + Level::Error => 4, + }, + ptr0, + len0, + ptr1, + len1, + ); + } + } +} + +#[allow(clippy::all)] +pub mod poll { + /// A "pollable" handle. + /// + /// This is conceptually represents a `stream<_, _>`, or in other words, + /// a stream that one can wait on, repeatedly, but which does not itself + /// produce any data. It's temporary scaffolding until component-model's + /// async features are ready. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// `pollable` lifetimes are not automatically managed. Users must ensure + /// that they do not outlive the resource they reference. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type Pollable = u32; + #[allow(clippy::all)] + /// Dispose of the specified `pollable`, after which it may no longer + /// be used. + pub fn drop_pollable(this: Pollable) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "poll")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-pollable")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_drop-pollable")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } + #[allow(clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// The "oneoff" in the name refers to the fact that this function must do a + /// linear scan through the entire list of subscriptions, which may be + /// inefficient if the number is large and the same subscriptions are used + /// many times. In the future, this is expected to be obsoleted by the + /// component model async proposal, which will include a scalable waiting + /// facility. + /// + /// Note that the return type would ideally be `list`, but that would + /// be more difficult to polyfill given the current state of `wit-bindgen`. + /// See + /// for details. For now, we use zero to mean "not ready" and non-zero to + /// mean "ready". + pub fn poll_oneoff(in_: &[Pollable]) -> wit_bindgen::rt::vec::Vec { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = in_; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "poll")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "poll-oneoff")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_poll-oneoff")] + fn wit_import(_: i32, _: i32, _: i32); + } + wit_import(ptr0, len0, ptr1); + let len2 = *((ptr1 + 4) as *const i32) as usize; + Vec::from_raw_parts(*((ptr1 + 0) as *const i32) as *mut _, len2, len2) + } + } +} + +#[allow(clippy::all)] +pub mod streams { + pub type Pollable = super::poll::Pollable; + /// An error type returned from a stream operation. Currently this + /// doesn't provide any additional information. + #[repr(C)] + #[derive(Copy, Clone)] + pub struct StreamError {} + impl core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("StreamError").finish() + } + } + impl core::fmt::Display for StreamError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for StreamError {} + /// An output bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `output-stream`s are *non-blocking* to the extent practical on + /// underlying platforms. Except where specified otherwise, I/O operations also + /// always return promptly, after the number of bytes that can be written + /// promptly, which could even be zero. To wait for the stream to be ready to + /// accept data, the `subscribe-to-output-stream` function to obtain a + /// `pollable` which can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type OutputStream = u32; + /// An input bytestream. In the future, this will be replaced by handle + /// types. + /// + /// This conceptually represents a `stream`. It's temporary + /// scaffolding until component-model's async features are ready. + /// + /// `input-stream`s are *non-blocking* to the extent practical on underlying + /// platforms. I/O operations always return promptly; if fewer bytes are + /// promptly available than requested, they return the number of bytes promptly + /// available, which could even be zero. To wait for data to be available, + /// use the `subscribe-to-input-stream` function to obtain a `pollable` which + /// can be polled for using `wasi_poll`. + /// + /// And at present, it is a `u32` instead of being an actual handle, until + /// the wit-bindgen implementation of handles and resources is ready. + /// + /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). + pub type InputStream = u32; + #[allow(clippy::all)] + /// Read bytes from a stream. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool indicating whether the end of the stream + /// was reached. The returned list will contain up to `len` bytes; it + /// may return fewer than requested, but not more. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// If `len` is 0, it represents a request to read 0 bytes, which should + /// always succeed, assuming the stream hasn't reached its end yet, and + /// return an empty list. + /// + /// The len here is a `u64`, but some callees may not be able to allocate + /// a buffer as large as that would imply. + /// FIXME: describe what happens if allocation fails. + pub fn read( + this: InputStream, + len: u64, + ) -> Result<(wit_bindgen::rt::vec::Vec, bool), StreamError> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "read")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_read")] + fn wit_import(_: i32, _: i64, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(this), + wit_bindgen::rt::as_i64(len), + ptr0, + ); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok({ + let len1 = *((ptr0 + 8) as *const i32) as usize; + + ( + Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1), + match i32::from(*((ptr0 + 12) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + }, + ) + }), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Skip bytes from a stream. + /// + /// This is similar to the `read` function, but avoids copying the + /// bytes into the instance. + /// + /// Once a stream has reached the end, subsequent calls to read or + /// `skip` will always report end-of-stream rather than producing more + /// data. + /// + /// This function returns the number of bytes skipped, along with a bool + /// indicating whether the end of the stream was reached. The returned + /// value will be at most `len`; it may be less. + pub fn skip(this: InputStream, len: u64) -> Result<(u64, bool), StreamError> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 24]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "skip")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_skip")] + fn wit_import(_: i32, _: i64, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(this), + wit_bindgen::rt::as_i64(len), + ptr0, + ); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(( + *((ptr0 + 8) as *const i64) as u64, + match i32::from(*((ptr0 + 16) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + }, + )), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Create a `pollable` which will resolve once either the specified stream + /// has bytes available to read or the other end of the stream has been + /// closed. + pub fn subscribe_to_input_stream(this: InputStream) -> Pollable { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-input-stream")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "streams_subscribe-to-input-stream" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(this)); + ret as u32 + } + } + #[allow(clippy::all)] + /// Dispose of the specified `input-stream`, after which it may no longer + /// be used. + pub fn drop_input_stream(this: InputStream) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-input-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-input-stream")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } + #[allow(clippy::all)] + /// Write bytes to a stream. + /// + /// This function returns a `u64` indicating the number of bytes from + /// `buf` that were written; it may be less than the full list. + pub fn write(this: OutputStream, buf: &[u8]) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = buf; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "write")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write")] + fn wit_import(_: i32, _: i32, _: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(this), ptr0, len0, ptr1); + match i32::from(*((ptr1 + 0) as *const u8)) { + 0 => Ok(*((ptr1 + 8) as *const i64) as u64), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Write multiple zero bytes to a stream. + /// + /// This function returns a `u64` indicating the number of zero bytes + /// that were written; it may be less than `len`. + pub fn write_zeroes(this: OutputStream, len: u64) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "write-zeroes")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write-zeroes")] + fn wit_import(_: i32, _: i64, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(this), + wit_bindgen::rt::as_i64(len), + ptr0, + ); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i64) as u64), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Read from one stream and write to another. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + /// + /// Unlike other I/O functions, this function blocks until all the data + /// read from the input stream has been written to the output stream. + pub fn splice( + this: OutputStream, + src: InputStream, + len: u64, + ) -> Result<(u64, bool), StreamError> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 24]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "splice")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_splice")] + fn wit_import(_: i32, _: i32, _: i64, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(this), + wit_bindgen::rt::as_i32(src), + wit_bindgen::rt::as_i64(len), + ptr0, + ); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(( + *((ptr0 + 8) as *const i64) as u64, + match i32::from(*((ptr0 + 16) as *const u8)) { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + }, + )), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Forward the entire contents of an input stream to an output stream. + /// + /// This function repeatedly reads from the input stream and writes + /// the data to the output stream, until the end of the input stream + /// is reached, or an error is encountered. + /// + /// Unlike other I/O functions, this function blocks until the end + /// of the input stream is seen and all the data has been written to + /// the output stream. + /// + /// This function returns the number of bytes transferred. + pub fn forward(this: OutputStream, src: InputStream) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(8))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "forward")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_forward")] + fn wit_import(_: i32, _: i32, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(this), + wit_bindgen::rt::as_i32(src), + ptr0, + ); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i64) as u64), + 1 => Err(StreamError {}), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + /// Create a `pollable` which will resolve once either the specified stream + /// is ready to accept bytes or the other end of the stream has been closed. + pub fn subscribe_to_output_stream(this: OutputStream) -> Pollable { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-output-stream")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "streams_subscribe-to-output-stream" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(this)); + ret as u32 + } + } + #[allow(clippy::all)] + /// Dispose of the specified `output-stream`, after which it may no longer + /// be used. + pub fn drop_output_stream(this: OutputStream) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "streams")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-output-stream")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-output-stream")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(this)); + } + } +} + +#[allow(clippy::all)] +pub mod types { + pub type InputStream = super::streams::InputStream; + pub type OutputStream = super::streams::OutputStream; + pub type Pollable = super::poll::Pollable; + pub type StatusCode = u16; + #[derive(Clone)] + pub enum SchemeParam<'a> { + Http, + Https, + Other(&'a str), + } + impl<'a> core::fmt::Debug for SchemeParam<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + SchemeParam::Http => f.debug_tuple("SchemeParam::Http").finish(), + SchemeParam::Https => f.debug_tuple("SchemeParam::Https").finish(), + SchemeParam::Other(e) => f.debug_tuple("SchemeParam::Other").field(e).finish(), + } + } + } + #[derive(Clone)] + pub enum SchemeResult { + Http, + Https, + Other(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for SchemeResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + SchemeResult::Http => f.debug_tuple("SchemeResult::Http").finish(), + SchemeResult::Https => f.debug_tuple("SchemeResult::Https").finish(), + SchemeResult::Other(e) => f.debug_tuple("SchemeResult::Other").field(e).finish(), + } + } + } + pub type ResponseOutparam = u32; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct RequestOptions { + pub connect_timeout_ms: Option, + pub first_byte_timeout_ms: Option, + pub between_bytes_timeout_ms: Option, + } + impl core::fmt::Debug for RequestOptions { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("RequestOptions") + .field("connect-timeout-ms", &self.connect_timeout_ms) + .field("first-byte-timeout-ms", &self.first_byte_timeout_ms) + .field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms) + .finish() + } + } + pub type OutgoingStream = OutputStream; + pub type OutgoingResponse = u32; + pub type OutgoingRequest = u32; + #[derive(Clone)] + pub enum MethodParam<'a> { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(&'a str), + } + impl<'a> core::fmt::Debug for MethodParam<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MethodParam::Get => f.debug_tuple("MethodParam::Get").finish(), + MethodParam::Head => f.debug_tuple("MethodParam::Head").finish(), + MethodParam::Post => f.debug_tuple("MethodParam::Post").finish(), + MethodParam::Put => f.debug_tuple("MethodParam::Put").finish(), + MethodParam::Delete => f.debug_tuple("MethodParam::Delete").finish(), + MethodParam::Connect => f.debug_tuple("MethodParam::Connect").finish(), + MethodParam::Options => f.debug_tuple("MethodParam::Options").finish(), + MethodParam::Trace => f.debug_tuple("MethodParam::Trace").finish(), + MethodParam::Patch => f.debug_tuple("MethodParam::Patch").finish(), + MethodParam::Other(e) => f.debug_tuple("MethodParam::Other").field(e).finish(), + } + } + } + #[derive(Clone)] + pub enum MethodResult { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for MethodResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MethodResult::Get => f.debug_tuple("MethodResult::Get").finish(), + MethodResult::Head => f.debug_tuple("MethodResult::Head").finish(), + MethodResult::Post => f.debug_tuple("MethodResult::Post").finish(), + MethodResult::Put => f.debug_tuple("MethodResult::Put").finish(), + MethodResult::Delete => f.debug_tuple("MethodResult::Delete").finish(), + MethodResult::Connect => f.debug_tuple("MethodResult::Connect").finish(), + MethodResult::Options => f.debug_tuple("MethodResult::Options").finish(), + MethodResult::Trace => f.debug_tuple("MethodResult::Trace").finish(), + MethodResult::Patch => f.debug_tuple("MethodResult::Patch").finish(), + MethodResult::Other(e) => f.debug_tuple("MethodResult::Other").field(e).finish(), + } + } + } + pub type IncomingStream = InputStream; + pub type IncomingResponse = u32; + pub type IncomingRequest = u32; + pub type FutureIncomingResponse = u32; + pub type Fields = u32; + pub type Trailers = Fields; + pub type Headers = Fields; + #[derive(Clone)] + pub enum ErrorParam<'a> { + InvalidUrl(&'a str), + TimeoutError(&'a str), + ProtocolError(&'a str), + UnexpectedError(&'a str), + } + impl<'a> core::fmt::Debug for ErrorParam<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + ErrorParam::InvalidUrl(e) => { + f.debug_tuple("ErrorParam::InvalidUrl").field(e).finish() + } + ErrorParam::TimeoutError(e) => { + f.debug_tuple("ErrorParam::TimeoutError").field(e).finish() + } + ErrorParam::ProtocolError(e) => { + f.debug_tuple("ErrorParam::ProtocolError").field(e).finish() + } + ErrorParam::UnexpectedError(e) => f + .debug_tuple("ErrorParam::UnexpectedError") + .field(e) + .finish(), + } + } + } + impl<'a> core::fmt::Display for ErrorParam<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl<'a> std::error::Error for ErrorParam<'a> {} + #[derive(Clone)] + pub enum ErrorResult { + InvalidUrl(wit_bindgen::rt::string::String), + TimeoutError(wit_bindgen::rt::string::String), + ProtocolError(wit_bindgen::rt::string::String), + UnexpectedError(wit_bindgen::rt::string::String), + } + impl core::fmt::Debug for ErrorResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + ErrorResult::InvalidUrl(e) => { + f.debug_tuple("ErrorResult::InvalidUrl").field(e).finish() + } + ErrorResult::TimeoutError(e) => { + f.debug_tuple("ErrorResult::TimeoutError").field(e).finish() + } + ErrorResult::ProtocolError(e) => f + .debug_tuple("ErrorResult::ProtocolError") + .field(e) + .finish(), + ErrorResult::UnexpectedError(e) => f + .debug_tuple("ErrorResult::UnexpectedError") + .field(e) + .finish(), + } + } + } + impl core::fmt::Display for ErrorResult { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for ErrorResult {} + #[allow(clippy::all)] + pub fn drop_fields(fields: Fields) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-fields")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-fields")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(fields)); + } + } + #[allow(clippy::all)] + pub fn new_fields(entries: &[(&str, &str)]) -> Fields { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let vec3 = entries; + let len3 = vec3.len() as i32; + let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); + let result3 = if layout3.size() != 0 { + let ptr = alloc::alloc(layout3); + if ptr.is_null() { + alloc::handle_alloc_error(layout3); + } + ptr + } else { + core::ptr::null_mut() + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3 as i32 + (i as i32) * 16; + { + let (t0_0, t0_1) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + *((base + 4) as *mut i32) = len1; + *((base + 0) as *mut i32) = ptr1; + let vec2 = t0_1; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + *((base + 12) as *mut i32) = len2; + *((base + 8) as *mut i32) = ptr2; + } + } + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-fields")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-fields")] + fn wit_import(_: i32, _: i32) -> i32; + } + let ret = wit_import(result3 as i32, len3); + if layout3.size() != 0 { + alloc::dealloc(result3, layout3); + } + ret as u32 + } + } + #[allow(clippy::all)] + pub fn fields_get( + fields: Fields, + name: &str, + ) -> wit_bindgen::rt::vec::Vec { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let ptr1 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-get")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-get")] + fn wit_import(_: i32, _: i32, _: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1); + let base3 = *((ptr1 + 0) as *const i32); + let len3 = *((ptr1 + 4) as *const i32); + let mut result3 = Vec::with_capacity(len3 as usize); + for i in 0..len3 { + let base = base3 + i * 8; + result3.push({ + let len2 = *((base + 4) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((base + 0) as *const i32) as *mut _, + len2, + len2, + )) + .unwrap() + }); + } + wit_bindgen::rt::dealloc(base3, (len3 as usize) * 8, 4); + result3 + } + } + #[allow(clippy::all)] + pub fn fields_set(fields: Fields, name: &str, value: &[&str]) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec2 = value; + let len2 = vec2.len() as i32; + let layout2 = alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = alloc::alloc(layout2); + if ptr.is_null() { + alloc::handle_alloc_error(layout2); + } + ptr + } else { + core::ptr::null_mut() + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2 as i32 + (i as i32) * 8; + { + let vec1 = e; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + *((base + 4) as *mut i32) = len1; + *((base + 0) as *mut i32) = ptr1; + } + } + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-set")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-set")] + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); + } + wit_import( + wit_bindgen::rt::as_i32(fields), + ptr0, + len0, + result2 as i32, + len2, + ); + if layout2.size() != 0 { + alloc::dealloc(result2, layout2); + } + } + } + #[allow(clippy::all)] + pub fn fields_delete(fields: Fields, name: &str) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-delete")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-delete")] + fn wit_import(_: i32, _: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0); + } + } + #[allow(clippy::all)] + pub fn fields_append(fields: Fields, name: &str, value: &str) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + let vec1 = value; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-append")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-append")] + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1, len1); + } + } + #[allow(clippy::all)] + pub fn fields_entries( + fields: Fields, + ) -> wit_bindgen::rt::vec::Vec<( + wit_bindgen::rt::string::String, + wit_bindgen::rt::string::String, + )> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-entries")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-entries")] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(fields), ptr0); + let base3 = *((ptr0 + 0) as *const i32); + let len3 = *((ptr0 + 4) as *const i32); + let mut result3 = Vec::with_capacity(len3 as usize); + for i in 0..len3 { + let base = base3 + i * 16; + result3.push({ + let len1 = *((base + 4) as *const i32) as usize; + let len2 = *((base + 12) as *const i32) as usize; + + ( + String::from_utf8(Vec::from_raw_parts( + *((base + 0) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap(), + String::from_utf8(Vec::from_raw_parts( + *((base + 8) as *const i32) as *mut _, + len2, + len2, + )) + .unwrap(), + ) + }); + } + wit_bindgen::rt::dealloc(base3, (len3 as usize) * 16, 4); + result3 + } + } + #[allow(clippy::all)] + pub fn fields_clone(fields: Fields) -> Fields { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "fields-clone")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-clone")] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(fields)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn finish_incoming_stream(s: IncomingStream) -> Option { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "finish-incoming-stream")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_finish-incoming-stream" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(s), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(*((ptr0 + 4) as *const i32) as u32), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn finish_outgoing_stream(s: OutgoingStream, trailers: Option) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let (result0_0, result0_1) = match trailers { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => (0i32, 0i32), + }; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "finish-outgoing-stream")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_finish-outgoing-stream" + )] + fn wit_import(_: i32, _: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(s), result0_0, result0_1); + } + } + #[allow(clippy::all)] + pub fn drop_incoming_request(request: IncomingRequest) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-request")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(request)); + } + } + #[allow(clippy::all)] + pub fn drop_outgoing_request(request: OutgoingRequest) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-request")] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(request)); + } + } + #[allow(clippy::all)] + pub fn incoming_request_method(request: IncomingRequest) -> MethodResult { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 12]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-method")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-method" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => MethodResult::Get, + 1 => MethodResult::Head, + 2 => MethodResult::Post, + 3 => MethodResult::Put, + 4 => MethodResult::Delete, + 5 => MethodResult::Connect, + 6 => MethodResult::Options, + 7 => MethodResult::Trace, + 8 => MethodResult::Patch, + 9 => MethodResult::Other({ + let len1 = *((ptr0 + 8) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 4) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn incoming_request_path(request: IncomingRequest) -> wit_bindgen::rt::string::String { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-path")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-path")] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 0) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_query(request: IncomingRequest) -> wit_bindgen::rt::string::String { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-query")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-query" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 0) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_scheme(request: IncomingRequest) -> Option { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 16]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-scheme")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-scheme" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { + 0 => SchemeResult::Http, + 1 => SchemeResult::Https, + 2 => SchemeResult::Other({ + let len1 = *((ptr0 + 12) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 8) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn incoming_request_authority(request: IncomingRequest) -> wit_bindgen::rt::string::String { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-authority")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-authority" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + let len1 = *((ptr0 + 4) as *const i32) as usize; + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 0) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + } + } + #[allow(clippy::all)] + pub fn incoming_request_headers(request: IncomingRequest) -> Headers { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-headers")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-headers" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(request)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn incoming_request_consume(request: IncomingRequest) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-consume")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-request-consume" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn new_outgoing_request( + method: MethodParam<'_>, + path: &str, + query: &str, + scheme: Option>, + authority: &str, + headers: Headers, + ) -> OutgoingRequest { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let (result1_0, result1_1, result1_2) = match method { + MethodParam::Get => (0i32, 0i32, 0i32), + MethodParam::Head => (1i32, 0i32, 0i32), + MethodParam::Post => (2i32, 0i32, 0i32), + MethodParam::Put => (3i32, 0i32, 0i32), + MethodParam::Delete => (4i32, 0i32, 0i32), + MethodParam::Connect => (5i32, 0i32, 0i32), + MethodParam::Options => (6i32, 0i32, 0i32), + MethodParam::Trace => (7i32, 0i32, 0i32), + MethodParam::Patch => (8i32, 0i32, 0i32), + MethodParam::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + (9i32, ptr0, len0) + } + }; + let vec2 = path; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + let vec3 = query; + let ptr3 = vec3.as_ptr() as i32; + let len3 = vec3.len() as i32; + let (result6_0, result6_1, result6_2, result6_3) = match scheme { + Some(e) => { + let (result5_0, result5_1, result5_2) = match e { + SchemeParam::Http => (0i32, 0i32, 0i32), + SchemeParam::Https => (1i32, 0i32, 0i32), + SchemeParam::Other(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr() as i32; + let len4 = vec4.len() as i32; + + (2i32, ptr4, len4) + } + }; + + (1i32, result5_0, result5_1, result5_2) + } + None => (0i32, 0i32, 0i32, 0i32), + }; + let vec7 = authority; + let ptr7 = vec7.as_ptr() as i32; + let len7 = vec7.len() as i32; + + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-request")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-request")] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + ) -> i32; + } + let ret = wit_import( + result1_0, + result1_1, + result1_2, + ptr2, + len2, + ptr3, + len3, + result6_0, + result6_1, + result6_2, + result6_3, + ptr7, + len7, + wit_bindgen::rt::as_i32(headers), + ); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn outgoing_request_write(request: OutgoingRequest) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-request-write")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_outgoing-request-write" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(request), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_response_outparam(response: ResponseOutparam) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-response-outparam")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_drop-response-outparam" + )] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn set_response_outparam( + response: Result>, + ) -> Result<(), ()> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let (result5_0, result5_1, result5_2, result5_3) = match response { + Ok(e) => (0i32, wit_bindgen::rt::as_i32(e), 0i32, 0i32), + Err(e) => { + let (result4_0, result4_1, result4_2) = match e { + ErrorParam::InvalidUrl(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + (0i32, ptr0, len0) + } + ErrorParam::TimeoutError(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr() as i32; + let len1 = vec1.len() as i32; + + (1i32, ptr1, len1) + } + ErrorParam::ProtocolError(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + + (2i32, ptr2, len2) + } + ErrorParam::UnexpectedError(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr() as i32; + let len3 = vec3.len() as i32; + + (3i32, ptr3, len3) + } + }; + + (1i32, result4_0, result4_1, result4_2) + } + }; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "set-response-outparam")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_set-response-outparam")] + fn wit_import(_: i32, _: i32, _: i32, _: i32) -> i32; + } + let ret = wit_import(result5_0, result5_1, result5_2, result5_3); + match ret { + 0 => Ok(()), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_incoming_response(response: IncomingResponse) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-response")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_drop-incoming-response" + )] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn drop_outgoing_response(response: OutgoingResponse) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-response")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_drop-outgoing-response" + )] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(response)); + } + } + #[allow(clippy::all)] + pub fn incoming_response_status(response: IncomingResponse) -> StatusCode { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-status")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-response-status" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(response)); + ret as u16 + } + } + #[allow(clippy::all)] + pub fn incoming_response_headers(response: IncomingResponse) -> Headers { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-headers")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-response-headers" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(response)); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn incoming_response_consume(response: IncomingResponse) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-consume")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_incoming-response-consume" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(response), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn new_outgoing_response(status_code: StatusCode, headers: Headers) -> OutgoingResponse { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-response")] + #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-response")] + fn wit_import(_: i32, _: i32) -> i32; + } + let ret = wit_import( + wit_bindgen::rt::as_i32(status_code), + wit_bindgen::rt::as_i32(headers), + ); + ret as u32 + } + } + #[allow(clippy::all)] + pub fn outgoing_response_write(response: OutgoingResponse) -> Result { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-response-write")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_outgoing-response-write" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(response), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => Ok(*((ptr0 + 4) as *const i32) as u32), + 1 => Err(()), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn drop_future_incoming_response(f: FutureIncomingResponse) -> () { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "drop-future-incoming-response")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_drop-future-incoming-response" + )] + fn wit_import(_: i32); + } + wit_import(wit_bindgen::rt::as_i32(f)); + } + } + #[allow(clippy::all)] + pub fn future_incoming_response_get( + f: FutureIncomingResponse, + ) -> Option> { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[repr(align(4))] + struct RetArea([u8; 20]); + let mut ret_area = core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "future-incoming-response-get")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_future-incoming-response-get" + )] + fn wit_import(_: i32, _: i32); + } + wit_import(wit_bindgen::rt::as_i32(f), ptr0); + match i32::from(*((ptr0 + 0) as *const u8)) { + 0 => None, + 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { + 0 => Ok(*((ptr0 + 8) as *const i32) as u32), + 1 => Err(match i32::from(*((ptr0 + 8) as *const u8)) { + 0 => ErrorResult::InvalidUrl({ + let len1 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 12) as *const i32) as *mut _, + len1, + len1, + )) + .unwrap() + }), + 1 => ErrorResult::TimeoutError({ + let len2 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 12) as *const i32) as *mut _, + len2, + len2, + )) + .unwrap() + }), + 2 => ErrorResult::ProtocolError({ + let len3 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 12) as *const i32) as *mut _, + len3, + len3, + )) + .unwrap() + }), + 3 => ErrorResult::UnexpectedError({ + let len4 = *((ptr0 + 16) as *const i32) as usize; + + String::from_utf8(Vec::from_raw_parts( + *((ptr0 + 12) as *const i32) as *mut _, + len4, + len4, + )) + .unwrap() + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + }), + _ => panic!("invalid enum discriminant"), + } + } + } + #[allow(clippy::all)] + pub fn listen_to_future_incoming_response(f: FutureIncomingResponse) -> Pollable { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + #[link(wasm_import_module = "types")] + extern "C" { + #[cfg_attr( + target_arch = "wasm32", + link_name = "listen-to-future-incoming-response" + )] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "types_listen-to-future-incoming-response" + )] + fn wit_import(_: i32) -> i32; + } + let ret = wit_import(wit_bindgen::rt::as_i32(f)); + ret as u32 + } + } +} + +#[allow(clippy::all)] +pub mod default_outgoing_http { + pub type OutgoingRequest = super::types::OutgoingRequest; + pub type RequestOptions = super::types::RequestOptions; + pub type FutureIncomingResponse = super::types::FutureIncomingResponse; + #[allow(clippy::all)] + pub fn handle( + request: OutgoingRequest, + options: Option, + ) -> FutureIncomingResponse { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + unsafe { + let (result4_0, result4_1, result4_2, result4_3, result4_4, result4_5, result4_6) = + match options { + Some(e) => { + let RequestOptions { + connect_timeout_ms: connect_timeout_ms0, + first_byte_timeout_ms: first_byte_timeout_ms0, + between_bytes_timeout_ms: between_bytes_timeout_ms0, + } = e; + let (result1_0, result1_1) = match connect_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => (0i32, 0i32), + }; + let (result2_0, result2_1) = match first_byte_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => (0i32, 0i32), + }; + let (result3_0, result3_1) = match between_bytes_timeout_ms0 { + Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 1i32, result1_0, result1_1, result2_0, result2_1, result3_0, result3_1, + ) + } + None => (0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32), + }; + #[link(wasm_import_module = "default-outgoing-HTTP")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "handle")] + #[cfg_attr( + not(target_arch = "wasm32"), + link_name = "default-outgoing-HTTP_handle" + )] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + _: i32, + ) -> i32; + } + let ret = wit_import( + wit_bindgen::rt::as_i32(request), + result4_0, + result4_1, + result4_2, + result4_3, + result4_4, + result4_5, + result4_6, + ); + ret as u32 + } + } +} + +#[allow(clippy::all)] +pub mod http { + pub type IncomingRequest = super::types::IncomingRequest; + pub type ResponseOutparam = super::types::ResponseOutparam; + pub trait Http { + fn handle(request: IncomingRequest, response_out: ResponseOutparam) -> (); + } + + #[doc(hidden)] + pub unsafe fn call_handle(arg0: i32, arg1: i32) { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, string::String, vec::Vec}; + T::handle(arg0 as u32, arg1 as u32); + } +} + +/// Declares the export of the component's world for the +/// given type. + +macro_rules! export_proxy(($t:ident) => { + const _: () = { + + #[doc(hidden)] + #[export_name = "HTTP#handle"] + #[allow(non_snake_case)] + unsafe extern "C" fn __export_http_handle(arg0: i32,arg1: i32,) { + http::call_handle::<$t>(arg0,arg1,) + } + + }; + + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = __force_section_ref; + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + fn __force_section_ref() { + __link_section() + } + }); + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:proxy"] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8155] = [ + 2, 0, 3, 119, 105, 116, 5, 112, 114, 111, 120, 121, 5, 112, 114, 111, 120, 121, 0, 97, 115, + 109, 12, 0, 1, 0, 7, 236, 17, 1, 65, 9, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, + 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, + 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, + 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, + 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, + 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, + 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, + 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, + 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, + 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, + 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, + 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, + 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, + 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, + 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, + 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, + 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, + 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, + 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, + 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, + 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, + 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, + 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, + 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, + 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, + 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, + 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, + 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, + 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, + 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, + 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, + 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, + 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, + 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, + 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, + 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, + 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, + 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, + 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, + 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, + 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, + 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, + 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, + 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, + 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, + 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, + 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, + 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, + 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, + 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, + 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, + 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, + 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, + 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, + 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, + 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, + 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, + 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, + 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, + 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, + 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, + 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, + 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, + 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, + 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, + 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, + 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, + 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, + 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, + 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, + 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, + 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, + 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, + 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, + 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, + 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, + 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, + 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, + 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, + 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, + 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, + 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, + 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, + 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, + 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, + 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, + 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, + 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, + 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, + 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, + 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, + 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, + 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, + 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, + 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, + 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, + 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, + 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, + 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, + 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, + 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, + 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, + 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, + 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, + 115, 101, 0, 1, 76, 4, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, + 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 11, 21, 1, 5, 116, 121, 112, 101, 115, 10, 112, + 107, 103, 58, 47, 116, 121, 112, 101, 115, 3, 0, 0, 7, 246, 8, 1, 65, 14, 1, 66, 2, 1, 121, 4, + 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, + 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, + 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, + 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, + 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, + 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, + 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, + 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, + 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, + 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, + 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, + 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, + 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, + 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, + 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, + 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, + 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, + 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, + 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, + 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, + 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, + 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, + 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, + 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, + 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, + 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, + 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, + 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, + 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, + 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, + 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, + 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, + 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, + 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, + 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, + 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, + 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, + 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, + 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, + 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, + 5, 2, 3, 0, 2, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, + 116, 2, 3, 0, 2, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, + 2, 3, 0, 2, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, + 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 6, 4, 16, 111, 117, 116, 103, + 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 15, + 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, + 1, 8, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, + 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, + 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, + 0, 1, 7, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, + 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, + 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, + 9, 11, 43, 1, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, + 21, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, + 101, 114, 3, 2, 0, 7, 188, 8, 1, 65, 13, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, + 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, + 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, + 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, + 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, + 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, + 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, + 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, + 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, + 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, + 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, + 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, + 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, + 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, + 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, + 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, + 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, + 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, + 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, + 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, + 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, + 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, + 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, + 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, + 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, + 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, + 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, + 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, + 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, + 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, + 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, + 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, + 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, + 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, + 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, + 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, + 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, + 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, + 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, + 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, + 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 17, 114, 101, 115, + 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 6, 4, + 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, + 2, 3, 2, 1, 7, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, + 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, + 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, + 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, + 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, + 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 8, 11, 43, 1, + 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, + 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 4, + 0, 7, 224, 26, 1, 65, 2, 1, 65, 22, 1, 66, 8, 1, 112, 125, 1, 64, 1, 3, 108, 101, 110, 119, 0, + 0, 4, 16, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 98, 121, 116, 101, 115, 0, 1, 1, + 1, 64, 0, 0, 119, 4, 14, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 117, 54, 52, 0, 1, + 2, 1, 111, 2, 119, 119, 1, 64, 0, 0, 3, 4, 15, 105, 110, 115, 101, 99, 117, 114, 101, 45, 114, + 97, 110, 100, 111, 109, 0, 1, 4, 3, 6, 114, 97, 110, 100, 111, 109, 26, 112, 97, 116, 104, 58, + 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, + 109, 5, 0, 1, 66, 4, 1, 109, 5, 5, 116, 114, 97, 99, 101, 5, 100, 101, 98, 117, 103, 4, 105, + 110, 102, 111, 4, 119, 97, 114, 110, 5, 101, 114, 114, 111, 114, 4, 5, 108, 101, 118, 101, 108, + 0, 3, 0, 0, 1, 64, 3, 5, 108, 101, 118, 101, 108, 1, 7, 99, 111, 110, 116, 101, 120, 116, 115, + 7, 109, 101, 115, 115, 97, 103, 101, 115, 1, 0, 4, 3, 108, 111, 103, 0, 1, 2, 3, 7, 99, 111, + 110, 115, 111, 108, 101, 29, 112, 97, 116, 104, 58, 47, 108, 111, 103, 103, 105, 110, 103, 47, + 104, 97, 110, 100, 108, 101, 114, 47, 104, 97, 110, 100, 108, 101, 114, 5, 1, 1, 66, 8, 1, 121, + 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 64, 1, 4, 116, 104, 105, 115, 1, 1, + 0, 4, 13, 100, 114, 111, 112, 45, 112, 111, 108, 108, 97, 98, 108, 101, 0, 1, 2, 1, 112, 1, 1, + 112, 125, 1, 64, 1, 2, 105, 110, 3, 0, 4, 4, 11, 112, 111, 108, 108, 45, 111, 110, 101, 111, + 102, 102, 0, 1, 5, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, + 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 2, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, + 98, 108, 101, 1, 66, 34, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, + 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, + 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, + 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 1, 112, 125, 1, 111, + 2, 8, 127, 1, 106, 1, 9, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, + 10, 4, 4, 114, 101, 97, 100, 0, 1, 11, 1, 111, 2, 119, 127, 1, 106, 1, 12, 1, 3, 1, 64, 2, 4, + 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 13, 4, 4, 115, 107, 105, 112, 0, 1, 14, 1, 64, + 1, 4, 116, 104, 105, 115, 7, 0, 1, 4, 25, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, + 111, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 15, 1, 64, 1, 4, 116, + 104, 105, 115, 7, 1, 0, 4, 17, 100, 114, 111, 112, 45, 105, 110, 112, 117, 116, 45, 115, 116, + 114, 101, 97, 109, 0, 1, 16, 1, 106, 1, 119, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 98, + 117, 102, 8, 0, 17, 4, 5, 119, 114, 105, 116, 101, 0, 1, 18, 1, 64, 2, 4, 116, 104, 105, 115, + 5, 3, 108, 101, 110, 119, 0, 17, 4, 12, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, + 115, 0, 1, 19, 1, 64, 3, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 3, 108, 101, 110, 119, + 0, 13, 4, 6, 115, 112, 108, 105, 99, 101, 0, 1, 20, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 115, + 114, 99, 7, 0, 17, 4, 7, 102, 111, 114, 119, 97, 114, 100, 0, 1, 21, 1, 64, 1, 4, 116, 104, + 105, 115, 5, 0, 1, 4, 26, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 111, 117, + 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 22, 1, 64, 1, 4, 116, 104, 105, 115, + 5, 1, 0, 4, 18, 100, 114, 111, 112, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, + 97, 109, 0, 1, 23, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, + 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 4, 2, 3, 0, + 3, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 3, 13, 111, 117, 116, + 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 5, 4, 12, 105, 110, + 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 6, 4, 13, 111, 117, + 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 3, 4, 8, 112, 111, + 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, + 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, + 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, + 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, + 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, + 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, + 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, + 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, + 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, + 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, + 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, + 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, + 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, + 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, + 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, + 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, + 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, + 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, + 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, + 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, + 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, + 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, + 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, + 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, + 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, + 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, + 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, + 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, + 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, + 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, + 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, + 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, + 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, + 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, + 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, + 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, + 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, + 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, + 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, + 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, + 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, + 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, + 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, + 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, + 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, + 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, + 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, + 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, + 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, + 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, + 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, + 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, + 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, + 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, + 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, + 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, + 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, + 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, + 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, + 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, + 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, + 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, + 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, + 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, + 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, + 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, + 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, + 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, + 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, + 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, + 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, + 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, + 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, + 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, + 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, + 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, + 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, + 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, + 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, + 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, + 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, + 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, + 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, + 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, + 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, + 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, + 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, + 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, + 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, + 115, 112, 111, 110, 115, 101, 0, 1, 76, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, + 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 7, 2, 3, 0, 4, 16, 111, 117, 116, + 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 15, 114, 101, 113, + 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 4, 24, 102, 117, 116, 117, + 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, + 101, 1, 66, 9, 2, 3, 2, 1, 8, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, + 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 9, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, + 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 10, 4, 24, 102, 117, 116, 117, 114, + 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, + 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, + 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 3, 21, 100, 101, 102, 97, + 117, 108, 116, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 72, 84, 84, 80, 38, 112, 107, + 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, + 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 11, 2, 3, 0, + 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, + 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, + 6, 2, 3, 2, 1, 12, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, + 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 13, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, + 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, + 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, + 100, 108, 101, 0, 1, 4, 4, 4, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, + 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, + 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 14, 4, 5, 112, 114, 111, 120, 121, 16, 112, 107, + 103, 58, 47, 112, 114, 111, 120, 121, 47, 112, 114, 111, 120, 121, 4, 0, 0, 45, 9, 112, 114, + 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, + 121, 1, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 48, 46, 54, 46, + 48, 11, 21, 1, 5, 112, 114, 111, 120, 121, 10, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, + 3, 6, 0, +]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} From 57a86aa6fdb13a802121a84852a3e9da8e1282b0 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 30 Mar 2023 15:34:00 +0000 Subject: [PATCH 20/46] Update to latest wit definition --- crates/wasi-http/src/types_impl.rs | 1 + crates/wasi-http/wasi-http | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index da735c78b1db..61e5d3b1ae0f 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -190,6 +190,7 @@ impl crate::types::Host for WasiHttp { } fn set_response_outparam( &mut self, + _outparam: ResponseOutparam, _response: Result, ) -> wasmtime::Result> { bail!("unimplemented: set_response_outparam") diff --git a/crates/wasi-http/wasi-http b/crates/wasi-http/wasi-http index 1185b0a0224b..244e068c2de4 160000 --- a/crates/wasi-http/wasi-http +++ b/crates/wasi-http/wasi-http @@ -1 +1 @@ -Subproject commit 1185b0a0224bc3e11274ad6298fd065cae472651 +Subproject commit 244e068c2de43088bda308fcdf51ed2479d885f5 From 3372ab070301097377a2865f74505a06f80cacf6 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 30 Mar 2023 15:35:03 +0000 Subject: [PATCH 21/46] Remove example code. --- crates/wasi-http/example/.gitignore | 5 - crates/wasi-http/example/Makefile | 17 - crates/wasi-http/example/main.c | 117 - crates/wasi-http/example/rust/Cargo.lock | 379 ---- crates/wasi-http/example/rust/Cargo.toml | 7 - crates/wasi-http/example/rust/Makefile | 17 - crates/wasi-http/example/rust/proxy.rs | 1901 ---------------- crates/wasi-http/example/rust/src/main.rs | 52 - crates/wasi-http/example/rust/src/proxy.rs | 2296 -------------------- 9 files changed, 4791 deletions(-) delete mode 100644 crates/wasi-http/example/.gitignore delete mode 100644 crates/wasi-http/example/Makefile delete mode 100644 crates/wasi-http/example/main.c delete mode 100644 crates/wasi-http/example/rust/Cargo.lock delete mode 100644 crates/wasi-http/example/rust/Cargo.toml delete mode 100644 crates/wasi-http/example/rust/Makefile delete mode 100644 crates/wasi-http/example/rust/proxy.rs delete mode 100644 crates/wasi-http/example/rust/src/main.rs delete mode 100644 crates/wasi-http/example/rust/src/proxy.rs diff --git a/crates/wasi-http/example/.gitignore b/crates/wasi-http/example/.gitignore deleted file mode 100644 index 8aedca81004c..000000000000 --- a/crates/wasi-http/example/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -proxy.c -proxy.h -proxy_component_type.o -**/*.wasm -rust/target/** diff --git a/crates/wasi-http/example/Makefile b/crates/wasi-http/example/Makefile deleted file mode 100644 index e6274d3cdf1c..000000000000 --- a/crates/wasi-http/example/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -cc := /wasi-sdk-19.0/bin/clang - -.phony: gen clean run - -default: main.wasm - -gen: - wit-bindgen c ../wit - -main.wasm: gen - ${cc} proxy.c proxy_component_type.o main.c -o main.wasm - -clean: - rm -f proxy.c proxy_component_type.o proxy.h main.wasm - -run: main.wasm - ../../../target/debug/wasmtime --wasi-modules=experimental-wasi-http main.wasm \ No newline at end of file diff --git a/crates/wasi-http/example/main.c b/crates/wasi-http/example/main.c deleted file mode 100644 index 87ae9133eb0f..000000000000 --- a/crates/wasi-http/example/main.c +++ /dev/null @@ -1,117 +0,0 @@ -#include "proxy.h" -#include - -void http_handle(uint32_t arg, uint32_t arg0) { - -} - -int request(uint8_t method_tag, uint8_t scheme_tag, const char * authority_str, const char* path_str, const char* query_str, const char* body) { - types_tuple2_string_string_t content_type[] = {{ - .f0 = { .ptr = "User-agent", .len = 10 }, - .f1 = { .ptr = "WASI-HTTP/0.0.1", .len = 15}, - }, - { - .f0 = { .ptr = "Content-type", .len = 12 }, - .f1 = { .ptr = "application/json", .len = 16}, - }}; - types_list_tuple2_string_string_t headers_list = { - .ptr = &content_type[0], - .len = 2, - }; - types_fields_t headers = types_new_fields(&headers_list); - types_method_t method = { .tag = method_tag }; - types_scheme_t scheme = { .tag = scheme_tag }; - proxy_string_t path, authority, query; - proxy_string_set(&path, path_str); - proxy_string_set(&authority, authority_str); - proxy_string_set(&query, query_str); - - default_outgoing_http_outgoing_request_t req = types_new_outgoing_request(&method, &path, &query, &scheme, &authority, headers); - default_outgoing_http_future_incoming_response_t res; - - if (req == 0) { - printf("Error creating request\n"); - return 4; - } - if (body != NULL) { - types_outgoing_stream_t ret; - if (!types_outgoing_request_write(req, &ret)) { - printf("Error getting output stream\n"); - return 7; - } - streams_list_u8_t buf = { - .ptr = (uint8_t *) body, - .len = strlen(body), - }; - uint64_t ret_val; - streams_write(ret, &buf, &ret_val, NULL); - } - - res = default_outgoing_http_handle(req, NULL); - if (res == 0) { - printf("Error sending request\n"); - return 5; - } - - types_result_incoming_response_error_t result; - if (!types_future_incoming_response_get(res, &result)) { - printf("failed to get value for incoming request\n"); - return 1; - } - - if (result.is_err) { - printf("response is error!\n"); - return 2; - } - // poll_drop_pollable(res); - - types_status_code_t code = types_incoming_response_status(result.val.ok); - printf("STATUS: %d\n", code); - - types_headers_t header_handle = types_incoming_response_headers(result.val.ok); - types_list_tuple2_string_string_t header_list; - types_fields_entries(header_handle, &header_list); - - for (int i = 0; i < header_list.len; i++) { - char name[128]; - char value[128]; - strncpy(name, header_list.ptr[i].f0.ptr, header_list.ptr[i].f0.len); - name[header_list.ptr[i].f0.len] = 0; - strncpy(value, header_list.ptr[i].f1.ptr, header_list.ptr[i].f1.len); - value[header_list.ptr[i].f1.len] = 0; - printf("%s: %s\n", name, value); - } - - - types_incoming_stream_t stream; - if (!types_incoming_response_consume(result.val.ok, &stream)) { - printf("stream is error!\n"); - return 3; - } - - printf("Stream is %d\n", stream); - - int32_t len = 64 * 1024; - streams_tuple2_list_u8_bool_t body_res; - streams_stream_error_t err; - if (!streams_read(stream, len, &body_res, &err)) { - printf("BODY read is error!\n"); - return 6; - } - printf("data from read: %s\n", body_res.f0.ptr); - streams_tuple2_list_u8_bool_free(&body_res); - - - types_drop_outgoing_request(req); - streams_drop_input_stream(stream); - types_drop_incoming_response(result.val.ok); - - return 0; -} - -int main() { - request(TYPES_METHOD_GET, TYPES_SCHEME_HTTPS, "postman-echo.com", "/get", "?some=arg&goes=here", NULL); - request(TYPES_METHOD_POST, TYPES_SCHEME_HTTPS, "postman-echo.com", "/post", "", "{\"foo\": \"bar\"}"); - request(TYPES_METHOD_PUT, TYPES_SCHEME_HTTP, "postman-echo.com", "/put", "", NULL); - return 0; -} \ No newline at end of file diff --git a/crates/wasi-http/example/rust/Cargo.lock b/crates/wasi-http/example/rust/Cargo.lock deleted file mode 100644 index b24cfb109d75..000000000000 --- a/crates/wasi-http/example/rust/Cargo.lock +++ /dev/null @@ -1,379 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "id-arena" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "proc-macro2" -version = "1.0.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "pulldown-cmark" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" -dependencies = [ - "bitflags", - "memchr", - "unicase", -] - -[[package]] -name = "quote" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rust" -version = "0.1.0" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "serde" -version = "1.0.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.10", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasm-encoder" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" -dependencies = [ - "leb128", -] - -[[package]] -name = "wasm-metadata" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6956efd8a1a2c48a707e9a1b2da729834a0f8e4c58117493b0d9d089cee468" -dependencies = [ - "anyhow", - "indexmap", - "serde", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.102.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" -dependencies = [ - "indexmap", - "url", -] - -[[package]] -name = "wit-bindgen" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7cf57f8786216c5652e1228b25203af2ff523808b5e9d3671894eee2bf7264" -dependencies = [ - "bitflags", - "wit-bindgen-rust-macro", -] - -[[package]] -name = "wit-bindgen-core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef177b73007d86c720931d0e2ea7e30eb8c9776e58361717743fc1e83cfacfe5" -dependencies = [ - "anyhow", - "wit-component", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efdf5b00935b7b52d0e56cae1960f8ac13019a285f5aa762ff6bd7139a5c28a2" -dependencies = [ - "heck", - "wasm-metadata", - "wit-bindgen-core", - "wit-bindgen-rust-lib", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-lib" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0a8f4b5fb1820b9d232beb122936425f72ec8fe6acb56e5d8782cfe55083da" -dependencies = [ - "heck", - "wit-bindgen-core", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadf1adf12ed25629b06272c16b335ef8c5a240d0ca64ab508a955ac3b46172c" -dependencies = [ - "anyhow", - "proc-macro2", - "syn 1.0.109", - "wit-bindgen-core", - "wit-bindgen-rust", - "wit-component", -] - -[[package]] -name = "wit-component" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed04310239706efc71cc8b995cb0226089c5b5fd260c3bd800a71486bd3cec97" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "url", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "pulldown-cmark", - "unicode-xid", - "url", -] diff --git a/crates/wasi-http/example/rust/Cargo.toml b/crates/wasi-http/example/rust/Cargo.toml deleted file mode 100644 index b22a2aef9b55..000000000000 --- a/crates/wasi-http/example/rust/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "rust" -version = "0.1.0" -edition = "2021" - -[dependencies] -wit-bindgen = { features = ["macros", "realloc"] } \ No newline at end of file diff --git a/crates/wasi-http/example/rust/Makefile b/crates/wasi-http/example/rust/Makefile deleted file mode 100644 index 14eb26e6e30d..000000000000 --- a/crates/wasi-http/example/rust/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -cc := /wasi-sdk-19.0/bin/clang - -.phony: gen clean run - -default: target/debug/rust.wasm - -gen: - wit-bindgen rust ../../wit - -target/wasm32-wasi/debug/rust.wasm: gen - cargo build --target=wasm32-wasi - -clean: - rm -rf proxy.rs target - -run: target/wasm32-wasi/debug/rust.wasm - ../../../../target/debug/wasmtime --wasi-modules=experimental-wasi-http target/wasm32-wasi/debug/rust.wasm \ No newline at end of file diff --git a/crates/wasi-http/example/rust/proxy.rs b/crates/wasi-http/example/rust/proxy.rs deleted file mode 100644 index 5e65d25da6bc..000000000000 --- a/crates/wasi-http/example/rust/proxy.rs +++ /dev/null @@ -1,1901 +0,0 @@ - -#[allow(clippy::all)] -pub mod random{ - #[allow(clippy::all)] - /// Return `len` cryptographically-secure pseudo-random bytes. - /// - /// This function must produce data from an adequately seeded - /// cryptographically-secure pseudo-random number generator (CSPRNG), so it - /// must not block, from the perspective of the calling program, and the - /// returned data is always unpredictable. - /// - /// This function must always return fresh pseudo-random data. Deterministic - /// environments must omit this function, rather than implementing it with - /// deterministic data. - pub fn get_random_bytes(len: u64,) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "get-random-bytes")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-bytes")] - fn wit_import( - _: i64, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i64(len), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1) - } - } - #[allow(clippy::all)] - /// Return a cryptographically-secure pseudo-random `u64` value. - /// - /// This function returns the same type of pseudo-random data as - /// `get-random-bytes`, represented as a `u64`. - pub fn get_random_u64() -> u64{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "get-random-u64")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-u64")] - fn wit_import( - ) -> i64; - } - let ret = wit_import(); - ret as u64 - } - } - #[allow(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. - pub fn insecure_random() -> (u64,u64,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "insecure-random")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_insecure-random")] - fn wit_import( - _: i32, ); - } - wit_import(ptr0); - (*((ptr0 + 0) as *const i64) as u64, *((ptr0 + 8) as *const i64) as u64) - } - } - -} - - -#[allow(clippy::all)] -pub mod console{ - /// A log level, describing a kind of message. - #[repr(u8)] - #[derive(Clone, Copy, PartialEq, Eq)] - pub enum Level { - /// Describes messages about the values of variables and the flow of - /// control within a program. - Trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. - Debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. - Info, - /// Describes messages indicating hazardous situations. - Warn, - /// Describes messages indicating serious errors. - Error, - } - impl core::fmt::Debug for Level { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Level::Trace => { - f.debug_tuple("Level::Trace").finish() - } - Level::Debug => { - f.debug_tuple("Level::Debug").finish() - } - Level::Info => { - f.debug_tuple("Level::Info").finish() - } - Level::Warn => { - f.debug_tuple("Level::Warn").finish() - } - Level::Error => { - f.debug_tuple("Level::Error").finish() - } - } - } - } - #[allow(clippy::all)] - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. - pub fn log(level: Level,context: &str,message: &str,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let vec0 = context; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = message; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[link(wasm_import_module = "console")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "log")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "console_log")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - wit_import(match level { - Level::Trace => 0, - Level::Debug => 1, - Level::Info => 2, - Level::Warn => 3, - Level::Error => 4, - }, ptr0, len0, ptr1, len1); - } - } - -} - - -#[allow(clippy::all)] -pub mod poll{ - /// A "pollable" handle. - /// - /// This is conceptually represents a `stream<_, _>`, or in other words, - /// a stream that one can wait on, repeatedly, but which does not itself - /// produce any data. It's temporary scaffolding until component-model's - /// async features are ready. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// `pollable` lifetimes are not automatically managed. Users must ensure - /// that they do not outlive the resource they reference. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type Pollable = u32; - #[allow(clippy::all)] - /// Dispose of the specified `pollable`, after which it may no longer - /// be used. - pub fn drop_pollable(this: Pollable,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "poll")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-pollable")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_drop-pollable")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } - #[allow(clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// The "oneoff" in the name refers to the fact that this function must do a - /// linear scan through the entire list of subscriptions, which may be - /// inefficient if the number is large and the same subscriptions are used - /// many times. In the future, this is expected to be obsoleted by the - /// component model async proposal, which will include a scalable waiting - /// facility. - /// - /// Note that the return type would ideally be `list`, but that would - /// be more difficult to polyfill given the current state of `wit-bindgen`. - /// See - /// for details. For now, we use zero to mean "not ready" and non-zero to - /// mean "ready". - pub fn poll_oneoff(in_: &[Pollable],) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = in_; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "poll")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "poll-oneoff")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_poll-oneoff")] - fn wit_import( - _: i32, _: i32, _: i32, ); - } - wit_import(ptr0, len0, ptr1); - let len2 = *((ptr1 + 4) as *const i32) as usize; - Vec::from_raw_parts(*((ptr1 + 0) as *const i32) as *mut _, len2, len2) - } - } - -} - - -#[allow(clippy::all)] -pub mod streams{ - pub type Pollable = super::poll::Pollable; - /// An error type returned from a stream operation. Currently this - /// doesn't provide any additional information. - #[repr(C)] - #[derive(Copy, Clone)] - pub struct StreamError { - } - impl core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("StreamError").finish() - } - } - impl core::fmt::Display for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self) - } - } - impl std::error::Error for StreamError{} - /// An output bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `output-stream`s are *non-blocking* to the extent practical on - /// underlying platforms. Except where specified otherwise, I/O operations also - /// always return promptly, after the number of bytes that can be written - /// promptly, which could even be zero. To wait for the stream to be ready to - /// accept data, the `subscribe-to-output-stream` function to obtain a - /// `pollable` which can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type OutputStream = u32; - /// An input bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `input-stream`s are *non-blocking* to the extent practical on underlying - /// platforms. I/O operations always return promptly; if fewer bytes are - /// promptly available than requested, they return the number of bytes promptly - /// available, which could even be zero. To wait for data to be available, - /// use the `subscribe-to-input-stream` function to obtain a `pollable` which - /// can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type InputStream = u32; - #[allow(clippy::all)] - /// Read bytes from a stream. - /// - /// This function returns a list of bytes containing the data that was - /// read, along with a bool indicating whether the end of the stream - /// was reached. The returned list will contain up to `len` bytes; it - /// may return fewer than requested, but not more. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// If `len` is 0, it represents a request to read 0 bytes, which should - /// always succeed, assuming the stream hasn't reached its end yet, and - /// return an empty list. - /// - /// The len here is a `u64`, but some callees may not be able to allocate - /// a buffer as large as that would imply. - /// FIXME: describe what happens if allocation fails. - pub fn read(this: InputStream,len: u64,) -> Result<(wit_bindgen::rt::vec::Vec::,bool,),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "read")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_read")] - fn wit_import( - _: i32, _: i64, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok({ - let len1 = *((ptr0 + 8) as *const i32) as usize; - - (Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1), match i32::from(*((ptr0 + 12) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - }) - }), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Skip bytes from a stream. - /// - /// This is similar to the `read` function, but avoids copying the - /// bytes into the instance. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// This function returns the number of bytes skipped, along with a bool - /// indicating whether the end of the stream was reached. The returned - /// value will be at most `len`; it may be less. - pub fn skip(this: InputStream,len: u64,) -> Result<(u64,bool,),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 24]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "skip")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_skip")] - fn wit_import( - _: i32, _: i64, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok((*((ptr0 + 8) as *const i64) as u64, match i32::from(*((ptr0 + 16) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - })), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Create a `pollable` which will resolve once either the specified stream - /// has bytes available to read or the other end of the stream has been - /// closed. - pub fn subscribe_to_input_stream(this: InputStream,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-input-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_subscribe-to-input-stream")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(this)); - ret as u32 - } - } - #[allow(clippy::all)] - /// Dispose of the specified `input-stream`, after which it may no longer - /// be used. - pub fn drop_input_stream(this: InputStream,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-input-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-input-stream")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } - #[allow(clippy::all)] - /// Write bytes to a stream. - /// - /// This function returns a `u64` indicating the number of bytes from - /// `buf` that were written; it may be less than the full list. - pub fn write(this: OutputStream,buf: &[u8],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = buf; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "write")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), ptr0, len0, ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(*((ptr1 + 8) as *const i64) as u64), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Write multiple zero bytes to a stream. - /// - /// This function returns a `u64` indicating the number of zero bytes - /// that were written; it may be less than `len`. - pub fn write_zeroes(this: OutputStream,len: u64,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "write-zeroes")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write-zeroes")] - fn wit_import( - _: i32, _: i64, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i64(len), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i64) as u64), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Read from one stream and write to another. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - /// - /// Unlike other I/O functions, this function blocks until all the data - /// read from the input stream has been written to the output stream. - pub fn splice(this: OutputStream,src: InputStream,len: u64,) -> Result<(u64,bool,),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 24]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "splice")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_splice")] - fn wit_import( - _: i32, _: i32, _: i64, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i32(src), wit_bindgen::rt::as_i64(len), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok((*((ptr0 + 8) as *const i64) as u64, match i32::from(*((ptr0 + 16) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - })), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Forward the entire contents of an input stream to an output stream. - /// - /// This function repeatedly reads from the input stream and writes - /// the data to the output stream, until the end of the input stream - /// is reached, or an error is encountered. - /// - /// Unlike other I/O functions, this function blocks until the end - /// of the input stream is seen and all the data has been written to - /// the output stream. - /// - /// This function returns the number of bytes transferred. - pub fn forward(this: OutputStream,src: InputStream,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "forward")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_forward")] - fn wit_import( - _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this), wit_bindgen::rt::as_i32(src), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i64) as u64), - 1 => Err(StreamError{}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Create a `pollable` which will resolve once either the specified stream - /// is ready to accept bytes or the other end of the stream has been closed. - pub fn subscribe_to_output_stream(this: OutputStream,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-output-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_subscribe-to-output-stream")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(this)); - ret as u32 - } - } - #[allow(clippy::all)] - /// Dispose of the specified `output-stream`, after which it may no longer - /// be used. - pub fn drop_output_stream(this: OutputStream,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-output-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-output-stream")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } - -} - - -#[allow(clippy::all)] -pub mod types{ - pub type InputStream = super::streams::InputStream; - pub type OutputStream = super::streams::OutputStream; - pub type Pollable = super::poll::Pollable; - pub type StatusCode = u16; - #[derive(Clone)] - pub enum SchemeParam<'a,>{ - Http, - Https, - Other(&'a str), - } - impl<'a,> core::fmt::Debug for SchemeParam<'a,> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - SchemeParam::Http => { - f.debug_tuple("SchemeParam::Http").finish() - } - SchemeParam::Https => { - f.debug_tuple("SchemeParam::Https").finish() - } - SchemeParam::Other(e) => { - f.debug_tuple("SchemeParam::Other").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub enum SchemeResult{ - Http, - Https, - Other(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for SchemeResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - SchemeResult::Http => { - f.debug_tuple("SchemeResult::Http").finish() - } - SchemeResult::Https => { - f.debug_tuple("SchemeResult::Https").finish() - } - SchemeResult::Other(e) => { - f.debug_tuple("SchemeResult::Other").field(e).finish() - } - } - } - } - pub type ResponseOutparam = u32; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct RequestOptions { - pub connect_timeout_ms: Option, - pub first_byte_timeout_ms: Option, - pub between_bytes_timeout_ms: Option, - } - impl core::fmt::Debug for RequestOptions { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("RequestOptions").field("connect-timeout-ms", &self.connect_timeout_ms).field("first-byte-timeout-ms", &self.first_byte_timeout_ms).field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms).finish() - } - } - pub type OutgoingStream = OutputStream; - pub type OutgoingResponse = u32; - pub type OutgoingRequest = u32; - #[derive(Clone)] - pub enum MethodParam<'a,>{ - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(&'a str), - } - impl<'a,> core::fmt::Debug for MethodParam<'a,> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - MethodParam::Get => { - f.debug_tuple("MethodParam::Get").finish() - } - MethodParam::Head => { - f.debug_tuple("MethodParam::Head").finish() - } - MethodParam::Post => { - f.debug_tuple("MethodParam::Post").finish() - } - MethodParam::Put => { - f.debug_tuple("MethodParam::Put").finish() - } - MethodParam::Delete => { - f.debug_tuple("MethodParam::Delete").finish() - } - MethodParam::Connect => { - f.debug_tuple("MethodParam::Connect").finish() - } - MethodParam::Options => { - f.debug_tuple("MethodParam::Options").finish() - } - MethodParam::Trace => { - f.debug_tuple("MethodParam::Trace").finish() - } - MethodParam::Patch => { - f.debug_tuple("MethodParam::Patch").finish() - } - MethodParam::Other(e) => { - f.debug_tuple("MethodParam::Other").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub enum MethodResult{ - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for MethodResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - MethodResult::Get => { - f.debug_tuple("MethodResult::Get").finish() - } - MethodResult::Head => { - f.debug_tuple("MethodResult::Head").finish() - } - MethodResult::Post => { - f.debug_tuple("MethodResult::Post").finish() - } - MethodResult::Put => { - f.debug_tuple("MethodResult::Put").finish() - } - MethodResult::Delete => { - f.debug_tuple("MethodResult::Delete").finish() - } - MethodResult::Connect => { - f.debug_tuple("MethodResult::Connect").finish() - } - MethodResult::Options => { - f.debug_tuple("MethodResult::Options").finish() - } - MethodResult::Trace => { - f.debug_tuple("MethodResult::Trace").finish() - } - MethodResult::Patch => { - f.debug_tuple("MethodResult::Patch").finish() - } - MethodResult::Other(e) => { - f.debug_tuple("MethodResult::Other").field(e).finish() - } - } - } - } - pub type IncomingStream = InputStream; - pub type IncomingResponse = u32; - pub type IncomingRequest = u32; - pub type FutureIncomingResponse = u32; - pub type Fields = u32; - pub type Trailers = Fields; - pub type Headers = Fields; - #[derive(Clone)] - pub enum ErrorParam<'a,>{ - InvalidUrl(&'a str), - TimeoutError(&'a str), - ProtocolError(&'a str), - UnexpectedError(&'a str), - } - impl<'a,> core::fmt::Debug for ErrorParam<'a,> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ErrorParam::InvalidUrl(e) => { - f.debug_tuple("ErrorParam::InvalidUrl").field(e).finish() - } - ErrorParam::TimeoutError(e) => { - f.debug_tuple("ErrorParam::TimeoutError").field(e).finish() - } - ErrorParam::ProtocolError(e) => { - f.debug_tuple("ErrorParam::ProtocolError").field(e).finish() - } - ErrorParam::UnexpectedError(e) => { - f.debug_tuple("ErrorParam::UnexpectedError").field(e).finish() - } - } - } - } - impl<'a,> core::fmt::Display for ErrorParam<'a,> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self)} - } - - impl<'a,> std::error::Error for ErrorParam<'a,> {} - #[derive(Clone)] - pub enum ErrorResult{ - InvalidUrl(wit_bindgen::rt::string::String), - TimeoutError(wit_bindgen::rt::string::String), - ProtocolError(wit_bindgen::rt::string::String), - UnexpectedError(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for ErrorResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ErrorResult::InvalidUrl(e) => { - f.debug_tuple("ErrorResult::InvalidUrl").field(e).finish() - } - ErrorResult::TimeoutError(e) => { - f.debug_tuple("ErrorResult::TimeoutError").field(e).finish() - } - ErrorResult::ProtocolError(e) => { - f.debug_tuple("ErrorResult::ProtocolError").field(e).finish() - } - ErrorResult::UnexpectedError(e) => { - f.debug_tuple("ErrorResult::UnexpectedError").field(e).finish() - } - } - } - } - impl core::fmt::Display for ErrorResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self)} - } - - impl std::error::Error for ErrorResult {} - #[allow(clippy::all)] - pub fn drop_fields(fields: Fields,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-fields")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-fields")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields)); - } - } - #[allow(clippy::all)] - pub fn new_fields(entries: &[(&str,&str,)],) -> Fields{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let vec3 = entries; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); - let result3 = if layout3.size() != 0 - { - let ptr = alloc::alloc(layout3); - if ptr.is_null() - { - alloc::handle_alloc_error(layout3); - } - ptr - }else { - core::ptr::null_mut() - }; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3 as i32 + (i as i32) * 16; - { - let (t0_0, t0_1, ) = e; - let vec1 = t0_0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - let vec2 = t0_1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - *((base + 12) as *mut i32) = len2; - *((base + 8) as *mut i32) = ptr2; - - }} - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-fields")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-fields")] - fn wit_import( - _: i32, _: i32, ) -> i32; - } - let ret = wit_import(result3 as i32, len3); - if layout3.size() != 0 { - alloc::dealloc(result3, layout3); - } - ret as u32 - } - } - #[allow(clippy::all)] - pub fn fields_get(fields: Fields,name: &str,) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-get")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-get")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1); - let base3 = *((ptr1 + 0) as *const i32); - let len3 = *((ptr1 + 4) as *const i32); - let mut result3 = Vec::with_capacity(len3 as usize); - for i in 0..len3 { - let base = base3 + i *8; - result3.push({ - let len2 = *((base + 4) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((base + 0) as *const i32) as *mut _, len2, len2)).unwrap() - }); - } - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 8, 4); - result3 - } - } - #[allow(clippy::all)] - pub fn fields_set(fields: Fields,name: &str,value: &[&str],) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = value; - let len2 = vec2.len() as i32; - let layout2 = alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = if layout2.size() != 0 - { - let ptr = alloc::alloc(layout2); - if ptr.is_null() - { - alloc::handle_alloc_error(layout2); - } - ptr - }else { - core::ptr::null_mut() - }; - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - - }} - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-set")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-set")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, result2 as i32, len2); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - } - } - #[allow(clippy::all)] - pub fn fields_delete(fields: Fields,name: &str,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-delete")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-delete")] - fn wit_import( - _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0); - } - } - #[allow(clippy::all)] - pub fn fields_append(fields: Fields,name: &str,value: &str,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = value; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-append")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-append")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1, len1); - } - } - #[allow(clippy::all)] - pub fn fields_entries(fields: Fields,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-entries")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-entries")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0); - let base3 = *((ptr0 + 0) as *const i32); - let len3 = *((ptr0 + 4) as *const i32); - let mut result3 = Vec::with_capacity(len3 as usize); - for i in 0..len3 { - let base = base3 + i *16; - result3.push({ - let len1 = *((base + 4) as *const i32) as usize; - let len2 = *((base + 12) as *const i32) as usize; - - (String::from_utf8(Vec::from_raw_parts(*((base + 0) as *const i32) as *mut _, len1, len1)).unwrap(), String::from_utf8(Vec::from_raw_parts(*((base + 8) as *const i32) as *mut _, len2, len2)).unwrap()) - }); - } - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 16, 4); - result3 - } - } - #[allow(clippy::all)] - pub fn fields_clone(fields: Fields,) -> Fields{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-clone")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-clone")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(fields)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn finish_incoming_stream(s: IncomingStream,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "finish-incoming-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_finish-incoming-stream")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(s), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(*((ptr0 + 4) as *const i32) as u32), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn finish_outgoing_stream(s: OutgoingStream,trailers: Option,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let (result0_0,result0_1,) = match trailers { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "finish-outgoing-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_finish-outgoing-stream")] - fn wit_import( - _: i32, _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(s), result0_0, result0_1); - } - } - #[allow(clippy::all)] - pub fn drop_incoming_request(request: IncomingRequest,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-request")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request)); - } - } - #[allow(clippy::all)] - pub fn drop_outgoing_request(request: OutgoingRequest,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-request")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request)); - } - } - #[allow(clippy::all)] - pub fn incoming_request_method(request: IncomingRequest,) -> MethodResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 12]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-method")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-method")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => MethodResult::Get, - 1 => MethodResult::Head, - 2 => MethodResult::Post, - 3 => MethodResult::Put, - 4 => MethodResult::Delete, - 5 => MethodResult::Connect, - 6 => MethodResult::Options, - 7 => MethodResult::Trace, - 8 => MethodResult::Patch, - 9 => MethodResult::Other({ - let len1 = *((ptr0 + 8) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1)).unwrap() - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn incoming_request_path(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-path")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-path")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_query(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-query")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-query")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_scheme(request: IncomingRequest,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-scheme")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-scheme")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { - 0 => SchemeResult::Http, - 1 => SchemeResult::Https, - 2 => SchemeResult::Other({ - let len1 = *((ptr0 + 12) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 8) as *const i32) as *mut _, len1, len1)).unwrap() - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn incoming_request_authority(request: IncomingRequest,) -> wit_bindgen::rt::string::String{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-authority")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-authority")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1)).unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_headers(request: IncomingRequest,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-headers")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-headers")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(request)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn incoming_request_consume(request: IncomingRequest,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-consume")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-consume")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn new_outgoing_request(method: MethodParam<'_,>,path: &str,query: &str,scheme: Option>,authority: &str,headers: Headers,) -> OutgoingRequest{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let (result1_0,result1_1,result1_2,) = match method { - MethodParam::Get=> { - (0i32, 0i32, 0i32) - } - MethodParam::Head=> { - (1i32, 0i32, 0i32) - } - MethodParam::Post=> { - (2i32, 0i32, 0i32) - } - MethodParam::Put=> { - (3i32, 0i32, 0i32) - } - MethodParam::Delete=> { - (4i32, 0i32, 0i32) - } - MethodParam::Connect=> { - (5i32, 0i32, 0i32) - } - MethodParam::Options=> { - (6i32, 0i32, 0i32) - } - MethodParam::Trace=> { - (7i32, 0i32, 0i32) - } - MethodParam::Patch=> { - (8i32, 0i32, 0i32) - } - MethodParam::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (9i32, ptr0, len0) - }, - }; - let vec2 = path; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = query; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let (result6_0,result6_1,result6_2,result6_3,) = match scheme { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - SchemeParam::Http=> { - (0i32, 0i32, 0i32) - } - SchemeParam::Https=> { - (1i32, 0i32, 0i32) - } - SchemeParam::Other(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - (2i32, ptr4, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, 0i32, 0i32) - }, - };let vec7 = authority; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-request")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - let ret = wit_import(result1_0, result1_1, result1_2, ptr2, len2, ptr3, len3, result6_0, result6_1, result6_2, result6_3, ptr7, len7, wit_bindgen::rt::as_i32(headers)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn outgoing_request_write(request: OutgoingRequest,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-request-write")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_outgoing-request-write")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_response_outparam(response: ResponseOutparam,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-response-outparam")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-response-outparam")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn set_response_outparam(response: Result>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let (result5_0,result5_1,result5_2,result5_3,) = match response { - Ok(e) => { (0i32, wit_bindgen::rt::as_i32(e), 0i32, 0i32) }, - Err(e) => { { - let (result4_0,result4_1,result4_2,) = match e { - ErrorParam::InvalidUrl(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (0i32, ptr0, len0) - }, - ErrorParam::TimeoutError(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - (1i32, ptr1, len1) - }, - ErrorParam::ProtocolError(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - - (2i32, ptr2, len2) - }, - ErrorParam::UnexpectedError(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - (3i32, ptr3, len3) - }, - }; - - (1i32, result4_0, result4_1, result4_2) - } }, - }; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "set-response-outparam")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_set-response-outparam")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - let ret = wit_import(result5_0, result5_1, result5_2, result5_3); - match ret { - 0 => Ok(()), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_incoming_response(response: IncomingResponse,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-response")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn drop_outgoing_response(response: OutgoingResponse,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-response")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn incoming_response_status(response: IncomingResponse,) -> StatusCode{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-status")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-status")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(response)); - ret as u16 - } - } - #[allow(clippy::all)] - pub fn incoming_response_headers(response: IncomingResponse,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-headers")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-headers")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(response)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn incoming_response_consume(response: IncomingResponse,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-consume")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-response-consume")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(response), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn new_outgoing_response(status_code: StatusCode,headers: Headers,) -> OutgoingResponse{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-response")] - fn wit_import( - _: i32, _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(status_code), wit_bindgen::rt::as_i32(headers)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn outgoing_response_write(response: OutgoingResponse,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-response-write")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_outgoing-response-write")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(response), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_future_incoming_response(f: FutureIncomingResponse,) -> (){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-future-incoming-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-future-incoming-response")] - fn wit_import( - _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(f)); - } - } - #[allow(clippy::all)] - pub fn future_incoming_response_get(f: FutureIncomingResponse,) -> Option>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[repr(align(4))] - struct RetArea([u8; 20]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "future-incoming-response-get")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_future-incoming-response-get")] - fn wit_import( - _: i32, _: i32, ); - } - wit_import(wit_bindgen::rt::as_i32(f), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i32) as u32), - 1 => Err(match i32::from(*((ptr0 + 8) as *const u8)) { - 0 => ErrorResult::InvalidUrl({ - let len1 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len1, len1)).unwrap() - }), - 1 => ErrorResult::TimeoutError({ - let len2 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len2, len2)).unwrap() - }), - 2 => ErrorResult::ProtocolError({ - let len3 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len3, len3)).unwrap() - }), - 3 => ErrorResult::UnexpectedError({ - let len4 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts(*((ptr0 + 12) as *const i32) as *mut _, len4, len4)).unwrap() - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn listen_to_future_incoming_response(f: FutureIncomingResponse,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "listen-to-future-incoming-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_listen-to-future-incoming-response")] - fn wit_import( - _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(f)); - ret as u32 - } - } - - } - - - #[allow(clippy::all)] - pub mod default_outgoing_http{ - pub type OutgoingRequest = super::types::OutgoingRequest; - pub type RequestOptions = super::types::RequestOptions; - pub type FutureIncomingResponse = super::types::FutureIncomingResponse; - #[allow(clippy::all)] - pub fn handle(request: OutgoingRequest,options: Option,) -> FutureIncomingResponse{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{{alloc, vec::Vec, string::String}}; - unsafe { - let (result4_0,result4_1,result4_2,result4_3,result4_4,result4_5,result4_6,) = match options { - Some(e) => { - let RequestOptions{ connect_timeout_ms:connect_timeout_ms0, first_byte_timeout_ms:first_byte_timeout_ms0, between_bytes_timeout_ms:between_bytes_timeout_ms0, } = e; - let (result1_0,result1_1,) = match connect_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result2_0,result2_1,) = match first_byte_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result3_0,result3_1,) = match between_bytes_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result1_0, result1_1, result2_0, result2_1, result3_0, result3_1) - }, - None => { - (0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32) - }, - }; - #[link(wasm_import_module = "default-outgoing-HTTP")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "handle")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "default-outgoing-HTTP_handle")] - fn wit_import( - _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(request), result4_0, result4_1, result4_2, result4_3, result4_4, result4_5, result4_6); - ret as u32 - } - } - - } - - - #[allow(clippy::all)] - pub mod http{ - pub type IncomingRequest = super::types::IncomingRequest; - pub type ResponseOutparam = super::types::ResponseOutparam; - pub trait Http { - fn handle(request: IncomingRequest,response_out: ResponseOutparam,) -> (); - } - - #[doc(hidden)] - pub unsafe fn call_handle(arg0: i32,arg1: i32,) { - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - T::handle(arg0 as u32, arg1 as u32); - } - - } - - - /// Declares the export of the component's world for the - /// given type. - - macro_rules! export_proxy(($t:ident) => { - const _: () = { - - #[doc(hidden)] - #[export_name = "HTTP#handle"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_http_handle(arg0: i32,arg1: i32,) { - http::call_handle::<$t>(arg0,arg1,) - } - - }; - - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = __force_section_ref; - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - fn __force_section_ref() { - __link_section() - } - }); - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:proxy"] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8155] = [2, 0, 3, 119, 105, 116, 5, 112, 114, 111, 120, 121, 5, 112, 114, 111, 120, 121, 0, 97, 115, 109, 12, 0, 1, 0, 7, 236, 17, 1, 65, 9, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 76, 4, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 11, 21, 1, 5, 116, 121, 112, 101, 115, 10, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 3, 0, 0, 7, 246, 8, 1, 65, 14, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 2, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 6, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 8, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 9, 11, 43, 1, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 2, 0, 7, 188, 8, 1, 65, 13, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 6, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 8, 11, 43, 1, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 4, 0, 7, 224, 26, 1, 65, 2, 1, 65, 22, 1, 66, 8, 1, 112, 125, 1, 64, 1, 3, 108, 101, 110, 119, 0, 0, 4, 16, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 98, 121, 116, 101, 115, 0, 1, 1, 1, 64, 0, 0, 119, 4, 14, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 117, 54, 52, 0, 1, 2, 1, 111, 2, 119, 119, 1, 64, 0, 0, 3, 4, 15, 105, 110, 115, 101, 99, 117, 114, 101, 45, 114, 97, 110, 100, 111, 109, 0, 1, 4, 3, 6, 114, 97, 110, 100, 111, 109, 26, 112, 97, 116, 104, 58, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 5, 0, 1, 66, 4, 1, 109, 5, 5, 116, 114, 97, 99, 101, 5, 100, 101, 98, 117, 103, 4, 105, 110, 102, 111, 4, 119, 97, 114, 110, 5, 101, 114, 114, 111, 114, 4, 5, 108, 101, 118, 101, 108, 0, 3, 0, 0, 1, 64, 3, 5, 108, 101, 118, 101, 108, 1, 7, 99, 111, 110, 116, 101, 120, 116, 115, 7, 109, 101, 115, 115, 97, 103, 101, 115, 1, 0, 4, 3, 108, 111, 103, 0, 1, 2, 3, 7, 99, 111, 110, 115, 111, 108, 101, 29, 112, 97, 116, 104, 58, 47, 108, 111, 103, 103, 105, 110, 103, 47, 104, 97, 110, 100, 108, 101, 114, 47, 104, 97, 110, 100, 108, 101, 114, 5, 1, 1, 66, 8, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 64, 1, 4, 116, 104, 105, 115, 1, 1, 0, 4, 13, 100, 114, 111, 112, 45, 112, 111, 108, 108, 97, 98, 108, 101, 0, 1, 2, 1, 112, 1, 1, 112, 125, 1, 64, 1, 2, 105, 110, 3, 0, 4, 4, 11, 112, 111, 108, 108, 45, 111, 110, 101, 111, 102, 102, 0, 1, 5, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 2, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 34, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 1, 112, 125, 1, 111, 2, 8, 127, 1, 106, 1, 9, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 10, 4, 4, 114, 101, 97, 100, 0, 1, 11, 1, 111, 2, 119, 127, 1, 106, 1, 12, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 13, 4, 4, 115, 107, 105, 112, 0, 1, 14, 1, 64, 1, 4, 116, 104, 105, 115, 7, 0, 1, 4, 25, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 15, 1, 64, 1, 4, 116, 104, 105, 115, 7, 1, 0, 4, 17, 100, 114, 111, 112, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 16, 1, 106, 1, 119, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 98, 117, 102, 8, 0, 17, 4, 5, 119, 114, 105, 116, 101, 0, 1, 18, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 108, 101, 110, 119, 0, 17, 4, 12, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 0, 1, 19, 1, 64, 3, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 3, 108, 101, 110, 119, 0, 13, 4, 6, 115, 112, 108, 105, 99, 101, 0, 1, 20, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 0, 17, 4, 7, 102, 111, 114, 119, 97, 114, 100, 0, 1, 21, 1, 64, 1, 4, 116, 104, 105, 115, 5, 0, 1, 4, 26, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 22, 1, 64, 1, 4, 116, 104, 105, 115, 5, 1, 0, 4, 18, 100, 114, 111, 112, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 23, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 4, 2, 3, 0, 3, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 3, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 5, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 6, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 76, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 7, 2, 3, 0, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 8, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 9, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 10, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 3, 21, 100, 101, 102, 97, 117, 108, 116, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 11, 2, 3, 0, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 12, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 13, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, 4, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 14, 4, 5, 112, 114, 111, 120, 121, 16, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, 47, 112, 114, 111, 120, 121, 4, 0, 0, 45, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 1, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 48, 46, 54, 46, 48, 11, 21, 1, 5, 112, 114, 111, 120, 121, 10, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, 3, 6, 0]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file diff --git a/crates/wasi-http/example/rust/src/main.rs b/crates/wasi-http/example/rust/src/main.rs deleted file mode 100644 index 2339641e3b3a..000000000000 --- a/crates/wasi-http/example/rust/src/main.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::proxy::types::new_fields; -use crate::proxy::types::new_outgoing_request; -use crate::proxy::types::MethodParam; -use crate::proxy::types::SchemeParam; - -pub mod proxy; - -fn request(method: MethodParam, scheme: Option, host: &str, path: &str) { - let headers = new_fields(&[ - ("Content-type", "text/plain"), - ("User-agent", "wasm32-wasi-rust"), - ]); - - let req = new_outgoing_request(method, path, "", scheme, host, headers); - let fut = crate::proxy::default_outgoing_http::handle(req, None); - let res = crate::proxy::types::future_incoming_response_get(fut) - .unwrap() - .unwrap(); - let code = crate::proxy::types::incoming_response_status(res); - let response_headers = crate::proxy::types::incoming_response_headers(res); - let stream = crate::proxy::types::incoming_response_consume(res).unwrap(); - let body = crate::proxy::streams::read(stream, 60 * 1024).unwrap().0; - - println!("Status is {}", code); - println!("Headers are:"); - let entries = crate::proxy::types::fields_entries(response_headers); - for tuple in entries.iter() { - println!("{}: {}", tuple.0, tuple.1); - } - println!("{}", String::from_utf8(body).unwrap()); -} - -fn main() { - request( - MethodParam::Get, - Some(SchemeParam::Https), - "postman-echo.com", - "/get", - ); - request( - MethodParam::Post, - Some(SchemeParam::Https), - "postman-echo.com", - "/post", - ); - request( - MethodParam::Put, - Some(SchemeParam::Http), - "postman-echo.com", - "/put", - ); -} diff --git a/crates/wasi-http/example/rust/src/proxy.rs b/crates/wasi-http/example/rust/src/proxy.rs deleted file mode 100644 index 54b50aa79aa8..000000000000 --- a/crates/wasi-http/example/rust/src/proxy.rs +++ /dev/null @@ -1,2296 +0,0 @@ -#[allow(clippy::all)] -pub mod random { - #[allow(clippy::all)] - /// Return `len` cryptographically-secure pseudo-random bytes. - /// - /// This function must produce data from an adequately seeded - /// cryptographically-secure pseudo-random number generator (CSPRNG), so it - /// must not block, from the perspective of the calling program, and the - /// returned data is always unpredictable. - /// - /// This function must always return fresh pseudo-random data. Deterministic - /// environments must omit this function, rather than implementing it with - /// deterministic data. - pub fn get_random_bytes(len: u64) -> wit_bindgen::rt::vec::Vec { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "get-random-bytes")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-bytes")] - fn wit_import(_: i64, _: i32); - } - wit_import(wit_bindgen::rt::as_i64(len), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - Vec::from_raw_parts(*((ptr0 + 0) as *const i32) as *mut _, len1, len1) - } - } - #[allow(clippy::all)] - /// Return a cryptographically-secure pseudo-random `u64` value. - /// - /// This function returns the same type of pseudo-random data as - /// `get-random-bytes`, represented as a `u64`. - pub fn get_random_u64() -> u64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "get-random-u64")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_get-random-u64")] - fn wit_import() -> i64; - } - let ret = wit_import(); - ret as u64 - } - } - #[allow(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. - pub fn insecure_random() -> (u64, u64) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "random")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "insecure-random")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "random_insecure-random")] - fn wit_import(_: i32); - } - wit_import(ptr0); - ( - *((ptr0 + 0) as *const i64) as u64, - *((ptr0 + 8) as *const i64) as u64, - ) - } - } -} - -#[allow(clippy::all)] -pub mod console { - /// A log level, describing a kind of message. - #[repr(u8)] - #[derive(Clone, Copy, PartialEq, Eq)] - pub enum Level { - /// Describes messages about the values of variables and the flow of - /// control within a program. - Trace, - /// Describes messages likely to be of interest to someone debugging a - /// program. - Debug, - /// Describes messages likely to be of interest to someone monitoring a - /// program. - Info, - /// Describes messages indicating hazardous situations. - Warn, - /// Describes messages indicating serious errors. - Error, - } - impl core::fmt::Debug for Level { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Level::Trace => f.debug_tuple("Level::Trace").finish(), - Level::Debug => f.debug_tuple("Level::Debug").finish(), - Level::Info => f.debug_tuple("Level::Info").finish(), - Level::Warn => f.debug_tuple("Level::Warn").finish(), - Level::Error => f.debug_tuple("Level::Error").finish(), - } - } - } - #[allow(clippy::all)] - /// Emit a log message. - /// - /// A log message has a `level` describing what kind of message is being - /// sent, a context, which is an uninterpreted string meant to help - /// consumers group similar messages, and a string containing the message - /// text. - pub fn log(level: Level, context: &str, message: &str) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let vec0 = context; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = message; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[link(wasm_import_module = "console")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "log")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "console_log")] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - match level { - Level::Trace => 0, - Level::Debug => 1, - Level::Info => 2, - Level::Warn => 3, - Level::Error => 4, - }, - ptr0, - len0, - ptr1, - len1, - ); - } - } -} - -#[allow(clippy::all)] -pub mod poll { - /// A "pollable" handle. - /// - /// This is conceptually represents a `stream<_, _>`, or in other words, - /// a stream that one can wait on, repeatedly, but which does not itself - /// produce any data. It's temporary scaffolding until component-model's - /// async features are ready. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// `pollable` lifetimes are not automatically managed. Users must ensure - /// that they do not outlive the resource they reference. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type Pollable = u32; - #[allow(clippy::all)] - /// Dispose of the specified `pollable`, after which it may no longer - /// be used. - pub fn drop_pollable(this: Pollable) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "poll")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-pollable")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_drop-pollable")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } - #[allow(clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// The "oneoff" in the name refers to the fact that this function must do a - /// linear scan through the entire list of subscriptions, which may be - /// inefficient if the number is large and the same subscriptions are used - /// many times. In the future, this is expected to be obsoleted by the - /// component model async proposal, which will include a scalable waiting - /// facility. - /// - /// Note that the return type would ideally be `list`, but that would - /// be more difficult to polyfill given the current state of `wit-bindgen`. - /// See - /// for details. For now, we use zero to mean "not ready" and non-zero to - /// mean "ready". - pub fn poll_oneoff(in_: &[Pollable]) -> wit_bindgen::rt::vec::Vec { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = in_; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "poll")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "poll-oneoff")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "poll_poll-oneoff")] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(ptr0, len0, ptr1); - let len2 = *((ptr1 + 4) as *const i32) as usize; - Vec::from_raw_parts(*((ptr1 + 0) as *const i32) as *mut _, len2, len2) - } - } -} - -#[allow(clippy::all)] -pub mod streams { - pub type Pollable = super::poll::Pollable; - /// An error type returned from a stream operation. Currently this - /// doesn't provide any additional information. - #[repr(C)] - #[derive(Copy, Clone)] - pub struct StreamError {} - impl core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("StreamError").finish() - } - } - impl core::fmt::Display for StreamError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self) - } - } - impl std::error::Error for StreamError {} - /// An output bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `output-stream`s are *non-blocking* to the extent practical on - /// underlying platforms. Except where specified otherwise, I/O operations also - /// always return promptly, after the number of bytes that can be written - /// promptly, which could even be zero. To wait for the stream to be ready to - /// accept data, the `subscribe-to-output-stream` function to obtain a - /// `pollable` which can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type OutputStream = u32; - /// An input bytestream. In the future, this will be replaced by handle - /// types. - /// - /// This conceptually represents a `stream`. It's temporary - /// scaffolding until component-model's async features are ready. - /// - /// `input-stream`s are *non-blocking* to the extent practical on underlying - /// platforms. I/O operations always return promptly; if fewer bytes are - /// promptly available than requested, they return the number of bytes promptly - /// available, which could even be zero. To wait for data to be available, - /// use the `subscribe-to-input-stream` function to obtain a `pollable` which - /// can be polled for using `wasi_poll`. - /// - /// And at present, it is a `u32` instead of being an actual handle, until - /// the wit-bindgen implementation of handles and resources is ready. - /// - /// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). - pub type InputStream = u32; - #[allow(clippy::all)] - /// Read bytes from a stream. - /// - /// This function returns a list of bytes containing the data that was - /// read, along with a bool indicating whether the end of the stream - /// was reached. The returned list will contain up to `len` bytes; it - /// may return fewer than requested, but not more. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// If `len` is 0, it represents a request to read 0 bytes, which should - /// always succeed, assuming the stream hasn't reached its end yet, and - /// return an empty list. - /// - /// The len here is a `u64`, but some callees may not be able to allocate - /// a buffer as large as that would imply. - /// FIXME: describe what happens if allocation fails. - pub fn read( - this: InputStream, - len: u64, - ) -> Result<(wit_bindgen::rt::vec::Vec, bool), StreamError> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "read")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_read")] - fn wit_import(_: i32, _: i64, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(this), - wit_bindgen::rt::as_i64(len), - ptr0, - ); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok({ - let len1 = *((ptr0 + 8) as *const i32) as usize; - - ( - Vec::from_raw_parts(*((ptr0 + 4) as *const i32) as *mut _, len1, len1), - match i32::from(*((ptr0 + 12) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - }, - ) - }), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Skip bytes from a stream. - /// - /// This is similar to the `read` function, but avoids copying the - /// bytes into the instance. - /// - /// Once a stream has reached the end, subsequent calls to read or - /// `skip` will always report end-of-stream rather than producing more - /// data. - /// - /// This function returns the number of bytes skipped, along with a bool - /// indicating whether the end of the stream was reached. The returned - /// value will be at most `len`; it may be less. - pub fn skip(this: InputStream, len: u64) -> Result<(u64, bool), StreamError> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 24]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "skip")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_skip")] - fn wit_import(_: i32, _: i64, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(this), - wit_bindgen::rt::as_i64(len), - ptr0, - ); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(( - *((ptr0 + 8) as *const i64) as u64, - match i32::from(*((ptr0 + 16) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - }, - )), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Create a `pollable` which will resolve once either the specified stream - /// has bytes available to read or the other end of the stream has been - /// closed. - pub fn subscribe_to_input_stream(this: InputStream) -> Pollable { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-input-stream")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "streams_subscribe-to-input-stream" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(this)); - ret as u32 - } - } - #[allow(clippy::all)] - /// Dispose of the specified `input-stream`, after which it may no longer - /// be used. - pub fn drop_input_stream(this: InputStream) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-input-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-input-stream")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } - #[allow(clippy::all)] - /// Write bytes to a stream. - /// - /// This function returns a `u64` indicating the number of bytes from - /// `buf` that were written; it may be less than the full list. - pub fn write(this: OutputStream, buf: &[u8]) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = buf; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "write")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write")] - fn wit_import(_: i32, _: i32, _: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(this), ptr0, len0, ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(*((ptr1 + 8) as *const i64) as u64), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Write multiple zero bytes to a stream. - /// - /// This function returns a `u64` indicating the number of zero bytes - /// that were written; it may be less than `len`. - pub fn write_zeroes(this: OutputStream, len: u64) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "write-zeroes")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_write-zeroes")] - fn wit_import(_: i32, _: i64, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(this), - wit_bindgen::rt::as_i64(len), - ptr0, - ); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i64) as u64), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Read from one stream and write to another. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - /// - /// Unlike other I/O functions, this function blocks until all the data - /// read from the input stream has been written to the output stream. - pub fn splice( - this: OutputStream, - src: InputStream, - len: u64, - ) -> Result<(u64, bool), StreamError> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 24]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "splice")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_splice")] - fn wit_import(_: i32, _: i32, _: i64, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(this), - wit_bindgen::rt::as_i32(src), - wit_bindgen::rt::as_i64(len), - ptr0, - ); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(( - *((ptr0 + 8) as *const i64) as u64, - match i32::from(*((ptr0 + 16) as *const u8)) { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - }, - )), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Forward the entire contents of an input stream to an output stream. - /// - /// This function repeatedly reads from the input stream and writes - /// the data to the output stream, until the end of the input stream - /// is reached, or an error is encountered. - /// - /// Unlike other I/O functions, this function blocks until the end - /// of the input stream is seen and all the data has been written to - /// the output stream. - /// - /// This function returns the number of bytes transferred. - pub fn forward(this: OutputStream, src: InputStream) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "forward")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_forward")] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(this), - wit_bindgen::rt::as_i32(src), - ptr0, - ); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i64) as u64), - 1 => Err(StreamError {}), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - /// Create a `pollable` which will resolve once either the specified stream - /// is ready to accept bytes or the other end of the stream has been closed. - pub fn subscribe_to_output_stream(this: OutputStream) -> Pollable { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "subscribe-to-output-stream")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "streams_subscribe-to-output-stream" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(this)); - ret as u32 - } - } - #[allow(clippy::all)] - /// Dispose of the specified `output-stream`, after which it may no longer - /// be used. - pub fn drop_output_stream(this: OutputStream) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "streams")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-output-stream")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "streams_drop-output-stream")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(this)); - } - } -} - -#[allow(clippy::all)] -pub mod types { - pub type InputStream = super::streams::InputStream; - pub type OutputStream = super::streams::OutputStream; - pub type Pollable = super::poll::Pollable; - pub type StatusCode = u16; - #[derive(Clone)] - pub enum SchemeParam<'a> { - Http, - Https, - Other(&'a str), - } - impl<'a> core::fmt::Debug for SchemeParam<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - SchemeParam::Http => f.debug_tuple("SchemeParam::Http").finish(), - SchemeParam::Https => f.debug_tuple("SchemeParam::Https").finish(), - SchemeParam::Other(e) => f.debug_tuple("SchemeParam::Other").field(e).finish(), - } - } - } - #[derive(Clone)] - pub enum SchemeResult { - Http, - Https, - Other(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for SchemeResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - SchemeResult::Http => f.debug_tuple("SchemeResult::Http").finish(), - SchemeResult::Https => f.debug_tuple("SchemeResult::Https").finish(), - SchemeResult::Other(e) => f.debug_tuple("SchemeResult::Other").field(e).finish(), - } - } - } - pub type ResponseOutparam = u32; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct RequestOptions { - pub connect_timeout_ms: Option, - pub first_byte_timeout_ms: Option, - pub between_bytes_timeout_ms: Option, - } - impl core::fmt::Debug for RequestOptions { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("RequestOptions") - .field("connect-timeout-ms", &self.connect_timeout_ms) - .field("first-byte-timeout-ms", &self.first_byte_timeout_ms) - .field("between-bytes-timeout-ms", &self.between_bytes_timeout_ms) - .finish() - } - } - pub type OutgoingStream = OutputStream; - pub type OutgoingResponse = u32; - pub type OutgoingRequest = u32; - #[derive(Clone)] - pub enum MethodParam<'a> { - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(&'a str), - } - impl<'a> core::fmt::Debug for MethodParam<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - MethodParam::Get => f.debug_tuple("MethodParam::Get").finish(), - MethodParam::Head => f.debug_tuple("MethodParam::Head").finish(), - MethodParam::Post => f.debug_tuple("MethodParam::Post").finish(), - MethodParam::Put => f.debug_tuple("MethodParam::Put").finish(), - MethodParam::Delete => f.debug_tuple("MethodParam::Delete").finish(), - MethodParam::Connect => f.debug_tuple("MethodParam::Connect").finish(), - MethodParam::Options => f.debug_tuple("MethodParam::Options").finish(), - MethodParam::Trace => f.debug_tuple("MethodParam::Trace").finish(), - MethodParam::Patch => f.debug_tuple("MethodParam::Patch").finish(), - MethodParam::Other(e) => f.debug_tuple("MethodParam::Other").field(e).finish(), - } - } - } - #[derive(Clone)] - pub enum MethodResult { - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for MethodResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - MethodResult::Get => f.debug_tuple("MethodResult::Get").finish(), - MethodResult::Head => f.debug_tuple("MethodResult::Head").finish(), - MethodResult::Post => f.debug_tuple("MethodResult::Post").finish(), - MethodResult::Put => f.debug_tuple("MethodResult::Put").finish(), - MethodResult::Delete => f.debug_tuple("MethodResult::Delete").finish(), - MethodResult::Connect => f.debug_tuple("MethodResult::Connect").finish(), - MethodResult::Options => f.debug_tuple("MethodResult::Options").finish(), - MethodResult::Trace => f.debug_tuple("MethodResult::Trace").finish(), - MethodResult::Patch => f.debug_tuple("MethodResult::Patch").finish(), - MethodResult::Other(e) => f.debug_tuple("MethodResult::Other").field(e).finish(), - } - } - } - pub type IncomingStream = InputStream; - pub type IncomingResponse = u32; - pub type IncomingRequest = u32; - pub type FutureIncomingResponse = u32; - pub type Fields = u32; - pub type Trailers = Fields; - pub type Headers = Fields; - #[derive(Clone)] - pub enum ErrorParam<'a> { - InvalidUrl(&'a str), - TimeoutError(&'a str), - ProtocolError(&'a str), - UnexpectedError(&'a str), - } - impl<'a> core::fmt::Debug for ErrorParam<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ErrorParam::InvalidUrl(e) => { - f.debug_tuple("ErrorParam::InvalidUrl").field(e).finish() - } - ErrorParam::TimeoutError(e) => { - f.debug_tuple("ErrorParam::TimeoutError").field(e).finish() - } - ErrorParam::ProtocolError(e) => { - f.debug_tuple("ErrorParam::ProtocolError").field(e).finish() - } - ErrorParam::UnexpectedError(e) => f - .debug_tuple("ErrorParam::UnexpectedError") - .field(e) - .finish(), - } - } - } - impl<'a> core::fmt::Display for ErrorParam<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl<'a> std::error::Error for ErrorParam<'a> {} - #[derive(Clone)] - pub enum ErrorResult { - InvalidUrl(wit_bindgen::rt::string::String), - TimeoutError(wit_bindgen::rt::string::String), - ProtocolError(wit_bindgen::rt::string::String), - UnexpectedError(wit_bindgen::rt::string::String), - } - impl core::fmt::Debug for ErrorResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ErrorResult::InvalidUrl(e) => { - f.debug_tuple("ErrorResult::InvalidUrl").field(e).finish() - } - ErrorResult::TimeoutError(e) => { - f.debug_tuple("ErrorResult::TimeoutError").field(e).finish() - } - ErrorResult::ProtocolError(e) => f - .debug_tuple("ErrorResult::ProtocolError") - .field(e) - .finish(), - ErrorResult::UnexpectedError(e) => f - .debug_tuple("ErrorResult::UnexpectedError") - .field(e) - .finish(), - } - } - } - impl core::fmt::Display for ErrorResult { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for ErrorResult {} - #[allow(clippy::all)] - pub fn drop_fields(fields: Fields) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-fields")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-fields")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(fields)); - } - } - #[allow(clippy::all)] - pub fn new_fields(entries: &[(&str, &str)]) -> Fields { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let vec3 = entries; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); - let result3 = if layout3.size() != 0 { - let ptr = alloc::alloc(layout3); - if ptr.is_null() { - alloc::handle_alloc_error(layout3); - } - ptr - } else { - core::ptr::null_mut() - }; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3 as i32 + (i as i32) * 16; - { - let (t0_0, t0_1) = e; - let vec1 = t0_0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - let vec2 = t0_1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - *((base + 12) as *mut i32) = len2; - *((base + 8) as *mut i32) = ptr2; - } - } - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-fields")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-fields")] - fn wit_import(_: i32, _: i32) -> i32; - } - let ret = wit_import(result3 as i32, len3); - if layout3.size() != 0 { - alloc::dealloc(result3, layout3); - } - ret as u32 - } - } - #[allow(clippy::all)] - pub fn fields_get( - fields: Fields, - name: &str, - ) -> wit_bindgen::rt::vec::Vec { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-get")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-get")] - fn wit_import(_: i32, _: i32, _: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1); - let base3 = *((ptr1 + 0) as *const i32); - let len3 = *((ptr1 + 4) as *const i32); - let mut result3 = Vec::with_capacity(len3 as usize); - for i in 0..len3 { - let base = base3 + i * 8; - result3.push({ - let len2 = *((base + 4) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((base + 0) as *const i32) as *mut _, - len2, - len2, - )) - .unwrap() - }); - } - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 8, 4); - result3 - } - } - #[allow(clippy::all)] - pub fn fields_set(fields: Fields, name: &str, value: &[&str]) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = value; - let len2 = vec2.len() as i32; - let layout2 = alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = if layout2.size() != 0 { - let ptr = alloc::alloc(layout2); - if ptr.is_null() { - alloc::handle_alloc_error(layout2); - } - ptr - } else { - core::ptr::null_mut() - }; - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - } - } - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-set")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-set")] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - wit_bindgen::rt::as_i32(fields), - ptr0, - len0, - result2 as i32, - len2, - ); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - } - } - #[allow(clippy::all)] - pub fn fields_delete(fields: Fields, name: &str) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-delete")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-delete")] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0); - } - } - #[allow(clippy::all)] - pub fn fields_append(fields: Fields, name: &str, value: &str) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = value; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-append")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-append")] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0, len0, ptr1, len1); - } - } - #[allow(clippy::all)] - pub fn fields_entries( - fields: Fields, - ) -> wit_bindgen::rt::vec::Vec<( - wit_bindgen::rt::string::String, - wit_bindgen::rt::string::String, - )> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-entries")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-entries")] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(fields), ptr0); - let base3 = *((ptr0 + 0) as *const i32); - let len3 = *((ptr0 + 4) as *const i32); - let mut result3 = Vec::with_capacity(len3 as usize); - for i in 0..len3 { - let base = base3 + i * 16; - result3.push({ - let len1 = *((base + 4) as *const i32) as usize; - let len2 = *((base + 12) as *const i32) as usize; - - ( - String::from_utf8(Vec::from_raw_parts( - *((base + 0) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap(), - String::from_utf8(Vec::from_raw_parts( - *((base + 8) as *const i32) as *mut _, - len2, - len2, - )) - .unwrap(), - ) - }); - } - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 16, 4); - result3 - } - } - #[allow(clippy::all)] - pub fn fields_clone(fields: Fields) -> Fields { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "fields-clone")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_fields-clone")] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(fields)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn finish_incoming_stream(s: IncomingStream) -> Option { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "finish-incoming-stream")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_finish-incoming-stream" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(s), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(*((ptr0 + 4) as *const i32) as u32), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn finish_outgoing_stream(s: OutgoingStream, trailers: Option) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let (result0_0, result0_1) = match trailers { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => (0i32, 0i32), - }; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "finish-outgoing-stream")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_finish-outgoing-stream" - )] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(s), result0_0, result0_1); - } - } - #[allow(clippy::all)] - pub fn drop_incoming_request(request: IncomingRequest) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-incoming-request")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(request)); - } - } - #[allow(clippy::all)] - pub fn drop_outgoing_request(request: OutgoingRequest) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_drop-outgoing-request")] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(request)); - } - } - #[allow(clippy::all)] - pub fn incoming_request_method(request: IncomingRequest) -> MethodResult { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 12]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-method")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-method" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => MethodResult::Get, - 1 => MethodResult::Head, - 2 => MethodResult::Post, - 3 => MethodResult::Put, - 4 => MethodResult::Delete, - 5 => MethodResult::Connect, - 6 => MethodResult::Options, - 7 => MethodResult::Trace, - 8 => MethodResult::Patch, - 9 => MethodResult::Other({ - let len1 = *((ptr0 + 8) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 4) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn incoming_request_path(request: IncomingRequest) -> wit_bindgen::rt::string::String { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-path")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_incoming-request-path")] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 0) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_query(request: IncomingRequest) -> wit_bindgen::rt::string::String { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-query")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-query" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 0) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_scheme(request: IncomingRequest) -> Option { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-scheme")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-scheme" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { - 0 => SchemeResult::Http, - 1 => SchemeResult::Https, - 2 => SchemeResult::Other({ - let len1 = *((ptr0 + 12) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 8) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn incoming_request_authority(request: IncomingRequest) -> wit_bindgen::rt::string::String { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-authority")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-authority" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - let len1 = *((ptr0 + 4) as *const i32) as usize; - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 0) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - } - } - #[allow(clippy::all)] - pub fn incoming_request_headers(request: IncomingRequest) -> Headers { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-headers")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-headers" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(request)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn incoming_request_consume(request: IncomingRequest) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-request-consume")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-request-consume" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn new_outgoing_request( - method: MethodParam<'_>, - path: &str, - query: &str, - scheme: Option>, - authority: &str, - headers: Headers, - ) -> OutgoingRequest { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let (result1_0, result1_1, result1_2) = match method { - MethodParam::Get => (0i32, 0i32, 0i32), - MethodParam::Head => (1i32, 0i32, 0i32), - MethodParam::Post => (2i32, 0i32, 0i32), - MethodParam::Put => (3i32, 0i32, 0i32), - MethodParam::Delete => (4i32, 0i32, 0i32), - MethodParam::Connect => (5i32, 0i32, 0i32), - MethodParam::Options => (6i32, 0i32, 0i32), - MethodParam::Trace => (7i32, 0i32, 0i32), - MethodParam::Patch => (8i32, 0i32, 0i32), - MethodParam::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (9i32, ptr0, len0) - } - }; - let vec2 = path; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = query; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let (result6_0, result6_1, result6_2, result6_3) = match scheme { - Some(e) => { - let (result5_0, result5_1, result5_2) = match e { - SchemeParam::Http => (0i32, 0i32, 0i32), - SchemeParam::Https => (1i32, 0i32, 0i32), - SchemeParam::Other(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - (2i32, ptr4, len4) - } - }; - - (1i32, result5_0, result5_1, result5_2) - } - None => (0i32, 0i32, 0i32, 0i32), - }; - let vec7 = authority; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-request")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-request")] - fn wit_import( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - ) -> i32; - } - let ret = wit_import( - result1_0, - result1_1, - result1_2, - ptr2, - len2, - ptr3, - len3, - result6_0, - result6_1, - result6_2, - result6_3, - ptr7, - len7, - wit_bindgen::rt::as_i32(headers), - ); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn outgoing_request_write(request: OutgoingRequest) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-request-write")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_outgoing-request-write" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(request), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_response_outparam(response: ResponseOutparam) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-response-outparam")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_drop-response-outparam" - )] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn set_response_outparam( - response: Result>, - ) -> Result<(), ()> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let (result5_0, result5_1, result5_2, result5_3) = match response { - Ok(e) => (0i32, wit_bindgen::rt::as_i32(e), 0i32, 0i32), - Err(e) => { - let (result4_0, result4_1, result4_2) = match e { - ErrorParam::InvalidUrl(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (0i32, ptr0, len0) - } - ErrorParam::TimeoutError(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - (1i32, ptr1, len1) - } - ErrorParam::ProtocolError(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - - (2i32, ptr2, len2) - } - ErrorParam::UnexpectedError(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - (3i32, ptr3, len3) - } - }; - - (1i32, result4_0, result4_1, result4_2) - } - }; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "set-response-outparam")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_set-response-outparam")] - fn wit_import(_: i32, _: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(result5_0, result5_1, result5_2, result5_3); - match ret { - 0 => Ok(()), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_incoming_response(response: IncomingResponse) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-incoming-response")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_drop-incoming-response" - )] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn drop_outgoing_response(response: OutgoingResponse) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-outgoing-response")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_drop-outgoing-response" - )] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(response)); - } - } - #[allow(clippy::all)] - pub fn incoming_response_status(response: IncomingResponse) -> StatusCode { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-status")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-response-status" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(response)); - ret as u16 - } - } - #[allow(clippy::all)] - pub fn incoming_response_headers(response: IncomingResponse) -> Headers { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-headers")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-response-headers" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(response)); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn incoming_response_consume(response: IncomingResponse) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "incoming-response-consume")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_incoming-response-consume" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(response), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn new_outgoing_response(status_code: StatusCode, headers: Headers) -> OutgoingResponse { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "new-outgoing-response")] - #[cfg_attr(not(target_arch = "wasm32"), link_name = "types_new-outgoing-response")] - fn wit_import(_: i32, _: i32) -> i32; - } - let ret = wit_import( - wit_bindgen::rt::as_i32(status_code), - wit_bindgen::rt::as_i32(headers), - ); - ret as u32 - } - } - #[allow(clippy::all)] - pub fn outgoing_response_write(response: OutgoingResponse) -> Result { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "outgoing-response-write")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_outgoing-response-write" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(response), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(*((ptr0 + 4) as *const i32) as u32), - 1 => Err(()), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn drop_future_incoming_response(f: FutureIncomingResponse) -> () { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "drop-future-incoming-response")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_drop-future-incoming-response" - )] - fn wit_import(_: i32); - } - wit_import(wit_bindgen::rt::as_i32(f)); - } - } - #[allow(clippy::all)] - pub fn future_incoming_response_get( - f: FutureIncomingResponse, - ) -> Option> { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 20]); - let mut ret_area = core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "future-incoming-response-get")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_future-incoming-response-get" - )] - fn wit_import(_: i32, _: i32); - } - wit_import(wit_bindgen::rt::as_i32(f), ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(match i32::from(*((ptr0 + 4) as *const u8)) { - 0 => Ok(*((ptr0 + 8) as *const i32) as u32), - 1 => Err(match i32::from(*((ptr0 + 8) as *const u8)) { - 0 => ErrorResult::InvalidUrl({ - let len1 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 12) as *const i32) as *mut _, - len1, - len1, - )) - .unwrap() - }), - 1 => ErrorResult::TimeoutError({ - let len2 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 12) as *const i32) as *mut _, - len2, - len2, - )) - .unwrap() - }), - 2 => ErrorResult::ProtocolError({ - let len3 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 12) as *const i32) as *mut _, - len3, - len3, - )) - .unwrap() - }), - 3 => ErrorResult::UnexpectedError({ - let len4 = *((ptr0 + 16) as *const i32) as usize; - - String::from_utf8(Vec::from_raw_parts( - *((ptr0 + 12) as *const i32) as *mut _, - len4, - len4, - )) - .unwrap() - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - }), - _ => panic!("invalid enum discriminant"), - } - } - } - #[allow(clippy::all)] - pub fn listen_to_future_incoming_response(f: FutureIncomingResponse) -> Pollable { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[link(wasm_import_module = "types")] - extern "C" { - #[cfg_attr( - target_arch = "wasm32", - link_name = "listen-to-future-incoming-response" - )] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "types_listen-to-future-incoming-response" - )] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(wit_bindgen::rt::as_i32(f)); - ret as u32 - } - } -} - -#[allow(clippy::all)] -pub mod default_outgoing_http { - pub type OutgoingRequest = super::types::OutgoingRequest; - pub type RequestOptions = super::types::RequestOptions; - pub type FutureIncomingResponse = super::types::FutureIncomingResponse; - #[allow(clippy::all)] - pub fn handle( - request: OutgoingRequest, - options: Option, - ) -> FutureIncomingResponse { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let (result4_0, result4_1, result4_2, result4_3, result4_4, result4_5, result4_6) = - match options { - Some(e) => { - let RequestOptions { - connect_timeout_ms: connect_timeout_ms0, - first_byte_timeout_ms: first_byte_timeout_ms0, - between_bytes_timeout_ms: between_bytes_timeout_ms0, - } = e; - let (result1_0, result1_1) = match connect_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => (0i32, 0i32), - }; - let (result2_0, result2_1) = match first_byte_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => (0i32, 0i32), - }; - let (result3_0, result3_1) = match between_bytes_timeout_ms0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => (0i32, 0i32), - }; - ( - 1i32, result1_0, result1_1, result2_0, result2_1, result3_0, result3_1, - ) - } - None => (0i32, 0i32, 0i32, 0i32, 0i32, 0i32, 0i32), - }; - #[link(wasm_import_module = "default-outgoing-HTTP")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "handle")] - #[cfg_attr( - not(target_arch = "wasm32"), - link_name = "default-outgoing-HTTP_handle" - )] - fn wit_import( - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - _: i32, - ) -> i32; - } - let ret = wit_import( - wit_bindgen::rt::as_i32(request), - result4_0, - result4_1, - result4_2, - result4_3, - result4_4, - result4_5, - result4_6, - ); - ret as u32 - } - } -} - -#[allow(clippy::all)] -pub mod http { - pub type IncomingRequest = super::types::IncomingRequest; - pub type ResponseOutparam = super::types::ResponseOutparam; - pub trait Http { - fn handle(request: IncomingRequest, response_out: ResponseOutparam) -> (); - } - - #[doc(hidden)] - pub unsafe fn call_handle(arg0: i32, arg1: i32) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - T::handle(arg0 as u32, arg1 as u32); - } -} - -/// Declares the export of the component's world for the -/// given type. - -macro_rules! export_proxy(($t:ident) => { - const _: () = { - - #[doc(hidden)] - #[export_name = "HTTP#handle"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_http_handle(arg0: i32,arg1: i32,) { - http::call_handle::<$t>(arg0,arg1,) - } - - }; - - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = __force_section_ref; - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - fn __force_section_ref() { - __link_section() - } - }); - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:proxy"] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8155] = [ - 2, 0, 3, 119, 105, 116, 5, 112, 114, 111, 120, 121, 5, 112, 114, 111, 120, 121, 0, 97, 115, - 109, 12, 0, 1, 0, 7, 236, 17, 1, 65, 9, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, - 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, - 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, - 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, - 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, - 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, - 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, - 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, - 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, - 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, - 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, - 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, - 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, - 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, - 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, - 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, - 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, - 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, - 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, - 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, - 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, - 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, - 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, - 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, - 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, - 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, - 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, - 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, - 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, - 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, - 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, - 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, - 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, - 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, - 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, - 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, - 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, - 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, - 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, - 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, - 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, 115, 0, 1, 35, 1, 111, 2, - 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 37, 0, 30, 4, 10, 110, - 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, 64, 2, 6, 102, 105, 101, - 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, 101, 108, 100, 115, 45, - 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, - 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, 115, 45, 115, 101, - 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 1, 0, - 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, 1, 42, 1, 64, 3, 6, - 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 115, 1, - 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, 0, 1, 43, 1, 64, 1, 6, - 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, 115, 45, 101, 110, - 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 30, 4, 12, - 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, 107, 31, 1, 64, 1, 1, - 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, 111, 109, 105, 110, 103, - 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, 116, 114, 97, 105, 108, - 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, 117, 116, 103, 111, 105, - 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, - 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, - 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, 1, - 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, - 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 21, 4, 23, - 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, - 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 115, 4, - 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 112, 97, - 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, - 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, 1, 7, 114, 101, 113, 117, - 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, - 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, 105, 110, 99, 111, 109, 105, - 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, - 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 32, 4, 24, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, - 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, - 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, - 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, 111, 100, 21, 4, - 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, 109, 101, 53, 9, - 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, - 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, - 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 19, - 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, - 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 11, - 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, - 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, 1, 8, 114, 101, - 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, 115, 112, 111, - 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, 114, 101, 115, - 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, 105, - 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, 114, 101, 115, - 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, - 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, 114, 101, 115, - 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, - 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, 1, 8, 114, 101, - 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, - 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, 1, 68, 1, 64, 1, 8, - 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, 111, 109, 105, 110, - 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, - 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, 7, 104, 101, 97, 100, - 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, - 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, - 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, - 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, 102, 28, 1, 0, 4, 29, - 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, - 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, 1, 34, 1, 107, 201, - 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, - 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, 101, 116, 0, 1, 75, 1, - 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, 111, 45, 102, 117, 116, - 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, - 115, 101, 0, 1, 76, 4, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, - 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 11, 21, 1, 5, 116, 121, 112, 101, 115, 10, 112, - 107, 103, 58, 47, 116, 121, 112, 101, 115, 3, 0, 0, 7, 246, 8, 1, 65, 14, 1, 66, 2, 1, 121, 4, - 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, - 116, 104, 58, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, - 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, - 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, - 114, 111, 114, 0, 3, 0, 2, 1, 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, - 97, 109, 0, 3, 0, 4, 1, 121, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, - 0, 3, 0, 6, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, - 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, - 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, - 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, - 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, - 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, - 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, - 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, - 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, - 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, - 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, - 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, - 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, - 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, - 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, - 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, - 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, - 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, - 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, - 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, - 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, - 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, - 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, - 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, - 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, - 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, - 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, - 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, - 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, - 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, - 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, - 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, - 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, - 101, 115, 16, 112, 107, 103, 58, 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, - 5, 2, 3, 0, 2, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, - 116, 2, 3, 0, 2, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, - 2, 3, 0, 2, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, - 114, 101, 115, 112, 111, 110, 115, 101, 1, 66, 9, 2, 3, 2, 1, 6, 4, 16, 111, 117, 116, 103, - 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 7, 4, 15, - 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, - 1, 8, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, - 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, - 115, 116, 1, 7, 111, 112, 116, 105, 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, - 0, 1, 7, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, - 38, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, - 101, 114, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, - 9, 11, 43, 1, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, - 21, 112, 107, 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, - 101, 114, 3, 2, 0, 7, 188, 8, 1, 65, 13, 1, 66, 2, 1, 121, 4, 8, 112, 111, 108, 108, 97, 98, - 108, 101, 0, 3, 0, 0, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, - 108, 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 0, 2, 3, 0, 0, 8, 112, 111, 108, 108, - 97, 98, 108, 101, 1, 66, 8, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, - 0, 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, - 121, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, - 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 3, 7, 115, 116, - 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, 111, 47, 115, 116, 114, 101, 97, - 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 2, 2, 3, 0, 1, 12, 105, 110, 112, 117, 116, - 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 1, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, - 114, 101, 97, 109, 1, 66, 35, 2, 3, 2, 1, 3, 4, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, - 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 4, 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, - 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 1, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, - 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, - 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, - 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, 17, 114, 101, 115, 112, 111, 110, 115, - 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 10, 1, 107, 121, 1, 114, 3, 18, 99, - 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 21, 102, - 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, - 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, - 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, - 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, - 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, - 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, 4, 16, 111, 117, 116, 103, 111, 105, - 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 18, 1, 113, 10, 3, 103, 101, 116, 0, - 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, 0, 3, 112, 117, 116, 0, 0, 6, 100, - 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, 99, 116, 0, 0, 7, 111, 112, 116, 105, - 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, 112, 97, 116, 99, 104, 0, 0, 5, 111, - 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, 111, 100, 0, 3, 0, 20, 4, 15, 105, - 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, - 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 23, - 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, - 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, - 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 27, 1, 121, 4, 6, 102, 105, 101, 108, - 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, 114, 115, 0, 3, 0, 30, 4, 7, 104, - 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, 110, 118, 97, 108, 105, 100, 45, - 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, 116, 45, 101, 114, 114, 111, 114, - 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, - 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, - 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, - 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 5, 2, 3, 0, 2, 16, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 2, 17, 114, 101, 115, - 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, 6, 2, 3, 2, 1, 6, 4, - 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 0, - 2, 3, 2, 1, 7, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, - 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 12, 114, 101, 115, 112, - 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 4, 4, - 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 38, 112, 107, - 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, - 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 8, 11, 43, 1, - 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 21, 112, 107, - 103, 58, 47, 105, 110, 99, 111, 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 3, 4, - 0, 7, 224, 26, 1, 65, 2, 1, 65, 22, 1, 66, 8, 1, 112, 125, 1, 64, 1, 3, 108, 101, 110, 119, 0, - 0, 4, 16, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 98, 121, 116, 101, 115, 0, 1, 1, - 1, 64, 0, 0, 119, 4, 14, 103, 101, 116, 45, 114, 97, 110, 100, 111, 109, 45, 117, 54, 52, 0, 1, - 2, 1, 111, 2, 119, 119, 1, 64, 0, 0, 3, 4, 15, 105, 110, 115, 101, 99, 117, 114, 101, 45, 114, - 97, 110, 100, 111, 109, 0, 1, 4, 3, 6, 114, 97, 110, 100, 111, 109, 26, 112, 97, 116, 104, 58, - 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, 109, 47, 114, 97, 110, 100, 111, - 109, 5, 0, 1, 66, 4, 1, 109, 5, 5, 116, 114, 97, 99, 101, 5, 100, 101, 98, 117, 103, 4, 105, - 110, 102, 111, 4, 119, 97, 114, 110, 5, 101, 114, 114, 111, 114, 4, 5, 108, 101, 118, 101, 108, - 0, 3, 0, 0, 1, 64, 3, 5, 108, 101, 118, 101, 108, 1, 7, 99, 111, 110, 116, 101, 120, 116, 115, - 7, 109, 101, 115, 115, 97, 103, 101, 115, 1, 0, 4, 3, 108, 111, 103, 0, 1, 2, 3, 7, 99, 111, - 110, 115, 111, 108, 101, 29, 112, 97, 116, 104, 58, 47, 108, 111, 103, 103, 105, 110, 103, 47, - 104, 97, 110, 100, 108, 101, 114, 47, 104, 97, 110, 100, 108, 101, 114, 5, 1, 1, 66, 8, 1, 121, - 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, 1, 64, 1, 4, 116, 104, 105, 115, 1, 1, - 0, 4, 13, 100, 114, 111, 112, 45, 112, 111, 108, 108, 97, 98, 108, 101, 0, 1, 2, 1, 112, 1, 1, - 112, 125, 1, 64, 1, 2, 105, 110, 3, 0, 4, 4, 11, 112, 111, 108, 108, 45, 111, 110, 101, 111, - 102, 102, 0, 1, 5, 3, 4, 112, 111, 108, 108, 20, 112, 97, 116, 104, 58, 47, 112, 111, 108, 108, - 47, 112, 111, 108, 108, 47, 112, 111, 108, 108, 5, 2, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, - 98, 108, 101, 1, 66, 34, 2, 3, 2, 1, 3, 4, 8, 112, 111, 108, 108, 97, 98, 108, 101, 0, 3, 0, 0, - 1, 114, 0, 4, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 0, 3, 0, 2, 1, 121, - 4, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 4, 1, 121, 4, - 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 6, 1, 112, 125, 1, 111, - 2, 8, 127, 1, 106, 1, 9, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, - 10, 4, 4, 114, 101, 97, 100, 0, 1, 11, 1, 111, 2, 119, 127, 1, 106, 1, 12, 1, 3, 1, 64, 2, 4, - 116, 104, 105, 115, 7, 3, 108, 101, 110, 119, 0, 13, 4, 4, 115, 107, 105, 112, 0, 1, 14, 1, 64, - 1, 4, 116, 104, 105, 115, 7, 0, 1, 4, 25, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, - 111, 45, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 15, 1, 64, 1, 4, 116, - 104, 105, 115, 7, 1, 0, 4, 17, 100, 114, 111, 112, 45, 105, 110, 112, 117, 116, 45, 115, 116, - 114, 101, 97, 109, 0, 1, 16, 1, 106, 1, 119, 1, 3, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 98, - 117, 102, 8, 0, 17, 4, 5, 119, 114, 105, 116, 101, 0, 1, 18, 1, 64, 2, 4, 116, 104, 105, 115, - 5, 3, 108, 101, 110, 119, 0, 17, 4, 12, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, - 115, 0, 1, 19, 1, 64, 3, 4, 116, 104, 105, 115, 5, 3, 115, 114, 99, 7, 3, 108, 101, 110, 119, - 0, 13, 4, 6, 115, 112, 108, 105, 99, 101, 0, 1, 20, 1, 64, 2, 4, 116, 104, 105, 115, 5, 3, 115, - 114, 99, 7, 0, 17, 4, 7, 102, 111, 114, 119, 97, 114, 100, 0, 1, 21, 1, 64, 1, 4, 116, 104, - 105, 115, 5, 0, 1, 4, 26, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 116, 111, 45, 111, 117, - 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 1, 22, 1, 64, 1, 4, 116, 104, 105, 115, - 5, 1, 0, 4, 18, 100, 114, 111, 112, 45, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, - 97, 109, 0, 1, 23, 3, 7, 115, 116, 114, 101, 97, 109, 115, 24, 112, 97, 116, 104, 58, 47, 105, - 111, 47, 115, 116, 114, 101, 97, 109, 115, 47, 115, 116, 114, 101, 97, 109, 115, 5, 4, 2, 3, 0, - 3, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 3, 13, 111, 117, 116, - 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 110, 2, 3, 2, 1, 5, 4, 12, 105, 110, - 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 0, 2, 3, 2, 1, 6, 4, 13, 111, 117, - 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 2, 2, 3, 2, 1, 3, 4, 8, 112, 111, - 108, 108, 97, 98, 108, 101, 0, 3, 0, 4, 1, 123, 4, 11, 115, 116, 97, 116, 117, 115, 45, 99, - 111, 100, 101, 0, 3, 0, 6, 1, 113, 3, 4, 72, 84, 84, 80, 0, 0, 5, 72, 84, 84, 80, 83, 0, 0, 5, - 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 115, 99, 104, 101, 109, 101, 0, 3, 0, 8, 1, 121, 4, - 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, - 10, 1, 107, 121, 1, 114, 3, 18, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, - 117, 116, 45, 109, 115, 12, 21, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, - 109, 101, 111, 117, 116, 45, 109, 115, 12, 24, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, - 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 45, 109, 115, 12, 4, 15, 114, 101, 113, - 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 13, 4, 15, 111, 117, 116, - 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 3, 0, 3, 1, 121, 4, 17, 111, 117, - 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, 16, 1, 121, - 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, - 18, 1, 113, 10, 3, 103, 101, 116, 0, 0, 4, 104, 101, 97, 100, 0, 0, 4, 112, 111, 115, 116, 0, - 0, 3, 112, 117, 116, 0, 0, 6, 100, 101, 108, 101, 116, 101, 0, 0, 7, 99, 111, 110, 110, 101, - 99, 116, 0, 0, 7, 111, 112, 116, 105, 111, 110, 115, 0, 0, 5, 116, 114, 97, 99, 101, 0, 0, 5, - 112, 97, 116, 99, 104, 0, 0, 5, 111, 116, 104, 101, 114, 1, 115, 0, 4, 6, 109, 101, 116, 104, - 111, 100, 0, 3, 0, 20, 4, 15, 105, 110, 99, 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, - 97, 109, 0, 3, 0, 1, 1, 121, 4, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, - 112, 111, 110, 115, 101, 0, 3, 0, 23, 1, 121, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, - 114, 101, 113, 117, 101, 115, 116, 0, 3, 0, 25, 1, 121, 4, 24, 102, 117, 116, 117, 114, 101, - 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 3, 0, - 27, 1, 121, 4, 6, 102, 105, 101, 108, 100, 115, 0, 3, 0, 29, 4, 8, 116, 114, 97, 105, 108, 101, - 114, 115, 0, 3, 0, 30, 4, 7, 104, 101, 97, 100, 101, 114, 115, 0, 3, 0, 30, 1, 113, 4, 11, 105, - 110, 118, 97, 108, 105, 100, 45, 117, 114, 108, 1, 115, 0, 13, 116, 105, 109, 101, 111, 117, - 116, 45, 101, 114, 114, 111, 114, 1, 115, 0, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, - 101, 114, 114, 111, 114, 1, 115, 0, 16, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 45, - 101, 114, 114, 111, 114, 1, 115, 0, 4, 5, 101, 114, 114, 111, 114, 0, 3, 0, 33, 1, 64, 1, 6, - 102, 105, 101, 108, 100, 115, 30, 1, 0, 4, 11, 100, 114, 111, 112, 45, 102, 105, 101, 108, 100, - 115, 0, 1, 35, 1, 111, 2, 115, 115, 1, 112, 36, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, - 37, 0, 30, 4, 10, 110, 101, 119, 45, 102, 105, 101, 108, 100, 115, 0, 1, 38, 1, 112, 115, 1, - 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 0, 39, 4, 10, 102, 105, - 101, 108, 100, 115, 45, 103, 101, 116, 0, 1, 40, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, - 4, 110, 97, 109, 101, 115, 5, 118, 97, 108, 117, 101, 39, 1, 0, 4, 10, 102, 105, 101, 108, 100, - 115, 45, 115, 101, 116, 0, 1, 41, 1, 64, 2, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, - 109, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 100, 101, 108, 101, 116, 101, 0, - 1, 42, 1, 64, 3, 6, 102, 105, 101, 108, 100, 115, 30, 4, 110, 97, 109, 101, 115, 5, 118, 97, - 108, 117, 101, 115, 1, 0, 4, 13, 102, 105, 101, 108, 100, 115, 45, 97, 112, 112, 101, 110, 100, - 0, 1, 43, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 30, 0, 37, 4, 14, 102, 105, 101, 108, 100, - 115, 45, 101, 110, 116, 114, 105, 101, 115, 0, 1, 44, 1, 64, 1, 6, 102, 105, 101, 108, 100, - 115, 30, 0, 30, 4, 12, 102, 105, 101, 108, 100, 115, 45, 99, 108, 111, 110, 101, 0, 1, 45, 1, - 107, 31, 1, 64, 1, 1, 115, 22, 0, 46, 4, 22, 102, 105, 110, 105, 115, 104, 45, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 47, 1, 64, 2, 1, 115, 15, 8, - 116, 114, 97, 105, 108, 101, 114, 115, 46, 1, 0, 4, 22, 102, 105, 110, 105, 115, 104, 45, 111, - 117, 116, 103, 111, 105, 110, 103, 45, 115, 116, 114, 101, 97, 109, 0, 1, 48, 1, 64, 1, 7, 114, - 101, 113, 117, 101, 115, 116, 26, 1, 0, 4, 21, 100, 114, 111, 112, 45, 105, 110, 99, 111, 109, - 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 49, 1, 64, 1, 7, 114, 101, 113, - 117, 101, 115, 116, 19, 1, 0, 4, 21, 100, 114, 111, 112, 45, 111, 117, 116, 103, 111, 105, 110, - 103, 45, 114, 101, 113, 117, 101, 115, 116, 0, 1, 50, 1, 64, 1, 7, 114, 101, 113, 117, 101, - 115, 116, 26, 0, 21, 4, 23, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, - 115, 116, 45, 109, 101, 116, 104, 111, 100, 0, 1, 51, 1, 64, 1, 7, 114, 101, 113, 117, 101, - 115, 116, 26, 0, 115, 4, 21, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, - 101, 115, 116, 45, 112, 97, 116, 104, 0, 1, 52, 4, 22, 105, 110, 99, 111, 109, 105, 110, 103, - 45, 114, 101, 113, 117, 101, 115, 116, 45, 113, 117, 101, 114, 121, 0, 1, 52, 1, 107, 9, 1, 64, - 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, 53, 4, 23, 105, 110, 99, 111, 109, 105, 110, - 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 115, 99, 104, 101, 109, 101, 0, 1, 54, 4, 26, - 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, 97, 117, 116, - 104, 111, 114, 105, 116, 121, 0, 1, 52, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 26, 0, - 32, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 45, - 104, 101, 97, 100, 101, 114, 115, 0, 1, 55, 1, 106, 1, 22, 0, 1, 64, 1, 7, 114, 101, 113, 117, - 101, 115, 116, 26, 0, 56, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, - 101, 115, 116, 45, 99, 111, 110, 115, 117, 109, 101, 0, 1, 57, 1, 64, 6, 6, 109, 101, 116, 104, - 111, 100, 21, 4, 112, 97, 116, 104, 115, 5, 113, 117, 101, 114, 121, 115, 6, 115, 99, 104, 101, - 109, 101, 53, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 115, 7, 104, 101, 97, 100, 101, - 114, 115, 32, 0, 19, 4, 20, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, - 101, 113, 117, 101, 115, 116, 0, 1, 58, 1, 106, 1, 15, 0, 1, 64, 1, 7, 114, 101, 113, 117, 101, - 115, 116, 19, 0, 59, 4, 22, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, - 101, 115, 116, 45, 119, 114, 105, 116, 101, 0, 1, 60, 1, 64, 1, 8, 114, 101, 115, 112, 111, - 110, 115, 101, 11, 1, 0, 4, 22, 100, 114, 111, 112, 45, 114, 101, 115, 112, 111, 110, 115, 101, - 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 61, 1, 106, 1, 17, 1, 34, 1, 106, 0, 0, 1, 64, - 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 62, 0, 63, 4, 21, 115, 101, 116, 45, 114, 101, - 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 0, 1, 64, 1, 64, 1, 8, - 114, 101, 115, 112, 111, 110, 115, 101, 24, 1, 0, 4, 22, 100, 114, 111, 112, 45, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 65, 1, 64, 1, 8, - 114, 101, 115, 112, 111, 110, 115, 101, 17, 1, 0, 4, 22, 100, 114, 111, 112, 45, 111, 117, 116, - 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 66, 1, 64, 1, 8, - 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 7, 4, 24, 105, 110, 99, 111, 109, 105, 110, 103, - 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 115, 116, 97, 116, 117, 115, 0, 1, 67, 1, 64, - 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 32, 4, 25, 105, 110, 99, 111, 109, 105, - 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 115, 0, - 1, 68, 1, 64, 1, 8, 114, 101, 115, 112, 111, 110, 115, 101, 24, 0, 56, 4, 25, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 115, - 117, 109, 101, 0, 1, 69, 1, 64, 2, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 7, - 7, 104, 101, 97, 100, 101, 114, 115, 32, 0, 17, 4, 21, 110, 101, 119, 45, 111, 117, 116, 103, - 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 70, 1, 64, 1, 8, 114, - 101, 115, 112, 111, 110, 115, 101, 17, 0, 59, 4, 23, 111, 117, 116, 103, 111, 105, 110, 103, - 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 119, 114, 105, 116, 101, 0, 1, 71, 1, 64, 1, 1, - 102, 28, 1, 0, 4, 29, 100, 114, 111, 112, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, - 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, 1, 72, 1, 106, 1, 24, - 1, 34, 1, 107, 201, 0, 1, 64, 1, 1, 102, 28, 0, 202, 0, 4, 28, 102, 117, 116, 117, 114, 101, - 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 103, - 101, 116, 0, 1, 75, 1, 64, 1, 1, 102, 28, 0, 5, 4, 34, 108, 105, 115, 116, 101, 110, 45, 116, - 111, 45, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, - 115, 112, 111, 110, 115, 101, 0, 1, 76, 3, 5, 116, 121, 112, 101, 115, 16, 112, 107, 103, 58, - 47, 116, 121, 112, 101, 115, 47, 116, 121, 112, 101, 115, 5, 7, 2, 3, 0, 4, 16, 111, 117, 116, - 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 4, 15, 114, 101, 113, - 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 4, 24, 102, 117, 116, 117, - 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, - 101, 1, 66, 9, 2, 3, 2, 1, 8, 4, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, - 117, 101, 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 9, 4, 15, 114, 101, 113, 117, 101, 115, 116, 45, - 111, 112, 116, 105, 111, 110, 115, 0, 3, 0, 2, 2, 3, 2, 1, 10, 4, 24, 102, 117, 116, 117, 114, - 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 0, - 3, 0, 4, 1, 107, 3, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, 7, 111, 112, 116, 105, - 111, 110, 115, 6, 0, 5, 4, 6, 104, 97, 110, 100, 108, 101, 0, 1, 7, 3, 21, 100, 101, 102, 97, - 117, 108, 116, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 72, 84, 84, 80, 38, 112, 107, - 103, 58, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, - 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 11, 2, 3, 0, - 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, - 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 1, 66, - 6, 2, 3, 2, 1, 12, 4, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, - 115, 116, 0, 3, 0, 0, 2, 3, 2, 1, 13, 4, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, - 117, 116, 112, 97, 114, 97, 109, 0, 3, 0, 2, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 1, - 12, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 3, 1, 0, 4, 6, 104, 97, 110, - 100, 108, 101, 0, 1, 4, 4, 4, 72, 84, 84, 80, 38, 112, 107, 103, 58, 47, 105, 110, 99, 111, - 109, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 47, 105, 110, 99, 111, 109, 105, 110, - 103, 45, 104, 97, 110, 100, 108, 101, 114, 5, 14, 4, 5, 112, 114, 111, 120, 121, 16, 112, 107, - 103, 58, 47, 112, 114, 111, 120, 121, 47, 112, 114, 111, 120, 121, 4, 0, 0, 45, 9, 112, 114, - 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, - 121, 1, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 48, 46, 54, 46, - 48, 11, 21, 1, 5, 112, 114, 111, 120, 121, 10, 112, 107, 103, 58, 47, 112, 114, 111, 120, 121, - 3, 6, 0, -]; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_section() {} From 27f21348422e8f4381568dc56d0fd4d9b293fcac Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 27 Mar 2023 11:17:09 -0700 Subject: [PATCH 22/46] wip: start writing a http test... --- .../test-programs/wasi-http-tests/Cargo.lock | 380 ++++++++++++++++++ .../test-programs/wasi-http-tests/Cargo.toml | 15 + .../src/bin/outbound_request.rs | 34 ++ .../test-programs/wasi-http-tests/src/lib.rs | 3 + crates/test-programs/wasi-http-tests/wit | 1 + 5 files changed, 433 insertions(+) create mode 100644 crates/test-programs/wasi-http-tests/Cargo.lock create mode 100644 crates/test-programs/wasi-http-tests/Cargo.toml create mode 100644 crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs create mode 100644 crates/test-programs/wasi-http-tests/src/lib.rs create mode 120000 crates/test-programs/wasi-http-tests/wit diff --git a/crates/test-programs/wasi-http-tests/Cargo.lock b/crates/test-programs/wasi-http-tests/Cargo.lock new file mode 100644 index 000000000000..b8d40a06d521 --- /dev/null +++ b/crates/test-programs/wasi-http-tests/Cargo.lock @@ -0,0 +1,380 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "proc-macro2" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.9", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da4a3c17e109f700685ec577c0f85efd9b19bcf15c913985f14dc1ac01775aa" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi-http-tests" +version = "0.0.0" +dependencies = [ + "anyhow", + "wit-bindgen", +] + +[[package]] +name = "wasm-encoder" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6956efd8a1a2c48a707e9a1b2da729834a0f8e4c58117493b0d9d089cee468" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wit-bindgen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7cf57f8786216c5652e1228b25203af2ff523808b5e9d3671894eee2bf7264" +dependencies = [ + "bitflags", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef177b73007d86c720931d0e2ea7e30eb8c9776e58361717743fc1e83cfacfe5" +dependencies = [ + "anyhow", + "wit-component", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efdf5b00935b7b52d0e56cae1960f8ac13019a285f5aa762ff6bd7139a5c28a2" +dependencies = [ + "heck", + "wasm-metadata", + "wit-bindgen-core", + "wit-bindgen-rust-lib", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-lib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0a8f4b5fb1820b9d232beb122936425f72ec8fe6acb56e5d8782cfe55083da" +dependencies = [ + "heck", + "wit-bindgen-core", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadf1adf12ed25629b06272c16b335ef8c5a240d0ca64ab508a955ac3b46172c" +dependencies = [ + "anyhow", + "proc-macro2", + "syn 1.0.109", + "wit-bindgen-core", + "wit-bindgen-rust", + "wit-component", +] + +[[package]] +name = "wit-component" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed04310239706efc71cc8b995cb0226089c5b5fd260c3bd800a71486bd3cec97" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "url", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "unicode-xid", + "url", +] diff --git a/crates/test-programs/wasi-http-tests/Cargo.toml b/crates/test-programs/wasi-http-tests/Cargo.toml new file mode 100644 index 000000000000..0c04ce6987ba --- /dev/null +++ b/crates/test-programs/wasi-http-tests/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "wasi-http-tests" +version = "0.0.0" +readme = "README.md" +edition = "2021" +publish = false + +[dependencies] +anyhow = "1" +wit-bindgen = "0.4.0" + +# This crate is built with the wasm32-wasi target, so it's separate +# from the main Wasmtime build, so use this directive to exclude it +# from the parent directory's workspace. +[workspace] diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs new file mode 100644 index 000000000000..5e748f062cd0 --- /dev/null +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs @@ -0,0 +1,34 @@ +use anyhow::{anyhow, Result}; +use wasi_http_tests::*; + +fn request( + method: types::MethodParam<'_>, + scheme: types::SchemeParam<'_>, + authority: &str, + path: &str, + query: &str, + body: &[u8], +) -> Result<()> { + let headers = types::new_fields(&[ + ("User-agent", "WASI-HTTP/0.0.1"), + ("Content-type", "application/json"), + ]); + + let request = + types::new_outgoing_request(method, path, query, Some(scheme), authority, headers); + + let request_stream = types::outgoing_request_write(request) + .map_err(|_| anyhow!("outgoing request write failed"))?; + + let mut body_cursor = 0; + while body_cursor < body.len() { + let written = streams::write(request_stream, &body[body_cursor..])?; + body_cursor += written as usize; + } + + default_outgoing_http::handle(request, None); + + todo!() +} + +fn main() {} diff --git a/crates/test-programs/wasi-http-tests/src/lib.rs b/crates/test-programs/wasi-http-tests/src/lib.rs new file mode 100644 index 000000000000..cb9976a0e90c --- /dev/null +++ b/crates/test-programs/wasi-http-tests/src/lib.rs @@ -0,0 +1,3 @@ +// The macro will generate a macro for defining exports which we won't be reusing +#![allow(unused)] +wit_bindgen::generate!(); diff --git a/crates/test-programs/wasi-http-tests/wit b/crates/test-programs/wasi-http-tests/wit new file mode 120000 index 000000000000..5b8c87666437 --- /dev/null +++ b/crates/test-programs/wasi-http-tests/wit @@ -0,0 +1 @@ +../../wasi-http/wasi-http/wit \ No newline at end of file From 6b7d84d6760bde83f15d17cb28116545497dc558 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 27 Mar 2023 12:53:24 -0700 Subject: [PATCH 23/46] finish writing the outbound request example havent executed it yet --- .../src/bin/outbound_request.rs | 99 +++++++++++++++++-- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs index 5e748f062cd0..eea8026ed2bc 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs @@ -1,6 +1,13 @@ -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use wasi_http_tests::*; +#[derive(Debug)] +struct Response { + status: types::StatusCode, + headers: Vec<(String, String)>, + body: Vec, +} + fn request( method: types::MethodParam<'_>, scheme: types::SchemeParam<'_>, @@ -8,7 +15,7 @@ fn request( path: &str, query: &str, body: &[u8], -) -> Result<()> { +) -> Result { let headers = types::new_fields(&[ ("User-agent", "WASI-HTTP/0.0.1"), ("Content-type", "application/json"), @@ -17,18 +24,96 @@ fn request( let request = types::new_outgoing_request(method, path, query, Some(scheme), authority, headers); - let request_stream = types::outgoing_request_write(request) + let request_body = types::outgoing_request_write(request) .map_err(|_| anyhow!("outgoing request write failed"))?; let mut body_cursor = 0; while body_cursor < body.len() { - let written = streams::write(request_stream, &body[body_cursor..])?; + let written = + streams::write(request_body, &body[body_cursor..]).context("writing request body")?; body_cursor += written as usize; } - default_outgoing_http::handle(request, None); + streams::drop_output_stream(request_body); + + let future_response = default_outgoing_http::handle(request, None); + // TODO: we could create a pollable from the future_response and poll on it here to test that + // its available immediately + + types::drop_outgoing_request(request); + + let incoming_response = types::future_incoming_response_get(future_response) + .ok_or_else(|| anyhow!("incoming response is available immediately"))? + // TODO: maybe anything that appears in the Result<_, E> position should impl + // Error? anyway, just use its Debug here: + .map_err(|e| anyhow!("incoming response error: {e:?}"))?; + + types::drop_future_incoming_response(future_response); + + let status = types::incoming_response_status(incoming_response); + + let headers_handle = types::incoming_response_headers(incoming_response); + let headers = types::fields_entries(headers_handle); + types::drop_fields(headers_handle); + + let body_stream = types::incoming_response_consume(incoming_response) + .map_err(|()| anyhow!("incoming response has no body stream"))?; + types::drop_incoming_response(incoming_response); - todo!() + let mut body = Vec::new(); + let mut eof = false; + while !eof { + let (mut body_chunk, stream_ended) = streams::read(body_stream, u64::MAX)?; + eof = stream_ended; + body.append(&mut body_chunk); + } + streams::drop_input_stream(body_stream); + + Ok(Response { + status, + headers, + body, + }) } -fn main() {} +fn main() -> Result<()> { + let r1 = request( + types::MethodParam::Get, + types::SchemeParam::Https, + "postman-echo.com", + "/get", + "?some=arg?goes=here", + &[], + ) + .context("postman-echo /get")?; + + println!("postman-echo /get: {r1:?}"); + assert_eq!(r1.status, 200); + + let r2 = request( + types::MethodParam::Post, + types::SchemeParam::Https, + "postman-echo.com", + "/post", + "", + b"{\"foo\": \"bar\"}", + ) + .context("postman-echo /post")?; + + println!("postman-echo /post: {r2:?}"); + assert_eq!(r2.status, 200); + + let r3 = request( + types::MethodParam::Put, + types::SchemeParam::Https, + "postman-echo.com", + "/put", + "", + &[], + ) + .context("postman-echo /put")?; + + println!("postman-echo /put: {r3:?}"); + assert_eq!(r3.status, 200); + Ok(()) +} From 54dbf9776835102e267d7456633af8b6bea8a11f Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 27 Mar 2023 13:06:21 -0700 Subject: [PATCH 24/46] better debug output --- .../wasi-http-tests/src/bin/outbound_request.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs index eea8026ed2bc..b591a772fa8c 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs @@ -1,12 +1,25 @@ use anyhow::{anyhow, Context, Result}; +use std::fmt; use wasi_http_tests::*; -#[derive(Debug)] struct Response { status: types::StatusCode, headers: Vec<(String, String)>, body: Vec, } +impl fmt::Debug for Response { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut out = f.debug_struct("Response"); + out.field("status", &self.status) + .field("headers", &self.headers); + if let Ok(body) = std::str::from_utf8(&self.body) { + out.field("body", &body); + } else { + out.field("body", &self.body); + } + out.finish() + } +} fn request( method: types::MethodParam<'_>, From eb619bd60e93b66b5f24946d09b64164d56b2773 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 27 Mar 2023 13:06:30 -0700 Subject: [PATCH 25/46] wasi-http: some stubs required for rust rewrite of the example --- crates/wasi-http/src/component_impl.rs | 17 +++++++++++++++++ crates/wasi-http/src/streams_impl.rs | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs index 2972ef77a05f..c45574a4bf0a 100644 --- a/crates/wasi-http/src/component_impl.rs +++ b/crates/wasi-http/src/component_impl.rs @@ -193,6 +193,14 @@ pub fn add_component_to_linker( Ok(ctx.incoming_response_status(id)?.into()) }, )?; + linker.func_wrap( + "types", + "drop-future-incoming-response", + move |mut caller: Caller<'_, T>, _future: u32| -> anyhow::Result<()> { + // FIXME: Intentionally left blank + Ok(()) + }, + )?; linker.func_wrap( "types", "future-incoming-response-get", @@ -254,6 +262,15 @@ pub fn add_component_to_linker( Ok(()) }, )?; + linker.func_wrap( + "streams", + "drop-output-stream", + move |mut caller: Caller<'_, T>, id: u32| -> anyhow::Result<()> { + let ctx = get_cx(caller.data_mut()); + ctx.drop_output_stream(id)?; + Ok(()) + }, + )?; linker.func_wrap( "types", "outgoing-request-write", diff --git a/crates/wasi-http/src/streams_impl.rs b/crates/wasi-http/src/streams_impl.rs index 457bbea9452e..afaf0153e655 100644 --- a/crates/wasi-http/src/streams_impl.rs +++ b/crates/wasi-http/src/streams_impl.rs @@ -86,6 +86,8 @@ impl crate::streams::Host for WasiHttp { } fn drop_output_stream(&mut self, _this: OutputStream) -> wasmtime::Result<()> { - bail!("unimplemented: drop_output_stream"); + //bail!("unimplemented: drop_output_stream"); + //FIXME: intentionally ignoring + Ok(()) } } From 86a0c5dd3f824a7890e81b5914ef0e6daf140515 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 28 Mar 2023 16:03:25 -0700 Subject: [PATCH 26/46] add wasi_http tests to test-programs --- Cargo.lock | 43 +++ crates/test-programs/Cargo.toml | 3 + crates/test-programs/build.rs | 266 ++++++++++++------ crates/test-programs/tests/http_tests/main.rs | 12 + .../tests/http_tests/runtime/mod.rs | 1 + .../http_tests/runtime/wasi_http_tests.rs | 39 +++ .../test-programs/tests/http_tests/utils.rs | 13 + 7 files changed, 287 insertions(+), 90 deletions(-) create mode 100644 crates/test-programs/tests/http_tests/main.rs create mode 100644 crates/test-programs/tests/http_tests/runtime/mod.rs create mode 100644 crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs create mode 100644 crates/test-programs/tests/http_tests/utils.rs diff --git a/Cargo.lock b/Cargo.lock index 0b1b718d2d7a..899b3b88d49b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,6 +240,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "camino" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +dependencies = [ + "serde", +] + [[package]] name = "cap-fs-ext" version = "1.0.5" @@ -336,6 +345,29 @@ dependencies = [ "libc", ] +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a1ec454bc3eead8719cb56e15dbbfecdbc14e4b3a3ae4936cc6e31f5fc0d07" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cast" version = "0.3.0" @@ -2845,6 +2877,15 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +dependencies = [ + "serde", +] + [[package]] name = "serde" version = "1.0.137" @@ -3124,6 +3165,7 @@ version = "0.0.0" dependencies = [ "anyhow", "cap-std", + "cargo_metadata", "cfg-if", "os_pipe", "target-lexicon", @@ -3132,6 +3174,7 @@ dependencies = [ "tracing-subscriber", "wasi-cap-std-sync", "wasi-common", + "wasi-http", "wasmtime", "wasmtime-wasi", "wat", diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index a9a30df23203..8e7dc7d8dbce 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -9,6 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" [build-dependencies] cfg-if = "1.0" +cargo_metadata = "0.15.3" [dev-dependencies] wasi-common = { workspace = true } @@ -23,6 +24,8 @@ anyhow = { workspace = true } wat = { workspace = true } cap-std = { workspace = true } tokio = { version = "1.8.0", features = ["rt-multi-thread"] } +wasi-http = { workspace = true } [features] test_programs = [] +test_programs_http = [ "wasmtime/component-model" ] diff --git a/crates/test-programs/build.rs b/crates/test-programs/build.rs index 55e12aa0b51b..d43de513fa97 100644 --- a/crates/test-programs/build.rs +++ b/crates/test-programs/build.rs @@ -1,25 +1,105 @@ +#![allow(dead_code)] //! Build program to generate a program which runs all the testsuites. //! //! By generating a separate `#[test]` test for each file, we allow cargo test //! to automatically run the files in parallel. +use std::fs::{read_dir, File}; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; fn main() { #[cfg(feature = "test_programs")] - wasi_tests::build_and_generate_tests() + wasi_tests::build_and_generate_tests(); + #[cfg(feature = "test_programs_http")] + wasi_http_tests::build_and_generate_tests(); +} + +fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result> { + let mut cmd = Command::new("cargo"); + cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "1"); + cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); + cmd.args(&[ + "build", + "--release", + "--target=wasm32-wasi", + "--target-dir", + out_dir.to_str().unwrap(), + ]) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .current_dir(testsuite); + let output = cmd.output()?; + + let status = output.status; + if !status.success() { + panic!( + "Building tests failed: exit code: {}", + status.code().unwrap() + ); + } + + let meta = cargo_metadata::MetadataCommand::new() + .manifest_path(PathBuf::from(testsuite).join("Cargo.toml")) + .exec() + .expect("cargo metadata"); + + Ok(meta + .packages + .iter() + .find(|p| p.name == testsuite) + .unwrap() + .targets + .iter() + .filter(|t| t.kind == ["bin"]) + .map(|t| t.name.clone()) + .collect::>()) +} + +#[allow(dead_code)] +fn test_directory( + out: &mut File, + test_binaries: &[String], + testsuite: &str, + runtime: &str, + out_dir: &Path, + mut write_testsuite_tests: impl FnMut(&mut File, &Path, &str) -> io::Result<()>, +) -> io::Result<()> { + writeln!( + out, + "mod {} {{", + Path::new(testsuite) + .file_stem() + .expect("testsuite filename should have a stem") + .to_str() + .expect("testsuite filename should be representable as a string") + .replace("-", "_") + )?; + writeln!( + out, + " use super::{{runtime::{} as runtime, utils, setup_log}};", + runtime + )?; + for test_binary in test_binaries { + let binary_path = out_dir + .join("wasm32-wasi") + .join("release") + .join(format!("{}.wasm", test_binary.replace("-", "_"))); + write_testsuite_tests(out, &binary_path, testsuite)?; + } + writeln!(out, "}}")?; + Ok(()) } #[cfg(feature = "test_programs")] mod wasi_tests { + use super::*; use std::env; - use std::fs::{read_dir, File}; - use std::io::{self, Write}; - use std::path::{Path, PathBuf}; - use std::process::{Command, Stdio}; pub(super) fn build_and_generate_tests() { // Validate if any of test sources are present and if they changed // This should always work since there is no submodule to init anymore - let bin_tests = std::fs::read_dir("wasi-tests/src/bin").unwrap(); + let bin_tests = read_dir("wasi-tests/src/bin").unwrap(); for test in bin_tests { if let Ok(test_file) = test { let test_file_path = test_file @@ -38,90 +118,25 @@ mod wasi_tests { ); let mut out = File::create(out_dir.join("wasi_tests.rs")).expect("error generating test source file"); - build_tests("wasi-tests", &out_dir).expect("building tests"); - test_directory(&mut out, "wasi-cap-std-sync", "cap_std_sync", &out_dir) - .expect("generating wasi-cap-std-sync tests"); - test_directory(&mut out, "wasi-tokio", "tokio", &out_dir) - .expect("generating wasi-tokio tests"); - } - - fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result<()> { - let mut cmd = Command::new("cargo"); - cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "1"); - cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); - cmd.args(&[ - "build", - "--release", - "--target=wasm32-wasi", - "--target-dir", - out_dir.to_str().unwrap(), - ]) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .current_dir(testsuite); - let output = cmd.output()?; - - let status = output.status; - if !status.success() { - panic!( - "Building tests failed: exit code: {}", - status.code().unwrap() - ); - } - - Ok(()) - } - - fn test_directory( - out: &mut File, - testsuite: &str, - runtime: &str, - out_dir: &Path, - ) -> io::Result<()> { - let mut dir_entries: Vec<_> = read_dir(out_dir.join("wasm32-wasi/release")) - .expect("reading testsuite directory") - .map(|r| r.expect("reading testsuite directory entry")) - .filter(|dir_entry| { - let p = dir_entry.path(); - if let Some(ext) = p.extension() { - // Only look at wast files. - if ext == "wasm" { - // Ignore files starting with `.`, which could be editor temporary files - if let Some(stem) = p.file_stem() { - if let Some(stemstr) = stem.to_str() { - if !stemstr.starts_with('.') { - return true; - } - } - } - } - } - false - }) - .collect(); - - dir_entries.sort_by_key(|dir| dir.path()); - - writeln!( - out, - "mod {} {{", - Path::new(testsuite) - .file_stem() - .expect("testsuite filename should have a stem") - .to_str() - .expect("testsuite filename should be representable as a string") - .replace("-", "_") - )?; - writeln!( - out, - " use super::{{runtime::{} as runtime, utils, setup_log}};", - runtime - )?; - for dir_entry in dir_entries { - write_testsuite_tests(out, &dir_entry.path(), testsuite)?; - } - writeln!(out, "}}")?; - Ok(()) + let test_binaries = build_tests("wasi-tests", &out_dir).expect("building tests"); + test_directory( + &mut out, + &test_binaries, + "wasi-cap-std-sync", + "cap_std_sync", + &out_dir, + write_testsuite_tests, + ) + .expect("generating wasi-cap-std-sync tests"); + test_directory( + &mut out, + &test_binaries, + "wasi-tokio", + "tokio", + &out_dir, + write_testsuite_tests, + ) + .expect("generating wasi-tokio tests"); } fn write_testsuite_tests(out: &mut File, path: &Path, testsuite: &str) -> io::Result<()> { @@ -277,3 +292,74 @@ mod wasi_tests { } } } + +#[cfg(feature = "test_programs_http")] +mod wasi_http_tests { + use super::*; + use std::env; + + pub(super) fn build_and_generate_tests() { + // Validate if any of test sources are present and if they changed + // This should always work since there is no submodule to init anymore + let bin_tests = read_dir("wasi-http-tests/src/bin").unwrap(); + for test in bin_tests { + if let Ok(test_file) = test { + let test_file_path = test_file + .path() + .into_os_string() + .into_string() + .expect("test file path"); + println!("cargo:rerun-if-changed={}", test_file_path); + } + } + println!("cargo:rerun-if-changed=wasi-http-tests/Cargo.toml"); + println!("cargo:rerun-if-changed=wasi-http-tests/src/lib.rs"); + // Build tests to OUT_DIR (target/*/build/wasi-common-*/out/wasm32-wasi/release/*.wasm) + let out_dir = PathBuf::from( + env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set"), + ); + let mut out = File::create(out_dir.join("wasi_http_tests.rs")) + .expect("error generating test source file"); + + let test_binaries = build_tests("wasi-http-tests", &out_dir).expect("building tests"); + test_directory( + &mut out, + &test_binaries, + "wasi-http-tests", + "wasi_http_tests", + &out_dir, + write_testsuite_tests, + ) + .expect("generating wasi-cap-std-sync tests"); + } + + fn write_testsuite_tests(out: &mut File, path: &Path, _testsuite: &str) -> io::Result<()> { + let stemstr = path + .file_stem() + .expect("file_stem") + .to_str() + .expect("to_str"); + + writeln!(out, " #[test]")?; + let test_fn_name = stemstr.replace("-", "_"); + writeln!(out, " fn r#{}() -> anyhow::Result<()> {{", test_fn_name,)?; + writeln!(out, " setup_log();")?; + writeln!( + out, + " let path = std::path::Path::new(r#\"{}\"#);", + path.display() + )?; + writeln!(out, " let data = wat::parse_file(path)?;")?; + writeln!( + out, + " let bin_name = utils::extract_exec_name_from_path(path)?;" + )?; + writeln!( + out, + " runtime::instantiate_inherit_stdio(&data, &bin_name, None)", + )?; + writeln!(out, " }}")?; + writeln!(out)?; + Ok(()) + } +} diff --git a/crates/test-programs/tests/http_tests/main.rs b/crates/test-programs/tests/http_tests/main.rs new file mode 100644 index 000000000000..28a8c956d9f4 --- /dev/null +++ b/crates/test-programs/tests/http_tests/main.rs @@ -0,0 +1,12 @@ +#![cfg(feature = "test_programs_http")] +use std::sync::Once; +mod runtime; +mod utils; + +static LOG_INIT: Once = Once::new(); + +fn setup_log() { + LOG_INIT.call_once(tracing_subscriber::fmt::init) +} + +include!(concat!(env!("OUT_DIR"), "/wasi_http_tests.rs")); diff --git a/crates/test-programs/tests/http_tests/runtime/mod.rs b/crates/test-programs/tests/http_tests/runtime/mod.rs new file mode 100644 index 000000000000..5af38c5cb518 --- /dev/null +++ b/crates/test-programs/tests/http_tests/runtime/mod.rs @@ -0,0 +1 @@ +pub mod wasi_http_tests; diff --git a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs new file mode 100644 index 000000000000..9ecc631fc812 --- /dev/null +++ b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs @@ -0,0 +1,39 @@ +use anyhow::Context; +use std::path::Path; +use wasi_http::WasiHttp; +use wasmtime::{Config, Engine, Linker, Module, Store}; +use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx}; + +pub fn instantiate_inherit_stdio( + data: &[u8], + bin_name: &str, + workspace: Option<&Path>, +) -> anyhow::Result<()> { + let mut config = Config::new(); + let engine = Engine::new(&config)?; + let module = Module::new(&engine, &data).context("failed to create wasm module")?; + let mut linker = Linker::new(&engine); + + struct Ctx { + wasi: WasiCtx, + http: WasiHttp, + } + + wasmtime_wasi::sync::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.wasi)?; + wasi_http::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.http)?; + + // Create our wasi context. + let mut builder = WasiCtxBuilder::new().inherit_stdio().arg(bin_name)?; + + let mut store = Store::new( + &engine, + Ctx { + wasi: builder.build(), + http: WasiHttp::new(), + }, + ); + + let instance = linker.instantiate(&mut store, &module)?; + let start = instance.get_typed_func::<(), ()>(&mut store, "_start")?; + start.call(&mut store, ()) +} diff --git a/crates/test-programs/tests/http_tests/utils.rs b/crates/test-programs/tests/http_tests/utils.rs new file mode 100644 index 000000000000..d455b96590c3 --- /dev/null +++ b/crates/test-programs/tests/http_tests/utils.rs @@ -0,0 +1,13 @@ +use std::path::Path; + +pub fn extract_exec_name_from_path(path: &Path) -> anyhow::Result { + path.file_stem() + .and_then(|s| s.to_str()) + .map(String::from) + .ok_or_else(|| { + anyhow::anyhow!( + "couldn't extract the file stem from path {}", + path.display() + ) + }) +} From 64d697980d99708564c8f445e8a0a1b96355c1b7 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 28 Mar 2023 16:06:41 -0700 Subject: [PATCH 27/46] CI: run the http tests --- .github/workflows/main.yml | 1 + ci/run-tests.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d37127a0596..b7e73eeec2a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -383,6 +383,7 @@ jobs: - run: cargo fetch --locked - run: cargo fetch --locked --manifest-path crates/test-programs/wasi-tests/Cargo.toml + - run: cargo fetch --locked --manifest-path crates/test-programs/wasi-http-tests/Cargo.toml - uses: actions/cache@v3 with: diff --git a/ci/run-tests.sh b/ci/run-tests.sh index db187b779e40..67e53eb87b51 100755 --- a/ci/run-tests.sh +++ b/ci/run-tests.sh @@ -2,6 +2,7 @@ cargo test \ --features "test-programs/test_programs" \ + --features "test-programs/test_programs_http" \ --features wasi-threads \ --workspace \ --exclude 'wasmtime-wasi-*' \ From 7c9cfd27d6f7fa1c2378e6c07a3b11da729380f5 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 30 Mar 2023 15:55:50 +0000 Subject: [PATCH 28/46] Fix some warnings. --- crates/wasi-http/src/component_impl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-http/src/component_impl.rs b/crates/wasi-http/src/component_impl.rs index c45574a4bf0a..a77af025e53e 100644 --- a/crates/wasi-http/src/component_impl.rs +++ b/crates/wasi-http/src/component_impl.rs @@ -196,7 +196,7 @@ pub fn add_component_to_linker( linker.func_wrap( "types", "drop-future-incoming-response", - move |mut caller: Caller<'_, T>, _future: u32| -> anyhow::Result<()> { + move |_caller: Caller<'_, T>, _future: u32| -> anyhow::Result<()> { // FIXME: Intentionally left blank Ok(()) }, From 3df74cf382e5e9070ca2c50483e1c4c5ba48b525 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 30 Mar 2023 08:57:03 -0700 Subject: [PATCH 29/46] bump new deps to latest releases (#3) * Add tests for wasi-http to test-programs (#2) * wip: start writing a http test... * finish writing the outbound request example havent executed it yet * better debug output * wasi-http: some stubs required for rust rewrite of the example * add wasi_http tests to test-programs * CI: run the http tests * bump new deps to latest releases h2 0.3.16 http 0.2.9 mio 0.8.6 openssl 0.10.48 openssl-sys 0.9.83 tokio 1.26.0 --------- Co-authored-by: Brendan Burns --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 899b3b88d49b..eca9a63e4444 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1536,9 +1536,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -1626,9 +1626,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -2035,14 +2035,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2190,9 +2190,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.45" +version = "0.10.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" dependencies = [ "bitflags", "cfg-if", @@ -2222,9 +2222,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" dependencies = [ "autocfg 1.1.0", "cc", @@ -3242,9 +3242,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg 1.1.0", "bytes", @@ -3255,7 +3255,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] From b73fad86849c2b5634ccc7d1dcc9df9e433db0c0 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 30 Mar 2023 12:59:29 -0700 Subject: [PATCH 30/46] Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs --- .../test-programs/tests/http_tests/runtime/wasi_http_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs index 9ecc631fc812..0ea47600d4ec 100644 --- a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs +++ b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs @@ -23,7 +23,7 @@ pub fn instantiate_inherit_stdio( wasi_http::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.http)?; // Create our wasi context. - let mut builder = WasiCtxBuilder::new().inherit_stdio().arg(bin_name)?; + let builder = WasiCtxBuilder::new().inherit_stdio().arg(bin_name)?; let mut store = Store::new( &engine, From ff6bf4a05f80e8cfcb870a4c00593c42cab57dae Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 30 Mar 2023 12:59:36 -0700 Subject: [PATCH 31/46] Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs --- .../test-programs/tests/http_tests/runtime/wasi_http_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs index 0ea47600d4ec..fbfb926c7451 100644 --- a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs +++ b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs @@ -9,7 +9,7 @@ pub fn instantiate_inherit_stdio( bin_name: &str, workspace: Option<&Path>, ) -> anyhow::Result<()> { - let mut config = Config::new(); + let config = Config::new(); let engine = Engine::new(&config)?; let module = Module::new(&engine, &data).context("failed to create wasm module")?; let mut linker = Linker::new(&engine); From daf5cc6bcca08beed901a1c3dc39ba5bbb8d54c4 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 30 Mar 2023 12:59:43 -0700 Subject: [PATCH 32/46] Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs --- .../test-programs/tests/http_tests/runtime/wasi_http_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs index fbfb926c7451..18fc04d2edf6 100644 --- a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs +++ b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs @@ -7,7 +7,7 @@ use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx}; pub fn instantiate_inherit_stdio( data: &[u8], bin_name: &str, - workspace: Option<&Path>, + _workspace: Option<&Path>, ) -> anyhow::Result<()> { let config = Config::new(); let engine = Engine::new(&config)?; From 362696a2d363d583887a726d979944d221eb5b4b Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 30 Mar 2023 17:05:21 -0700 Subject: [PATCH 33/46] wasi-http: fix cargo.toml file and publish script to work together (#4) unfortunately, the publish script doesn't use a proper toml parser (in order to not have any dependencies), so the whitespace has to be the trivial expected case. then, add wasi-http to the list of crates to publish. --- crates/wasi-http/Cargo.toml | 36 ++++++++++++++++++------------------ scripts/publish.rs | 1 + 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 5f16bd97be87..aa8c9ebaa598 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -1,21 +1,21 @@ [package] - name = "wasi-http" - version = "0.0.1" - authors.workspace = true - edition.workspace = true - repository = "https://github.com/WebAssembly/wasi-http" - license = "Apache-2.0 WITH LLVM-exception" - description = "Experimental HTTP library for WebAssembly in Wasmtime" - readme = "readme.md" +name = "wasi-http" +version = "0.0.1" +authors.workspace = true +edition.workspace = true +repository = "https://github.com/bytecodealliance/wasmtime" +license = "Apache-2.0 WITH LLVM-exception" +description = "Experimental HTTP library for WebAssembly in Wasmtime" +readme = "readme.md" [dependencies] - anyhow = { workspace = true } - bytes = "1.1.0" - hyper = { version = "1.0.0-rc.3", features = ["full"] } - tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } - tokio-native-tls = { version = "0.3.1" } - futures = { version = "0.3.27" } - http-body = "1.0.0-rc.2" - http-body-util = "0.1.0-rc.2" - thiserror = { workspace = true } - wasmtime = { workspace = true, features = ['component-model'] } +anyhow = { workspace = true } +bytes = "1.1.0" +hyper = { version = "1.0.0-rc.3", features = ["full"] } +tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } +tokio-native-tls = { version = "0.3.1" } +futures = { version = "0.3.27" } +http-body = "1.0.0-rc.2" +http-body-util = "0.1.0-rc.2" +thiserror = { workspace = true } +wasmtime = { workspace = true, features = ['component-model'] } diff --git a/scripts/publish.rs b/scripts/publish.rs index b64b178db8e0..6825eb40a32d 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -64,6 +64,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[ "wasi-common", "wasi-cap-std-sync", "wasi-tokio", + "wasi-http", // other misc wasmtime crates "wasmtime-wasi", "wasmtime-wasi-crypto", From f9fe6d4283354c787e55b7b75a21184240d538da Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 31 Mar 2023 09:20:24 -0700 Subject: [PATCH 34/46] Update crates/test-programs/build.rs --- crates/test-programs/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-programs/build.rs b/crates/test-programs/build.rs index d43de513fa97..60c010aa01bd 100644 --- a/crates/test-programs/build.rs +++ b/crates/test-programs/build.rs @@ -1,4 +1,4 @@ -#![allow(dead_code)] +#![allow(dead_code, unused_imports)] //! Build program to generate a program which runs all the testsuites. //! //! By generating a separate `#[test]` test for each file, we allow cargo test From cd7bb1fd7dbd5df1fa46a18a9718decf95d36314 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 21:04:36 +0000 Subject: [PATCH 35/46] Switch to rustls --- Cargo.lock | 75 +++++++++++++++++++++++++++++++ crates/wasi-http/Cargo.toml | 7 +++ crates/wasi-http/src/http_impl.rs | 36 ++++++++++++--- 3 files changed, 113 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eca9a63e4444..08eda9448920 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2769,6 +2769,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "rsa" version = "0.5.0" @@ -2812,6 +2827,28 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "rustls" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07180898a28ed6a7f7ba2311594308f595e3dd2e3c3812fa0a80a47b45f17e5d" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rusty-fork" version = "0.3.0" @@ -2854,6 +2891,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "2.8.1" @@ -3279,6 +3326,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.4" @@ -3405,6 +3462,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.3.1" @@ -3584,10 +3647,13 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "rustls", "thiserror", "tokio", "tokio-native-tls", + "tokio-rustls", "wasmtime", + "webpki-roots", ] [[package]] @@ -4333,6 +4399,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa54963694b65584e170cf5dc46aeb4dcaa5584e652ff5f3952e56d66aff0125" +dependencies = [ + "rustls-webpki", +] + [[package]] name = "which" version = "4.2.5" diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index aa8c9ebaa598..341f73514d9b 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -13,8 +13,15 @@ anyhow = { workspace = true } bytes = "1.1.0" hyper = { version = "1.0.0-rc.3", features = ["full"] } tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } +<<<<<<< HEAD tokio-native-tls = { version = "0.3.1" } futures = { version = "0.3.27" } +======= +tokio-rustls = { version = "0.24.0" } +rustls = { version = "0.21.0" } +webpki-roots = { version = "0.23.0" } +http = { version = "0.2.9" } +>>>>>>> e9f704c80... Switch to rustls http-body = "1.0.0-rc.2" http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 832b4314e162..9267a1cf3939 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -1,7 +1,7 @@ use crate::r#struct::ActiveResponse; pub use crate::r#struct::WasiHttp; use crate::types::{RequestOptions, Scheme}; -use anyhow::bail; +use anyhow::{anyhow, bail}; use bytes::{BufMut, Bytes, BytesMut}; use http_body_util::{BodyExt, Full}; use hyper::Method; @@ -10,6 +10,8 @@ use std::time::Duration; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio::time::timeout; +use std::sync::Arc; +use tokio_rustls::rustls::{self, OwnedTrustAnchor}; impl crate::default_outgoing_http::Host for WasiHttp { fn handle( @@ -101,10 +103,34 @@ impl WasiHttp { let mut sender = if scheme == "https://" { let stream = TcpStream::connect(authority.clone()).await?; - let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; - let connector = tokio_native_tls::TlsConnector::from(connector); - let host = authority.split(":").next().unwrap_or(&authority); - let stream = connector.connect(&host, stream).await?; + //TODO: uncomment this code and make the tls implementation a feature decision. + //let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; + //let connector = tokio_native_tls::TlsConnector::from(connector); + //let host = authority.split(":").next().unwrap_or(&authority); + //let stream = connector.connect(&host, stream).await?; + + // derived from https://github.com/tokio-rs/tls/blob/master/tokio-rustls/examples/client/src/main.rs + let mut root_cert_store = rustls::RootCertStore::empty(); + root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map( + |ta| { + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + }, + )); + let config = rustls::ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(root_cert_store) + .with_no_client_auth(); + let connector = tokio_rustls::TlsConnector::from(Arc::new(config)); + let mut parts = authority.split(":"); + let host = parts.next().unwrap_or(&authority); + let domain = rustls::ServerName::try_from(host) + .map_err(|_| anyhow!("invalid dnsname"))?; + let stream = connector.connect(domain, stream).await?; + let t = timeout( connect_timeout, hyper::client::conn::http1::handshake(stream), From 039bc9ed1ed4effee851f037c27af5b8f1c01e9f Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 02:42:49 +0000 Subject: [PATCH 36/46] Cleanups. --- Cargo.lock | 23 +++++++++++++++++++++-- Cargo.toml | 7 ++++--- crates/test-programs/Cargo.toml | 2 +- crates/wasi-http/Cargo.toml | 2 +- src/commands/run.rs | 19 ++++++++++++++----- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08eda9448920..9cddb2b770cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3221,9 +3221,9 @@ dependencies = [ "tracing-subscriber", "wasi-cap-std-sync", "wasi-common", - "wasi-http", "wasmtime", "wasmtime-wasi", + "wasmtime-wasi-http", "wat", ] @@ -3638,6 +3638,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "wasi-http" version = "0.0.1" dependencies = [ @@ -3657,6 +3658,8 @@ dependencies = [ ] [[package]] +======= +>>>>>>> b6a7055bd... Cleanups. name = "wasi-tokio" version = "8.0.0" dependencies = [ @@ -4001,7 +4004,6 @@ dependencies = [ "tempfile", "test-programs", "tokio", - "wasi-http", "wasm-coredump-builder", "wasmparser", "wasmtime", @@ -4014,6 +4016,7 @@ dependencies = [ "wasmtime-runtime", "wasmtime-wasi", "wasmtime-wasi-crypto", + "wasmtime-wasi-http", "wasmtime-wasi-nn", "wasmtime-wasi-threads", "wasmtime-wast", @@ -4302,6 +4305,22 @@ dependencies = [ "wiggle", ] +[[package]] +name = "wasmtime-wasi-http" +version = "0.0.1" +dependencies = [ + "anyhow", + "bytes", + "futures", + "http-body", + "http-body-util", + "hyper", + "thiserror", + "tokio", + "tokio-native-tls", + "wasmtime", +] + [[package]] name = "wasmtime-wasi-nn" version = "8.0.0" diff --git a/Cargo.toml b/Cargo.toml index 581c687eed31..dc48b3b270f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ wasmtime-wasi = { workspace = true, features = ["exit"] } wasmtime-wasi-crypto = { workspace = true, optional = true } wasmtime-wasi-nn = { workspace = true, optional = true } wasmtime-wasi-threads = { workspace = true, optional = true } -wasi-http = { workspace = true } +wasmtime-wasi-http = { workspace = true, optional = true } clap = { workspace = true, features = ["color", "suggestions", "derive"] } anyhow = { workspace = true } target-lexicon = { workspace = true } @@ -107,7 +107,6 @@ members = [ ] exclude = [ 'crates/wasi-common/WASI/tools/witx-cli', - 'crates/wasi-http/example/rust', 'docs/rust_wasi_markdown_parser' ] @@ -165,7 +164,7 @@ cranelift-fuzzgen = { path = "cranelift/fuzzgen" } cranelift-bforest = { path = "cranelift/bforest", version = "0.95.0" } cranelift = { path = "cranelift/umbrella", version = "0.95.0" } -wasi-http = { path = "crates/wasi-http", version = "=0.0.1" } +wasmtime-wasi-http = { path = "crates/wasi-http", version = "=0.0.1" } winch-codegen = { path = "winch/codegen", version = "=0.6.0" } winch-environ = { path = "winch/environ", version = "=0.6.0" } @@ -215,6 +214,7 @@ default = [ "vtune", "wasi-nn", "wasi-threads", + "wasi-http", "pooling-allocator", ] jitdump = ["wasmtime/jitdump"] @@ -222,6 +222,7 @@ vtune = ["wasmtime/vtune"] wasi-crypto = ["dep:wasmtime-wasi-crypto"] wasi-nn = ["dep:wasmtime-wasi-nn"] wasi-threads = ["dep:wasmtime-wasi-threads"] +wasi-http = ["dep:wasmtime-wasi-http"] pooling-allocator = ["wasmtime/pooling-allocator", "wasmtime-cli-flags/pooling-allocator"] all-arch = ["wasmtime/all-arch"] posix-signals-on-macos = ["wasmtime/posix-signals-on-macos"] diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index 8e7dc7d8dbce..99f893f17467 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -24,7 +24,7 @@ anyhow = { workspace = true } wat = { workspace = true } cap-std = { workspace = true } tokio = { version = "1.8.0", features = ["rt-multi-thread"] } -wasi-http = { workspace = true } +wasmtime-wasi-http = { workspace = true } [features] test_programs = [] diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 341f73514d9b..192ae99e6a01 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasi-http" +name = "wasmtime-wasi-http" version = "0.0.1" authors.workspace = true edition.workspace = true diff --git a/src/commands/run.rs b/src/commands/run.rs index 8e4610d02d19..276310c8f640 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -14,7 +14,7 @@ use wasmtime_cli_flags::{CommonOptions, WasiModules}; use wasmtime_wasi::maybe_exit_on_error; use wasmtime_wasi::sync::{ambient_authority, Dir, TcpListener, WasiCtxBuilder}; -#[cfg(any(feature = "wasi-crypto", feature = "wasi-nn", feature = "wasi-threads"))] +#[cfg(any(feature = "wasi-crypto", feature = "wasi-nn", feature = "wasi-threads", feature = "wasi-http"))] use std::sync::Arc; #[cfg(feature = "wasi-nn")] @@ -26,7 +26,8 @@ use wasmtime_wasi_crypto::WasiCryptoCtx; #[cfg(feature = "wasi-threads")] use wasmtime_wasi_threads::WasiThreadsCtx; -use wasi_http::WasiHttp; +#[cfg(feature = "wasi-http")] +use wasmtime_wasi_http::WasiHttp; fn parse_module(s: &OsStr) -> anyhow::Result { // Do not accept wasmtime subcommand names as the module name @@ -472,6 +473,7 @@ struct Host { wasi_nn: Option>, #[cfg(feature = "wasi-threads")] wasi_threads: Option>>, + #[cfg(feature = "wasi-http")] wasi_http: Option, } @@ -573,9 +575,16 @@ fn populate_with_wasi( } if wasi_modules.wasi_http { - let w_http = WasiHttp::new(); - wasi_http::add_to_linker(linker, |host: &mut Host| host.wasi_http.as_mut().unwrap())?; - store.data_mut().wasi_http = Some(w_http); + #[cfg(not(feature = "wasi-http"))] + { + bail!("Cannot enable wasi-http when the binary is not compiled with this feature."); + } + #[cfg(feature = "wasi-http")] + { + let w_http = WasiHttp::new(); + wasmtime_wasi_http::add_to_linker(linker, |host: &mut Host| host.wasi_http.as_mut().unwrap())?; + store.data_mut().wasi_http = Some(w_http); + } } Ok(()) From 0150963621bb64178bd2b5a4feb56d2bb251f0c8 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 21:23:00 +0000 Subject: [PATCH 37/46] Merge switch to rustls. --- Cargo.lock | 285 ++++-------------------------------- crates/wasi-http/Cargo.toml | 5 - 2 files changed, 26 insertions(+), 264 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9cddb2b770cb..eb2d3cd98489 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,7 +258,7 @@ dependencies = [ "cap-primitives", "cap-std", "io-lifetimes", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -274,7 +274,7 @@ dependencies = [ "ipnet", "maybe-owned", "rustix", - "windows-sys 0.45.0", + "windows-sys", "winx", ] @@ -558,22 +558,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "cpp_demangle" version = "0.3.5" @@ -743,7 +727,7 @@ dependencies = [ "region", "target-lexicon", "wasmtime-jit-icache-coherence", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1264,7 +1248,7 @@ checksum = "8ef1a30ae415c3a691a4f41afddc2dbcd6d70baf338368d85ebc1e8ed92cedb9" dependencies = [ "cfg-if", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1321,21 +1305,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1353,7 +1322,7 @@ checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" dependencies = [ "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1366,21 +1335,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "futures" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.27" @@ -1388,7 +1342,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -1397,34 +1350,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" -[[package]] -name = "futures-executor" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" - -[[package]] -name = "futures-macro" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "futures-sink" version = "0.3.27" @@ -1443,16 +1368,10 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ - "futures-channel", "futures-core", - "futures-io", - "futures-macro", - "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", - "slab", ] [[package]] @@ -1768,7 +1687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d79107d6e60d78351e11f0a2dc9d0eaf304a7efb592e92603783afb8479c7d97" dependencies = [ "io-lifetimes", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1778,7 +1697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" dependencies = [ "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1796,7 +1715,7 @@ dependencies = [ "hermit-abi 0.3.0", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -2042,25 +1961,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", + "windows-sys", ] [[package]] @@ -2188,51 +2089,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl" -version = "0.10.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" -dependencies = [ - "autocfg 1.1.0", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "openvino" version = "0.4.2" @@ -2374,12 +2230,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - [[package]] name = "plotters" version = "0.3.1" @@ -2824,7 +2674,7 @@ dependencies = [ "libc", "linux-raw-sys", "once_cell", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -2876,15 +2726,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys 0.42.0", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -2901,29 +2742,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.17" @@ -3163,7 +2981,7 @@ dependencies = [ "fd-lock", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys", "winx", ] @@ -3302,7 +3120,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -3316,16 +3134,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.0" @@ -3507,12 +3315,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" @@ -3587,7 +3389,7 @@ dependencies = [ "tempfile", "tracing", "wasi-common", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -3605,7 +3407,7 @@ dependencies = [ "tracing", "wasmtime", "wiggle", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -3638,28 +3440,6 @@ dependencies = [ ] [[package]] -<<<<<<< HEAD -name = "wasi-http" -version = "0.0.1" -dependencies = [ - "anyhow", - "bytes", - "futures", - "http-body", - "http-body-util", - "hyper", - "rustls", - "thiserror", - "tokio", - "tokio-native-tls", - "tokio-rustls", - "wasmtime", - "webpki-roots", -] - -[[package]] -======= ->>>>>>> b6a7055bd... Cleanups. name = "wasi-tokio" version = "8.0.0" dependencies = [ @@ -3902,7 +3682,7 @@ dependencies = [ "wasmtime-runtime", "wasmtime-wasi", "wat", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -3972,7 +3752,7 @@ dependencies = [ "sha2 0.10.2", "tempfile", "toml", - "windows-sys 0.45.0", + "windows-sys", "zstd", ] @@ -4022,7 +3802,7 @@ dependencies = [ "wasmtime-wast", "wast 55.0.0", "wat", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -4150,7 +3930,7 @@ dependencies = [ "cfg-if", "rustix", "wasmtime-asm-macros", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -4226,7 +4006,7 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -4244,7 +4024,7 @@ version = "8.0.0" dependencies = [ "cfg-if", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -4269,7 +4049,7 @@ dependencies = [ "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -4311,14 +4091,16 @@ version = "0.0.1" dependencies = [ "anyhow", "bytes", - "futures", + "http", "http-body", "http-body-util", "hyper", + "rustls", "thiserror", "tokio", - "tokio-native-tls", + "tokio-rustls", "wasmtime", + "webpki-roots", ] [[package]] @@ -4595,21 +4377,6 @@ dependencies = [ "winch-test-macros", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -4684,7 +4451,7 @@ checksum = "129cd8ee937d535e1a239d9d3c9c0525af0454bc0967d9211a251be062513520" dependencies = [ "bitflags", "io-lifetimes", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 192ae99e6a01..3fc7b10ad2ec 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -13,15 +13,10 @@ anyhow = { workspace = true } bytes = "1.1.0" hyper = { version = "1.0.0-rc.3", features = ["full"] } tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } -<<<<<<< HEAD -tokio-native-tls = { version = "0.3.1" } -futures = { version = "0.3.27" } -======= tokio-rustls = { version = "0.24.0" } rustls = { version = "0.21.0" } webpki-roots = { version = "0.23.0" } http = { version = "0.2.9" } ->>>>>>> e9f704c80... Switch to rustls http-body = "1.0.0-rc.2" http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } From 28ebfe2408bdc490c8667e23eafc3e4f75376fee Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 21:25:05 +0000 Subject: [PATCH 38/46] Formatting --- crates/wasi-http/src/http_impl.rs | 8 ++++---- src/commands/run.rs | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 9267a1cf3939..d00c96fe0aac 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -6,11 +6,11 @@ use bytes::{BufMut, Bytes, BytesMut}; use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; +use std::sync::Arc; use std::time::Duration; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio::time::timeout; -use std::sync::Arc; use tokio_rustls::rustls::{self, OwnedTrustAnchor}; impl crate::default_outgoing_http::Host for WasiHttp { @@ -127,10 +127,10 @@ impl WasiHttp { let connector = tokio_rustls::TlsConnector::from(Arc::new(config)); let mut parts = authority.split(":"); let host = parts.next().unwrap_or(&authority); - let domain = rustls::ServerName::try_from(host) - .map_err(|_| anyhow!("invalid dnsname"))?; + let domain = + rustls::ServerName::try_from(host).map_err(|_| anyhow!("invalid dnsname"))?; let stream = connector.connect(domain, stream).await?; - + let t = timeout( connect_timeout, hyper::client::conn::http1::handshake(stream), diff --git a/src/commands/run.rs b/src/commands/run.rs index 276310c8f640..21bde693938e 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -14,7 +14,12 @@ use wasmtime_cli_flags::{CommonOptions, WasiModules}; use wasmtime_wasi::maybe_exit_on_error; use wasmtime_wasi::sync::{ambient_authority, Dir, TcpListener, WasiCtxBuilder}; -#[cfg(any(feature = "wasi-crypto", feature = "wasi-nn", feature = "wasi-threads", feature = "wasi-http"))] +#[cfg(any( + feature = "wasi-crypto", + feature = "wasi-nn", + feature = "wasi-threads", + feature = "wasi-http" +))] use std::sync::Arc; #[cfg(feature = "wasi-nn")] @@ -582,7 +587,9 @@ fn populate_with_wasi( #[cfg(feature = "wasi-http")] { let w_http = WasiHttp::new(); - wasmtime_wasi_http::add_to_linker(linker, |host: &mut Host| host.wasi_http.as_mut().unwrap())?; + wasmtime_wasi_http::add_to_linker(linker, |host: &mut Host| { + host.wasi_http.as_mut().unwrap() + })?; store.data_mut().wasi_http = Some(w_http); } } From 04f3e1357e4c753b175defc7f7e2e243b354bc5e Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 21:25:52 +0000 Subject: [PATCH 39/46] Remove libssl install --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f95a901a9b7f..44a56893bc44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -394,7 +394,7 @@ jobs: run: | set -ex sudo apt-get update - sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build libssl-dev + sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build # Configure Cargo for cross compilation and tell it how it can run # cross executables From f02db0f19f99eeb82c369b511cb56743f31b7f60 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 31 Mar 2023 22:20:56 +0000 Subject: [PATCH 40/46] Fix tests. --- .../test-programs/tests/http_tests/runtime/wasi_http_tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs index 18fc04d2edf6..e322b6d799e4 100644 --- a/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs +++ b/crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs @@ -1,8 +1,8 @@ use anyhow::Context; use std::path::Path; -use wasi_http::WasiHttp; use wasmtime::{Config, Engine, Linker, Module, Store}; use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx}; +use wasmtime_wasi_http::WasiHttp; pub fn instantiate_inherit_stdio( data: &[u8], @@ -20,7 +20,7 @@ pub fn instantiate_inherit_stdio( } wasmtime_wasi::sync::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.wasi)?; - wasi_http::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.http)?; + wasmtime_wasi_http::add_to_linker(&mut linker, |cx: &mut Ctx| &mut cx.http)?; // Create our wasi context. let builder = WasiCtxBuilder::new().inherit_stdio().arg(bin_name)?; From 0c704c7f4728accd2d8cad4a0d130513b8d16569 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 4 Apr 2023 18:59:24 +0000 Subject: [PATCH 41/46] Rename wasi-http -> wasmtime-wasi-http --- scripts/publish.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.rs b/scripts/publish.rs index 6825eb40a32d..64081e5dece1 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -64,10 +64,10 @@ const CRATES_TO_PUBLISH: &[&str] = &[ "wasi-common", "wasi-cap-std-sync", "wasi-tokio", - "wasi-http", // other misc wasmtime crates "wasmtime-wasi", "wasmtime-wasi-crypto", + "wasmtime-wasi-http", "wasmtime-wasi-nn", "wasmtime-wasi-threads", "wasmtime-wast", From 8caa6660cc960e44d89a8a019d6ea782e07a6d2c Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 5 Apr 2023 03:18:26 +0000 Subject: [PATCH 42/46] prtest:full Conditionalize TLS on riscv64gc. --- crates/wasi-http/Cargo.toml | 8 ++- crates/wasi-http/src/http_impl.rs | 92 +++++++++++++++++-------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 3fc7b10ad2ec..996b5ec67012 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -13,11 +13,13 @@ anyhow = { workspace = true } bytes = "1.1.0" hyper = { version = "1.0.0-rc.3", features = ["full"] } tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } -tokio-rustls = { version = "0.24.0" } -rustls = { version = "0.21.0" } -webpki-roots = { version = "0.23.0" } http = { version = "0.2.9" } http-body = "1.0.0-rc.2" http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } wasmtime = { workspace = true, features = ['component-model'] } + +[target.'cfg(not(target_arch = "riscv64gc"))'.dependencies] +tokio-rustls = { version = "0.24.0" } +rustls = { version = "0.21.0" } +webpki-roots = { version = "0.23.0" } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index d00c96fe0aac..cbef4b729197 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -1,17 +1,21 @@ use crate::r#struct::ActiveResponse; pub use crate::r#struct::WasiHttp; use crate::types::{RequestOptions, Scheme}; -use anyhow::{anyhow, bail}; +use anyhow::bail; use bytes::{BufMut, Bytes, BytesMut}; use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; -use std::sync::Arc; use std::time::Duration; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio::time::timeout; +#[cfg(not(target_arch = "riscv64gc"))] +use std::sync::Arc; +#[cfg(not(target_arch = "riscv64gc"))] use tokio_rustls::rustls::{self, OwnedTrustAnchor}; +#[cfg(not(target_arch = "riscv64gc"))] +use anyhow::anyhow; impl crate::default_outgoing_http::Host for WasiHttp { fn handle( @@ -100,49 +104,53 @@ impl WasiHttp { Some(_) => request.authority.clone(), None => request.authority.clone() + port_for_scheme(&request.scheme), }; - let mut sender = if scheme == "https://" { - let stream = TcpStream::connect(authority.clone()).await?; - //TODO: uncomment this code and make the tls implementation a feature decision. - //let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; - //let connector = tokio_native_tls::TlsConnector::from(connector); - //let host = authority.split(":").next().unwrap_or(&authority); - //let stream = connector.connect(&host, stream).await?; + #[cfg(not(target_arch = "riscv64gc"))] + { + let stream = TcpStream::connect(authority.clone()).await?; + //TODO: uncomment this code and make the tls implementation a feature decision. + //let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; + //let connector = tokio_native_tls::TlsConnector::from(connector); + //let host = authority.split(":").next().unwrap_or(&authority); + //let stream = connector.connect(&host, stream).await?; - // derived from https://github.com/tokio-rs/tls/blob/master/tokio-rustls/examples/client/src/main.rs - let mut root_cert_store = rustls::RootCertStore::empty(); - root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map( - |ta| { - OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) - }, - )); - let config = rustls::ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(root_cert_store) - .with_no_client_auth(); - let connector = tokio_rustls::TlsConnector::from(Arc::new(config)); - let mut parts = authority.split(":"); - let host = parts.next().unwrap_or(&authority); - let domain = - rustls::ServerName::try_from(host).map_err(|_| anyhow!("invalid dnsname"))?; - let stream = connector.connect(domain, stream).await?; + // derived from https://github.com/tokio-rs/tls/blob/master/tokio-rustls/examples/client/src/main.rs + let mut root_cert_store = rustls::RootCertStore::empty(); + root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map( + |ta| { + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + }, + )); + let config = rustls::ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(root_cert_store) + .with_no_client_auth(); + let connector = tokio_rustls::TlsConnector::from(Arc::new(config)); + let mut parts = authority.split(":"); + let host = parts.next().unwrap_or(&authority); + let domain = + rustls::ServerName::try_from(host).map_err(|_| anyhow!("invalid dnsname"))?; + let stream = connector.connect(domain, stream).await?; - let t = timeout( - connect_timeout, - hyper::client::conn::http1::handshake(stream), - ) - .await?; - let (s, conn) = t?; - tokio::task::spawn(async move { - if let Err(err) = conn.await { - println!("Connection failed: {:?}", err); - } - }); - s + let t = timeout( + connect_timeout, + hyper::client::conn::http1::handshake(stream), + ) + .await?; + let (s, conn) = t?; + tokio::task::spawn(async move { + if let Err(err) = conn.await { + println!("Connection failed: {:?}", err); + } + }); + s + } + #[cfg(target_arch = "riscv64gc")] + bail!("unsupported architecture for SSL") } else { let tcp = TcpStream::connect(authority).await?; let t = timeout(connect_timeout, hyper::client::conn::http1::handshake(tcp)).await?; From b6b70f5122143430b1473d90f7ac9845cb03fae4 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 5 Apr 2023 03:32:14 +0000 Subject: [PATCH 43/46] prtest:full Fix formatting, also disable tls on s390x --- crates/wasi-http/Cargo.toml | 2 +- crates/wasi-http/src/http_impl.rs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index 996b5ec67012..c6887a5e09b4 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -19,7 +19,7 @@ http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } wasmtime = { workspace = true, features = ['component-model'] } -[target.'cfg(not(target_arch = "riscv64gc"))'.dependencies] +[target.'cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))'.dependencies] tokio-rustls = { version = "0.24.0" } rustls = { version = "0.21.0" } webpki-roots = { version = "0.23.0" } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index cbef4b729197..206ebabcc0c3 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -1,21 +1,21 @@ use crate::r#struct::ActiveResponse; pub use crate::r#struct::WasiHttp; use crate::types::{RequestOptions, Scheme}; +#[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] +use anyhow::anyhow; use anyhow::bail; use bytes::{BufMut, Bytes, BytesMut}; use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; +#[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] +use std::sync::Arc; use std::time::Duration; use tokio::net::TcpStream; use tokio::runtime::Runtime; use tokio::time::timeout; -#[cfg(not(target_arch = "riscv64gc"))] -use std::sync::Arc; -#[cfg(not(target_arch = "riscv64gc"))] +#[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] use tokio_rustls::rustls::{self, OwnedTrustAnchor}; -#[cfg(not(target_arch = "riscv64gc"))] -use anyhow::anyhow; impl crate::default_outgoing_http::Host for WasiHttp { fn handle( @@ -105,7 +105,7 @@ impl WasiHttp { None => request.authority.clone() + port_for_scheme(&request.scheme), }; let mut sender = if scheme == "https://" { - #[cfg(not(target_arch = "riscv64gc"))] + #[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] { let stream = TcpStream::connect(authority.clone()).await?; //TODO: uncomment this code and make the tls implementation a feature decision. @@ -116,15 +116,15 @@ impl WasiHttp { // derived from https://github.com/tokio-rs/tls/blob/master/tokio-rustls/examples/client/src/main.rs let mut root_cert_store = rustls::RootCertStore::empty(); - root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map( - |ta| { + root_cert_store.add_server_trust_anchors( + webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| { OwnedTrustAnchor::from_subject_spki_name_constraints( ta.subject, ta.spki, ta.name_constraints, ) - }, - )); + }), + ); let config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(root_cert_store) @@ -149,7 +149,7 @@ impl WasiHttp { }); s } - #[cfg(target_arch = "riscv64gc")] + #[cfg(any(target_arch = "riscv64", target_arch = "s390x"))] bail!("unsupported architecture for SSL") } else { let tcp = TcpStream::connect(authority).await?; From c16aa23801216d88b7258950484669b2675a5c90 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 5 Apr 2023 13:51:59 +0000 Subject: [PATCH 44/46] prtest:full Add a path parameter to wit-bindgen, remove symlink. --- crates/test-programs/wasi-http-tests/src/lib.rs | 2 +- crates/wasi-http/src/lib.rs | 2 +- crates/wasi-http/wit | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 120000 crates/wasi-http/wit diff --git a/crates/test-programs/wasi-http-tests/src/lib.rs b/crates/test-programs/wasi-http-tests/src/lib.rs index cb9976a0e90c..7da3c0508914 100644 --- a/crates/test-programs/wasi-http-tests/src/lib.rs +++ b/crates/test-programs/wasi-http-tests/src/lib.rs @@ -1,3 +1,3 @@ // The macro will generate a macro for defining exports which we won't be reusing #![allow(unused)] -wit_bindgen::generate!(); +wit_bindgen::generate!({ path: "../../wasi-http/wasi-http/wit" }); diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs index eef1cc57aa54..4f90015cc5ce 100644 --- a/crates/wasi-http/src/lib.rs +++ b/crates/wasi-http/src/lib.rs @@ -1,7 +1,7 @@ use crate::component_impl::add_component_to_linker; pub use crate::r#struct::WasiHttp; -wasmtime::component::bindgen!("proxy"); +wasmtime::component::bindgen!({ path: "wasi-http/wit", world: "proxy"}); pub mod component_impl; pub mod http_impl; diff --git a/crates/wasi-http/wit b/crates/wasi-http/wit deleted file mode 120000 index a4267f5b0445..000000000000 --- a/crates/wasi-http/wit +++ /dev/null @@ -1 +0,0 @@ -wasi-http/wit \ No newline at end of file From 35e6a59beb83e0a93aa860c312155ce5b315d6ac Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 5 Apr 2023 15:37:12 +0000 Subject: [PATCH 45/46] prtest:full Fix tests for places where SSL isn't supported. --- .../wasi-http-tests/src/bin/outbound_request.rs | 8 ++++---- crates/test-programs/wasi-http-tests/wit | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) delete mode 120000 crates/test-programs/wasi-http-tests/wit diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs index b591a772fa8c..0e96aed29b68 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs @@ -89,10 +89,10 @@ fn request( }) } -fn main() -> Result<()> { +fn main() -> Result<()> { let r1 = request( types::MethodParam::Get, - types::SchemeParam::Https, + types::SchemeParam::Http, "postman-echo.com", "/get", "?some=arg?goes=here", @@ -105,7 +105,7 @@ fn main() -> Result<()> { let r2 = request( types::MethodParam::Post, - types::SchemeParam::Https, + types::SchemeParam::Http, "postman-echo.com", "/post", "", @@ -118,7 +118,7 @@ fn main() -> Result<()> { let r3 = request( types::MethodParam::Put, - types::SchemeParam::Https, + types::SchemeParam::Http, "postman-echo.com", "/put", "", diff --git a/crates/test-programs/wasi-http-tests/wit b/crates/test-programs/wasi-http-tests/wit deleted file mode 120000 index 5b8c87666437..000000000000 --- a/crates/test-programs/wasi-http-tests/wit +++ /dev/null @@ -1 +0,0 @@ -../../wasi-http/wasi-http/wit \ No newline at end of file From 224ba1c9c26ff23c446f206c002101c47f5931c2 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 5 Apr 2023 13:00:06 -0700 Subject: [PATCH 46/46] Update crates/wasi-http/Cargo.toml --- crates/wasi-http/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index c6887a5e09b4..e5b88e9f6ff3 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -19,6 +19,7 @@ http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } wasmtime = { workspace = true, features = ['component-model'] } +# The `ring` crate, used to implement TLS, does not build on riscv64 or s390x [target.'cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))'.dependencies] tokio-rustls = { version = "0.24.0" } rustls = { version = "0.21.0" }