diff --git a/Cargo.lock b/Cargo.lock index b9547d2e77..5c993200ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" dependencies = [ - "lazy_static", + "lazy_static 1.4.0", "regex", ] @@ -18,7 +18,16 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli", + "gimli 0.28.1", +] + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli 0.29.0", ] [[package]] @@ -37,18 +46,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug", -] - [[package]] name = "aes" version = "0.8.4" @@ -56,7 +53,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", - "cipher 0.4.4", + "cipher", "cpufeatures", ] @@ -67,8 +64,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", - "aes 0.8.4", - "cipher 0.4.4", + "aes", + "cipher", "ctr", "ghash", "subtle", @@ -98,9 +95,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "ambient-authority" @@ -123,49 +120,59 @@ dependencies = [ "libc", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -173,9 +180,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -192,6 +199,12 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "assert2" version = "0.3.14" @@ -226,24 +239,35 @@ dependencies = [ "futures-core", ] +[[package]] +name = "async-broadcast" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" +dependencies = [ + "event-listener 5.3.1", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-channel" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", - "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-compression" -version = "0.4.6" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" dependencies = [ "flate2", "futures-core", @@ -274,7 +298,7 @@ dependencies = [ "async-trait", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "tokio", ] @@ -293,14 +317,13 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.8.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" dependencies = [ - "async-lock 3.3.0", "async-task", "concurrent-queue", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-lite 2.3.0", "slab", ] @@ -319,11 +342,11 @@ dependencies = [ [[package]] name = "async-fs" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc19683171f287921f2405677dd2ed2549c3b3bda697a563ebc3a121ace2aba1" +checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ - "async-lock 3.3.0", + "async-lock 3.4.0", "blocking", "futures-lite 2.3.0", ] @@ -350,18 +373,18 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ - "async-lock 3.3.0", + "async-lock 3.4.0", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.6.0", - "rustix 0.38.32", + "polling 3.7.2", + "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", @@ -378,12 +401,12 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 4.0.3", - "event-listener-strategy 0.4.0", + "event-listener 5.3.1", + "event-listener-strategy", "pin-project-lite", ] @@ -409,19 +432,19 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.48.0", ] [[package]] name = "async-recursion" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -447,20 +470,20 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" dependencies = [ - "async-io 2.3.2", - "async-lock 2.8.0", + "async-io 2.3.3", + "async-lock 3.4.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.32", + "rustix 0.38.34", "signal-hook-registry", "slab", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -482,24 +505,24 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -508,7 +531,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -539,15 +562,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.1.9" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297b64446175a73987cedc3c438d79b2a654d0fff96f65ff530fbe039347644c" +checksum = "2ac9889352d632214df943e26740c46a0f3da6e329fbd28164fe7ae1b061da7b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -562,10 +585,10 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes 1.6.0", - "fastrand 2.0.2", + "fastrand 2.1.0", "hex", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "ring", "time", "tokio", @@ -576,9 +599,9 @@ dependencies = [ [[package]] name = "aws-credential-types" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8587ae17c8e967e4b05a62d495be2fb7701bec52a97f7acfe8a29f938384c8" +checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -586,11 +609,38 @@ dependencies = [ "zeroize", ] +[[package]] +name = "aws-lc-rs" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7d844e282b4b56750b2d4e893b2205581ded8709fddd2b6aa5418c150ca877" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a2c29203f6bf296d01141cc8bb9dbd5ecd4c27843f2ee0767bcd5985a927da" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "aws-runtime" -version = "1.1.8" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13dc54b4b49f8288532334bba8f87386a40571c47c37b1304979b556dc613c8" +checksum = "36978815abdd7297662bf906adff132941a02ecf425bc78fac7d90653ce87560" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -601,7 +651,7 @@ dependencies = [ "aws-smithy-types", "aws-types", "bytes 1.6.0", - "fastrand 2.0.2", + "fastrand 2.1.0", "http 0.2.12", "http-body 0.4.6", "percent-encoding", @@ -612,9 +662,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.21.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc075ffee2a40cb1590bed35d7ec953589a564e768fa91947c565425cd569269" +checksum = "724119d8fd2d2638b9979673f3b5c2979fa388c9ca27815e3cb5ad6234fac3f5" dependencies = [ "ahash", "aws-credential-types", @@ -631,7 +681,7 @@ dependencies = [ "aws-smithy-xml", "aws-types", "bytes 1.6.0", - "fastrand 2.0.2", + "fastrand 2.1.0", "hex", "hmac", "http 0.2.12", @@ -647,9 +697,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.18.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "019a07902c43b03167ea5df0182f0cb63fae89f9a9682c44d18cf2e4a042cb34" +checksum = "da75cf91cbb46686a27436d639a720a3a198b148efa76dc2467b7e5374a67fc0" dependencies = [ "aws-credential-types", "aws-runtime", @@ -669,9 +719,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.18.0" +version = "1.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c46ee08a48a7f4eaa4ad201dcc1dd537b49c50859d14d4510e00ad9d3f9af2" +checksum = "cf2ec8a6687299685ed0a4a3137c129cdb132b5235bc3aa3443f6cffe468b9ff" dependencies = [ "aws-credential-types", "aws-runtime", @@ -691,9 +741,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.18.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f752ac730125ca6017f72f9db5ec1772c9ecc664f87aa7507a7d81b023c23713" +checksum = "458f1031e094b1411b59b49b19e4118f069e1fe13a9c5b8888e933daaf7ffdd6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -714,9 +764,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d6f29688a4be9895c0ba8bef861ad0c0dac5c15e9618b9b7a6c233990fc263" +checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -743,9 +793,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7a41ccd6b74401a49ca828617049e5c23d83163d330a4f90a8081aadee0ac45" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" dependencies = [ "futures-util", "pin-project-lite", @@ -754,9 +804,9 @@ dependencies = [ [[package]] name = "aws-smithy-checksums" -version = "0.60.7" +version = "0.60.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fa43bc04a6b2441968faeab56e68da3812f978a670a5db32accbdcafddd12f" +checksum = "c5b30ea96823b8b25fb6471643a516e1bd475fd5575304e6240aea179f213216" dependencies = [ "aws-smithy-http", "aws-smithy-types", @@ -786,9 +836,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.7" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f10fa66956f01540051b0aa7ad54574640f748f9839e843442d99b970d3aff9" +checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", @@ -826,34 +876,35 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.1.8" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec81002d883e5a7fd2bb063d6fb51c4999eb55d404f4fff3dd878bf4733b9f01" +checksum = "d0d3965f6417a92a6d1009c5958a67042f57e46342afb37ca58f9ad26744ec73" dependencies = [ "aws-smithy-async", "aws-smithy-http", "aws-smithy-runtime-api", "aws-smithy-types", "bytes 1.6.0", - "fastrand 2.0.2", - "h2 0.3.25", + "fastrand 2.1.0", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", - "hyper-rustls", + "http-body 1.0.0", + "hyper 0.14.29", + "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", - "rustls 0.21.10", + "rustls 0.21.12", "tokio", "tracing", ] [[package]] name = "aws-smithy-runtime-api" -version = "1.2.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9acb931e0adaf5132de878f1398d83f8677f90ba70f01f65ff87f6d7244be1c5" +checksum = "1b570ea39eb95bd32543f6e4032bce172cb6209b9bc8c83c770d08169e875afc" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -868,22 +919,25 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe14dceea1e70101d38fbf2a99e6a34159477c0fb95e68e05c66bd7ae4c3729" +checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" dependencies = [ "base64-simd", "bytes 1.6.0", "bytes-utils", "futures-core", "http 0.2.12", + "http 1.1.0", "http-body 0.4.6", + "http-body 1.0.0", + "http-body-util", "itoa", "num-integer", "pin-project-lite", "pin-utils", "ryu", - "serde", + "serde 1.0.203", "time", "tokio", "tokio-util", @@ -891,18 +945,18 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.7" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872c68cf019c0e4afc5de7753c4f7288ce4b71663212771bf5e4542eb9346ca9" +checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" dependencies = [ "xmlparser", ] [[package]] name = "aws-types" -version = "1.1.8" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dbf2f3da841a8930f159163175cf6a3d16ddde517c1b0fba7aa776822800f40" +checksum = "6f734808d43702a67e57d478a12e227d4d038d0b90c9005a78c87890d3805922" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -926,7 +980,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "itoa", "matchit", "memchr", @@ -934,8 +988,8 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustversion", - "serde", - "sync_wrapper", + "serde 1.0.203", + "sync_wrapper 0.1.2", "tower", "tower-layer", "tower-service", @@ -971,16 +1025,16 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ - "addr2line", + "addr2line 0.22.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.36.0", "rustc-demangle", ] @@ -996,12 +1050,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -1010,9 +1058,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64-simd" @@ -1038,24 +1086,15 @@ checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" [[package]] name = "bigdecimal" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9324c8014cd04590682b34f1e9448d38f0674d0f7b2dc553331016ef0e4e9ebc" +checksum = "51d712318a27c7150326677b321a5fa91b55f6d9034ffd67f20319e147d40cee" dependencies = [ "autocfg", "libm", "num-bigint", "num-integer", - "num-traits", -] - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", + "num-traits 0.2.19", ] [[package]] @@ -1065,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95" dependencies = [ "bincode_derive", - "serde", + "serde 1.0.203", ] [[package]] @@ -1087,16 +1126,16 @@ dependencies = [ "cexpr", "clang-sys", "itertools 0.12.1", - "lazy_static", + "lazy_static 1.4.0", "lazycell", "log", - "prettyplease 0.2.17", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.55", + "syn 2.0.66", "which 4.4.2", ] @@ -1127,7 +1166,7 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] @@ -1149,35 +1188,25 @@ dependencies = [ ] [[package]] -name = "block-modes" -version = "0.8.1" +name = "block-padding" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" dependencies = [ - "block-padding", - "cipher 0.3.0", + "generic-array 0.14.7", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel", - "async-lock 3.3.0", "async-task", - "fastrand 2.0.2", "futures-io", "futures-lite 2.3.0", "piper", - "tracing", ] [[package]] @@ -1186,21 +1215,21 @@ version = "1.42.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed59b5c00048f48d7af971b71f800fdf23e858844a6f9e4d32ca72e9399e7864" dependencies = [ - "serde", + "serde 1.0.203", "serde_with 1.14.0", ] [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" [[package]] name = "byteorder" @@ -1232,18 +1261,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] name = "cap-fs-ext" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e341d15ac1029aadce600be764a1a1edafe40e03cde23285bc1d261b3a4866" +checksum = "2fc2d2954524be4866aaa720f008fba9995de54784957a1b0e0119992d6d5e52" dependencies = [ "cap-primitives", "cap-std", @@ -1253,21 +1282,21 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434168fe6533055f0f4204039abe3ff6d7db338ef46872a5fa39e9d5ad5ab7a9" +checksum = "799c81d79ea9c71a1438efd417c788214bc9e7986046d3710b6bbe60da4d8275" dependencies = [ "cap-primitives", "cap-std", - "rustix 0.38.32", + "rustix 0.38.34", "smallvec", ] [[package]] name = "cap-primitives" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe16767ed8eee6d3f1f00d6a7576b81c226ab917eb54b96e5f77a5216ef67abb" +checksum = "00172660727e2d7f808e7cc2bfffd093fdb3ea2ff2ef819289418a3c3ffab5ac" dependencies = [ "ambient-authority", "fs-set-times", @@ -1275,16 +1304,16 @@ dependencies = [ "io-lifetimes 2.0.3", "ipnet", "maybe-owned", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", "winx", ] [[package]] name = "cap-rand" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20e5695565f0cd7106bc3c7170323597540e772bb73e0be2cd2c662a0f8fa4ca" +checksum = "270f1d341a2afc62604f8f688bee4e444d052b7a74c1458dd3aa7efb47d4077f" dependencies = [ "ambient-authority", "rand 0.8.5", @@ -1292,44 +1321,44 @@ dependencies = [ [[package]] name = "cap-std" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "593db20e4c51f62d3284bae7ee718849c3214f93a3b94ea1899ad85ba119d330" +checksum = "8cd9187bb3f7478a4c135ea10473a41a5f029d2ac800c1adf64f35ec7d4c8603" dependencies = [ "cap-primitives", "io-extras", "io-lifetimes 2.0.3", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] name = "cap-time-ext" -version = "2.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03261630f291f425430a36f38c847828265bc928f517cdd2004c56f4b02f002b" +checksum = "91666f31e30c85b1d2ee8432c90987f752c45f5821f5638027b41e73e16a395b" dependencies = [ "ambient-authority", "cap-primitives", "iana-time-zone", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", "winx", ] [[package]] name = "cargo-component" -version = "0.7.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a90ee34d07165ca14cba2aaf8587d34498018e2b1482299f8dad053b294d7d4a" +checksum = "00f82bbaf66b4e5e7944bc499d096229cc39d76258e471e9be99651c2eb00745" dependencies = [ "anyhow", "bytes 1.6.0", "cargo-component-core", "cargo-config2", "cargo_metadata", - "clap 4.5.4", + "clap 4.5.7", "futures", - "heck 0.4.1", + "heck 0.5.0", "indexmap 2.2.6", "libc", "log", @@ -1339,61 +1368,63 @@ dependencies = [ "rand_core 0.6.4", "rpassword", "semver", - "serde", + "serde 1.0.203", "serde_json", + "shell-escape", + "tempfile", "tokio", "tokio-util", - "toml_edit 0.21.1", + "toml_edit 0.22.14", "url", "warg-client", "warg-crypto", "warg-protocol", - "wasm-metadata", + "wasm-metadata 0.208.1", + "wasmparser 0.208.1", "which 6.0.1", - "wit-bindgen-core 0.16.0", - "wit-bindgen-rust 0.16.0", - "wit-component 0.20.3", - "wit-parser 0.13.2", + "wit-bindgen-core 0.25.0", + "wit-bindgen-rust 0.25.0", + "wit-component 0.208.1", + "wit-parser 0.208.1", ] [[package]] name = "cargo-component-core" -version = "0.7.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dbb541c99779193ac7dcf8c8abc10c2b81955635de0bcfbaaa94e9720c4ed65" +checksum = "bf60eee7916f926d079ac6dc1851bfd8e2869bbdfc3ff997013cf7b802565f86" dependencies = [ "anyhow", - "clap 4.5.4", + "clap 4.5.7", "futures", "indexmap 2.2.6", - "keyring", "libc", "log", "owo-colors", "semver", - "serde", + "serde 1.0.203", "tokio", - "toml_edit 0.21.1", + "toml_edit 0.22.14", "unicode-width", "url", "warg-client", "warg-crypto", "warg-protocol", "windows-sys 0.52.0", - "wit-component 0.20.3", - "wit-parser 0.13.2", + "wit-component 0.208.1", + "wit-parser 0.208.1", ] [[package]] name = "cargo-config2" -version = "0.1.22" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3108787cb889089c29b110a3a7165c7c942f081c91d46c477818c33202b2a9cb" +checksum = "d83ce0be8bd1479e5de6202def660e6c7e27e4e0599bffa4fed05bd380ec2ede" dependencies = [ "home", - "serde", + "serde 1.0.203", "serde_derive", - "toml_edit 0.22.9", + "toml_edit 0.22.14", ] [[package]] @@ -1402,7 +1433,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] @@ -1414,19 +1445,19 @@ dependencies = [ "camino", "cargo-platform", "semver", - "serde", + "serde 1.0.203", "serde_json", "thiserror", ] [[package]] name = "cargo_toml" -version = "0.19.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a98356df42a2eb1bd8f1793ae4ee4de48e384dd974ce5eac8eee802edb7492be" +checksum = "4895c018bb228aa6b3ba1a0285543fcb4b704734c3fb1f72afaa75aa769500c1" dependencies = [ - "serde", - "toml 0.8.12", + "serde 1.0.203", + "toml 0.8.14", ] [[package]] @@ -1435,14 +1466,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" -version = "1.0.90" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -1451,7 +1492,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom", + "nom 7.1.3", ] [[package]] @@ -1460,28 +1501,25 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", - "num-traits", - "serde", + "num-traits 0.2.19", + "serde 1.0.203", "wasm-bindgen", - "windows-targets 0.52.4", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.7", + "windows-targets 0.52.5", ] [[package]] @@ -1496,9 +1534,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -1518,9 +1556,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -1532,39 +1570,39 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb9b20c0dd58e4c2e991c8d203bbeb76c11304d1011659686b5b644bc29aa478" dependencies = [ - "clap 4.5.4", + "clap 4.5.7", "log", ] [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "cli-table" @@ -1589,6 +1627,21 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + [[package]] name = "color_quant" version = "1.1.0" @@ -1597,9 +1650,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "colored" @@ -1607,7 +1660,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" dependencies = [ - "lazy_static", + "lazy_static 1.4.0", "windows-sys 0.48.0", ] @@ -1623,31 +1676,60 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] +[[package]] +name = "config" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369" +dependencies = [ + "lazy_static 1.4.0", + "nom 5.1.3", + "rust-ini", + "serde 1.0.203", + "serde-hjson", + "serde_json", + "toml 0.5.11", + "yaml-rust", +] + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static 1.4.0", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + [[package]] name = "console-api" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" +checksum = "a257c22cd7e487dd4a13d413beabc512c5052f0bc048db0da6a84c3d8a6142fd" dependencies = [ "futures-core", - "prost 0.12.3", - "prost-types 0.12.3", + "prost", + "prost-types", "tonic", "tracing-core", ] [[package]] name = "console-subscriber" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" +checksum = "31c4cc54bae66f7d9188996404abdf7fdfa23034ef8e43478c8810828abad758" dependencies = [ "console-api", "crossbeam-channel", @@ -1655,8 +1737,9 @@ dependencies = [ "futures-task", "hdrhistogram", "humantime", - "prost-types 0.12.3", - "serde", + "prost", + "prost-types", + "serde 1.0.203", "serde_json", "thread_local", "tokio", @@ -1695,7 +1778,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ "aes-gcm", - "base64 0.22.0", + "base64 0.22.1", "hkdf", "hmac", "percent-encoding", @@ -1708,12 +1791,9 @@ dependencies = [ [[package]] name = "cookie-factory" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" -dependencies = [ - "futures", -] +checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b" [[package]] name = "copy_dir" @@ -1778,9 +1858,9 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.3.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" dependencies = [ "cfg-if", ] @@ -1796,16 +1876,16 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "bumpalo", "cranelift-bforest", @@ -1814,48 +1894,49 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli", - "hashbrown 0.14.3", + "gimli 0.28.1", + "hashbrown 0.14.5", "log", "regalloc2", + "rustc-hash", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" [[package]] name = "cranelift-control" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ - "serde", + "serde 1.0.203", "serde_derive", ] [[package]] name = "cranelift-frontend" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-codegen", "log", @@ -1865,13 +1946,13 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" [[package]] name = "cranelift-native" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-codegen", "libc", @@ -1880,24 +1961,24 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.104.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.108.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.10.5", + "itertools 0.12.1", "log", "smallvec", - "wasmparser 0.118.2", + "wasmparser 0.207.0", "wasmtime-types", ] [[package]] name = "crc" -version = "3.0.1" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" dependencies = [ "crc-catalog", ] @@ -1916,18 +1997,18 @@ checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" [[package]] name = "crc32c" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89254598aa9b9fa608de44b3ae54c810f0f06d755e24c50177f1f8f31ff50ce2" +checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" dependencies = [ "rustc_version", ] [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -1944,13 +2025,13 @@ dependencies = [ "criterion-plot", "csv", "itertools 0.10.5", - "lazy_static", - "num-traits", + "lazy_static 1.4.0", + "num-traits 0.2.19", "oorandom", "plotters", "rayon", "regex", - "serde", + "serde 1.0.203", "serde_cbor", "serde_derive", "serde_json", @@ -1970,9 +2051,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -2007,9 +2088,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -2090,7 +2171,7 @@ dependencies = [ "csv-core", "itoa", "ryu", - "serde", + "serde 1.0.203", ] [[package]] @@ -2104,12 +2185,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -2118,7 +2199,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -2133,12 +2214,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ - "darling_core 0.20.8", - "darling_macro 0.20.8", + "darling_core 0.20.9", + "darling_macro 0.20.9", ] [[package]] @@ -2157,16 +2238,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", - "syn 2.0.55", + "strsim 0.11.1", + "syn 2.0.66", ] [[package]] @@ -2182,13 +2263,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ - "darling_core 0.20.8", + "darling_core 0.20.9", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -2198,7 +2279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -2206,9 +2287,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "debugid" @@ -2231,9 +2312,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -2247,7 +2328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", + "serde 1.0.203", ] [[package]] @@ -2269,20 +2350,33 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.66", +] + +[[package]] +name = "dialoguer" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" +dependencies = [ + "console", + "shell-words", + "tempfile", + "thiserror", + "zeroize", ] [[package]] @@ -2312,6 +2406,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "directories" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "directories-next" version = "2.0.0" @@ -2384,6 +2487,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "dlib" version = "0.5.2" @@ -2399,13 +2513,19 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "dwrote" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ - "lazy_static", + "lazy_static 1.4.0", "libc", "winapi", "wio", @@ -2435,7 +2555,7 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.8", + "der 0.7.9", "digest", "elliptic-curve 0.13.8", "rfc6979 0.4.0", @@ -2445,11 +2565,11 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] @@ -2492,34 +2612,46 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] [[package]] name = "enumflags2" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" +checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", - "serde", + "serde 1.0.203", ] [[package]] name = "enumflags2_derive" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" +checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -2566,9 +2698,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2576,12 +2708,9 @@ dependencies = [ [[package]] name = "escape8259" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4911e3666fcd7826997b4745c8224295a6f3072f1418c3067b97a67557ee" -dependencies = [ - "rustversion", -] +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" [[package]] name = "etcetera" @@ -2613,20 +2742,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener" -version = "5.2.0" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", @@ -2635,21 +2753,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" -dependencies = [ - "event-listener 4.0.3", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.1", "pin-project-lite", ] @@ -2681,8 +2789,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" dependencies = [ "bit-set", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -2696,9 +2804,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fd-lock" @@ -2707,7 +2815,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -2742,24 +2850,18 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.15" +version = "0.10.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7270677e7067213e04f323b55084586195f18308cd7546cfac9f873344ccceb6" +checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" dependencies = [ "atomic", "pear", - "serde", - "toml 0.8.12", + "serde 1.0.203", + "toml 0.8.14", "uncased", "version_check", ] -[[package]] -name = "finl_unicode" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" - [[package]] name = "fixedbitset" version = "0.4.2" @@ -2768,9 +2870,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -2782,7 +2884,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -2791,6 +2893,15 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "flume" version = "0.11.0" @@ -2830,7 +2941,7 @@ dependencies = [ "dwrote", "float-ord", "freetype-sys", - "lazy_static", + "lazy_static 1.4.0", "libc", "log", "pathfinder_geometry", @@ -2867,7 +2978,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -2893,9 +3004,9 @@ dependencies = [ [[package]] name = "fred" -version = "8.0.5" +version = "9.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fcd11eb1309e72c6b23317309fe247f560da4e258364104f4e1a6821b381d77" +checksum = "915e065b377f6e16d5c01eae96bf31eeaf81e1e300b76f938761b3c21307cad8" dependencies = [ "arc-swap", "async-trait", @@ -2910,7 +3021,7 @@ dependencies = [ "redis-protocol", "semver", "serde_json", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tokio-stream", "tokio-util", @@ -2938,7 +3049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" dependencies = [ "io-lifetimes 2.0.3", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -3034,7 +3145,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "futures-io", "parking", @@ -3049,7 +3160,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -3121,7 +3232,7 @@ dependencies = [ "bitflags 2.5.0", "debugid", "fxhash", - "serde", + "serde 1.0.203", "serde_json", ] @@ -3163,9 +3274,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -3205,6 +3316,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "glob" version = "0.3.1" @@ -3216,14 +3333,14 @@ name = "golem-api-grpc" version = "0.0.0" dependencies = [ "async-trait", - "bincode 2.0.0-rc.3", + "bincode", "bytes 1.6.0", "cargo_metadata", "futures-core", "golem-wasm-rpc", - "prost 0.12.3", - "prost-types 0.12.3", - "serde", + "prost", + "prost-types", + "serde 1.0.203", "tokio", "tonic", "tonic-build", @@ -3239,7 +3356,7 @@ dependencies = [ "async-recursion", "async-trait", "chrono", - "clap 4.5.4", + "clap 4.5.7", "clap-verbosity-flag", "cli-table", "colored", @@ -3254,12 +3371,12 @@ dependencies = [ "golem-wasm-ast", "golem-wasm-rpc", "golem-wasm-rpc-stubgen", - "h2 0.3.25", + "h2 0.3.26", "http 1.1.0", - "hyper 1.2.0", + "hyper 1.3.1", "indoc", "inquire", - "itertools 0.12.1", + "itertools 0.13.0", "libtest-mimic", "log", "native-tls", @@ -3269,7 +3386,7 @@ dependencies = [ "redis", "regex", "reqwest", - "serde", + "serde 1.0.203", "serde_json", "serde_json_path", "serde_yaml", @@ -3306,7 +3423,7 @@ dependencies = [ "http 1.1.0", "relative-path", "reqwest", - "serde", + "serde 1.0.203", "serde_json", "tracing", "uuid", @@ -3317,7 +3434,7 @@ name = "golem-common" version = "0.0.0" dependencies = [ "async-trait", - "bincode 2.0.0-rc.3", + "bincode", "bytes 1.6.0", "combine", "dashmap", @@ -3329,16 +3446,16 @@ dependencies = [ "golem-wasm-rpc", "humantime-serde", "iso8601-timestamp", - "lazy_static", + "lazy_static 1.4.0", "poem", "poem-openapi", "prometheus", - "prost 0.12.3", - "prost-types 0.12.3", + "prost", + "prost-types", "rand 0.8.5", "range-set-blaze", "semver", - "serde", + "serde 1.0.203", "serde_json", "tokio", "tonic", @@ -3362,9 +3479,9 @@ dependencies = [ "golem-worker-executor-base", "http 0.2.12", "http 1.1.0", - "lazy_static", + "lazy_static 1.4.0", "prometheus", - "serde", + "serde 1.0.203", "thiserror", "tokio", "tonic", @@ -3392,15 +3509,15 @@ dependencies = [ "golem-wasm-rpc", "http 0.2.12", "humantime-serde", - "lazy_static", + "lazy_static 1.4.0", "mappable-rc", - "opentelemetry", - "opentelemetry-prometheus", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry-prometheus 0.16.0", + "opentelemetry_sdk 0.23.0", "poem", "poem-openapi", "prometheus", - "serde", + "serde 1.0.203", "serde_json", "sqlx", "tap", @@ -3426,16 +3543,16 @@ dependencies = [ "golem-service-base", "golem-wasm-ast", "http 0.2.12", - "serde", + "serde 1.0.203", "thiserror", "tracing", ] [[package]] name = "golem-examples" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97faf7aba9d41c971f625762fa95a993586b7d9389b7ec0ae85c8fdc512bda4" +checksum = "96509916280eb50e0235fe119458eeff3382413f16ab6165d741cf890d7c5a4f" dependencies = [ "Inflector", "cargo_metadata", @@ -3446,7 +3563,7 @@ dependencies = [ "golem-wit", "include_dir", "once_cell", - "serde", + "serde 1.0.203", "serde_json", "strum", "strum_macros", @@ -3458,14 +3575,14 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93808434ae66e60e3316b99a3c2333a112bdb0662efb9a52d81ba7713e1d5808" dependencies = [ - "clap 4.5.4", + "clap 4.5.7", "convert_case 0.6.0", "fmt", "indexmap 2.2.6", "indoc", "itertools 0.12.1", "openapiv3", - "serde", + "serde 1.0.203", "serde_yaml", ] @@ -3485,12 +3602,12 @@ dependencies = [ "golem-wasm-rpc", "http 0.2.12", "http 1.1.0", - "hyper 1.2.0", - "num-traits", + "hyper 1.3.1", + "num-traits 0.2.19", "poem-openapi", "proptest", "rand 0.8.5", - "serde", + "serde 1.0.203", "serde_json", "thiserror", "tokio", @@ -3506,7 +3623,7 @@ dependencies = [ "anyhow", "async-rwlock", "async-trait", - "bincode 2.0.0-rc.3", + "bincode", "bytes 1.6.0", "figment", "fred", @@ -3519,8 +3636,8 @@ dependencies = [ "k8s-openapi", "kube", "prometheus", - "prost 0.12.3", - "serde", + "prost", + "serde 1.0.203", "serde_json", "tokio", "tonic", @@ -3542,14 +3659,14 @@ dependencies = [ "async-dropper-simple", "async-scoped", "async-trait", - "clap 4.5.4", + "clap 4.5.7", "cli-table", "colored", "golem-api-grpc", "golem-common", "golem-wasm-ast", "golem-wasm-rpc", - "itertools 0.12.1", + "itertools 0.13.0", "k8s-openapi", "kill_tree", "kube", @@ -3557,7 +3674,7 @@ dependencies = [ "once_cell", "postgres", "redis", - "serde", + "serde 1.0.203", "serde_json", "serde_yaml", "testcontainers", @@ -3574,68 +3691,68 @@ dependencies = [ [[package]] name = "golem-wasm-ast" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a73b7e97992db438181bc0884406e2066fbe8c22e6d288a960790221036a9da" +checksum = "ece8710411f0474ae85b2ff6ec69b01cd8bbb732334694fcf60ba1b36d8ac686" dependencies = [ "leb128", "mappable-rc", - "wasm-encoder 0.41.2", - "wasm-metadata", + "wasm-encoder 0.207.0", + "wasm-metadata 0.207.0", "wasm-wave", - "wasmparser 0.121.2", + "wasmparser 0.207.0", ] [[package]] name = "golem-wasm-rpc" -version = "0.0.26" +version = "0.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0651b9abd5bef6c22b5b46dfd096fb2b94f494b56775a69a258f18d11e6ceae6" +checksum = "5ae26028226e258a3cfa04cd35b6e1fdcde4d86037ee7df4f1ec9dfc537447b7" dependencies = [ "arbitrary", "bigdecimal", - "bincode 2.0.0-rc.3", + "bincode", "golem-wasm-ast", - "prost 0.12.3", - "prost-build 0.12.3", - "serde", + "prost", + "prost-build", + "serde 1.0.203", "serde_json", "wasm-wave", "wasmtime", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "golem-wasm-rpc-stubgen" -version = "0.0.26" +version = "0.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "106b8ad7022e5b49dc0a05bc4690a483e6bae50cd6585fc8d37e3f13e99d96e2" +checksum = "6747797bb59967886446693f6fbe574c1c1e84fdaf9367ef1bb5cc2aa1f1c3e4" dependencies = [ "anyhow", "cargo-component", "cargo-component-core", "cargo_toml", - "clap 4.5.4", + "clap 4.5.7", "dir-diff", "fs_extra", "golem-wasm-ast", "golem-wasm-rpc", - "heck 0.4.1", + "heck 0.5.0", "id-arena", "indexmap 2.2.6", "pretty_env_logger", - "prettyplease 0.2.17", + "prettyplease", "proc-macro2", "quote", "regex", - "serde", - "syn 2.0.55", + "serde 1.0.203", + "syn 2.0.66", "tempdir", "tokio", - "toml 0.8.12", - "wasm-compose", - "wit-bindgen-rust 0.17.0", - "wit-parser 0.201.0", + "toml 0.8.14", + "wasm-compose 0.207.0", + "wit-bindgen-rust 0.26.0", + "wit-parser 0.207.0", ] [[package]] @@ -3659,7 +3776,7 @@ dependencies = [ "golem-worker-executor-base", "humantime-serde", "prometheus", - "serde", + "serde 1.0.203", "serde_json", "tempfile", "tokio", @@ -3670,7 +3787,6 @@ dependencies = [ "tracing-subscriber", "uuid", "wasmtime", - "wasmtime-runtime", "wasmtime-wasi", "wasmtime-wasi-http", ] @@ -3681,13 +3797,13 @@ version = "0.0.0" dependencies = [ "anyhow", "assert2", - "async-fs 2.1.1", + "async-fs 2.1.2", "async-mutex", "async-stream", "async-trait", "aws-config", "aws-sdk-s3", - "bincode 2.0.0-rc.3", + "bincode", "bitflags 2.5.0", "bytes 1.6.0", "cap-fs-ext", @@ -3716,10 +3832,10 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "humantime-serde", - "hyper 1.2.0", + "hyper 1.3.1", "io-extras", "iso8601-timestamp", - "lazy_static", + "lazy_static 1.4.0", "log", "md5", "metrohash", @@ -3727,18 +3843,18 @@ dependencies = [ "once_cell", "prometheus", "proptest", - "prost 0.12.3", + "prost", "redis", "ringbuf", - "rustls 0.22.3", - "serde", + "rustls 0.23.10", + "serde 1.0.203", "serde_json", "tempfile", "testcontainers", "testcontainers-modules", "thiserror", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-stream", "tonic", "tonic-health", @@ -3749,11 +3865,10 @@ dependencies = [ "uuid", "warp", "wasmtime", - "wasmtime-runtime", "wasmtime-wasi", "wasmtime-wasi-http", "windows-sys 0.52.0", - "zstd 0.13.1", + "zstd", ] [[package]] @@ -3762,7 +3877,7 @@ version = "0.0.0" dependencies = [ "anyhow", "async-trait", - "bincode 2.0.0-rc.3", + "bincode", "bytes 1.6.0", "derive_more", "figment", @@ -3777,18 +3892,18 @@ dependencies = [ "http 0.2.12", "http 1.1.0", "humantime-serde", - "hyper 1.2.0", - "lazy_static", - "nom", + "hyper 1.3.1", + "lazy_static 1.4.0", + "nom 7.1.3", "openapiv3", - "opentelemetry", - "opentelemetry-prometheus", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry-prometheus 0.16.0", + "opentelemetry_sdk 0.23.0", "poem", "poem-openapi", "prometheus", "regex", - "serde", + "serde 1.0.203", "serde_json", "serde_yaml", "strum", @@ -3812,11 +3927,11 @@ version = "0.0.0" dependencies = [ "anyhow", "async-trait", - "bincode 2.0.0-rc.3", + "bincode", "bytes 1.6.0", "criterion", "derive_more", - "fastrand 2.0.2", + "fastrand 2.1.0", "figment", "futures", "futures-util", @@ -3828,19 +3943,19 @@ dependencies = [ "http 0.2.12", "http 1.1.0", "humantime-serde", - "hyper 1.2.0", - "lazy_static", - "nom", + "hyper 1.3.1", + "lazy_static 1.4.0", + "nom 7.1.3", "openapiv3", - "opentelemetry", - "opentelemetry-prometheus", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry-prometheus 0.16.0", + "opentelemetry_sdk 0.23.0", "poem", "poem-openapi", "prometheus", "regex", "rustc-hash", - "serde", + "serde 1.0.203", "serde_json", "serde_yaml", "strum", @@ -3884,9 +3999,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes 1.6.0", "fnv", @@ -3903,15 +4018,15 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes 1.6.0", "fnv", "futures-core", "futures-sink", - "futures-util", "http 1.1.0", "indexmap 2.2.6", "slab", @@ -3943,12 +4058,13 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", + "serde 1.0.203", ] [[package]] @@ -3957,7 +4073,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -3969,8 +4085,8 @@ dependencies = [ "base64 0.21.7", "byteorder", "flate2", - "nom", - "num-traits", + "nom 7.1.3", + "num-traits 0.2.19", ] [[package]] @@ -4051,6 +4167,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -4129,28 +4251,22 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes 1.6.0", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", ] -[[package]] -name = "http-range-header" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" - [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -4171,27 +4287,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" dependencies = [ "humantime", - "serde", + "serde 1.0.203", ] [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes 1.6.0", "futures-channel", "futures-core", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -4200,14 +4316,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes 1.6.0", "futures-channel", "futures-util", - "h2 0.4.3", + "h2 0.4.5", "http 1.1.0", "http-body 1.0.0", "httparse", @@ -4219,6 +4335,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-http-proxy" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d06dbdfbacf34d996c6fb540a71a684a7aae9056c71951163af8a8a4c07b9a4" +dependencies = [ + "bytes 1.6.0", + "futures-util", + "headers 0.4.0", + "http 1.1.0", + "hyper 1.3.1", + "hyper-rustls 0.27.2", + "hyper-util", + "pin-project-lite", + "rustls-native-certs 0.7.0", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -4227,53 +4363,92 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "log", - "rustls 0.21.10", - "rustls-native-certs", + "rustls 0.21.12", + "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.3.1", + "hyper-util", + "log", + "rustls 0.23.10", + "rustls-native-certs 0.7.0", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", +] + [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.28", + "hyper 0.14.29", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.3.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes 1.6.0", - "hyper 0.14.28", + "http-body-util", + "hyper 1.3.1", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", ] [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes 1.6.0", + "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.1", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -4299,6 +4474,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -4313,12 +4606,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", ] [[package]] @@ -4345,24 +4640,24 @@ dependencies = [ "byteorder", "color_quant", "jpeg-decoder", - "num-traits", + "num-traits 0.2.19", "png", ] [[package]] name = "include_dir" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" dependencies = [ "include_dir_macros", ] [[package]] name = "include_dir_macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" dependencies = [ "proc-macro2", "quote", @@ -4376,7 +4671,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", + "serde 1.0.203", ] [[package]] @@ -4386,8 +4681,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", - "serde", + "hashbrown 0.14.5", + "serde 1.0.203", ] [[package]] @@ -4408,6 +4703,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ + "block-padding", "generic-array 0.14.7", ] @@ -4430,9 +4726,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -4443,7 +4739,7 @@ version = "0.0.0" dependencies = [ "assert2", "async-trait", - "clap 4.5.4", + "clap 4.5.7", "console-subscriber", "ctor", "golem-api-grpc", @@ -4454,7 +4750,7 @@ dependencies = [ "poem", "rand 0.8.5", "reqwest", - "serde", + "serde 1.0.203", "serde_json", "tokio", "tracing", @@ -4470,9 +4766,9 @@ checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" [[package]] name = "io-extras" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c301e73fb90e8a29e600a9f402d095765f74310d582916a952f618836a1bd1ed" +checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b" dependencies = [ "io-lifetimes 2.0.3", "windows-sys 0.52.0", @@ -4512,6 +4808,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "iso8601-timestamp" version = "0.2.17" @@ -4519,7 +4821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d4e5d712dd664b11e778d1cfc06c79ba2700d6bc1771e44fb7b6a4656b487d" dependencies = [ "generic-array 1.0.0", - "serde", + "serde 1.0.203", "time", ] @@ -4550,6 +4852,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -4578,9 +4889,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -4602,22 +4913,24 @@ dependencies = [ [[package]] name = "json-patch" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ff1e1486799e3f64129f8ccad108b38290df9cd7015cd31bed17239f0789d6" +checksum = "5b1fb8864823fad91877e6caea0baca82e49e8db50f8e5c9f9a453e27d3330fc" dependencies = [ - "serde", + "jsonptr", + "serde 1.0.203", "serde_json", "thiserror", - "treediff", ] [[package]] name = "jsonpath-rust" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96acbc6188d3bd83519d053efec756aa4419de62ec47be7f28dec297f7dc9eb0" +checksum = "19d8fe85bd70ff715f31ce8c739194b423d79811a19602115d611a3ec85d6200" dependencies = [ + "lazy_static 1.4.0", + "once_cell", "pest", "pest_derive", "regex", @@ -4625,27 +4938,38 @@ dependencies = [ "thiserror", ] +[[package]] +name = "jsonptr" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6e529149475ca0b2820835d3dce8fcc41c6b943ca608d32f35b449255e4627" +dependencies = [ + "fluent-uri", + "serde 1.0.203", + "serde_json", +] + [[package]] name = "k8s-openapi" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "550f99d93aa4c2b25de527bce492d772caf5e21d7ac9bd4b508ba781c8d91e30" +checksum = "19501afb943ae5806548bc3ebd7f3374153ca057a38f480ef30adfde5ef09755" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "chrono", - "serde", + "serde 1.0.203", "serde-value", "serde_json", ] [[package]] name = "keyring" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be8bc4c6b6e9d85ecdad090fcf342a9216f53d747a537cc05e3452fd650ca46" +checksum = "363387f0019d714aa60cc30ab4fe501a747f4c08fc58f069dd14be971bd495a0" dependencies = [ "byteorder", - "lazy_static", + "lazy_static 1.4.0", "linux-keyutils", "secret-service", "security-framework", @@ -4667,9 +4991,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.88.1" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462fe330a0617b276ec864c2255810adcdf519ecb6844253c54074b2086a97bc" +checksum = "12dc4487eda98835dcaa7ac92a14165446db29dbd67a743c79fe9f41bf38ee72" dependencies = [ "k8s-openapi", "kube-client", @@ -4680,30 +5004,32 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.88.1" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe0d65dd6f3adba29cfb84f19dfe55449c7f6c35425f9d8294bec40313e0b64" +checksum = "408f35eab36927d3b883e4ad54c3080ea8c49f899ac84a7856e7182e4ee3b392" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes 1.6.0", "chrono", "either", "futures", "home", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-rustls", - "hyper-timeout", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-http-proxy", + "hyper-rustls 0.27.2", + "hyper-timeout 0.5.1", + "hyper-util", "jsonpath-rust", "k8s-openapi", "kube-core", "pem", - "pin-project 1.1.5", - "rustls 0.21.10", - "rustls-pemfile", + "rustls 0.23.10", + "rustls-pemfile 2.1.2", "secrecy", - "serde", + "serde 1.0.203", "serde_json", "serde_yaml", "thiserror", @@ -4716,61 +5042,68 @@ dependencies = [ [[package]] name = "kube-core" -version = "0.88.1" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6b42844e9172f631b8263ea9ce003b9251da13beb1401580937ad206dd82f4c" +checksum = "f776624097c1e09e72eb1e9e0c2bb5d17d97c27a6a87734390a9fba246a8f67f" dependencies = [ "chrono", "form_urlencoded", - "http 0.2.12", + "http 1.1.0", "json-patch", "k8s-openapi", - "once_cell", "schemars", - "serde", + "serde 1.0.203", "serde_json", "thiserror", ] [[package]] name = "kube-derive" -version = "0.88.1" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5b5a111ee287bd237b8190b8c39543ea9fd22f79e9c32a36c24e08234bcda22" +checksum = "8ae07adfd7d21b7fa582789206391243f98e155b46c806eb494839569853bcfd" dependencies = [ - "darling 0.20.8", + "darling 0.20.9", "proc-macro2", "quote", "serde_json", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "kube-runtime" -version = "0.88.1" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc06275064c81056fbb28ea876b3fb339d970e8132282119359afca0835c0ea" +checksum = "12e5933f2d429f3a05d4cb67f935b25c94a133b0baeb558ab3917c270a11f6ef" dependencies = [ "ahash", + "async-broadcast 0.7.1", + "async-stream", "async-trait", "backoff", "derivative", "futures", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "json-patch", + "jsonptr", "k8s-openapi", "kube-client", "parking_lot", "pin-project 1.1.5", - "serde", + "serde 1.0.203", "serde_json", - "smallvec", "thiserror", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" + [[package]] name = "lazy_static" version = "1.4.0" @@ -4792,11 +5125,24 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "lexical-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "cfg-if", + "ryu", + "static_assertions", +] + [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -4805,7 +5151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -4816,13 +5162,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -4841,7 +5186,7 @@ name = "libtest-mimic" version = "0.7.0" source = "git+https://github.com/senia-psm/libtest-mimic.git?branch=async_and_context_tests#904a9367691b7eb47dc25a876391ee4a958c0319" dependencies = [ - "clap 4.5.4", + "clap 4.5.7", "escape8259", "termcolor", "threadpool", @@ -4849,7 +5194,13 @@ dependencies = [ ] [[package]] -name = "linux-keyutils" +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-keyutils" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "761e49ec5fd8a5a463f9b84e877c373d888935b71c6be78f3767fe2ae6bed18e" @@ -4860,27 +5211,27 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] -name = "linux-raw-sys" -version = "0.4.13" +name = "litemap" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -4894,32 +5245,33 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logos" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" +checksum = "161971eb88a0da7ae0c333e1063467c5b5727e7fb6b710b8db4814eade3a42e8" dependencies = [ "logos-derive", ] [[package]] name = "logos-codegen" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68" +checksum = "8e31badd9de5131fdf4921f6473d457e3dd85b11b7f091ceb50e4df7c3eeb12a" dependencies = [ "beef", "fnv", + "lazy_static 1.4.0", "proc-macro2", "quote", - "regex-syntax 0.6.29", - "syn 2.0.55", + "regex-syntax 0.8.4", + "syn 2.0.66", ] [[package]] name = "logos-derive" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e" +checksum = "1c2a69b3eb68d5bd595107c9ee58d7e07fe2bb5e360cc85b0f084dedac80de0a" dependencies = [ "logos-codegen", ] @@ -4930,14 +5282,14 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] -name = "mach" -version = "0.3.2" +name = "mach2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" dependencies = [ "libc", ] @@ -4987,9 +5339,9 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memfd" @@ -4997,7 +5349,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -5026,25 +5378,25 @@ checksum = "3ba553cb19e2acbc54baa16faef215126243fe45e53357a3b2e9f4ebc7b0506c" [[package]] name = "miette" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ + "cfg-if", "miette-derive", - "once_cell", "thiserror", "unicode-width", ] [[package]] name = "miette-derive" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -5071,9 +5423,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -5091,6 +5443,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "multer" version = "2.1.0" @@ -5111,16 +5469,15 @@ dependencies = [ [[package]] name = "multer" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15d522be0a9c3e46fd2632e272d178f56387bdb5c9fbb3a36c649062e9b5219" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" dependencies = [ "bytes 1.6.0", "encoding_rs", "futures-util", "http 1.1.0", "httparse", - "log", "memchr", "mime", "spin 0.9.8", @@ -5130,9 +5487,9 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "nanorand" @@ -5145,11 +5502,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -5193,6 +5549,29 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nom" +version = "5.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +dependencies = [ + "lexical-core", + "memchr", + "version_check", +] + [[package]] name = "nom" version = "7.1.3" @@ -5230,27 +5609,26 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", "num-integer", "num-iter", "num-rational", - "num-traits", + "num-traits 0.2.19", ] [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -5260,11 +5638,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" dependencies = [ "byteorder", - "lazy_static", + "lazy_static 1.4.0", "libm", "num-integer", "num-iter", - "num-traits", + "num-traits 0.2.19", "rand 0.8.5", "smallvec", "zeroize", @@ -5272,11 +5650,11 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -5291,37 +5669,45 @@ version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", - "num-traits", + "num-traits 0.2.19", ] [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", - "num-traits", + "num-traits 0.2.19", ] [[package]] name = "num-traits" -version = "0.2.18" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +dependencies = [ + "num-traits 0.2.19", +] + +[[package]] +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -5339,16 +5725,25 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "d8dd6c0cdf9429bce006e1362bfce61fa1bfd8c898a643ed8d2b471934701d3d" dependencies = [ "crc32fast", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "indexmap 2.2.6", "memchr", ] +[[package]] +name = "object" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -5374,7 +5769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc02deea53ffe807708244e5914f6b099ad7015a207ee24317c22112e17d9c5c" dependencies = [ "indexmap 2.2.6", - "serde", + "serde 1.0.203", "serde_json", ] @@ -5401,7 +5796,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -5412,9 +5807,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -5424,13 +5819,12 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.2.6", "js-sys", "once_cell", "pin-project-lite", @@ -5438,54 +5832,95 @@ dependencies = [ "urlencoding", ] +[[package]] +name = "opentelemetry" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + [[package]] name = "opentelemetry-http" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f51189ce8be654f9b5f7e70e49967ed894e84a06fc35c6c042e64ac1fc5399e" +checksum = "7690dc77bf776713848c4faa6501157469017eaf332baccd4eb1cea928743d94" dependencies = [ "async-trait", "bytes 1.6.0", "http 0.2.12", - "opentelemetry", + "opentelemetry 0.22.0", +] + +[[package]] +name = "opentelemetry-prometheus" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bbcf6341cab7e2193e5843f0ac36c446a5b3fccb28747afaeda17996dcd02e" +dependencies = [ + "once_cell", + "opentelemetry 0.22.0", + "opentelemetry_sdk 0.22.1", + "prometheus", + "protobuf", ] [[package]] name = "opentelemetry-prometheus" -version = "0.14.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8f082da115b0dcb250829e3ed0b8792b8f963a1ad42466e48422fbe6a079bd" +checksum = "5e1a24eafe47b693cb938f8505f240dc26c71db60df9aca376b4f857e9653ec7" dependencies = [ "once_cell", - "opentelemetry", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry_sdk 0.23.0", "prometheus", "protobuf", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" +checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" + +[[package]] +name = "opentelemetry_sdk" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" dependencies = [ - "opentelemetry", + "async-trait", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "once_cell", + "opentelemetry 0.22.0", + "ordered-float 4.2.0", + "thiserror", ] [[package]] name = "opentelemetry_sdk" -version = "0.21.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" +checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" dependencies = [ "async-trait", - "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", "glob", + "lazy_static 1.4.0", "once_cell", - "opentelemetry", + "opentelemetry 0.23.0", "ordered-float 4.2.0", "percent-encoding", "rand 0.8.5", @@ -5504,7 +5939,7 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -5513,7 +5948,7 @@ version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -5584,9 +6019,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -5594,15 +6029,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.2", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -5613,9 +6048,9 @@ checksum = "14248cc8eced350e20122a291613de29e4fa129ba2731818c4cdbb44fccd3e55" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" @@ -5644,39 +6079,39 @@ dependencies = [ [[package]] name = "pbjson" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048f9ac93c1eab514f9470c4bc8d97ca2a0a236b84f45cc19d69a59fc11467f6" +checksum = "1030c719b0ec2a2d25a5df729d6cff1acf3cc230bf766f4f97833591f7577b90" dependencies = [ - "base64 0.13.1", - "serde", + "base64 0.21.7", + "serde 1.0.203", ] [[package]] name = "pbjson-build" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbb7b706f2afc610f3853550cdbbf6372fd324824a087806bd4480ea4996e24" +checksum = "2580e33f2292d34be285c5bc3dba5259542b083cfad6037b6d70345f24dcb735" dependencies = [ "heck 0.4.1", - "itertools 0.10.5", - "prost 0.11.9", - "prost-types 0.11.9", + "itertools 0.11.0", + "prost", + "prost-types", ] [[package]] name = "pbjson-types" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a88c8d87f99a4ac14325e7a4c24af190fca261956e3b82dd7ed67e77e6c7043" +checksum = "18f596653ba4ac51bdecbb4ef6773bc7f56042dc13927910de1684ad3d32aa12" dependencies = [ "bytes 1.6.0", "chrono", "pbjson", "pbjson-build", - "prost 0.11.9", - "prost-build 0.11.9", - "serde", + "prost", + "prost-build", + "serde 1.0.203", ] [[package]] @@ -5699,17 +6134,17 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "pem" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.21.7", - "serde", + "base64 0.22.1", + "serde 1.0.203", ] [[package]] @@ -5729,9 +6164,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -5740,9 +6175,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -5750,22 +6185,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -5774,9 +6209,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap 2.2.6", @@ -5837,14 +6272,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -5854,12 +6289,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" dependencies = [ "atomic-waker", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-io", ] @@ -5869,7 +6304,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.8", + "der 0.7.9", "pkcs8 0.10.2", "spki 0.7.3", ] @@ -5890,7 +6325,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.8", + "der 0.7.9", "spki 0.7.3", ] @@ -5909,8 +6344,8 @@ dependencies = [ "chrono", "font-kit", "image", - "lazy_static", - "num-traits", + "lazy_static 1.4.0", + "num-traits 0.2.19", "pathfinder_geometry", "plotters-backend", "plotters-bitmap", @@ -5961,12 +6396,11 @@ dependencies = [ [[package]] name = "poem" -version = "2.0.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec6f0033707ce6eb76240e39a592e7eac2f702768636cb03969293227ca8e642" +checksum = "e88b6912ed1e8833d7c22c9c986c517f4518d7d37e3c04566d917c789aaea591" dependencies = [ - "async-trait", - "base64 0.21.7", + "base64 0.22.1", "bytes 1.6.0", "chrono", "cookie", @@ -5974,14 +6408,14 @@ dependencies = [ "headers 0.4.0", "http 1.1.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "mime", - "multer 3.0.0", - "nix 0.27.1", - "opentelemetry", + "multer 3.1.0", + "nix 0.28.0", + "opentelemetry 0.22.0", "opentelemetry-http", - "opentelemetry-prometheus", + "opentelemetry-prometheus 0.15.0", "opentelemetry-semantic-conventions", "parking_lot", "percent-encoding", @@ -5991,13 +6425,13 @@ dependencies = [ "quick-xml", "regex", "rfc7239", - "serde", + "serde 1.0.203", "serde_json", "serde_urlencoded", "serde_yaml", "smallvec", "sse-codec", - "sync_wrapper", + "sync_wrapper 1.0.1", "tempfile", "thiserror", "time", @@ -6011,23 +6445,23 @@ dependencies = [ [[package]] name = "poem-derive" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4826d63b6760f8e5d24be9f738a5e38a43d726f32a3c2cc9388b1cc66e587f5c" +checksum = "c2b961d58a6c53380c20236394381d9292fda03577f902b158f1638932964dcf" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "poem-openapi" -version = "4.0.1" +version = "5.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41a6bbb99ef0046e3214b0be463d68f5716e752f6b04dba06ba4a5d54d159d2" +checksum = "b6445b50be2e26f142d4e554d15773fc1e7510b994083c9625a65eba0d3f4287" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes 1.6.0", "chrono", "derive_more", @@ -6035,12 +6469,12 @@ dependencies = [ "humantime", "indexmap 2.2.6", "mime", - "num-traits", + "num-traits 0.2.19", "poem", "poem-openapi-derive", "quick-xml", "regex", - "serde", + "serde 1.0.203", "serde_json", "serde_urlencoded", "serde_yaml", @@ -6053,11 +6487,11 @@ dependencies = [ [[package]] name = "poem-openapi-derive" -version = "4.0.1" +version = "5.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb2131050ed98d61c903123ab6e4bed5f4fe7f4623f770cb017f0baa632fae5" +checksum = "e890165626ff447a1ff3d6f2293e6ccacbf7fcbdd4c94086aa548de655735b03" dependencies = [ - "darling 0.20.8", + "darling 0.20.9", "http 1.1.0", "indexmap 2.2.6", "mime", @@ -6065,7 +6499,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.55", + "syn 2.0.66", "thiserror", ] @@ -6087,15 +6521,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.6.0" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi 0.3.9", + "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.32", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -6112,6 +6546,17 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde 1.0.203", +] + [[package]] name = "postgres" version = "0.19.7" @@ -6179,22 +6624,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "prettyplease" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -6227,9 +6662,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -6242,33 +6677,43 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "version_check", "yansi 1.0.1", ] [[package]] name = "procfs" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de8dacb0873f77e6aefc6d71e044761fcc68060290f5b1089fcdf84626bb69" +checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4" dependencies = [ - "bitflags 1.3.2", - "byteorder", + "bitflags 2.5.0", + "hex", + "lazy_static 1.4.0", + "procfs-core", + "rustix 0.38.34", +] + +[[package]] +name = "procfs-core" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29" +dependencies = [ + "bitflags 2.5.0", "hex", - "lazy_static", - "rustix 0.36.17", ] [[package]] name = "prometheus" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" dependencies = [ "cfg-if", "fnv", - "lazy_static", + "lazy_static 1.4.0", "libc", "memchr", "parking_lot", @@ -6286,12 +6731,12 @@ dependencies = [ "bit-set", "bit-vec", "bitflags 2.5.0", - "lazy_static", - "num-traits", + "lazy_static 1.4.0", + "num-traits 0.2.19", "rand 0.8.5", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "rusty-fork", "tempfile", "unarray", @@ -6299,123 +6744,68 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes 1.6.0", - "prost-derive 0.11.9", -] - -[[package]] -name = "prost" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" -dependencies = [ - "bytes 1.6.0", - "prost-derive 0.12.3", -] - -[[package]] -name = "prost-build" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes 1.6.0", - "heck 0.4.1", - "itertools 0.10.5", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease 0.1.25", - "prost 0.11.9", - "prost-types 0.11.9", - "regex", - "syn 1.0.109", - "tempfile", - "which 4.4.2", + "prost-derive", ] [[package]] name = "prost-build" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes 1.6.0", - "heck 0.4.1", - "itertools 0.11.0", + "heck 0.5.0", + "itertools 0.12.1", "log", "multimap", "once_cell", "petgraph", - "prettyplease 0.2.17", - "prost 0.12.3", - "prost-types 0.12.3", + "prettyplease", + "prost", + "prost-types", "regex", - "syn 2.0.55", + "syn 2.0.66", "tempfile", - "which 4.4.2", -] - -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 1.0.109", ] [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "prost-reflect" -version = "0.11.5" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b823de344848e011658ac981009100818b322421676740546f8b52ed5249428" +checksum = "6f5eec97d5d34bdd17ad2db2219aabf46b054c6c41bd5529767c9ce55be5898f" dependencies = [ "logos", "miette", "once_cell", - "prost 0.11.9", - "prost-types 0.11.9", -] - -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost 0.11.9", + "prost", + "prost-types", ] [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.3", + "prost", ] [[package]] @@ -6426,28 +6816,28 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "protox" -version = "0.4.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a5aacd1f6147ceac5e3896e0c766187dc6a9645f3b93ec821fabbaf821b887" +checksum = "ac532509cee918d40f38c3e12f8ef9230f215f017d54de7dd975015538a42ce7" dependencies = [ "bytes 1.6.0", "miette", - "prost 0.11.9", + "prost", "prost-reflect", - "prost-types 0.11.9", + "prost-types", "protox-parse", "thiserror", ] [[package]] name = "protox-parse" -version = "0.4.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30fc6d0af2dec2c39da31eb02cc78cbc05b843b04f30ad78ccc6e8a342ec5518" +checksum = "7f6c33f43516fe397e2f930779d720ca12cd057f7da4cd6326a0ef78d69dee96" dependencies = [ "logos", "miette", - "prost-types 0.11.9", + "prost-types", "thiserror", ] @@ -6460,6 +6850,22 @@ dependencies = [ "cc", ] +[[package]] +name = "ptree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de80796b316aec75344095a6d2ef68ec9b8f573b9e7adc821149ba3598e270" +dependencies = [ + "ansi_term", + "atty", + "config", + "directories", + "petgraph", + "serde 1.0.203", + "serde-value", + "tint", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -6473,14 +6879,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", - "serde", + "serde 1.0.203", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -6570,7 +6976,7 @@ dependencies = [ "gen_ops", "itertools 0.12.1", "num-integer", - "num-traits", + "num-traits 0.2.19", ] [[package]] @@ -6604,31 +7010,31 @@ dependencies = [ [[package]] name = "redis" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6472825949c09872e8f2c50bde59fcefc17748b6be5c90fd67cd8b4daca73bfd" +checksum = "e0d7a6955c7511f60f3ba9e86c6d02b3c3f144f8c24b288d1f4e18074ab8bbec" dependencies = [ "combine", "itoa", "percent-encoding", "ryu", "sha1_smol", - "socket2 0.5.6", + "socket2 0.5.7", "url", ] [[package]] name = "redis-protocol" -version = "4.1.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c31deddf734dc0a39d3112e73490e88b61a05e83e074d211f348404cee4d2c6" +checksum = "65deb7c9501fbb2b6f812a30d59c0253779480853545153a51d8e9e444ddc99f" dependencies = [ "bytes 1.6.0", "bytes-utils", "cookie-factory", "crc16", "log", - "nom", + "nom 7.1.3", ] [[package]] @@ -6640,11 +7046,20 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -6666,14 +7081,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -6687,20 +7102,20 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] name = "regex-lite" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" @@ -6710,15 +7125,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "relative-path" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "remove_dir_all" @@ -6731,21 +7146,24 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "async-compression", - "base64 0.21.7", + "base64 0.22.1", "bytes 1.6.0", "encoding_rs", "futures-core", "futures-util", - "h2 0.3.25", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-rustls 0.27.2", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -6755,14 +7173,15 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", - "serde", + "rustls-pemfile 2.1.2", + "serde 1.0.203", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "system-configuration", "tokio", "tokio-native-tls", + "tokio-socks", "tokio-util", "tower-service", "url", @@ -6796,9 +7215,9 @@ dependencies = [ [[package]] name = "rfc7239" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087317b3cf7eb481f13bd9025d729324b7cd068d6f470e2d76d049e191f5ba47" +checksum = "b106a85eeb5b0336d16d6a20eab857f92861d4fbb1eb9a239866fb98fb6a1063" dependencies = [ "uncased", ] @@ -6848,7 +7267,7 @@ dependencies = [ "digest", "num-bigint-dig", "num-integer", - "num-traits", + "num-traits 0.2.19", "pkcs1", "pkcs8 0.10.2", "rand_core 0.6.4", @@ -6868,11 +7287,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rust-ini" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" + [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -6889,20 +7314,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.36.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes 1.0.11", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - [[package]] name = "rustix" version = "0.37.27" @@ -6919,24 +7330,24 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", "itoa", "libc", - "linux-raw-sys 0.4.13", + "linux-raw-sys 0.4.14", "once_cell", "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -6946,14 +7357,30 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ + "aws-lc-rs", "log", + "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.4", "subtle", "zeroize", ] @@ -6965,7 +7392,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "schannel", "security-framework", ] @@ -6979,11 +7419,21 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -6997,10 +7447,11 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -7008,9 +7459,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rusty-fork" @@ -7026,9 +7477,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -7050,26 +7501,26 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", "schemars_derive", - "serde", + "serde 1.0.203", "serde_json", ] [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -7115,7 +7566,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", - "der 0.7.8", + "der 0.7.9", "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", @@ -7128,36 +7579,36 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" dependencies = [ - "serde", + "serde 1.0.203", "zeroize", ] [[package]] name = "secret-service" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da1a5ad4d28c03536f82f77d9f36603f5e37d8869ac98f0a750d5b5686d8d95" +checksum = "b5204d39df37f06d1944935232fd2dfe05008def7ca599bf28c0800366c8a8f9" dependencies = [ - "aes 0.7.5", - "block-modes", + "aes", + "cbc", "futures-util", "generic-array 0.14.7", "hkdf", "num", "once_cell", "rand 0.8.5", - "serde", + "serde 1.0.203", "sha2", "zbus", ] [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -7166,9 +7617,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -7180,18 +7631,36 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] name = "serde" -version = "1.0.197" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" + +[[package]] +name = "serde" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-hjson" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" +dependencies = [ + "lazy_static 1.4.0", + "num-traits 0.1.43", + "regex", + "serde 0.8.23", +] + [[package]] name = "serde-value" version = "0.7.0" @@ -7199,7 +7668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" dependencies = [ "ordered-float 2.10.1", - "serde", + "serde 1.0.203", ] [[package]] @@ -7209,40 +7678,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", - "serde", + "serde 1.0.203", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", - "serde", + "serde 1.0.203", ] [[package]] @@ -7252,10 +7721,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bc0207b6351893eafa1e39aa9aea452abb6425ca7b02dd64faf29109e7a33ba" dependencies = [ "inventory", - "nom", + "nom 7.1.3", "once_cell", "regex", - "serde", + "serde 1.0.203", "serde_json", "serde_json_path_core", "serde_json_path_macros", @@ -7270,7 +7739,7 @@ checksum = "a3d64fe53ce1aaa31bea2b2b46d3b6ab6a37e61854bedcbd9f174e188f3f7d79" dependencies = [ "inventory", "once_cell", - "serde", + "serde 1.0.203", "serde_json", "thiserror", ] @@ -7295,27 +7764,27 @@ checksum = "75dde5a1d2ed78dfc411fc45592f72d3694436524d3353683ecb3d22009731dc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] @@ -7327,7 +7796,7 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde", + "serde 1.0.203", ] [[package]] @@ -7336,25 +7805,25 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ - "serde", + "serde 1.0.203", "serde_with_macros 1.5.2", ] [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.2.6", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", - "serde_with_macros 3.7.0", + "serde_with_macros 3.8.1", "time", ] @@ -7372,14 +7841,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ - "darling 0.20.8", + "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -7391,7 +7860,7 @@ dependencies = [ "indexmap 2.2.6", "itoa", "ryu", - "serde", + "serde 1.0.203", "unsafe-libyaml", ] @@ -7423,15 +7892,40 @@ dependencies = [ "digest", ] +[[package]] +name = "sha256" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" +dependencies = [ + "async-trait", + "bytes 1.6.0", + "hex", + "sha2", + "tokio", +] + [[package]] name = "sharded-slab" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ - "lazy_static", + "lazy_static 1.4.0", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shellexpand" version = "2.1.2" @@ -7470,9 +7964,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -7539,6 +8033,9 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde 1.0.203", +] [[package]] name = "smawk" @@ -7558,9 +8055,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -7568,9 +8065,9 @@ dependencies = [ [[package]] name = "spdx" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ef1a0fa1e39ac22972c8db23ff89aea700ab96aa87114e1fb55937a631a0c9" +checksum = "47317bbaf63785b53861e1ae2d11b80d6b624211d42cb20efcd210ee6f8a14bc" dependencies = [ "smallvec", ] @@ -7607,7 +8104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.8", + "der 0.7.9", ] [[package]] @@ -7618,12 +8115,11 @@ checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" [[package]] name = "sqlformat" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +checksum = "f895e3734318cc55f1fe66258926c9b910c124d47520339efecbb6c59cec7c1f" dependencies = [ - "itertools 0.12.1", - "nom", + "nom 7.1.3", "unicode_categories", ] @@ -7668,7 +8164,7 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "serde", + "serde 1.0.203", "serde_json", "sha2", "smallvec", @@ -7707,7 +8203,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "serde", + "serde 1.0.203", "serde_json", "sha2", "sqlx-core", @@ -7752,7 +8248,7 @@ dependencies = [ "percent-encoding", "rand 0.8.5", "rsa", - "serde", + "serde 1.0.203", "sha1", "sha2", "smallvec", @@ -7792,7 +8288,7 @@ dependencies = [ "memchr", "once_cell", "rand 0.8.5", - "serde", + "serde 1.0.203", "serde_json", "sha2", "smallvec", @@ -7821,7 +8317,7 @@ dependencies = [ "libsqlite3-sys", "log", "percent-encoding", - "serde", + "serde 1.0.203", "sqlx-core", "tracing", "url", @@ -7855,13 +8351,13 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stringprep" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ - "finl_unicode", "unicode-bidi", "unicode-normalization", + "unicode-properties", ] [[package]] @@ -7881,9 +8377,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -7893,15 +8389,15 @@ checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -7923,9 +8419,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -7937,10 +8433,27 @@ name = "sync_wrapper" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -7964,16 +8477,16 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.26.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" +checksum = "b858526d22750088a9b3cf2e3c2aacebd5377f13adeec02860c30d09113010a6" dependencies = [ "bitflags 2.5.0", "cap-fs-ext", "cap-std", "fd-lock", "io-lifetimes 2.0.3", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", "winx", ] @@ -8007,8 +8520,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.2", - "rustix 0.38.32", + "fastrand 2.1.0", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -8034,7 +8547,7 @@ dependencies = [ "hmac", "log", "rand 0.8.5", - "serde", + "serde 1.0.203", "serde_json", "sha2", "tokio", @@ -8042,9 +8555,9 @@ dependencies = [ [[package]] name = "testcontainers-modules" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "204d1c7516bfdc8a01bb85d3e30145e5bbeb2351812e5e8aa6971769109b45b5" +checksum = "8debb5e215d9e89ea93255fffff00bf037ea44075d7a2669a21a8a988d6b52fd" dependencies = [ "testcontainers", ] @@ -8071,22 +8584,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -8110,15 +8623,15 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", - "serde", + "serde 1.0.203", "time-core", "time-macros", ] @@ -8131,21 +8644,40 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", ] +[[package]] +name = "tint" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7af24570664a3074673dbbf69a65bdae0ae0b72f2949b1adfbacb736ee4d6896" +dependencies = [ + "lazy_static 0.2.11", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ - "serde", + "serde 1.0.203", "serde_json", ] @@ -8166,9 +8698,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes 1.6.0", @@ -8178,7 +8710,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -8196,13 +8728,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -8235,7 +8767,7 @@ dependencies = [ "postgres-protocol", "postgres-types", "rand 0.8.5", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tokio-util", "whoami", @@ -8247,7 +8779,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.10", + "rustls 0.21.12", "tokio", ] @@ -8257,11 +8789,34 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.3", + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.10", "rustls-pki-types", "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -8302,9 +8857,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes 1.6.0", "futures-core", @@ -8313,7 +8868,6 @@ dependencies = [ "pin-project-lite", "slab", "tokio", - "tracing", ] [[package]] @@ -8322,28 +8876,28 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] name = "toml" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ - "serde", + "serde 1.0.203", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.14", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ - "serde", + "serde 1.0.203", ] [[package]] @@ -8364,44 +8918,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", - "serde", - "serde_spanned", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", - "serde", + "serde 1.0.203", "serde_spanned", "toml_datetime", - "winnow 0.6.5", + "winnow 0.6.13", ] [[package]] name = "tonic" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", "axum", "base64 0.21.7", "bytes 1.6.0", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", - "hyper-timeout", + "hyper 0.14.29", + "hyper-timeout 0.4.1", "percent-encoding", "pin-project 1.1.5", - "prost 0.12.3", + "prost", "tokio", "tokio-stream", "tower", @@ -8416,21 +8968,21 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" dependencies = [ - "prettyplease 0.2.17", + "prettyplease", "proc-macro2", - "prost-build 0.12.3", + "prost-build", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "tonic-health" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f80db390246dfb46553481f6024f0082ba00178ea495dbb99e70ba9a4fafb5e1" +checksum = "2cef6e24bc96871001a7e48e820ab240b3de2201e59b517cf52835df2f1d2350" dependencies = [ "async-stream", - "prost 0.12.3", + "prost", "tokio", "tokio-stream", "tonic", @@ -8438,12 +8990,12 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa37c513df1339d197f4ba21d28c918b9ef1ac1768265f11ecb6b7f1cba1b76" +checksum = "548c227bd5c0fae5925812c4ec6c66ffcfced23ea370cb823f4d18f0fc1cb6a7" dependencies = [ - "prost 0.12.3", - "prost-types 0.12.3", + "prost", + "prost-types", "tokio", "tokio-stream", "tonic", @@ -8471,18 +9023,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "base64 0.21.7", "bitflags 2.5.0", "bytes 1.6.0", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "http-range-header", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", "pin-project-lite", "tower-layer", @@ -8522,7 +9072,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] @@ -8562,7 +9112,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ - "serde", + "serde 1.0.203", "tracing-core", ] @@ -8576,7 +9126,7 @@ dependencies = [ "nu-ansi-term", "once_cell", "regex", - "serde", + "serde 1.0.203", "serde_json", "sharded-slab", "smallvec", @@ -8589,11 +9139,10 @@ dependencies = [ [[package]] name = "tracing-test" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" +checksum = "557b891436fe0d5e0e363427fc7f217abf9ccd510d5136549847bdcbcd011d68" dependencies = [ - "lazy_static", "tracing-core", "tracing-subscriber", "tracing-test-macro", @@ -8601,22 +9150,12 @@ dependencies = [ [[package]] name = "tracing-test-macro" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" +checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ - "lazy_static", "quote", - "syn 1.0.109", -] - -[[package]] -name = "treediff" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d127780145176e2b5d16611cc25a900150e86e9fd79d3bde6ff3a37359c9cb5" -dependencies = [ - "serde_json", + "syn 2.0.66", ] [[package]] @@ -8744,6 +9283,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-properties" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -8752,9 +9297,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -8792,14 +9337,14 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", "idna", "percent-encoding", - "serde", + "serde 1.0.203", ] [[package]] @@ -8814,11 +9359,23 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -8827,7 +9384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", - "serde", + "serde 1.0.203", ] [[package]] @@ -8878,9 +9435,9 @@ dependencies = [ [[package]] name = "vte_generate_state_changes" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" dependencies = [ "proc-macro2", "quote", @@ -8897,9 +9454,9 @@ dependencies = [ [[package]] name = "waker-fn" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" [[package]] name = "walkdir" @@ -8922,13 +9479,14 @@ dependencies = [ [[package]] name = "warg-api" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6155f45f54e013e7e4016ed728d132e5b5e4da6a9ab688edfa0a19a3d6fe87f6" +checksum = "6a22d3c9026f2f6a628cf386963844cdb7baea3b3419ba090c9096da114f977d" dependencies = [ - "itertools 0.11.0", - "serde", - "serde_with 3.7.0", + "indexmap 2.2.6", + "itertools 0.12.1", + "serde 1.0.203", + "serde_with 3.8.1", "thiserror", "warg-crypto", "warg-protocol", @@ -8936,24 +9494,32 @@ dependencies = [ [[package]] name = "warg-client" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807a117360b22b04a5e89adf980d48f0076fc28c6d971bf3a868cce29b76a29a" +checksum = "6b8b5a2b17e737e1847dbf4642e4ebe49f5df32a574520251ff080ef0a120423" dependencies = [ "anyhow", + "async-recursion", "async-trait", "bytes 1.6.0", - "clap 4.5.4", + "clap 4.5.7", + "dialoguer", "dirs 5.0.1", "futures-util", - "itertools 0.11.0", + "indexmap 2.2.6", + "itertools 0.12.1", + "keyring", "libc", "normpath", "once_cell", "pathdiff", + "ptree", "reqwest", - "serde", + "secrecy", + "semver", + "serde 1.0.203", "serde_json", + "sha256", "tempfile", "thiserror", "tokio", @@ -8965,14 +9531,18 @@ dependencies = [ "warg-crypto", "warg-protocol", "warg-transparency", - "windows-sys 0.48.0", + "wasm-compose 0.5.5", + "wasm-encoder 0.41.2", + "wasmparser 0.121.2", + "wasmprinter 0.2.80", + "windows-sys 0.52.0", ] [[package]] name = "warg-crypto" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3421fa178ce468087d2c51b53ae4ab6d435e4e41bb6fee2c2b25bd555df9f6c3" +checksum = "834bf58863aa4bc3821732afb0c77e08a5cbf05f63ee93116acae694eab04460" dependencies = [ "anyhow", "base64 0.21.7", @@ -8983,7 +9553,7 @@ dependencies = [ "p256 0.13.2", "rand_core 0.6.4", "secrecy", - "serde", + "serde 1.0.203", "sha2", "signature 2.2.0", "thiserror", @@ -8991,54 +9561,55 @@ dependencies = [ [[package]] name = "warg-protobuf" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a6adafed625d8d254d34ee0c9836c2f9e6bd5a799b489ffc31c2c572554234" +checksum = "cf8a2dee6b14f5b0b0c461711a81cdef45d45ea94f8460cb6205cada7fec732a" dependencies = [ "anyhow", "pbjson", "pbjson-build", "pbjson-types", - "prost 0.11.9", - "prost-build 0.11.9", - "prost-types 0.11.9", + "prost", + "prost-build", + "prost-types", "protox", "regex", - "serde", + "serde 1.0.203", "warg-crypto", ] [[package]] name = "warg-protocol" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e47b7e7a8a9f9895268b68e7cf29ca1d3129faa9f9bcbc973ff5e92884a014" +checksum = "4053a3276d3fee83645411b1b5f462f72402e70fbf645164274a3a0a2fd72538" dependencies = [ "anyhow", "base64 0.21.7", "hex", "indexmap 2.2.6", "pbjson-types", - "prost 0.11.9", - "prost-types 0.11.9", + "prost", + "prost-types", "semver", - "serde", - "serde_with 3.7.0", + "serde 1.0.203", + "serde_with 3.8.1", "thiserror", "warg-crypto", "warg-protobuf", "warg-transparency", - "wasmparser 0.108.0", + "wasmparser 0.121.2", ] [[package]] name = "warg-transparency" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cd84da2c4f298556706e75a8f19df3e2c844be2ce9e959b07904fb66c333cc" +checksum = "513ef81a5bb1ac5d7bd04f90d3c192dad8f590f4c02b3ef68d3ae4fbbb53c1d7" dependencies = [ "anyhow", - "prost 0.11.9", + "indexmap 2.2.6", + "prost", "thiserror", "warg-crypto", "warg-protobuf", @@ -9046,30 +9617,28 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" dependencies = [ "bytes 1.6.0", "futures-channel", "futures-util", "headers 0.3.9", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "log", "mime", "mime_guess", "multer 2.1.0", "percent-encoding", "pin-project 1.1.5", - "rustls-pemfile", "scoped-tls", - "serde", + "serde 1.0.203", "serde_json", "serde_urlencoded", "tokio", - "tokio-stream", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite 0.21.0", "tokio-util", "tower-service", "tracing", @@ -9081,47 +9650,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi-cap-std-sync" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" -dependencies = [ - "anyhow", - "async-trait", - "cap-fs-ext", - "cap-rand", - "cap-std", - "cap-time-ext", - "fs-set-times", - "io-extras", - "io-lifetimes 2.0.3", - "once_cell", - "rustix 0.38.32", - "system-interface", - "tracing", - "wasi-common", - "windows-sys 0.52.0", -] - -[[package]] -name = "wasi-common" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" -dependencies = [ - "anyhow", - "bitflags 2.5.0", - "cap-rand", - "cap-std", - "io-extras", - "log", - "rustix 0.38.32", - "thiserror", - "tracing", - "wasmtime", - "wiggle", - "windows-sys 0.52.0", -] - [[package]] name = "wasite" version = "0.1.0" @@ -9149,7 +9677,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -9183,7 +9711,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9196,9 +9724,9 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-compose" -version = "0.201.0" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10501f9526fedb9592271a19c34257582b6abcb4636e276ee75cb95aa242ee2a" +checksum = "fd324927af875ebedb1b820c00e3c585992d33c2c787c5021fe6d8982527359b" dependencies = [ "anyhow", "heck 0.4.1", @@ -9206,22 +9734,34 @@ dependencies = [ "indexmap 2.2.6", "log", "petgraph", - "serde", + "serde 1.0.203", "serde_derive", "serde_yaml", "smallvec", - "wasm-encoder 0.201.0", - "wasmparser 0.201.0", + "wasm-encoder 0.41.2", + "wasmparser 0.121.2", "wat", ] [[package]] -name = "wasm-encoder" -version = "0.38.1" +name = "wasm-compose" +version = "0.207.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +checksum = "ef991fbc1344f90e4742ea2f9f200fdefec5f4ff993e5b3573b6311825619ead" dependencies = [ - "leb128", + "anyhow", + "heck 0.4.1", + "im-rc", + "indexmap 2.2.6", + "log", + "petgraph", + "serde 1.0.203", + "serde_derive", + "serde_yaml", + "smallvec", + "wasm-encoder 0.207.0", + "wasmparser 0.207.0", + "wat", ] [[package]] @@ -9231,41 +9771,92 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" dependencies = [ "leb128", + "wasmparser 0.121.2", ] [[package]] name = "wasm-encoder" -version = "0.201.0" +version = "0.207.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +checksum = "d996306fb3aeaee0d9157adbe2f670df0236caf19f6728b221e92d0f27b3fe17" dependencies = [ "leb128", - "wasmparser 0.201.0", + "wasmparser 0.207.0", ] [[package]] name = "wasm-encoder" -version = "0.202.0" +version = "0.208.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" +checksum = "6425e84e42f7f558478e40ecc2287912cb319f2ca68e5c0bb93c61d4fc63fa17" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.210.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e3764d9d6edabd8c9e16195e177be0d20f6ab942ad18af52860f12f82bc59a" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.10.20" +version = "0.207.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18ebaa7bd0f9e7a5e5dd29b9a998acf21c4abed74265524dd7e85934597bfb10" +checksum = "b2c44e62d325ce9253f88c01f0f67be121356767d12f2f13e701fdcd99e1f5b0" dependencies = [ "anyhow", "indexmap 2.2.6", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", "spdx", - "wasm-encoder 0.41.2", - "wasmparser 0.121.2", + "wasm-encoder 0.207.0", + "wasmparser 0.207.0", +] + +[[package]] +name = "wasm-metadata" +version = "0.208.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a2c4280ad374a6db3d76d4bb61e2ec4b3b9ce5469cc4f2bbc5708047a2bbff" +dependencies = [ + "anyhow", + "indexmap 2.2.6", + "serde 1.0.203", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder 0.208.1", + "wasmparser 0.208.1", +] + +[[package]] +name = "wasm-metadata" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d32029ce424f6d3c2b39b4419fb45a0e2d84fb0751e0c0a32b7ce8bd5d97f46" +dependencies = [ + "anyhow", + "indexmap 2.2.6", + "serde 1.0.203", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder 0.209.1", + "wasmparser 0.209.1", ] [[package]] @@ -9283,55 +9874,64 @@ dependencies = [ [[package]] name = "wasm-wave" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "132211e87e40f5470a159f6f44aa87c37f0e24321c42cb1d957d18de1ff576cd" +checksum = "9de15f412defafcc78c2f9271d86c0fae5fa44886b3f317c5eaa51f5f07af534" dependencies = [ "indexmap 2.2.6", "logos", "thiserror", "wasmtime", - "wit-parser 0.13.2", + "wit-parser 0.208.1", ] [[package]] name = "wasmparser" -version = "0.108.0" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c956109dcb41436a39391139d9b6e2d0a5e0b158e1293ef352ec977e5e36c5" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ + "bitflags 2.5.0", "indexmap 2.2.6", "semver", ] [[package]] name = "wasmparser" -version = "0.118.2" +version = "0.207.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f1154f1ab868e2a01d9834a805faca7bf8b50d041b4ca714d005d0dab1c50c" +checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" dependencies = [ + "ahash", + "bitflags 2.5.0", + "hashbrown 0.14.5", "indexmap 2.2.6", "semver", ] [[package]] name = "wasmparser" -version = "0.121.2" +version = "0.208.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" +checksum = "dd921789c9dcc495f589cb37d200155dee65b4a4beeb853323b5e24e0a5f9c58" dependencies = [ + "ahash", "bitflags 2.5.0", + "hashbrown 0.14.5", "indexmap 2.2.6", "semver", + "serde 1.0.203", ] [[package]] name = "wasmparser" -version = "0.201.0" +version = "0.209.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" dependencies = [ + "ahash", "bitflags 2.5.0", + "hashbrown 0.14.5", "indexmap 2.2.6", "semver", ] @@ -9346,39 +9946,66 @@ dependencies = [ "wasmparser 0.121.2", ] +[[package]] +name = "wasmprinter" +version = "0.207.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2d8a7b4dabb460208e6b4334d9db5766e84505038b2529e69c3d07ac619115" +dependencies = [ + "anyhow", + "wasmparser 0.207.0", +] + [[package]] name = "wasmtime" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ + "addr2line 0.21.0", "anyhow", "async-trait", - "bincode 1.3.3", "bumpalo", + "cc", "cfg-if", "encoding_rs", "fxprof-processed-profile", + "gimli 0.28.1", + "hashbrown 0.14.5", "indexmap 2.2.6", + "ittapi", "libc", + "libm", "log", - "object", + "mach2", + "memfd", + "memoffset 0.9.1", + "object 0.33.0", "once_cell", "paste", + "postcard", + "psm", "rayon", - "serde", + "rustix 0.38.34", + "semver", + "serde 1.0.203", "serde_derive", "serde_json", + "smallvec", + "sptr", "target-lexicon", - "wasm-encoder 0.38.1", - "wasmparser 0.118.2", + "wasm-encoder 0.207.0", + "wasmparser 0.207.0", + "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", - "wasmtime-jit", - "wasmtime-runtime", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-slab", + "wasmtime-versioned-export-macros", "wasmtime-winch", "wat", "windows-sys 0.52.0", @@ -9386,54 +10013,54 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "base64 0.21.7", - "bincode 1.3.3", "directories-next", "log", - "rustix 0.38.32", - "serde", + "postcard", + "rustix 0.38.34", + "serde 1.0.203", "serde_derive", "sha2", - "toml 0.5.11", + "toml 0.8.14", "windows-sys 0.52.0", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser 0.13.2", + "wit-parser 0.207.0", ] [[package]] name = "wasmtime-component-util" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" [[package]] name = "wasmtime-cranelift" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "cfg-if", @@ -9443,170 +10070,107 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.28.1", "log", - "object", + "object 0.33.0", "target-lexicon", "thiserror", - "wasmparser 0.118.2", - "wasmtime-cranelift-shared", + "wasmparser 0.207.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] -[[package]] -name = "wasmtime-cranelift-shared" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-control", - "cranelift-native", - "gimli", - "object", - "target-lexicon", - "wasmtime-environ", -] - [[package]] name = "wasmtime-environ" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", + "cpp_demangle", "cranelift-entity", - "gimli", + "gimli 0.28.1", "indexmap 2.2.6", "log", - "object", - "serde", + "object 0.33.0", + "postcard", + "rustc-demangle", + "serde 1.0.203", "serde_derive", "target-lexicon", - "thiserror", - "wasm-encoder 0.38.1", - "wasmparser 0.118.2", - "wasmprinter", + "wasm-encoder 0.207.0", + "wasmparser 0.207.0", + "wasmprinter 0.207.0", "wasmtime-component-util", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "cc", "cfg-if", - "rustix 0.38.32", + "rustix 0.38.34", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", "windows-sys 0.52.0", ] -[[package]] -name = "wasmtime-jit" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" -dependencies = [ - "addr2line", - "anyhow", - "bincode 1.3.3", - "cfg-if", - "cpp_demangle", - "gimli", - "ittapi", - "log", - "object", - "rustc-demangle", - "rustix 0.38.32", - "serde", - "serde_derive", - "target-lexicon", - "wasmtime-environ", - "wasmtime-jit-debug", - "wasmtime-jit-icache-coherence", - "wasmtime-runtime", - "windows-sys 0.52.0", -] - [[package]] name = "wasmtime-jit-debug" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ - "object", + "object 0.33.0", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ + "anyhow", "cfg-if", "libc", "windows-sys 0.52.0", ] [[package]] -name = "wasmtime-runtime" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" -dependencies = [ - "anyhow", - "cc", - "cfg-if", - "encoding_rs", - "indexmap 2.2.6", - "libc", - "log", - "mach", - "memfd", - "memoffset 0.9.1", - "paste", - "psm", - "rustix 0.38.32", - "sptr", - "wasm-encoder 0.38.1", - "wasmtime-asm-macros", - "wasmtime-environ", - "wasmtime-fiber", - "wasmtime-jit-debug", - "wasmtime-versioned-export-macros", - "wasmtime-wmemcheck", - "windows-sys 0.52.0", -] +name = "wasmtime-slab" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" [[package]] name = "wasmtime-types" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "cranelift-entity", - "serde", + "serde 1.0.203", "serde_derive", - "thiserror", - "wasmparser 0.118.2", + "smallvec", + "wasmparser 0.207.0", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", ] [[package]] name = "wasmtime-wasi" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "async-trait", @@ -9621,17 +10185,13 @@ dependencies = [ "futures", "io-extras", "io-lifetimes 2.0.3", - "libc", - "log", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", "system-interface", "thiserror", "tokio", "tracing", "url", - "wasi-cap-std-sync", - "wasi-common", "wasmtime", "wiggle", "windows-sys 0.52.0", @@ -9639,8 +10199,8 @@ dependencies = [ [[package]] name = "wasmtime-wasi-http" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "async-trait", @@ -9649,10 +10209,10 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", - "rustls 0.21.10", + "hyper 1.3.1", + "rustls 0.22.4", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.25.0", "tracing", "wasmtime", "wasmtime-wasi", @@ -9661,36 +10221,31 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "cranelift-codegen", - "gimli", - "object", + "gimli 0.28.1", + "object 0.33.0", "target-lexicon", - "wasmparser 0.118.2", - "wasmtime-cranelift-shared", + "wasmparser 0.207.0", + "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", ] [[package]] name = "wasmtime-wit-bindgen" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "heck 0.4.1", "indexmap 2.2.6", - "wit-parser 0.13.2", + "wit-parser 0.207.0", ] -[[package]] -name = "wasmtime-wmemcheck" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" - [[package]] name = "wast" version = "35.0.2" @@ -9702,24 +10257,24 @@ dependencies = [ [[package]] name = "wast" -version = "202.0.0" +version = "210.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbcb11204515c953c9b42ede0a46a1c5e17f82af05c4fae201a8efff1b0f4fe" +checksum = "aa835c59bd615e00f16be65705d85517d40b44b3c831d724e450244685176c3c" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.202.0", + "wasm-encoder 0.210.0", ] [[package]] name = "wat" -version = "1.202.0" +version = "1.210.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de4b15a47135c56a3573406e9977b9518787a6154459b4842a9b9d3d1684848" +checksum = "67faece8487996430c6812be7f8776dc563ca0efcd3db77f8839070480c0d1a6" dependencies = [ - "wast 202.0.0", + "wast 210.0.0", ] [[package]] @@ -9734,9 +10289,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "weezl" @@ -9753,7 +10311,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -9764,7 +10322,7 @@ checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "rustix 0.38.32", + "rustix 0.38.34", "winsafe", ] @@ -9774,15 +10332,15 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "redox_syscall", + "redox_syscall 0.4.1", "wasite", "web-sys", ] [[package]] name = "wiggle" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "async-trait", @@ -9795,34 +10353,34 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn 2.0.55", + "syn 2.0.66", "witx", ] [[package]] name = "wiggle-macro" -version = "17.0.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "21.0.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", "wiggle-generate", ] [[package]] name = "wildmatch" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939e59c1bc731542357fdaad98b209ef78c8743d652bb61439d16b16a79eb025" +checksum = "3928939971918220fed093266b809d1ee4ec6c1a2d72692ff6876898f3b16c19" [[package]] name = "winapi" @@ -9842,11 +10400,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -9857,16 +10415,17 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.15.0" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +version = "0.19.1" +source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-v21.0.1#5a812469cbf13d213755d979e1c86ebc5478c5e9" dependencies = [ "anyhow", "cranelift-codegen", - "gimli", + "gimli 0.28.1", "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.118.2", + "wasmparser 0.207.0", + "wasmtime-cranelift", "wasmtime-environ", ] @@ -9877,7 +10436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -9886,16 +10445,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.5", ] [[package]] @@ -9913,22 +10463,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.5", ] [[package]] @@ -9948,25 +10483,20 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -9975,15 +10505,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -9993,15 +10517,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -10011,15 +10529,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_msvc" -version = "0.42.2" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -10029,15 +10547,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -10047,15 +10559,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -10065,15 +10571,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -10083,9 +10583,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -10098,18 +10598,18 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.50.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", @@ -10141,139 +10641,161 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-core" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "7076a12e69af6e1f6093bd16657d7ae61c30cfd3c5f62321046eb863b17ab1e2" dependencies = [ - "bitflags 2.5.0", + "anyhow", + "heck 0.5.0", + "wit-parser 0.208.1", ] [[package]] name = "wit-bindgen-core" -version = "0.16.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75d55e1a488af2981fb0edac80d8d20a51ac36897a1bdef4abde33c29c1b6d0d" +checksum = "36d4706efb67fadfbbde77955b299b111dd096e6776d8c6561d92f6147941880" dependencies = [ "anyhow", - "wit-component 0.18.2", - "wit-parser 0.13.2", + "heck 0.5.0", + "wit-parser 0.209.1", ] [[package]] -name = "wit-bindgen-core" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d22547a645a7d3e4311b977a34f12e1d47df48125dc06e11e45984c99282ed" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ - "anyhow", - "wit-component 0.20.3", - "wit-parser 0.13.2", + "bitflags 2.5.0", ] [[package]] name = "wit-bindgen-rust" -version = "0.16.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01ff9cae7bf5736750d94d91eb8a49f5e3a04aff1d1a3218287d9b2964510f8" +checksum = "7f8ca0dd2aa75452450da1906391aba9d3a43d95fa920e872361ea00acc452a5" dependencies = [ "anyhow", - "heck 0.4.1", - "wasm-metadata", - "wit-bindgen-core 0.16.0", - "wit-component 0.18.2", + "heck 0.5.0", + "indexmap 2.2.6", + "wasm-metadata 0.208.1", + "wit-bindgen-core 0.25.0", + "wit-component 0.208.1", ] [[package]] name = "wit-bindgen-rust" -version = "0.17.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a691b95d07cc4e7f7aa259b480f7f0208c4ded49406fd4f8bfd5a5a61c5db1" +checksum = "514295193d1a2f42e6a948cd7d9fd81e2b8fadc319667dcf19fd7aceaf2113a2" dependencies = [ "anyhow", - "heck 0.4.1", - "wasm-metadata", - "wit-bindgen-core 0.17.0", - "wit-component 0.20.3", + "heck 0.5.0", + "indexmap 2.2.6", + "wasm-metadata 0.209.1", + "wit-bindgen-core 0.26.0", + "wit-component 0.209.1", ] [[package]] name = "wit-component" -version = "0.18.2" +version = "0.208.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a35a2a9992898c9d27f1664001860595a4bc99d32dd3599d547412e17d7e2" +checksum = "fef7dd0e47f5135dd8739ccc5b188ab8b7e27e1d64df668aa36680f0b8646db8" dependencies = [ "anyhow", "bitflags 2.5.0", "indexmap 2.2.6", "log", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", - "wasm-encoder 0.38.1", - "wasm-metadata", - "wasmparser 0.118.2", - "wit-parser 0.13.2", + "wasm-encoder 0.208.1", + "wasm-metadata 0.208.1", + "wasmparser 0.208.1", + "wit-parser 0.208.1", ] [[package]] name = "wit-component" -version = "0.20.3" +version = "0.209.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4436190e87b4e539807bcdcf5b817e79d2e29e16bc5ddb6445413fe3d1f5716" +checksum = "25a2bb5b039f9cb03425e1d5a6e54b441ca4ca1b1d4fa6a0924db67a55168f99" dependencies = [ "anyhow", "bitflags 2.5.0", "indexmap 2.2.6", "log", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", - "wasm-encoder 0.41.2", - "wasm-metadata", - "wasmparser 0.121.2", - "wit-parser 0.13.2", + "wasm-encoder 0.209.1", + "wasm-metadata 0.209.1", + "wasmparser 0.209.1", + "wit-parser 0.209.1", ] [[package]] name = "wit-parser" -version = "0.13.2" +version = "0.207.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" +checksum = "78c83dab33a9618d86cfe3563cc864deffd08c17efc5db31a3b7cd1edeffe6e1" dependencies = [ "anyhow", "id-arena", "indexmap 2.2.6", "log", "semver", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", "unicode-xid", + "wasmparser 0.207.0", ] [[package]] name = "wit-parser" -version = "0.201.0" +version = "0.208.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" +checksum = "516417a730725fe3e6c9e2efc8d86697480f80496d32b24e62736950704c047c" dependencies = [ "anyhow", "id-arena", "indexmap 2.2.6", "log", "semver", - "serde", + "serde 1.0.203", "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.201.0", + "wasmparser 0.208.1", +] + +[[package]] +name = "wit-parser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.2.6", + "log", + "semver", + "serde 1.0.203", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser 0.209.1", ] [[package]] name = "witx" version = "0.9.1" -source = "git+https://github.com/golemcloud/wasmtime.git?branch=golem-wasmtime-17#c2e97ff31dfaa0da2deeb9365e53551183039dd3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", @@ -10281,14 +10803,26 @@ dependencies = [ "wast 35.0.2", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "xdg-home" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e5a325c3cb8398ad6cf859c1135b25dd29e186679cf2da7581d9679f63b38e" +checksum = "ca91dcf8f93db085f3a0a29358cd0b9d670915468f4290e8b85d118a34211ab8" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -10297,6 +10831,15 @@ version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yansi" version = "0.5.1" @@ -10321,13 +10864,37 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde 1.0.203", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zbus" version = "3.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "675d170b632a6ad49804c8cf2105d7c31eddd3312555cffd4b740e08e97c25e6" dependencies = [ - "async-broadcast", + "async-broadcast 0.5.1", "async-executor", "async-fs 1.6.0", "async-io 1.13.0", @@ -10349,7 +10916,7 @@ dependencies = [ "once_cell", "ordered-stream", "rand 0.8.5", - "serde", + "serde 1.0.203", "serde_repr", "sha1", "static_assertions", @@ -10382,63 +10949,101 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "437d738d3750bed6ca9b8d423ccc7a8eb284f6b1d6d4e225a0e4e6258d864c8d" dependencies = [ - "serde", + "serde 1.0.203", "static_assertions", "zvariant", ] [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.66", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] [[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" +name = "zerovec" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", + "yoke", + "zerofrom", + "zerovec-derive", ] [[package]] -name = "zstd" -version = "0.13.1" +name = "zerovec-derive" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" dependencies = [ - "zstd-safe 7.1.0", + "proc-macro2", + "quote", + "syn 2.0.66", ] [[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +name = "zstd" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ - "libc", - "zstd-sys", + "zstd-safe", ] [[package]] @@ -10452,9 +11057,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", @@ -10469,7 +11074,7 @@ dependencies = [ "byteorder", "enumflags2", "libc", - "serde", + "serde 1.0.203", "static_assertions", "zvariant_derive", ] diff --git a/Cargo.toml b/Cargo.toml index 4cdd31223e..c8e2fbbbea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ aws-config = "1.1.3" aws-sdk-s3 = "1.13.0" bincode = { version = "2.0.0-rc.3", features = ["serde"] } bytes = "1.5.0" -cap-std = "2.0.0" # keep in sync with wasmtime +cap-std = "3.0.0" # keep in sync with wasmtime chrono = { version = "0.4.32", features = ["serde"] } clap = { version = "4.5.4", features = [ "derive", @@ -72,12 +72,12 @@ clap = { version = "4.5.4", features = [ "help", ] } cli-table = "0.4.7" -console-subscriber = "0.2.0" +console-subscriber = "0.3.0" ctor = "0.2.6" dashmap = "5.5.3" derive_more = "0.99.17" figment = { version = "0.10.14", features = ["toml", "env"] } -fred = { version = "8.0.0", features = [ +fred = { version = "9.0.3", features = [ "metrics", "serde-json", "partial-tracing", @@ -85,8 +85,8 @@ fred = { version = "8.0.0", features = [ futures = "0.3" futures-core = "0.3.29" futures-util = "0.3.29" -golem-wasm-ast = "0.2.2" -golem-wasm-rpc = { version = "0.0.26", default-features = false, features = [ +golem-wasm-ast = "0.3.0" +golem-wasm-rpc = { version = "0.0.29", default-features = false, features = [ "host", ] } http = "1.0.0" # keep in sync with wasmtime @@ -94,18 +94,18 @@ http_02 = { package = "http", version = "0.2.11" } humantime-serde = "1.1.1" hyper = { version = "1.0.1", features = ["full"] } # keep in sync with wasmtime iso8601-timestamp = "0.2.16" -itertools = "0.12.1" -k8s-openapi = { version = "0.21.1", features = ["earliest"] } -kube = { version = "0.88.1", features = ["runtime", "derive"] } -kube-derive = "0.88.1" +itertools = "0.13.0" +k8s-openapi = { version = "0.22.0", features = ["earliest"] } +kube = { version = "0.92.0", features = ["runtime", "derive"] } +kube-derive = "0.92.0" lazy_static = "1.4.0" nom = "7.1.3" once_cell = "1.19.0" openapiv3 = "2.0.0" -opentelemetry = "0.21.0" -opentelemetry-prometheus = "0.14.1" -opentelemetry_sdk = "0.21.2" -poem-openapi = { version = "4.0.0", features = [ +opentelemetry = "0.23.0" +opentelemetry-prometheus = "0.16.0" +opentelemetry_sdk = "0.23.0" +poem-openapi = { version = "5.0.2", features = [ "swagger-ui", "chrono", "time", @@ -114,7 +114,7 @@ poem-openapi = { version = "4.0.0", features = [ "url", "websocket", ] } -poem = { version = "2.0.0", features = ["prometheus", "opentelemetry", "test"] } +poem = { version = "3.0.1", features = ["prometheus", "opentelemetry", "test"] } postgres = "0.19.7" prometheus = { version = "0.13.3", features = ["process"] } proptest = "1.4.0" @@ -122,13 +122,13 @@ prost = "0.12.3" prost-types = "0.12.3" redis = { version = "0.25.2", features = ["default"] } regex = "1.10.3" -reqwest = { version = "0.11.27", features = [ +reqwest = { version = "0.12.5", features = [ "gzip", "json", "multipart", "stream", ] } -rustls = { version = "0.22.2" } +rustls = { version = "0.23.10" } rand = "0.8.5" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } @@ -150,14 +150,14 @@ tokio = { version = "1.0", features = [ "process", ] } tokio-postgres = "0.7.10" -tokio-rustls = { version = "0.25.0" } +tokio-rustls = { version = "0.26.0" } tokio-stream = { version = "0.1", features = ["sync"] } tokio-util = "0.7.10" -tonic = "0.10.2" -tonic-reflection = "0.10.2" -tonic-health = "0.10.2" +tonic = "0.11.0" +tonic-reflection = "0.11.0" +tonic-health = "0.11.0" tracing = { version = "0.1.40", features = ["log"] } -tracing-opentelemetry = "0.22.0" +tracing-opentelemetry = "0.24.0" tracing-subscriber = { version = "0.3.18", features = [ "env-filter", "fmt", @@ -167,15 +167,13 @@ tracing-subscriber = { version = "0.3.18", features = [ url = "2.5.0" uuid = { version = "1.7.0", features = ["serde", "v4"] } warp = "0.3.6" -wasm-wave = "=0.4.0" -wasmtime = { version = "=17.0.0", features = ["component-model"] } -wasmtime-runtime = { version = "=17.0.0" } -wasmtime-wasi = { version = "=17.0.0" } -wasmtime-wasi-http = { version = "=17.0.0" } +wasm-wave = "=0.6.0" +wasmtime = { version = "=21.0.1", features = ["component-model"] } +wasmtime-wasi = { version = "=21.0.1" } +wasmtime-wasi-http = { version = "=21.0.1" } webpki-roots = { version = "0.26.0" } [patch.crates-io] -wasmtime = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-17" } -wasmtime-runtime = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-17" } -wasmtime-wasi = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-17" } -wasmtime-wasi-http = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-17" } +wasmtime = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-v21.0.1" } +wasmtime-wasi = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-v21.0.1" } +wasmtime-wasi-http = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-v21.0.1" } diff --git a/demo/shopping-cart/.vscode/settings.json b/demo/shopping-cart/.vscode/settings.json deleted file mode 100644 index 7530c05d7b..0000000000 --- a/demo/shopping-cart/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.server.extraEnv": { "CARGO": "cargo-component" } -} \ No newline at end of file diff --git a/demo/shopping-cart/Cargo.toml b/demo/shopping-cart/Cargo.toml deleted file mode 100644 index 8f738fb962..0000000000 --- a/demo/shopping-cart/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "shopping-cart" -version = "0.0.1" -edition = "2021" - -[lib] -path = "src/lib.rs" -crate-type = ["cdylib"] - -[profile.release] -lto = true -opt-level = 's' - -[dependencies] -once_cell = "1.17.1" -rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } - -[package.metadata.component.target] -path = "wit" - -[package.metadata.component.target.dependencies] \ No newline at end of file diff --git a/demo/shopping-cart/src/lib.rs b/demo/shopping-cart/src/lib.rs deleted file mode 100644 index f3418f9fbd..0000000000 --- a/demo/shopping-cart/src/lib.rs +++ /dev/null @@ -1,160 +0,0 @@ -mod bindings; - -use crate::bindings::exports::demo::shopping-cart::api::*; - -use rand::prelude::*; - -struct Component; - -/** - * This is one of any number of data types that our application - * uses. Golem will take care to persist all application state, - * whether that state is local to a function being executed or - * global across the entire program. - */ -struct State { - user_id: String, - items: Vec, -} - -fn reserve_inventory() -> Result<(), &'static str> { - // generate a random float 32: - let mut rng = rand::thread_rng(); - let random_float: f32 = rng.gen(); - - // Reserve inventory for the items in the cart. - // If the inventory is not available, return an error. - // Otherwise, return a success result. - if random_float < 0.1 { - return Err("Inventory not available"); - } else { - Ok(()) - } -} - -#[allow(unused)] -fn release_inventory() -> Result<(), &'static str> { - // Release inventory for the items in the cart. - // If the inventory is not available, return an error. - // Otherwise, return a success result. - Ok(()) -} - -fn charge_credit_card() -> Result<(), &'static str> { - // Charge the user's credit card for the items in the cart. - // If the charge fails, return an error. - // Otherwise, return a success result. - Ok(()) -} - -fn generate_order() -> String { - // Save the order to the database. - // Return the order ID. - "238738674".to_string() -} - -fn dispatch_order() -> Result<(), &'static str> { - // Dispatch the order to the warehouse. - // If the order cannot be dispatched, return an error. - // Otherwise, return a success result. - Ok(()) -} - -/** - * This holds the state of our application, which is always bound to - * a given user. It is a global variable, which Rust doesn't like, so - * we use `with_state` to access or update the global variable, so we - * can avoid `unsafe` noise. - */ -static mut STATE: State = State { - user_id: String::new(), - items: vec![], -}; - -fn with_state(f: impl FnOnce(&mut State) -> T) -> T { - let result = unsafe { f(&mut STATE) }; - - return result; -} - -// Here, we declare a Rust implementation of the `ShoppingCart` trait. -impl Guest for Component { - fn initialize_cart(user_id: String) -> () { - with_state(|state| { - println!("Initializing cart for user {}", user_id); - - state.user_id = user_id; - }); - } - - fn add_item(item: ProductItem) -> () { - with_state(|state| { - println!( - "Adding item {:?} to the cart of user {}", - item, state.user_id - ); - - state.items.push(item); - }); - } - - fn remove_item(product_id: String) -> () { - with_state(|state| { - println!( - "Removing item with product ID {} from the cart of user {}", - product_id, state.user_id - ); - - state.items.retain(|item| item.product_id != product_id); - }); - } - - fn update_item_quantity(product_id: String, quantity: u32) -> () { - with_state(|state| { - println!( - "Updating quantity of item with product ID {} to {} in the cart of user {}", - product_id, quantity, state.user_id - ); - - for item in &mut state.items { - if item.product_id == product_id { - item.quantity = quantity; - } - } - }); - } - - fn checkout() -> CheckoutResult { - let result: Result = with_state(|state| { - reserve_inventory()?; - - charge_credit_card()?; - - let order_id = generate_order(); - - dispatch_order()?; - - state.items.clear(); - - println!("Checkout for order {}", order_id); - Ok(OrderConfirmation { order_id }) - }); - - match result { - Ok(OrderConfirmation { order_id }) => { - CheckoutResult::Success(OrderConfirmation { - order_id, - }) - } - Err(err) => CheckoutResult::Error(err.to_string()), - } - } - - fn get_cart_contents() -> Vec { - with_state(|state| { - println!("Getting cart contents for user {}", state.user_id); - - state.items.clone() - }) - } -} diff --git a/demo/shopping-cart/wit/shopping-cart.wit b/demo/shopping-cart/wit/shopping-cart.wit deleted file mode 100644 index 91ea66c858..0000000000 --- a/demo/shopping-cart/wit/shopping-cart.wit +++ /dev/null @@ -1,42 +0,0 @@ -package demo:shopping-cart; - -interface api { - record product-item { - product-id: string, - name: string, - price: float32, - quantity: u32, - } - - record order { - order-id: string, - items: list, - total: float32, - timestamp: u64, - } - - record order-confirmation { - order-id: string, - } - - variant checkout-result { - error(string), - success(order-confirmation), - } - - initialize-cart: func(user-id: string) -> (); - - add-item: func(item: product-item) -> (); - - remove-item: func(product-id: string) -> (); - - update-item-quantity: func(product-id: string, quantity: u32) -> (); - - checkout: func() -> checkout-result; - - get-cart-contents: func() -> list; -} - -world shopping-cart { - export api; -} \ No newline at end of file diff --git a/golem-cli/Cargo.toml b/golem-cli/Cargo.toml index 3ca1503cf1..c5b337ece6 100644 --- a/golem-cli/Cargo.toml +++ b/golem-cli/Cargo.toml @@ -33,7 +33,7 @@ futures-util = { workspace = true } golem-examples = "0.2.1" golem-wasm-ast = { workspace = true } golem-wasm-rpc = { workspace = true } -golem-wasm-rpc-stubgen = { version = "0.0.26", optional = true } +golem-wasm-rpc-stubgen = { version = "0.0.29", optional = true } h2 = "0.3.24" http = { workspace = true } hyper = { workspace = true } @@ -48,7 +48,7 @@ serde_json = { workspace = true } serde_yaml = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } -testcontainers-modules = { version = "0.3.2", features = ["postgres", "redis"] } +testcontainers-modules = { workspace = true } tokio = { workspace = true } tokio-tungstenite = { version = "0.20.1", features = ["native-tls"] } tower = "0.4.13" diff --git a/golem-cli/src/service/component.rs b/golem-cli/src/service/component.rs index c16352e9a4..498497f051 100644 --- a/golem-cli/src/service/component.rs +++ b/golem-cli/src/service/component.rs @@ -144,7 +144,7 @@ impl ComponentService .await?; let components: Vec = components .into_iter() - .group_by(|c| c.versioned_component_id.component_id) + .chunk_by(|c| c.versioned_component_id.component_id) .into_iter() .map(|(_, group)| { group diff --git a/golem-cli/tests/text.rs b/golem-cli/tests/text.rs index d09a3520ae..ad9166ef14 100644 --- a/golem-cli/tests/text.rs +++ b/golem-cli/tests/text.rs @@ -205,7 +205,7 @@ fn text_component_update( assert_eq!( *lines.first().unwrap(), format!( - "Updated component with ID {}. New version: 1. Component size is 72309 bytes.", + "Updated component with ID {}. New version: 1. Component size is 72129 bytes.", component.component_id ) ); @@ -256,7 +256,7 @@ fn text_component_get( assert_eq!( *lines.first().unwrap(), format!( - "Component with ID {}. Version: 0. Component size is 72309 bytes.", + "Component with ID {}. Version: 0. Component size is 72129 bytes.", component.component_id ) ); @@ -307,7 +307,7 @@ fn text_component_list( +--------------------------------------+-------------------------------+---------+-------+---------------+ | ID | Name | Version | Size | Exports count | +--------------------------------------+-------------------------------+---------+-------+---------------+ - | {} | {} | 0 | 72309 | 2 | + | {} | {} | 0 | 72129 | 2 | +--------------------------------------+-------------------------------+---------+-------+---------------+ ", component.component_id, diff --git a/golem-component-service/src/server.rs b/golem-component-service/src/server.rs index 7eb917a86f..405efed8a8 100644 --- a/golem-component-service/src/server.rs +++ b/golem-component-service/src/server.rs @@ -17,7 +17,6 @@ use golem_component_service::config::{ComponentServiceConfig, DbConfig}; use golem_component_service::service::Services; use golem_component_service::{api, db, grpcapi, metrics}; use opentelemetry::global; -use opentelemetry_sdk::metrics::MeterProvider; use poem::listener::TcpListener; use poem::middleware::{OpenTelemetryMetrics, Tracing}; use poem::EndpointExt; @@ -60,7 +59,11 @@ fn main() -> Result<(), std::io::Error> { .build() .unwrap(); - global::set_meter_provider(MeterProvider::builder().with_reader(exporter).build()); + global::set_meter_provider( + opentelemetry_sdk::metrics::MeterProviderBuilder::default() + .with_reader(exporter) + .build(), + ); tokio::runtime::Builder::new_multi_thread() .enable_all() diff --git a/golem-service-base/src/service/component_object_store.rs b/golem-service-base/src/service/component_object_store.rs index d6979f703c..48018ed58b 100644 --- a/golem-service-base/src/service/component_object_store.rs +++ b/golem-service-base/src/service/component_object_store.rs @@ -63,7 +63,7 @@ impl AwsS3ComponentObjectStore { "S3 Component Object Store bucket: {}, prefix: {}", config.bucket_name, config.object_prefix ); - let sdk_config = aws_config::load_defaults(BehaviorVersion::v2023_11_09()).await; + let sdk_config = aws_config::load_defaults(BehaviorVersion::v2024_03_28()).await; let client = aws_sdk_s3::Client::new(&sdk_config); Self { client, diff --git a/golem-test-framework/src/components/component_compilation_service/docker.rs b/golem-test-framework/src/components/component_compilation_service/docker.rs index 714a496622..f26644937e 100644 --- a/golem-test-framework/src/components/component_compilation_service/docker.rs +++ b/golem-test-framework/src/components/component_compilation_service/docker.rs @@ -26,6 +26,8 @@ use tracing::{info, Level}; pub struct DockerComponentCompilationService { container: Container<'static, GolemComponentCompilationServiceImage>, + public_http_port: u16, + public_grpc_port: u16, } impl DockerComponentCompilationService { @@ -33,7 +35,7 @@ impl DockerComponentCompilationService { pub const HTTP_PORT: u16 = 8083; pub const GRPC_PORT: u16 = 9094; - pub fn new( + pub async fn new( component_service: Arc, verbosity: Level, ) -> Self { @@ -55,7 +57,14 @@ impl DockerComponentCompilationService { .with_network(NETWORK); let container = DOCKER.run(image); - Self { container } + let public_http_port = container.get_host_port_ipv4(Self::HTTP_PORT); + let public_grpc_port = container.get_host_port_ipv4(Self::GRPC_PORT); + + Self { + container, + public_http_port, + public_grpc_port, + } } } @@ -78,15 +87,15 @@ impl ComponentCompilationService for DockerComponentCompilationService { } fn public_http_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::HTTP_PORT) + self.public_http_port } fn public_grpc_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::GRPC_PORT) + self.public_grpc_port } fn kill(&self) { - self.container.stop() + self.container.stop(); } } @@ -98,9 +107,8 @@ impl Drop for DockerComponentCompilationService { #[derive(Debug)] struct GolemComponentCompilationServiceImage { - grpc_port: u16, - http_port: u16, env_vars: HashMap, + expose_ports: [u16; 2], } impl GolemComponentCompilationServiceImage { @@ -110,9 +118,8 @@ impl GolemComponentCompilationServiceImage { env_vars: HashMap, ) -> GolemComponentCompilationServiceImage { GolemComponentCompilationServiceImage { - grpc_port, - http_port, env_vars, + expose_ports: [grpc_port, http_port], } } } @@ -137,6 +144,6 @@ impl Image for GolemComponentCompilationServiceImage { } fn expose_ports(&self) -> Vec { - vec![self.grpc_port, self.http_port] + self.expose_ports.to_vec() } } diff --git a/golem-test-framework/src/components/component_service/docker.rs b/golem-test-framework/src/components/component_service/docker.rs index e20ecb892d..95c36f7d0b 100644 --- a/golem-test-framework/src/components/component_service/docker.rs +++ b/golem-test-framework/src/components/component_service/docker.rs @@ -26,6 +26,8 @@ use tracing::{info, Level}; pub struct DockerComponentService { container: Container<'static, GolemComponentServiceImage>, + public_http_port: u16, + public_grpc_port: u16, } impl DockerComponentService { @@ -33,7 +35,7 @@ impl DockerComponentService { const HTTP_PORT: u16 = 8081; const GRPC_PORT: u16 = 9091; - pub fn new( + pub async fn new( component_compilation_service: Option<(&str, u16)>, rdb: Arc, verbosity: Level, @@ -55,9 +57,17 @@ impl DockerComponentService { )) .with_container_name(Self::NAME) .with_network(NETWORK); + let container = DOCKER.run(image); - Self { container } + let public_http_port = container.get_host_port_ipv4(Self::HTTP_PORT); + let public_grpc_port = container.get_host_port_ipv4(Self::GRPC_PORT); + + Self { + container, + public_http_port, + public_grpc_port, + } } } @@ -80,15 +90,15 @@ impl ComponentService for DockerComponentService { } fn public_http_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::HTTP_PORT) + self.public_http_port } fn public_grpc_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::GRPC_PORT) + self.public_grpc_port } fn kill(&self) { - self.container.stop() + self.container.stop(); } } @@ -100,9 +110,8 @@ impl Drop for DockerComponentService { #[derive(Debug)] struct GolemComponentServiceImage { - grpc_port: u16, - http_port: u16, env_vars: HashMap, + expose_ports: [u16; 2], } impl GolemComponentServiceImage { @@ -112,9 +121,8 @@ impl GolemComponentServiceImage { env_vars: HashMap, ) -> GolemComponentServiceImage { GolemComponentServiceImage { - grpc_port, - http_port, env_vars, + expose_ports: [grpc_port, http_port], } } } @@ -139,6 +147,6 @@ impl Image for GolemComponentServiceImage { } fn expose_ports(&self) -> Vec { - vec![self.grpc_port, self.http_port] + self.expose_ports.to_vec() } } diff --git a/golem-test-framework/src/components/redis/docker.rs b/golem-test-framework/src/components/redis/docker.rs index 1a22e494b9..61f2fb79dd 100644 --- a/golem-test-framework/src/components/redis/docker.rs +++ b/golem-test-framework/src/components/redis/docker.rs @@ -24,12 +24,13 @@ pub struct DockerRedis { container: Container<'static, testcontainers_modules::redis::Redis>, prefix: String, valid: AtomicBool, + public_port: u16, } impl DockerRedis { const NAME: &'static str = "golem_redis"; - pub fn new(prefix: String) -> Self { + pub async fn new(prefix: String) -> Self { info!("Starting Redis container"); let image = RunnableImage::from(testcontainers_modules::redis::Redis) @@ -38,16 +39,15 @@ impl DockerRedis { .with_network(NETWORK); let container = DOCKER.run(image); - super::wait_for_startup( - "localhost", - container.get_host_port_ipv4(REDIS_PORT), - Duration::from_secs(10), - ); + let public_port = container.get_host_port_ipv4(REDIS_PORT); + + super::wait_for_startup("localhost", public_port, Duration::from_secs(10)); Self { container, prefix, valid: AtomicBool::new(true), + public_port, } } } @@ -72,7 +72,7 @@ impl Redis for DockerRedis { } fn public_port(&self) -> u16 { - self.container.get_host_port_ipv4(REDIS_PORT) + self.public_port } fn prefix(&self) -> &str { @@ -81,8 +81,7 @@ impl Redis for DockerRedis { fn kill(&self) { info!("Stopping Redis container"); - self.valid.store(false, Ordering::Release); - self.container.stop(); + self.container.stop() } } diff --git a/golem-test-framework/src/components/shard_manager/docker.rs b/golem-test-framework/src/components/shard_manager/docker.rs index a54eea56d0..875dab8c27 100644 --- a/golem-test-framework/src/components/shard_manager/docker.rs +++ b/golem-test-framework/src/components/shard_manager/docker.rs @@ -26,6 +26,8 @@ use tracing::{info, Level}; pub struct DockerShardManager { container: Container<'static, ShardManagerImage>, + public_http_port: u16, + public_grpc_port: u16, } impl DockerShardManager { @@ -33,7 +35,7 @@ impl DockerShardManager { const HTTP_PORT: u16 = 9021; const GRPC_PORT: u16 = 9020; - pub fn new(redis: Arc, verbosity: Level) -> Self { + pub async fn new(redis: Arc, verbosity: Level) -> Self { info!("Starting golem-shard-manager container"); let env_vars = env_vars(Self::HTTP_PORT, Self::GRPC_PORT, redis, verbosity); @@ -47,7 +49,14 @@ impl DockerShardManager { .with_network(NETWORK); let container = DOCKER.run(image); - Self { container } + let public_http_port = container.get_host_port_ipv4(Self::HTTP_PORT); + let public_grpc_port = container.get_host_port_ipv4(Self::GRPC_PORT); + + Self { + container, + public_http_port, + public_grpc_port, + } } } @@ -70,15 +79,15 @@ impl ShardManager for DockerShardManager { } fn public_http_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::HTTP_PORT) + self.public_http_port } fn public_grpc_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::GRPC_PORT) + self.public_grpc_port } fn kill(&self) { - self.container.stop() + self.container.stop(); } async fn restart(&self) { @@ -94,17 +103,19 @@ impl Drop for DockerShardManager { #[derive(Debug)] struct ShardManagerImage { - grpc_port: u16, - http_port: u16, env_vars: HashMap, + expose_ports: [u16; 2], } impl ShardManagerImage { - pub fn new(port: u16, http_port: u16, env_vars: HashMap) -> ShardManagerImage { + pub fn new( + grpc_port: u16, + http_port: u16, + env_vars: HashMap, + ) -> ShardManagerImage { ShardManagerImage { - grpc_port: port, - http_port, env_vars, + expose_ports: [grpc_port, http_port], } } } @@ -131,6 +142,6 @@ impl Image for ShardManagerImage { } fn expose_ports(&self) -> Vec { - vec![self.grpc_port, self.http_port] + self.expose_ports.to_vec() } } diff --git a/golem-test-framework/src/components/worker_executor/docker.rs b/golem-test-framework/src/components/worker_executor/docker.rs index bb3f50e3c8..5bd065f222 100644 --- a/golem-test-framework/src/components/worker_executor/docker.rs +++ b/golem-test-framework/src/components/worker_executor/docker.rs @@ -31,11 +31,13 @@ pub struct DockerWorkerExecutor { name: String, http_port: u16, grpc_port: u16, + public_http_port: u16, + public_grpc_port: u16, container: Container<'static, WorkerExecutorImage>, } impl DockerWorkerExecutor { - pub fn new( + pub async fn new( http_port: u16, grpc_port: u16, redis: Arc, @@ -63,10 +65,15 @@ impl DockerWorkerExecutor { .with_network(NETWORK); let container = DOCKER.run(image); + let public_http_port = container.get_host_port_ipv4(http_port); + let public_grpc_port = container.get_host_port_ipv4(grpc_port); + Self { name, http_port, grpc_port, + public_http_port, + public_grpc_port, container, } } @@ -91,15 +98,15 @@ impl WorkerExecutor for DockerWorkerExecutor { } fn public_http_port(&self) -> u16 { - self.container.get_host_port_ipv4(self.http_port) + self.public_http_port } fn public_grpc_port(&self) -> u16 { - self.container.get_host_port_ipv4(self.grpc_port) + self.public_grpc_port } fn kill(&self) { - self.container.stop() + self.container.stop(); } async fn restart(&self) { @@ -115,9 +122,8 @@ impl Drop for DockerWorkerExecutor { #[derive(Debug)] struct WorkerExecutorImage { - grpc_port: u16, - http_port: u16, env_vars: HashMap, + expose_ports: [u16; 2], } impl WorkerExecutorImage { @@ -127,9 +133,8 @@ impl WorkerExecutorImage { env_vars: HashMap, ) -> WorkerExecutorImage { WorkerExecutorImage { - grpc_port, - http_port, env_vars, + expose_ports: [grpc_port, http_port], } } } @@ -154,6 +159,6 @@ impl Image for WorkerExecutorImage { } fn expose_ports(&self) -> Vec { - vec![self.grpc_port, self.http_port] + self.expose_ports.to_vec() } } diff --git a/golem-test-framework/src/components/worker_executor_cluster/docker.rs b/golem-test-framework/src/components/worker_executor_cluster/docker.rs index 31307383d1..3ecad04679 100644 --- a/golem-test-framework/src/components/worker_executor_cluster/docker.rs +++ b/golem-test-framework/src/components/worker_executor_cluster/docker.rs @@ -39,15 +39,18 @@ impl DockerWorkerExecutorCluster { worker_service: Arc, verbosity: Level, ) -> Arc { - Arc::new(DockerWorkerExecutor::new( - http_port, - grpc_port, - redis, - component_service, - shard_manager, - worker_service, - verbosity, - )) + Arc::new( + DockerWorkerExecutor::new( + http_port, + grpc_port, + redis, + component_service, + shard_manager, + worker_service, + verbosity, + ) + .await, + ) } pub async fn new( diff --git a/golem-test-framework/src/components/worker_service/docker.rs b/golem-test-framework/src/components/worker_service/docker.rs index c2b46ed555..6986e852b3 100644 --- a/golem-test-framework/src/components/worker_service/docker.rs +++ b/golem-test-framework/src/components/worker_service/docker.rs @@ -27,6 +27,9 @@ use tracing::{info, Level}; pub struct DockerWorkerService { container: Container<'static, GolemWorkerServiceImage>, + public_http_port: u16, + public_grpc_port: u16, + public_custom_request_port: u16, } impl DockerWorkerService { @@ -35,7 +38,7 @@ impl DockerWorkerService { const GRPC_PORT: u16 = 9092; const CUSTOM_REQUEST_PORT: u16 = 9093; - pub fn new( + pub async fn new( component_service: Arc, shard_manager: Arc, rdb: Arc, @@ -65,7 +68,16 @@ impl DockerWorkerService { .with_network(NETWORK); let container = DOCKER.run(image); - Self { container } + let public_http_port = container.get_host_port_ipv4(Self::HTTP_PORT); + let public_grpc_port = container.get_host_port_ipv4(Self::GRPC_PORT); + let public_custom_request_port = container.get_host_port_ipv4(Self::CUSTOM_REQUEST_PORT); + + Self { + container, + public_http_port, + public_grpc_port, + public_custom_request_port, + } } } @@ -92,19 +104,19 @@ impl WorkerService for DockerWorkerService { } fn public_http_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::HTTP_PORT) + self.public_http_port } fn public_grpc_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::GRPC_PORT) + self.public_grpc_port } fn public_custom_request_port(&self) -> u16 { - self.container.get_host_port_ipv4(Self::CUSTOM_REQUEST_PORT) + self.public_custom_request_port } fn kill(&self) { - self.container.stop() + self.container.stop(); } } @@ -116,10 +128,8 @@ impl Drop for DockerWorkerService { #[derive(Debug)] struct GolemWorkerServiceImage { - grpc_port: u16, - http_port: u16, - custom_request_port: u16, env_vars: HashMap, + expose_ports: [u16; 3], } impl GolemWorkerServiceImage { @@ -130,10 +140,8 @@ impl GolemWorkerServiceImage { env_vars: HashMap, ) -> GolemWorkerServiceImage { GolemWorkerServiceImage { - grpc_port, - http_port, - custom_request_port, env_vars, + expose_ports: [grpc_port, http_port, custom_request_port], } } } @@ -158,6 +166,6 @@ impl Image for GolemWorkerServiceImage { } fn expose_ports(&self) -> Vec { - vec![self.grpc_port, self.http_port, self.custom_request_port] + self.expose_ports.to_vec() } } diff --git a/golem-test-framework/src/config/cli.rs b/golem-test-framework/src/config/cli.rs index ee48c1b7a2..be99b36660 100644 --- a/golem-test-framework/src/config/cli.rs +++ b/golem-test-framework/src/config/cli.rs @@ -343,45 +343,51 @@ impl CliTestDependencies { None }; - let component_service: Arc = - Arc::new(DockerComponentService::new( + let component_service: Arc = Arc::new( + DockerComponentService::new( component_compilation_service, rdb.clone(), params_clone.service_verbosity(), - )); + ) + .await, + ); let component_compilation_service: Arc< dyn ComponentCompilationService + Send + Sync + 'static, - > = Arc::new(DockerComponentCompilationService::new( - component_service.clone(), - params_clone.service_verbosity(), - )); + > = Arc::new( + DockerComponentCompilationService::new( + component_service.clone(), + params_clone.service_verbosity(), + ) + .await, + ); (rdb, component_service, component_compilation_service) }); let redis: Arc = - Arc::new(DockerRedis::new(redis_prefix.to_string())); + Arc::new(DockerRedis::new(redis_prefix.to_string()).await); let redis_monitor: Arc = Arc::new( SpawnedRedisMonitor::new(redis.clone(), Level::DEBUG, Level::ERROR), ); - let shard_manager: Arc = Arc::new( - DockerShardManager::new(redis.clone(), params.service_verbosity()), - ); + let shard_manager: Arc = + Arc::new(DockerShardManager::new(redis.clone(), params.service_verbosity()).await); let (rdb, component_service, component_compilation_service) = rdb_and_component_service_join .await .expect("Failed to join"); - let worker_service: Arc = - Arc::new(DockerWorkerService::new( + let worker_service: Arc = Arc::new( + DockerWorkerService::new( component_service.clone(), shard_manager.clone(), rdb.clone(), redis.clone(), params.service_verbosity(), - )); + ) + .await, + ); let worker_executor_cluster: Arc = Arc::new( DockerWorkerExecutorCluster::new( diff --git a/golem-test-framework/src/config/env.rs b/golem-test-framework/src/config/env.rs index d9a339c00e..46bf517448 100644 --- a/golem-test-framework/src/config/env.rs +++ b/golem-test-framework/src/config/env.rs @@ -77,7 +77,7 @@ impl EnvBasedTestDependencies { async fn make_redis() -> Arc { let prefix = Self::redis_prefix().unwrap_or("".to_string()); if Self::use_docker() { - Arc::new(DockerRedis::new(prefix)) + Arc::new(DockerRedis::new(prefix).await) } else { let host = Self::redis_host().unwrap_or("localhost".to_string()); let port = Self::redis_port().unwrap_or(6379); @@ -109,7 +109,7 @@ impl EnvBasedTestDependencies { redis: Arc, ) -> Arc { if Self::use_docker() { - Arc::new(DockerShardManager::new(redis, Self::default_verbosity())) + Arc::new(DockerShardManager::new(redis, Self::default_verbosity()).await) } else { Arc::new( SpawnedShardManager::new( @@ -131,14 +131,17 @@ impl EnvBasedTestDependencies { rdb: Arc, ) -> Arc { if Self::use_docker() { - Arc::new(DockerComponentService::new( - Some(( - DockerComponentCompilationService::NAME, - DockerComponentCompilationService::GRPC_PORT, - )), - rdb, - Self::default_verbosity(), - )) + Arc::new( + DockerComponentService::new( + Some(( + DockerComponentCompilationService::NAME, + DockerComponentCompilationService::GRPC_PORT, + )), + rdb, + Self::default_verbosity(), + ) + .await, + ) } else { Arc::new( SpawnedComponentService::new( @@ -161,10 +164,13 @@ impl EnvBasedTestDependencies { component_service: Arc, ) -> Arc { if Self::use_docker() { - Arc::new(DockerComponentCompilationService::new( - component_service, - Self::default_verbosity(), - )) + Arc::new( + DockerComponentCompilationService::new( + component_service, + Self::default_verbosity(), + ) + .await, + ) } else { Arc::new( SpawnedComponentCompilationService::new( @@ -189,13 +195,16 @@ impl EnvBasedTestDependencies { redis: Arc, ) -> Arc { if Self::use_docker() { - Arc::new(DockerWorkerService::new( - component_service, - shard_manager, - rdb, - redis, - Self::default_verbosity(), - )) + Arc::new( + DockerWorkerService::new( + component_service, + shard_manager, + rdb, + redis, + Self::default_verbosity(), + ) + .await, + ) } else { Arc::new( SpawnedWorkerService::new( diff --git a/golem-test-framework/src/dsl/benchmark.rs b/golem-test-framework/src/dsl/benchmark.rs index 0b4a5c5342..3217806904 100644 --- a/golem-test-framework/src/dsl/benchmark.rs +++ b/golem-test-framework/src/dsl/benchmark.rs @@ -640,7 +640,7 @@ impl BenchmarkApi for B { let groups = runs .iter() - .group_by(|r| r.cluster_size) + .chunk_by(|r| r.cluster_size) .into_iter() .map(|(cluster_size, group)| (cluster_size, group.collect::>())) .collect::>(); diff --git a/golem-worker-executor-base/Cargo.toml b/golem-worker-executor-base/Cargo.toml index 43342273cf..49dbbf46d3 100644 --- a/golem-worker-executor-base/Cargo.toml +++ b/golem-worker-executor-base/Cargo.toml @@ -32,9 +32,9 @@ aws-sdk-s3 = { workspace = true } bincode = { workspace = true } bitflags = "2.4.2" bytes = { workspace = true } -cap-fs-ext = "2.0.0" # keep in sync with wasmtime +cap-fs-ext = "3.0.0" # keep in sync with wasmtime cap-std = { workspace = true } -cap-time-ext = "2.0.0" # keep in sync with wasmtime +cap-time-ext = "3.0.0" # keep in sync with wasmtime chrono = { workspace = true } dashmap = { workspace = true } evicting_cache_map = "0.4.0" @@ -77,7 +77,6 @@ url = { workspace = true } uuid = { workspace = true } warp = { workspace = true } wasmtime = { workspace = true } -wasmtime-runtime = { workspace = true } wasmtime-wasi = { workspace = true } wasmtime-wasi-http = { workspace = true } windows-sys = "0.52.0" diff --git a/golem-worker-executor-base/build.rs b/golem-worker-executor-base/build.rs index 357aec613c..cf6a8c8d29 100644 --- a/golem-worker-executor-base/build.rs +++ b/golem-worker-executor-base/build.rs @@ -43,6 +43,7 @@ fn preview2_mod_gen(golem_wit_path: &str) -> String { ", tracing: false, async: true, + trappable_imports: true, with: {{ "wasi:io/streams/input-stream": InputStream, "wasi:io/streams/output-stream": OutputStream, @@ -56,7 +57,8 @@ fn preview2_mod_gen(golem_wit_path: &str) -> String { "wasi:keyvalue/types/incoming-value": super::durable_host::keyvalue::types::IncomingValueEntry, "wasi:keyvalue/types/outgoing-value": super::durable_host::keyvalue::types::OutgoingValueEntry, "golem:api/host/get-workers": super::durable_host::golem::GetWorkersEntry, - }} + }}, + skip_mut_forwarding_impls: true, }}); "# ) diff --git a/golem-worker-executor-base/src/durable_host/blobstore/container.rs b/golem-worker-executor-base/src/durable_host/blobstore/container.rs index 3ba0ecaa3b..6a342b98a3 100644 --- a/golem-worker-executor-base/src/durable_host/blobstore/container.rs +++ b/golem-worker-executor-base/src/durable_host/blobstore/container.rs @@ -15,7 +15,7 @@ use async_trait::async_trait; use golem_common::model::oplog::WrappedFunctionType; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::durable_host::blobstore::types::{ ContainerEntry, IncomingValueEntry, OutgoingValueEntry, StreamObjectNamesEntry, @@ -94,7 +94,7 @@ impl HostContainer for DurableWorkerCtx { Ok(get_data) => { let incoming_value = self .as_wasi_view() - .table_mut() + .table() .push(IncomingValueEntry::new(get_data))?; Ok(Ok(incoming_value)) } @@ -168,7 +168,7 @@ impl HostContainer for DurableWorkerCtx { Ok(list_objects) => { let stream_object_names = self .as_wasi_view() - .table_mut() + .table() .push(StreamObjectNamesEntry::new(list_objects))?; Ok(Ok(stream_object_names)) } @@ -342,7 +342,7 @@ impl HostContainer for DurableWorkerCtx { fn drop(&mut self, container: Resource) -> anyhow::Result<()> { record_host_function_call("blobstore::container::container", "drop"); self.as_wasi_view() - .table_mut() + .table() .delete::(container)?; Ok(()) } @@ -404,10 +404,119 @@ impl HostStreamObjectNames for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("blobstore::container::stream_object_names", "drop"); - self.as_wasi_view().table_mut().delete(rep)?; + self.as_wasi_view().table().delete(rep)?; Ok(()) } } #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostContainer for &mut DurableWorkerCtx { + async fn name( + &mut self, + container: Resource, + ) -> anyhow::Result> { + (*self).name(container).await + } + + async fn info( + &mut self, + container: Resource, + ) -> anyhow::Result> { + (*self).info(container).await + } + + async fn get_data( + &mut self, + container: Resource, + name: ObjectName, + start: u64, + end: u64, + ) -> anyhow::Result, Error>> { + (*self).get_data(container, name, start, end).await + } + + async fn write_data( + &mut self, + container: Resource, + name: ObjectName, + data: Resource, + ) -> anyhow::Result> { + (*self).write_data(container, name, data).await + } + + async fn list_objects( + &mut self, + container: Resource, + ) -> anyhow::Result, Error>> { + (*self).list_objects(container).await + } + + async fn delete_object( + &mut self, + container: Resource, + name: ObjectName, + ) -> anyhow::Result> { + (*self).delete_object(container, name).await + } + + async fn delete_objects( + &mut self, + container: Resource, + names: Vec, + ) -> anyhow::Result> { + (*self).delete_objects(container, names).await + } + + async fn has_object( + &mut self, + container: Resource, + name: ObjectName, + ) -> anyhow::Result> { + (*self).has_object(container, name).await + } + + async fn object_info( + &mut self, + container: Resource, + name: ObjectName, + ) -> anyhow::Result> { + (*self).object_info(container, name).await + } + + async fn clear(&mut self, container: Resource) -> anyhow::Result> { + (*self).clear(container).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostContainer::drop(*self, rep) + } +} + +#[async_trait] +impl HostStreamObjectNames for &mut DurableWorkerCtx { + async fn read_stream_object_names( + &mut self, + self_: Resource, + len: u64, + ) -> anyhow::Result, bool), Error>> { + (*self).read_stream_object_names(self_, len).await + } + + async fn skip_stream_object_names( + &mut self, + self_: Resource, + num: u64, + ) -> anyhow::Result> { + (*self).skip_stream_object_names(self_, num).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostStreamObjectNames::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/blobstore/mod.rs b/golem-worker-executor-base/src/durable_host/blobstore/mod.rs index 22cba916b3..4070ed1b12 100644 --- a/golem-worker-executor-base/src/durable_host/blobstore/mod.rs +++ b/golem-worker-executor-base/src/durable_host/blobstore/mod.rs @@ -18,7 +18,7 @@ pub mod types; use async_trait::async_trait; use golem_common::model::oplog::WrappedFunctionType; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::durable_host::blobstore::types::ContainerEntry; use crate::durable_host::serialized::SerializableError; @@ -63,7 +63,7 @@ impl Host for DurableWorkerCtx { Ok(created_at) => { let container = self .as_wasi_view() - .table_mut() + .table() .push(ContainerEntry::new(name, created_at))?; Ok(Ok(container)) } @@ -92,7 +92,7 @@ impl Host for DurableWorkerCtx { Ok(Some(created_at)) => { let container = self .as_wasi_view() - .table_mut() + .table() .push(ContainerEntry::new(name, created_at))?; Ok(Ok(container)) } @@ -200,3 +200,47 @@ impl Host for DurableWorkerCtx { } } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn create_container( + &mut self, + name: ContainerName, + ) -> anyhow::Result, Error>> { + (*self).create_container(name).await + } + + async fn get_container( + &mut self, + name: ContainerName, + ) -> anyhow::Result, Error>> { + (*self).get_container(name).await + } + + async fn delete_container(&mut self, name: ContainerName) -> anyhow::Result> { + (*self).delete_container(name).await + } + + async fn container_exists( + &mut self, + name: ContainerName, + ) -> anyhow::Result> { + (*self).container_exists(name).await + } + + async fn copy_object( + &mut self, + src: ObjectId, + dest: ObjectId, + ) -> anyhow::Result> { + (*self).copy_object(src, dest).await + } + + async fn move_object( + &mut self, + src: ObjectId, + dest: ObjectId, + ) -> anyhow::Result> { + (*self).move_object(src, dest).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/blobstore/types.rs b/golem-worker-executor-base/src/durable_host/blobstore/types.rs index 40ad8e505a..33a86f057f 100644 --- a/golem-worker-executor-base/src/durable_host/blobstore/types.rs +++ b/golem-worker-executor-base/src/durable_host/blobstore/types.rs @@ -18,7 +18,7 @@ use std::sync::{Arc, RwLock}; use async_trait::async_trait; use bytes::Bytes; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::{ +use wasmtime_wasi::{ HostInputStream, HostOutputStream, InputStream, StreamResult, Subscribe, WasiView, }; @@ -37,7 +37,7 @@ impl HostOutgoingValue for DurableWorkerCtx { record_host_function_call("blobstore::types::outgoing_value", "new_outgoing_value"); let outgoing_value = self .as_wasi_view() - .table_mut() + .table() .push(OutgoingValueEntry::new())?; Ok(outgoing_value) } @@ -57,14 +57,14 @@ impl HostOutgoingValue for DurableWorkerCtx { .body .clone(); let body: Box = Box::new(OutgoingValueEntryStream::new(body)); - let outgoing_value_async_body = self.as_wasi_view().table_mut().push(body)?; + let outgoing_value_async_body = self.as_wasi_view().table().push(body)?; Ok(Ok(outgoing_value_async_body)) } fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("blobstore::types::outgoing_value", "drop"); self.as_wasi_view() - .table_mut() + .table() .delete::(rep)?; Ok(()) } @@ -105,7 +105,7 @@ impl HostIncomingValue for DurableWorkerCtx { .body .clone(); let body: InputStream = InputStream::Host(Box::new(IncomingValueEntryStream::new(body))); - let incoming_value_async_body = self.as_wasi_view().table_mut().push(body)?; + let incoming_value_async_body = self.as_wasi_view().table().push(body)?; Ok(Ok(incoming_value_async_body)) } @@ -124,7 +124,7 @@ impl HostIncomingValue for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("blobstore::types::incoming_value", "drop"); self.as_wasi_view() - .table_mut() + .table() .delete::(rep)?; Ok(()) } @@ -133,6 +133,52 @@ impl HostIncomingValue for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} +#[async_trait] +impl HostOutgoingValue for &mut DurableWorkerCtx { + async fn new_outgoing_value(&mut self) -> anyhow::Result> { + (*self).new_outgoing_value().await + } + + async fn outgoing_value_write_body( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + (*self).outgoing_value_write_body(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingValue::drop(*self, rep) + } +} + +#[async_trait] +impl HostIncomingValue for &mut DurableWorkerCtx { + async fn incoming_value_consume_sync( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + (*self).incoming_value_consume_sync(self_).await + } + + async fn incoming_value_consume_async( + &mut self, + self_: Resource, + ) -> anyhow::Result, Error>> { + (*self).incoming_value_consume_async(self_).await + } + + async fn size(&mut self, self_: Resource) -> anyhow::Result { + (*self).size(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingValue::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} + pub struct ContainerEntry { pub name: String, pub created_at: u64, @@ -170,6 +216,10 @@ impl OutgoingValueEntryStream { pub fn new(body: Arc>>) -> Self { Self { body } } + + fn as_any(&self) -> &dyn Any { + self + } } #[async_trait] @@ -180,7 +230,7 @@ impl Subscribe for OutgoingValueEntryStream { #[async_trait] impl HostOutputStream for OutgoingValueEntryStream { fn as_any(&self) -> &dyn Any { - self + OutgoingValueEntryStream::as_any(self) } fn write(&mut self, bytes: Bytes) -> StreamResult<()> { diff --git a/golem-worker-executor-base/src/durable_host/cli/environment.rs b/golem-worker-executor-base/src/durable_host/cli/environment.rs index 34912ab642..4cb31a5d64 100644 --- a/golem-worker-executor-base/src/durable_host/cli/environment.rs +++ b/golem-worker-executor-base/src/durable_host/cli/environment.rs @@ -19,7 +19,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::cli::environment::Host; +use wasmtime_wasi::bindings::cli::environment::Host; #[async_trait] impl Host for DurableWorkerCtx { @@ -56,3 +56,18 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl<'a, Ctx: WorkerCtx> Host for &'a mut DurableWorkerCtx { + async fn get_environment(&mut self) -> anyhow::Result> { + (*self).get_environment().await + } + + async fn get_arguments(&mut self) -> anyhow::Result> { + (*self).get_arguments().await + } + + async fn initial_cwd(&mut self) -> anyhow::Result> { + (*self).initial_cwd().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/exit.rs b/golem-worker-executor-base/src/durable_host/cli/exit.rs index b09f5d9e08..262857ed43 100644 --- a/golem-worker-executor-base/src/durable_host/cli/exit.rs +++ b/golem-worker-executor-base/src/durable_host/cli/exit.rs @@ -17,7 +17,7 @@ use async_trait::async_trait; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::exit::Host; +use wasmtime_wasi::bindings::cli::exit::Host; #[async_trait] impl Host for DurableWorkerCtx { @@ -26,3 +26,10 @@ impl Host for DurableWorkerCtx { Host::exit(&mut self.as_wasi_view(), status) } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn exit(&mut self, status: Result<(), ()>) -> anyhow::Result<()> { + (*self).exit(status) + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/stderr.rs b/golem-worker-executor-base/src/durable_host/cli/stderr.rs index e9515a3867..c51aadace5 100644 --- a/golem-worker-executor-base/src/durable_host/cli/stderr.rs +++ b/golem-worker-executor-base/src/durable_host/cli/stderr.rs @@ -17,7 +17,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::stderr::{Host, OutputStream}; +use wasmtime_wasi::bindings::cli::stderr::{Host, OutputStream}; impl Host for DurableWorkerCtx { fn get_stderr(&mut self) -> anyhow::Result> { @@ -25,3 +25,9 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_stderr() } } + +impl Host for &mut DurableWorkerCtx { + fn get_stderr(&mut self) -> anyhow::Result> { + (*self).get_stderr() + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/stdin.rs b/golem-worker-executor-base/src/durable_host/cli/stdin.rs index ff45a38507..675ca189f1 100644 --- a/golem-worker-executor-base/src/durable_host/cli/stdin.rs +++ b/golem-worker-executor-base/src/durable_host/cli/stdin.rs @@ -17,7 +17,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::stdin::{Host, InputStream}; +use wasmtime_wasi::bindings::cli::stdin::{Host, InputStream}; impl Host for DurableWorkerCtx { fn get_stdin(&mut self) -> anyhow::Result> { @@ -25,3 +25,9 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_stdin() } } + +impl Host for &mut DurableWorkerCtx { + fn get_stdin(&mut self) -> anyhow::Result> { + (*self).get_stdin() + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/stdout.rs b/golem-worker-executor-base/src/durable_host/cli/stdout.rs index 7cb6e92ff8..1ccbce67bc 100644 --- a/golem-worker-executor-base/src/durable_host/cli/stdout.rs +++ b/golem-worker-executor-base/src/durable_host/cli/stdout.rs @@ -17,7 +17,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::stdout::{Host, OutputStream}; +use wasmtime_wasi::bindings::cli::stdout::{Host, OutputStream}; impl Host for DurableWorkerCtx { fn get_stdout(&mut self) -> anyhow::Result> { @@ -25,3 +25,9 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_stdout() } } + +impl Host for &mut DurableWorkerCtx { + fn get_stdout(&mut self) -> anyhow::Result> { + (*self).get_stdout() + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/terminal_input.rs b/golem-worker-executor-base/src/durable_host/cli/terminal_input.rs index fbfc3441a7..3afa5ca75a 100644 --- a/golem-worker-executor-base/src/durable_host/cli/terminal_input.rs +++ b/golem-worker-executor-base/src/durable_host/cli/terminal_input.rs @@ -18,9 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::terminal_input::{ - Host, HostTerminalInput, TerminalInput, -}; +use wasmtime_wasi::bindings::cli::terminal_input::{Host, HostTerminalInput, TerminalInput}; #[async_trait] impl HostTerminalInput for DurableWorkerCtx { @@ -32,3 +30,13 @@ impl HostTerminalInput for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostTerminalInput for &mut DurableWorkerCtx { + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/cli/terminal_output.rs b/golem-worker-executor-base/src/durable_host/cli/terminal_output.rs index 3c07fc5bf1..2a2c99858c 100644 --- a/golem-worker-executor-base/src/durable_host/cli/terminal_output.rs +++ b/golem-worker-executor-base/src/durable_host/cli/terminal_output.rs @@ -18,9 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::terminal_output::{ - Host, HostTerminalOutput, TerminalOutput, -}; +use wasmtime_wasi::bindings::cli::terminal_output::{Host, HostTerminalOutput, TerminalOutput}; #[async_trait] impl HostTerminalOutput for DurableWorkerCtx { @@ -32,3 +30,13 @@ impl HostTerminalOutput for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostTerminalOutput for &mut DurableWorkerCtx { + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/cli/terminal_stderr.rs b/golem-worker-executor-base/src/durable_host/cli/terminal_stderr.rs index 933ce8a9d4..2edff6bcde 100644 --- a/golem-worker-executor-base/src/durable_host/cli/terminal_stderr.rs +++ b/golem-worker-executor-base/src/durable_host/cli/terminal_stderr.rs @@ -18,7 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::terminal_stderr::{Host, TerminalOutput}; +use wasmtime_wasi::bindings::cli::terminal_stderr::{Host, TerminalOutput}; #[async_trait] impl Host for DurableWorkerCtx { @@ -27,3 +27,10 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_terminal_stderr() } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn get_terminal_stderr(&mut self) -> anyhow::Result>> { + (*self).get_terminal_stderr() + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/terminal_stdin.rs b/golem-worker-executor-base/src/durable_host/cli/terminal_stdin.rs index 688d15b7ca..752322df76 100644 --- a/golem-worker-executor-base/src/durable_host/cli/terminal_stdin.rs +++ b/golem-worker-executor-base/src/durable_host/cli/terminal_stdin.rs @@ -18,7 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::terminal_stdin::{Host, TerminalInput}; +use wasmtime_wasi::bindings::cli::terminal_stdin::{Host, TerminalInput}; #[async_trait] impl Host for DurableWorkerCtx { @@ -27,3 +27,10 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_terminal_stdin() } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn get_terminal_stdin(&mut self) -> anyhow::Result>> { + (*self).get_terminal_stdin() + } +} diff --git a/golem-worker-executor-base/src/durable_host/cli/terminal_stdout.rs b/golem-worker-executor-base/src/durable_host/cli/terminal_stdout.rs index 9d7b6c8427..d92668cc2b 100644 --- a/golem-worker-executor-base/src/durable_host/cli/terminal_stdout.rs +++ b/golem-worker-executor-base/src/durable_host/cli/terminal_stdout.rs @@ -18,7 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::cli::terminal_stdout::{Host, TerminalOutput}; +use wasmtime_wasi::bindings::cli::terminal_stdout::{Host, TerminalOutput}; #[async_trait] impl Host for DurableWorkerCtx { @@ -27,3 +27,10 @@ impl Host for DurableWorkerCtx { self.as_wasi_view().get_terminal_stdout() } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn get_terminal_stdout(&mut self) -> anyhow::Result>> { + (*self).get_terminal_stdout() + } +} diff --git a/golem-worker-executor-base/src/durable_host/clocks/monotonic_clock.rs b/golem-worker-executor-base/src/durable_host/clocks/monotonic_clock.rs index b8efc0fb67..b59b98c48c 100644 --- a/golem-worker-executor-base/src/durable_host/clocks/monotonic_clock.rs +++ b/golem-worker-executor-base/src/durable_host/clocks/monotonic_clock.rs @@ -20,9 +20,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::clocks::monotonic_clock::{ - Duration, Host, Instant, Pollable, -}; +use wasmtime_wasi::bindings::clocks::monotonic_clock::{Duration, Host, Instant, Pollable}; #[async_trait] impl Host for DurableWorkerCtx { @@ -61,3 +59,22 @@ impl Host for DurableWorkerCtx { Host::subscribe_instant(&mut self.as_wasi_view(), when).await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn now(&mut self) -> anyhow::Result { + (*self).now().await + } + + async fn resolution(&mut self) -> anyhow::Result { + (*self).resolution().await + } + + async fn subscribe_instant(&mut self, when: Instant) -> anyhow::Result> { + (*self).subscribe_instant(when).await + } + + async fn subscribe_duration(&mut self, when: Duration) -> anyhow::Result> { + (*self).subscribe_duration(when).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/clocks/wall_clock.rs b/golem-worker-executor-base/src/durable_host/clocks/wall_clock.rs index 44b99e88f7..d6d2ab1425 100644 --- a/golem-worker-executor-base/src/durable_host/clocks/wall_clock.rs +++ b/golem-worker-executor-base/src/durable_host/clocks/wall_clock.rs @@ -19,7 +19,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::clocks::wall_clock::{Datetime, Host}; +use wasmtime_wasi::bindings::clocks::wall_clock::{Datetime, Host}; #[async_trait] impl Host for DurableWorkerCtx { @@ -45,3 +45,14 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn now(&mut self) -> anyhow::Result { + (*self).now().await + } + + async fn resolution(&mut self) -> anyhow::Result { + (*self).resolution().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/durability.rs b/golem-worker-executor-base/src/durable_host/durability.rs index f4f46e2e71..55d544a4f8 100644 --- a/golem-worker-executor-base/src/durable_host/durability.rs +++ b/golem-worker-executor-base/src/durable_host/durability.rs @@ -151,7 +151,7 @@ impl } else { let (_, oplog_entry) = crate::get_oplog_entry!(self.state, OplogEntry::ImportedFunctionInvoked)?; - Self::validate_oplog_entry(&oplog_entry, function_name)?; + DurableWorkerCtx::::validate_oplog_entry(&oplog_entry, function_name)?; let response = self .state .oplog @@ -217,7 +217,7 @@ impl } else { let (_, oplog_entry) = crate::get_oplog_entry!(self.state, OplogEntry::ImportedFunctionInvoked)?; - Self::validate_oplog_entry(&oplog_entry, function_name)?; + DurableWorkerCtx::::validate_oplog_entry(&oplog_entry, function_name)?; let response = self .state .oplog diff --git a/golem-worker-executor-base/src/durable_host/filesystem/preopens.rs b/golem-worker-executor-base/src/durable_host/filesystem/preopens.rs index 6d9d4eb073..1aaf876312 100644 --- a/golem-worker-executor-base/src/durable_host/filesystem/preopens.rs +++ b/golem-worker-executor-base/src/durable_host/filesystem/preopens.rs @@ -21,7 +21,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::filesystem::preopens::{Descriptor, Host}; +use wasmtime_wasi::bindings::filesystem::preopens::{Descriptor, Host}; #[async_trait] impl Host for DurableWorkerCtx { @@ -64,3 +64,10 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get_directories(&mut self) -> anyhow::Result, String)>> { + (*self).get_directories().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/filesystem/types.rs b/golem-worker-executor-base/src/durable_host/filesystem/types.rs index 675b0ff8cb..565f7ad452 100644 --- a/golem-worker-executor-base/src/durable_host/filesystem/types.rs +++ b/golem-worker-executor-base/src/durable_host/filesystem/types.rs @@ -19,14 +19,16 @@ use async_trait::async_trait; use fs_set_times::{set_symlink_times, SystemTimeSpec}; use metrohash::MetroHash128; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::bindings::clocks::wall_clock::Datetime; -use wasmtime_wasi::preview2::bindings::filesystem::types::{ +use wasmtime_wasi::bindings::clocks::wall_clock::Datetime; +use wasmtime_wasi::bindings::filesystem::types::{ Advice, Descriptor, DescriptorFlags, DescriptorStat, DescriptorType, DirectoryEntry, DirectoryEntryStream, Error, ErrorCode, Filesize, Host, HostDescriptor, HostDirectoryEntryStream, InputStream, MetadataHashValue, NewTimestamp, OpenFlags, OutputStream, PathFlags, }; -use wasmtime_wasi::preview2::{spawn_blocking, FsError, ReaddirIterator}; +use wasmtime_wasi::runtime::spawn_blocking; +use wasmtime_wasi::FsError; +use wasmtime_wasi::ReaddirIterator; use golem_common::model::oplog::WrappedFunctionType; @@ -144,14 +146,14 @@ impl HostDescriptor for DurableWorkerCtx { let stream = HostDescriptor::read_directory(&mut self.as_wasi_view(), self_).await?; // Iterating through the whole stream to make sure we have a stable order let mut entries = Vec::new(); - let iter = self.table.delete(stream)?; + let iter = self.table().delete(stream)?; for entry in iter { entries.push(entry?.clone()); } entries.sort_by_key(|entry| entry.name.clone()); Ok(self - .table + .table() .push(ReaddirIterator::new(entries.into_iter().map(Ok)))?) } @@ -172,7 +174,7 @@ impl HostDescriptor for DurableWorkerCtx { async fn stat(&mut self, self_: Resource) -> Result { record_host_function_call("filesystem::types::descriptor", "stat"); - let path = match self.table.get(&self_)? { + let path = match self.table().get(&self_)? { Descriptor::File(f) => f.path.clone(), Descriptor::Dir(d) => d.path.clone(), }; @@ -225,7 +227,7 @@ impl HostDescriptor for DurableWorkerCtx { path: String, ) -> Result { record_host_function_call("filesystem::types::descriptor", "stat_at"); - let full_path = match self.table.get(&self_)? { + let full_path = match self.table().get(&self_)? { Descriptor::File(f) => f.path.join(path.clone()), Descriptor::Dir(d) => d.path.join(path.clone()), }; @@ -456,6 +458,266 @@ impl Host for DurableWorkerCtx { } } +#[async_trait] +impl HostDescriptor for &mut DurableWorkerCtx { + fn read_via_stream( + &mut self, + self_: Resource, + offset: Filesize, + ) -> Result, FsError> { + (*self).read_via_stream(self_, offset) + } + + fn write_via_stream( + &mut self, + self_: Resource, + offset: Filesize, + ) -> Result, FsError> { + (*self).write_via_stream(self_, offset) + } + + fn append_via_stream( + &mut self, + self_: Resource, + ) -> Result, FsError> { + (*self).append_via_stream(self_) + } + + async fn advise( + &mut self, + self_: Resource, + offset: Filesize, + length: Filesize, + advice: Advice, + ) -> Result<(), FsError> { + (*self).advise(self_, offset, length, advice).await + } + + async fn sync_data(&mut self, self_: Resource) -> Result<(), FsError> { + (*self).sync_data(self_).await + } + + async fn get_flags(&mut self, self_: Resource) -> Result { + (*self).get_flags(self_).await + } + + async fn get_type(&mut self, self_: Resource) -> Result { + (*self).get_type(self_).await + } + + async fn set_size( + &mut self, + self_: Resource, + size: Filesize, + ) -> Result<(), FsError> { + (*self).set_size(self_, size).await + } + + async fn set_times( + &mut self, + self_: Resource, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> Result<(), FsError> { + (*self) + .set_times(self_, data_access_timestamp, data_modification_timestamp) + .await + } + + async fn read( + &mut self, + self_: Resource, + length: Filesize, + offset: Filesize, + ) -> Result<(Vec, bool), FsError> { + (*self).read(self_, length, offset).await + } + + async fn write( + &mut self, + self_: Resource, + buffer: Vec, + offset: Filesize, + ) -> Result { + (*self).write(self_, buffer, offset).await + } + + async fn read_directory( + &mut self, + self_: Resource, + ) -> Result, FsError> { + (*self).read_directory(self_).await + } + + async fn sync(&mut self, self_: Resource) -> Result<(), FsError> { + (*self).sync(self_).await + } + + async fn create_directory_at( + &mut self, + self_: Resource, + path: String, + ) -> Result<(), FsError> { + (*self).create_directory_at(self_, path).await + } + + async fn stat(&mut self, self_: Resource) -> Result { + (*self).stat(self_).await + } + + async fn stat_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + ) -> Result { + (*self).stat_at(self_, path_flags, path).await + } + + async fn set_times_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> Result<(), FsError> { + (*self) + .set_times_at( + self_, + path_flags, + path, + data_access_timestamp, + data_modification_timestamp, + ) + .await + } + + async fn link_at( + &mut self, + self_: Resource, + old_path_flags: PathFlags, + old_path: String, + new_descriptor: Resource, + new_path: String, + ) -> Result<(), FsError> { + (*self) + .link_at(self_, old_path_flags, old_path, new_descriptor, new_path) + .await + } + + async fn open_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + open_flags: OpenFlags, + flags: DescriptorFlags, + ) -> Result, FsError> { + (*self) + .open_at(self_, path_flags, path, open_flags, flags) + .await + } + + async fn readlink_at( + &mut self, + self_: Resource, + path: String, + ) -> Result { + (*self).readlink_at(self_, path).await + } + + async fn remove_directory_at( + &mut self, + self_: Resource, + path: String, + ) -> Result<(), FsError> { + (*self).remove_directory_at(self_, path).await + } + + async fn rename_at( + &mut self, + self_: Resource, + old_path: String, + new_descriptor: Resource, + new_path: String, + ) -> Result<(), FsError> { + (*self) + .rename_at(self_, old_path, new_descriptor, new_path) + .await + } + + async fn symlink_at( + &mut self, + self_: Resource, + old_path: String, + new_path: String, + ) -> Result<(), FsError> { + (*self).symlink_at(self_, old_path, new_path).await + } + + async fn unlink_file_at( + &mut self, + self_: Resource, + path: String, + ) -> Result<(), FsError> { + (*self).unlink_file_at(self_, path).await + } + + async fn is_same_object( + &mut self, + self_: Resource, + other: Resource, + ) -> anyhow::Result { + (*self).is_same_object(self_, other).await + } + + async fn metadata_hash( + &mut self, + self_: Resource, + ) -> Result { + (*self).metadata_hash(self_).await + } + + async fn metadata_hash_at( + &mut self, + self_: Resource, + path_flags: PathFlags, + path: String, + ) -> Result { + (*self).metadata_hash_at(self_, path_flags, path).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostDescriptor::drop(*self, rep) + } +} + +#[async_trait] +impl HostDirectoryEntryStream for &mut DurableWorkerCtx { + async fn read_directory_entry( + &mut self, + self_: Resource, + ) -> Result, FsError> { + (*self).read_directory_entry(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostDirectoryEntryStream::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn filesystem_error_code(&mut self, err: Resource) -> anyhow::Result> { + (*self).filesystem_error_code(err) + } + + fn convert_error_code(&mut self, err: FsError) -> anyhow::Result { + (*self).convert_error_code(err) + } +} + fn calculate_metadata_hash(meta: &DescriptorStat) -> MetadataHashValue { let mut hasher = MetroHash128::new(); diff --git a/golem-worker-executor-base/src/durable_host/golem/mod.rs b/golem-worker-executor-base/src/durable_host/golem/mod.rs index 8d43348c3b..aa422fe623 100644 --- a/golem-worker-executor-base/src/durable_host/golem/mod.rs +++ b/golem-worker-executor-base/src/durable_host/golem/mod.rs @@ -19,7 +19,7 @@ use std::time::Duration; use tracing::debug; use uuid::Uuid; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::durable_host::serialized::SerializableError; use crate::durable_host::wasm_rpc::UriExtensions; @@ -30,7 +30,7 @@ use crate::metrics::wasm::record_host_function_call; use crate::model::InterruptKind; use crate::preview2::golem; use crate::preview2::golem::api::host::{ - ComponentVersion, HostGetWorkers, PersistenceLevel, RetryPolicy, UpdateMode, + ComponentVersion, HostGetWorkers, PersistenceLevel, RetryPolicy, UpdateMode, Uri, }; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::{OplogEntry, OplogIndex, WrappedFunctionType}; @@ -47,7 +47,7 @@ impl HostGetWorkers for DurableWorkerCtx { ) -> anyhow::Result> { record_host_function_call("golem::api::get-workers", "new"); let entry = GetWorkersEntry::new(component_id.into(), filter.map(|f| f.into()), precise); - let resource = self.as_wasi_view().table_mut().push(entry)?; + let resource = self.as_wasi_view().table().push(entry)?; Ok(resource) } @@ -78,7 +78,7 @@ impl HostGetWorkers for DurableWorkerCtx { let _ = self .as_wasi_view() - .table_mut() + .table() .get_mut::(&self_) .map(|e| e.set_next_cursor(new_cursor))?; @@ -90,9 +90,7 @@ impl HostGetWorkers for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("golem::api::get-workers", "drop"); - self.as_wasi_view() - .table_mut() - .delete::(rep)?; + self.as_wasi_view().table().delete::(rep)?; Ok(()) } } @@ -466,6 +464,130 @@ impl golem::api::host::Host for DurableWorkerCtx { } } +#[async_trait] +impl golem::api::host::HostGetWorkers for &mut DurableWorkerCtx { + async fn new( + &mut self, + component_id: golem::api::host::ComponentId, + filter: Option, + precise: bool, + ) -> anyhow::Result> { + (*self).new(component_id, filter, precise).await + } + + async fn get_next( + &mut self, + self_: Resource, + ) -> anyhow::Result>> { + (*self).get_next(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl golem::api::host::Host for &mut DurableWorkerCtx { + async fn golem_create_promise(&mut self) -> anyhow::Result { + (*self).golem_create_promise().await + } + + async fn golem_await_promise( + &mut self, + promise_id: golem::api::host::PromiseId, + ) -> anyhow::Result> { + (*self).golem_await_promise(promise_id).await + } + + async fn golem_complete_promise( + &mut self, + promise_id: golem::api::host::PromiseId, + data: Vec, + ) -> anyhow::Result { + (*self).golem_complete_promise(promise_id, data).await + } + + async fn golem_delete_promise( + &mut self, + promise_id: golem::api::host::PromiseId, + ) -> anyhow::Result<()> { + (*self).golem_delete_promise(promise_id).await + } + + async fn get_self_uri(&mut self, function_name: String) -> anyhow::Result { + (*self).get_self_uri(function_name).await + } + + async fn get_oplog_index(&mut self) -> anyhow::Result { + (*self).get_oplog_index().await + } + + async fn set_oplog_index( + &mut self, + oplog_idx: golem::api::host::OplogIndex, + ) -> anyhow::Result<()> { + (*self).set_oplog_index(oplog_idx).await + } + + async fn oplog_commit(&mut self, replicas: u8) -> anyhow::Result<()> { + (*self).oplog_commit(replicas).await + } + + async fn mark_begin_operation(&mut self) -> anyhow::Result { + (*self).mark_begin_operation().await + } + + async fn mark_end_operation( + &mut self, + begin: golem::api::host::OplogIndex, + ) -> anyhow::Result<()> { + (*self).mark_end_operation(begin).await + } + + async fn get_retry_policy(&mut self) -> anyhow::Result { + (*self).get_retry_policy().await + } + + async fn set_retry_policy(&mut self, new_retry_policy: RetryPolicy) -> anyhow::Result<()> { + (*self).set_retry_policy(new_retry_policy).await + } + + async fn get_oplog_persistence_level(&mut self) -> anyhow::Result { + (*self).get_oplog_persistence_level().await + } + + async fn set_oplog_persistence_level( + &mut self, + new_persistence_level: PersistenceLevel, + ) -> anyhow::Result<()> { + (*self) + .set_oplog_persistence_level(new_persistence_level) + .await + } + + async fn get_idempotence_mode(&mut self) -> anyhow::Result { + (*self).get_idempotence_mode().await + } + + async fn set_idempotence_mode(&mut self, idempotent: bool) -> anyhow::Result<()> { + (*self).set_idempotence_mode(idempotent).await + } + + async fn generate_idempotency_key(&mut self) -> anyhow::Result { + (*self).generate_idempotency_key().await + } + + async fn update_worker( + &mut self, + worker_id: golem::api::host::WorkerId, + target_version: ComponentVersion, + mode: UpdateMode, + ) -> anyhow::Result<()> { + (*self).update_worker(worker_id, target_version, mode).await + } +} + impl From for golem::api::host::WorkerId { fn from(worker_id: WorkerId) -> Self { golem::api::host::WorkerId { diff --git a/golem-worker-executor-base/src/durable_host/http/outgoing_http.rs b/golem-worker-executor-base/src/durable_host/http/outgoing_http.rs index b32ab87b4e..a1073d1e60 100644 --- a/golem-worker-executor-base/src/durable_host/http/outgoing_http.rs +++ b/golem-worker-executor-base/src/durable_host/http/outgoing_http.rs @@ -12,32 +12,35 @@ // See the License for the specific language governing permissions and // limitations under the License. +use anyhow::anyhow; use async_trait::async_trait; use wasmtime::component::Resource; -use wasmtime_wasi_http::bindings::http::types::ErrorCode; +use wasmtime_wasi_http::bindings::http::types; +use wasmtime_wasi_http::bindings::wasi::http::outgoing_handler::Host; +use wasmtime_wasi_http::types::{HostFutureIncomingResponse, HostOutgoingRequest}; +use wasmtime_wasi_http::{HttpError, HttpResult}; + +use golem_common::model::oplog::WrappedFunctionType; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi_http::bindings::wasi::http::outgoing_handler::{ - FutureIncomingResponse, Host, OutgoingRequest, RequestOptions, -}; #[async_trait] impl Host for DurableWorkerCtx { async fn handle( &mut self, - request: Resource, - options: Option>, - ) -> anyhow::Result, ErrorCode>> { + request: Resource, + options: Option>, + ) -> HttpResult> { record_host_function_call("http::outgoing_handler", "handle"); // Durability is handled by the WasiHttpView send_request method and the follow-up calls to await/poll the response future let begin_index = self .state .begin_function(&WrappedFunctionType::WriteRemote) - .await?; - let result = Host::handle(&mut self.as_wasi_http_view(), request, options).await?; + .await + .map_err(|err| HttpError::trap(anyhow!(err)))?; + let result = Host::handle(&mut self.as_wasi_http_view(), request, options).await; match &result { Ok(future_incoming_response) => { @@ -49,10 +52,22 @@ impl Host for DurableWorkerCtx { Err(_) => { self.state .end_function(&WrappedFunctionType::WriteRemote, begin_index) - .await?; + .await + .map_err(|err| HttpError::trap(anyhow!(err)))?; } } - Ok(result) + result + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn handle( + &mut self, + request: Resource, + options: Option>, + ) -> HttpResult> { + (*self).handle(request, options).await } } diff --git a/golem-worker-executor-base/src/durable_host/http/serialized.rs b/golem-worker-executor-base/src/durable_host/http/serialized.rs index 38080bad51..719d7d9721 100644 --- a/golem-worker-executor-base/src/durable_host/http/serialized.rs +++ b/golem-worker-executor-base/src/durable_host/http/serialized.rs @@ -17,7 +17,6 @@ use http::{HeaderName, HeaderValue, Version}; use std::collections::HashMap; use std::str::FromStr; -use std::sync::Arc; use crate::durable_host::serialized::SerializableError; use wasmtime_wasi_http::bindings::http::types::{ @@ -110,15 +109,12 @@ impl TryFrom for HostIncomingResponse { headers.insert(HeaderName::from_str(&key)?, HeaderValue::try_from(value)?); } - let fake_worker = tokio::spawn(async {}).into(); - Ok(Self { status: value.status, headers, body: Some(HostIncomingBody::failing( "Body stream was interrupted due to a restart".to_string(), )), // NOTE: high enough timeout so it does not matter, but not as high to overflow instants - worker: Arc::new(fake_worker), }) } } diff --git a/golem-worker-executor-base/src/durable_host/http/types.rs b/golem-worker-executor-base/src/durable_host/http/types.rs index 4cc50227a8..0eed9d8ab1 100644 --- a/golem-worker-executor-base/src/durable_host/http/types.rs +++ b/golem-worker-executor-base/src/durable_host/http/types.rs @@ -22,7 +22,7 @@ use std::str::FromStr; use tracing::warn; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::subscribe; +use wasmtime_wasi::subscribe; use crate::durable_host::{Durability, DurableWorkerCtx, Ready}; use crate::metrics::wasm::record_host_function_call; @@ -45,8 +45,9 @@ use wasmtime_wasi_http::bindings::wasi::http::types::{ OutgoingRequest, OutgoingResponse, OutputStream, Pollable, RequestOptions, ResponseOutparam, Scheme, StatusCode, Trailers, }; +use wasmtime_wasi_http::get_fields; use wasmtime_wasi_http::types::FieldMap; -use wasmtime_wasi_http::types_impl::get_fields; +use wasmtime_wasi_http::{HttpError, HttpResult}; impl HostFields for DurableWorkerCtx { fn new(&mut self) -> anyhow::Result> { @@ -384,8 +385,8 @@ impl HostFutureTrailers for DurableWorkerCtx { fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { record_host_function_call("http::types::future_trailers", "subscribe"); if self.state.is_replay() { - let ready = self.table.push(Ready {})?; - subscribe(&mut self.table, ready, None) + let ready = self.table().push(Ready {})?; + subscribe(self.table(), ready, None) } else { HostFutureTrailers::subscribe(&mut self.as_wasi_http_view(), self_) } @@ -416,7 +417,7 @@ impl HostFutureTrailers for DurableWorkerCtx { let host_fields: &Resource = unsafe { std::mem::transmute(trailers) }; - for (key, value) in get_fields(&mut ctx.table, host_fields)? { + for (key, value) in get_fields(ctx.table(), host_fields)? { serialized_trailers .insert(key.as_str().to_string(), value.as_bytes().to_vec()); } @@ -439,7 +440,7 @@ impl HostFutureTrailers for DurableWorkerCtx { ); } let hdrs = ctx - .table + .table() .push(wasmtime_wasi_http::types::HostFields::Owned { fields })?; Ok(Some(Ok(Ok(Some(hdrs))))) } @@ -513,7 +514,7 @@ impl HostOutgoingBody for DurableWorkerCtx { &mut self, this: Resource, trailers: Option>, - ) -> anyhow::Result> { + ) -> HttpResult<()> { record_host_function_call("http::types::outgoing_body", "finish"); HostOutgoingBody::finish(&mut self.as_wasi_http_view(), this, trailers) } @@ -560,7 +561,7 @@ impl HostFutureIncomingResponse for DurableWorkerCtx { let serializable_response = match &response { Ok(None) => SerializableResponse::Pending, Ok(Some(Ok(Ok(resource)))) => { - let incoming_response = self.table.get(resource)?; + let incoming_response = self.table().get(resource)?; SerializableResponse::HeadersReceived(SerializableResponseHeaders::try_from( incoming_response, )?) @@ -636,7 +637,7 @@ impl HostFutureIncomingResponse for DurableWorkerCtx { let incoming_response: wasmtime_wasi_http::types::HostIncomingResponse = serializable_response_headers.try_into()?; - let rep = self.table.push(incoming_response)?; + let rep = self.table().push(incoming_response)?; Ok(Some(Ok(Ok(rep)))) } SerializableResponse::InternalError(None) => Ok(Some(Err(()))), @@ -659,4 +660,396 @@ impl Host for DurableWorkerCtx { record_host_function_call("http::types", "http_error_code"); Host::http_error_code(&mut self.as_wasi_http_view(), err) } + + fn convert_error_code(&mut self, err: HttpError) -> wasmtime::Result { + record_host_function_call("http::types", "convert_error_code"); + Host::convert_error_code(&mut self.as_wasi_http_view(), err) + } +} + +#[async_trait] +impl HostFutureIncomingResponse for &mut DurableWorkerCtx { + fn subscribe( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostFutureIncomingResponse::subscribe(*self, self_) + } + + async fn get( + &mut self, + self_: Resource, + ) -> anyhow::Result, ErrorCode>, ()>>> { + HostFutureIncomingResponse::get(*self, self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureIncomingResponse::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutgoingBody for &mut DurableWorkerCtx { + fn write( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostOutgoingBody::write(*self, self_) + } + + fn finish( + &mut self, + this: Resource, + trailers: Option>, + ) -> HttpResult<()> { + HostOutgoingBody::finish(*self, this, trailers) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingBody::drop(*self, rep) + } +} + +#[async_trait] +impl HostFields for &mut DurableWorkerCtx { + fn new(&mut self) -> anyhow::Result> { + HostFields::new(*self) + } + + fn from_list( + &mut self, + entries: Vec<(FieldKey, FieldValue)>, + ) -> anyhow::Result, HeaderError>> { + HostFields::from_list(*self, entries) + } + + fn get(&mut self, self_: Resource, name: FieldKey) -> anyhow::Result> { + HostFields::get(*self, self_, name) + } + + fn has(&mut self, self_: Resource, name: FieldKey) -> anyhow::Result { + HostFields::has(*self, self_, name) + } + + fn set( + &mut self, + self_: Resource, + name: FieldKey, + value: Vec, + ) -> anyhow::Result> { + HostFields::set(*self, self_, name, value) + } + + fn delete( + &mut self, + self_: Resource, + name: FieldKey, + ) -> anyhow::Result> { + HostFields::delete(*self, self_, name) + } + + fn append( + &mut self, + self_: Resource, + name: FieldKey, + value: FieldValue, + ) -> anyhow::Result> { + HostFields::append(*self, self_, name, value) + } + + fn entries(&mut self, self_: Resource) -> anyhow::Result> { + HostFields::entries(*self, self_) + } + + fn clone(&mut self, self_: Resource) -> anyhow::Result> { + HostFields::clone(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFields::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutgoingResponse for &mut DurableWorkerCtx { + fn new(&mut self, headers: Resource) -> anyhow::Result> { + HostOutgoingResponse::new(*self, headers) + } + + fn status_code(&mut self, self_: Resource) -> anyhow::Result { + HostOutgoingResponse::status_code(*self, self_) + } + + fn set_status_code( + &mut self, + self_: Resource, + status_code: StatusCode, + ) -> anyhow::Result> { + HostOutgoingResponse::set_status_code(*self, self_, status_code) + } + + fn headers(&mut self, self_: Resource) -> anyhow::Result> { + HostOutgoingResponse::headers(*self, self_) + } + + fn body( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostOutgoingResponse::body(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingResponse::drop(*self, rep) + } +} + +#[async_trait] +impl HostFutureTrailers for &mut DurableWorkerCtx { + fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { + HostFutureTrailers::subscribe(*self, self_) + } + + async fn get( + &mut self, + self_: Resource, + ) -> anyhow::Result>, ErrorCode>, ()>>> { + HostFutureTrailers::get(*self, self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureTrailers::drop(*self, rep) + } +} + +#[async_trait] +impl HostIncomingBody for &mut DurableWorkerCtx { + fn stream( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostIncomingBody::stream(*self, self_) + } + + fn finish(&mut self, this: Resource) -> anyhow::Result> { + HostIncomingBody::finish(*self, this) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingBody::drop(*self, rep) + } +} + +#[async_trait] +impl HostIncomingResponse for &mut DurableWorkerCtx { + fn status(&mut self, self_: Resource) -> anyhow::Result { + HostIncomingResponse::status(*self, self_) + } + + fn headers(&mut self, self_: Resource) -> anyhow::Result> { + HostIncomingResponse::headers(*self, self_) + } + + fn consume( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostIncomingResponse::consume(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingResponse::drop(*self, rep) + } +} + +#[async_trait] +impl HostResponseOutparam for &mut DurableWorkerCtx { + fn set( + &mut self, + param: Resource, + response: Result, ErrorCode>, + ) -> anyhow::Result<()> { + HostResponseOutparam::set(*self, param, response) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostResponseOutparam::drop(*self, rep) + } +} + +#[async_trait] +impl HostRequestOptions for &mut DurableWorkerCtx { + fn new(&mut self) -> anyhow::Result> { + HostRequestOptions::new(*self) + } + + fn connect_timeout( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostRequestOptions::connect_timeout(*self, self_) + } + + fn set_connect_timeout( + &mut self, + self_: Resource, + duration: Option, + ) -> anyhow::Result> { + HostRequestOptions::set_connect_timeout(*self, self_, duration) + } + + fn first_byte_timeout( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostRequestOptions::first_byte_timeout(*self, self_) + } + + fn set_first_byte_timeout( + &mut self, + self_: Resource, + duration: Option, + ) -> anyhow::Result> { + HostRequestOptions::set_first_byte_timeout(*self, self_, duration) + } + + fn between_bytes_timeout( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostRequestOptions::between_bytes_timeout(*self, self_) + } + + fn set_between_bytes_timeout( + &mut self, + self_: Resource, + duration: Option, + ) -> anyhow::Result> { + HostRequestOptions::set_between_bytes_timeout(*self, self_, duration) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostRequestOptions::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutgoingRequest for &mut DurableWorkerCtx { + fn new(&mut self, headers: Resource) -> anyhow::Result> { + HostOutgoingRequest::new(*self, headers) + } + + fn body( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostOutgoingRequest::body(*self, self_) + } + + fn method(&mut self, self_: Resource) -> anyhow::Result { + HostOutgoingRequest::method(*self, self_) + } + + fn set_method( + &mut self, + self_: Resource, + method: Method, + ) -> anyhow::Result> { + HostOutgoingRequest::set_method(*self, self_, method) + } + + fn path_with_query( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostOutgoingRequest::path_with_query(*self, self_) + } + + fn set_path_with_query( + &mut self, + self_: Resource, + path_with_query: Option, + ) -> anyhow::Result> { + HostOutgoingRequest::set_path_with_query(*self, self_, path_with_query) + } + + fn scheme(&mut self, self_: Resource) -> anyhow::Result> { + HostOutgoingRequest::scheme(*self, self_) + } + + fn set_scheme( + &mut self, + self_: Resource, + scheme: Option, + ) -> anyhow::Result> { + HostOutgoingRequest::set_scheme(*self, self_, scheme) + } + + fn authority(&mut self, self_: Resource) -> anyhow::Result> { + HostOutgoingRequest::authority(*self, self_) + } + + fn set_authority( + &mut self, + self_: Resource, + authority: Option, + ) -> anyhow::Result> { + HostOutgoingRequest::set_authority(*self, self_, authority) + } + + fn headers(&mut self, self_: Resource) -> anyhow::Result> { + HostOutgoingRequest::headers(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingRequest::drop(*self, rep) + } +} + +#[async_trait] +impl HostIncomingRequest for &mut DurableWorkerCtx { + fn method(&mut self, self_: Resource) -> anyhow::Result { + HostIncomingRequest::method(*self, self_) + } + + fn path_with_query( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostIncomingRequest::path_with_query(*self, self_) + } + + fn scheme(&mut self, self_: Resource) -> anyhow::Result> { + HostIncomingRequest::scheme(*self, self_) + } + + fn authority(&mut self, self_: Resource) -> anyhow::Result> { + HostIncomingRequest::authority(*self, self_) + } + + fn headers(&mut self, self_: Resource) -> anyhow::Result> { + HostIncomingRequest::headers(*self, self_) + } + + fn consume( + &mut self, + self_: Resource, + ) -> anyhow::Result, ()>> { + HostIncomingRequest::consume(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingRequest::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn http_error_code(&mut self, err: Resource) -> anyhow::Result> { + (*self).http_error_code(err) + } + + fn convert_error_code(&mut self, err: HttpError) -> anyhow::Result { + (*self).convert_error_code(err) + } } diff --git a/golem-worker-executor-base/src/durable_host/io/error.rs b/golem-worker-executor-base/src/durable_host/io/error.rs index cbd0320502..12991aeb19 100644 --- a/golem-worker-executor-base/src/durable_host/io/error.rs +++ b/golem-worker-executor-base/src/durable_host/io/error.rs @@ -17,7 +17,7 @@ use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use async_trait::async_trait; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::bindings::wasi::io::error::{Error, Host, HostError}; +use wasmtime_wasi::bindings::io::error::{Error, Host, HostError}; #[async_trait] impl HostError for DurableWorkerCtx { @@ -34,3 +34,17 @@ impl HostError for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostError for &mut DurableWorkerCtx { + fn to_debug_string(&mut self, self_: Resource) -> anyhow::Result { + (*self).to_debug_string(self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/io/mod.rs b/golem-worker-executor-base/src/durable_host/io/mod.rs index cbeaa15cc3..4bf30c707f 100644 --- a/golem-worker-executor-base/src/durable_host/io/mod.rs +++ b/golem-worker-executor-base/src/durable_host/io/mod.rs @@ -21,7 +21,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use tokio::task::JoinHandle; -use wasmtime_wasi::preview2::{ +use wasmtime_wasi::{ HostInputStream, HostOutputStream, Stderr, StdinStream, StdoutStream, StreamError, StreamResult, Subscribe, }; diff --git a/golem-worker-executor-base/src/durable_host/io/poll.rs b/golem-worker-executor-base/src/durable_host/io/poll.rs index 041df524ca..4beadf8912 100644 --- a/golem-worker-executor-base/src/durable_host/io/poll.rs +++ b/golem-worker-executor-base/src/durable_host/io/poll.rs @@ -16,7 +16,7 @@ use crate::model::InterruptKind; use async_trait::async_trait; use chrono::{Duration, Utc}; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::bindings::wasi::io::poll::{Host, HostPollable, Pollable}; +use wasmtime_wasi::bindings::io::poll::{Host, HostPollable, Pollable}; use crate::durable_host::{DurableWorkerCtx, SuspendForSleep}; use crate::metrics::wasm::record_host_function_call; @@ -58,6 +58,28 @@ impl Host for DurableWorkerCtx { } } +#[async_trait] +impl HostPollable for &mut DurableWorkerCtx { + async fn ready(&mut self, self_: Resource) -> anyhow::Result { + (*self).ready(self_).await + } + + async fn block(&mut self, self_: Resource) -> anyhow::Result<()> { + (*self).block(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn poll(&mut self, in_: Vec>) -> anyhow::Result> { + (*self).poll(in_).await + } +} + fn is_suspend_for_sleep(result: &Result) -> Option { if let Err(err) = result { if let Some(SuspendForSleep(duration)) = err.root_cause().downcast_ref::() diff --git a/golem-worker-executor-base/src/durable_host/io/streams.rs b/golem-worker-executor-base/src/durable_host/io/streams.rs index 5e8f1350a0..c54d2a7450 100644 --- a/golem-worker-executor-base/src/durable_host/io/streams.rs +++ b/golem-worker-executor-base/src/durable_host/io/streams.rs @@ -15,7 +15,7 @@ use anyhow::anyhow; use async_trait::async_trait; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::{ResourceTable, StreamError}; +use wasmtime_wasi::{ResourceTable, StreamError}; use crate::durable_host::io::{ManagedStdErr, ManagedStdOut}; use crate::durable_host::serialized::SerializableStreamError; @@ -25,7 +25,7 @@ use crate::metrics::wasm::record_host_function_call; use crate::model::PersistenceLevel; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::io::streams::{ +use wasmtime_wasi::bindings::io::streams::{ Host, HostInputStream, HostOutputStream, InputStream, OutputStream, Pollable, }; use wasmtime_wasi_http::body::{FailingStream, HostIncomingBodyStream}; @@ -38,7 +38,7 @@ impl HostInputStream for DurableWorkerCtx { len: u64, ) -> Result, StreamError> { record_host_function_call("io::streams::input_stream", "read"); - if is_incoming_http_body_stream(&self.table, &self_) { + if is_incoming_http_body_stream(self.table(), &self_) { Durability::, SerializableStreamError>::wrap( self, WrappedFunctionType::ReadRemote, @@ -61,7 +61,7 @@ impl HostInputStream for DurableWorkerCtx { len: u64, ) -> Result, StreamError> { record_host_function_call("io::streams::input_stream", "blocking_read"); - if is_incoming_http_body_stream(&self.table, &self_) { + if is_incoming_http_body_stream(self.table(), &self_) { Durability::, SerializableStreamError>::wrap( self, WrappedFunctionType::ReadRemote, @@ -80,7 +80,7 @@ impl HostInputStream for DurableWorkerCtx { async fn skip(&mut self, self_: Resource, len: u64) -> Result { record_host_function_call("io::streams::input_stream", "skip"); - if is_incoming_http_body_stream(&self.table, &self_) { + if is_incoming_http_body_stream(self.table(), &self_) { Durability::::wrap( self, WrappedFunctionType::ReadRemote, @@ -103,7 +103,7 @@ impl HostInputStream for DurableWorkerCtx { len: u64, ) -> Result { record_host_function_call("io::streams::input_stream", "blocking_skip"); - if is_incoming_http_body_stream(&self.table, &self_) { + if is_incoming_http_body_stream(self.table(), &self_) { Durability::::wrap( self, WrappedFunctionType::ReadRemote, @@ -145,12 +145,12 @@ impl HostOutputStream for DurableWorkerCtx { ) -> Result<(), StreamError> { record_host_function_call("io::streams::output_stream", "write"); - let event_service = &self.public_state.event_service; + let event_service = self.public_state.event_service.clone(); let mut is_std = false; let is_live = self.state.is_live() || self.state.persistence_level == PersistenceLevel::PersistNothing; - let output = self.table.get(&self_)?; + let output = self.table().get(&self_)?; if output.as_any().downcast_ref::().is_some() { if is_live { event_service.emit_stdout(contents.clone()); @@ -177,12 +177,12 @@ impl HostOutputStream for DurableWorkerCtx { ) -> Result<(), StreamError> { record_host_function_call("io::streams::output_stream", "blocking_write_and_flush"); - let event_service = &self.public_state.event_service; + let event_service = self.public_state.event_service.clone(); let mut is_std = false; let is_live = self.state.is_live() || self.state.persistence_level == PersistenceLevel::PersistNothing; - let output = self.table.get(&self_)?; + let output = self.table().get(&self_)?; if output.as_any().downcast_ref::().is_some() { if is_live { event_service.emit_stdout(contents.clone()); @@ -267,11 +267,129 @@ impl Host for DurableWorkerCtx { fn convert_stream_error( &mut self, err: StreamError, - ) -> anyhow::Result { + ) -> anyhow::Result { Host::convert_stream_error(&mut self.as_wasi_view(), err) } } +#[async_trait] +impl HostInputStream for &mut DurableWorkerCtx { + async fn read( + &mut self, + self_: Resource, + len: u64, + ) -> Result, StreamError> { + (*self).read(self_, len).await + } + + async fn blocking_read( + &mut self, + self_: Resource, + len: u64, + ) -> Result, StreamError> { + (*self).blocking_read(self_, len).await + } + + async fn skip(&mut self, self_: Resource, len: u64) -> Result { + (*self).skip(self_, len).await + } + + async fn blocking_skip( + &mut self, + self_: Resource, + len: u64, + ) -> Result { + (*self).blocking_skip(self_, len).await + } + + fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { + HostInputStream::subscribe(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostInputStream::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutputStream for &mut DurableWorkerCtx { + fn check_write(&mut self, self_: Resource) -> Result { + (*self).check_write(self_) + } + + fn write( + &mut self, + self_: Resource, + contents: Vec, + ) -> Result<(), StreamError> { + (*self).write(self_, contents) + } + + async fn blocking_write_and_flush( + &mut self, + self_: Resource, + contents: Vec, + ) -> Result<(), StreamError> { + (*self).blocking_write_and_flush(self_, contents).await + } + + fn flush(&mut self, self_: Resource) -> Result<(), StreamError> { + (*self).flush(self_) + } + + async fn blocking_flush(&mut self, self_: Resource) -> Result<(), StreamError> { + (*self).blocking_flush(self_).await + } + + fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { + HostOutputStream::subscribe(*self, self_) + } + + fn write_zeroes(&mut self, self_: Resource, len: u64) -> Result<(), StreamError> { + (*self).write_zeroes(self_, len) + } + + async fn blocking_write_zeroes_and_flush( + &mut self, + self_: Resource, + len: u64, + ) -> Result<(), StreamError> { + (*self).blocking_write_zeroes_and_flush(self_, len).await + } + + async fn splice( + &mut self, + self_: Resource, + src: Resource, + len: u64, + ) -> Result { + (*self).splice(self_, src, len).await + } + + async fn blocking_splice( + &mut self, + self_: Resource, + src: Resource, + len: u64, + ) -> Result { + (*self).blocking_splice(self_, src, len).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutputStream::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn convert_stream_error( + &mut self, + err: StreamError, + ) -> anyhow::Result { + (*self).convert_stream_error(err) + } +} + fn is_incoming_http_body_stream(table: &ResourceTable, stream: &Resource) -> bool { let stream = table.get::(stream).unwrap(); match stream { diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/atomic.rs b/golem-worker-executor-base/src/durable_host/keyvalue/atomic.rs index 52534ed3b4..24dcd61ae7 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/atomic.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/atomic.rs @@ -43,3 +43,25 @@ impl Host for DurableWorkerCtx { unimplemented!("compare_and_swap") } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn increment( + &mut self, + bucket: Resource, + key: Key, + delta: u64, + ) -> anyhow::Result>> { + (*self).increment(bucket, key, delta).await + } + + async fn compare_and_swap( + &mut self, + bucket: Resource, + key: Key, + old: u64, + new: u64, + ) -> anyhow::Result>> { + (*self).compare_and_swap(bucket, key, old, new).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/caching.rs b/golem-worker-executor-base/src/durable_host/keyvalue/caching.rs index bffcd816eb..054b1e0545 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/caching.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/caching.rs @@ -178,3 +178,130 @@ impl Host for DurableWorkerCtx { unimplemented!("delete") } } + +#[async_trait] +impl HostFutureGetResult for &mut DurableWorkerCtx { + async fn future_get_result_get( + &mut self, + self_: Resource, + ) -> anyhow::Result>, Resource>>> { + (*self).future_get_result_get(self_).await + } + + async fn listen_to_future_get_result( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + (*self).listen_to_future_get_result(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureGetResult::drop(*self, rep) + } +} + +#[async_trait] +impl HostFutureExistsResult for &mut DurableWorkerCtx { + async fn future_exists_result_get( + &mut self, + self_: Resource, + ) -> anyhow::Result>>> { + (*self).future_exists_result_get(self_).await + } + + async fn listen_to_future_exists_result( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + (*self).listen_to_future_exists_result(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureExistsResult::drop(*self, rep) + } +} + +#[async_trait] +impl HostFutureResult for &mut DurableWorkerCtx { + async fn future_result_get( + &mut self, + self_: Resource, + ) -> anyhow::Result>>> { + (*self).future_result_get(self_).await + } + + async fn listen_to_future_result( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + (*self).listen_to_future_result(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureResult::drop(*self, rep) + } +} + +#[async_trait] +impl HostFutureGetOrSetResult for &mut DurableWorkerCtx { + async fn future_get_or_set_result_get( + &mut self, + _self_: Resource, + ) -> anyhow::Result>>> { + (*self).future_get_or_set_result_get(_self_).await + } + + async fn listen_to_future_get_or_set_result( + &mut self, + _self_: Resource, + ) -> anyhow::Result> { + (*self).listen_to_future_get_or_set_result(_self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostFutureGetOrSetResult::drop(*self, rep) + } +} + +#[async_trait] +impl HostVacancy for &mut DurableWorkerCtx { + async fn vacancy_fill( + &mut self, + _self_: Resource, + _ttl_ms: Option, + ) -> anyhow::Result> { + (*self).vacancy_fill(_self_, _ttl_ms).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostVacancy::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get(&mut self, k: Key) -> anyhow::Result> { + (*self).get(k).await + } + + async fn exists(&mut self, k: Key) -> anyhow::Result> { + (*self).exists(k).await + } + + async fn set( + &mut self, + k: Key, + v: Resource, + ttl_ms: Option, + ) -> anyhow::Result> { + (*self).set(k, v, ttl_ms).await + } + + async fn get_or_set(&mut self, k: Key) -> anyhow::Result> { + (*self).get_or_set(k).await + } + + async fn delete(&mut self, k: Key) -> anyhow::Result> { + (*self).delete(k).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/error.rs b/golem-worker-executor-base/src/durable_host/keyvalue/error.rs index 26dc2ca7c7..98cffbe0c8 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/error.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/error.rs @@ -14,7 +14,7 @@ use async_trait::async_trait; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; @@ -36,7 +36,7 @@ impl HostError for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("keyvalue::wasi_cloud_error", "drop_error"); - self.as_wasi_view().table_mut().delete::(rep)?; + self.as_wasi_view().table().delete::(rep)?; Ok(()) } } @@ -44,6 +44,20 @@ impl HostError for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} +#[async_trait] +impl HostError for &mut DurableWorkerCtx { + async fn trace(&mut self, self_: Resource) -> anyhow::Result { + (*self).trace(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} + pub struct ErrorEntry { trace: String, } diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/eventual.rs b/golem-worker-executor-base/src/durable_host/keyvalue/eventual.rs index 95eafa209a..63365a4143 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/eventual.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/eventual.rs @@ -15,7 +15,7 @@ use async_trait::async_trait; use golem_common::model::oplog::WrappedFunctionType; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::durable_host::keyvalue::error::ErrorEntry; use crate::durable_host::keyvalue::types::{BucketEntry, IncomingValueEntry, OutgoingValueEntry}; @@ -57,7 +57,7 @@ impl Host for DurableWorkerCtx { Ok(Some(value)) => { let incoming_value = self .as_wasi_view() - .table_mut() + .table() .push(IncomingValueEntry::new(value))?; Ok(Ok(Some(incoming_value))) } @@ -65,7 +65,7 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } @@ -113,7 +113,7 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } @@ -149,7 +149,7 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } @@ -185,10 +185,46 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } } } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get( + &mut self, + bucket: Resource, + key: Key, + ) -> anyhow::Result>, Resource>> { + (*self).get(bucket, key).await + } + + async fn set( + &mut self, + bucket: Resource, + key: Key, + outgoing_value: Resource, + ) -> anyhow::Result>> { + (*self).set(bucket, key, outgoing_value).await + } + + async fn delete( + &mut self, + bucket: Resource, + key: Key, + ) -> anyhow::Result>> { + (*self).delete(bucket, key).await + } + + async fn exists( + &mut self, + bucket: Resource, + key: Key, + ) -> anyhow::Result>> { + (*self).exists(bucket, key).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/eventual_batch.rs b/golem-worker-executor-base/src/durable_host/keyvalue/eventual_batch.rs index bc000fddb6..68d61fc438 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/eventual_batch.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/eventual_batch.rs @@ -15,7 +15,7 @@ use async_trait::async_trait; use golem_common::model::oplog::WrappedFunctionType; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::{ResourceTableError, WasiView}; +use wasmtime_wasi::{ResourceTableError, WasiView}; use crate::durable_host::keyvalue::error::ErrorEntry; use crate::durable_host::keyvalue::types::{BucketEntry, IncomingValueEntry, OutgoingValueEntry}; @@ -64,7 +64,7 @@ impl Host for DurableWorkerCtx { Some(incoming_value) => { let value = self .as_wasi_view() - .table_mut() + .table() .push(IncomingValueEntry::new(incoming_value))?; result.push(Some(value)); } @@ -78,7 +78,7 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } @@ -156,7 +156,7 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } @@ -194,10 +194,44 @@ impl Host for DurableWorkerCtx { Err(e) => { let error = self .as_wasi_view() - .table_mut() + .table() .push(ErrorEntry::new(format!("{:?}", e)))?; Ok(Err(error)) } } } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get_many( + &mut self, + bucket: Resource, + keys: Vec, + ) -> anyhow::Result>>, Resource>> { + (*self).get_many(bucket, keys).await + } + + async fn keys( + &mut self, + bucket: Resource, + ) -> anyhow::Result, Resource>> { + (*self).keys(bucket).await + } + + async fn set_many( + &mut self, + bucket: Resource, + key_values: Vec<(Key, Resource)>, + ) -> anyhow::Result>> { + (*self).set_many(bucket, key_values).await + } + + async fn delete_many( + &mut self, + bucket: Resource, + keys: Vec, + ) -> anyhow::Result>> { + (*self).delete_many(bucket, keys).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/keyvalue/types.rs b/golem-worker-executor-base/src/durable_host/keyvalue/types.rs index d64f2a558d..b5e3b6cfe3 100644 --- a/golem-worker-executor-base/src/durable_host/keyvalue/types.rs +++ b/golem-worker-executor-base/src/durable_host/keyvalue/types.rs @@ -25,7 +25,7 @@ use crate::workerctx::WorkerCtx; use async_trait::async_trait; use bytes::Bytes; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::{ +use wasmtime_wasi::{ HostInputStream, HostOutputStream, InputStream, StreamResult, Subscribe, WasiView, }; @@ -36,16 +36,13 @@ impl HostBucket for DurableWorkerCtx { name: String, ) -> anyhow::Result, Resource>> { record_host_function_call("keyvalue::types::bucket", "open"); - let bucket = self - .as_wasi_view() - .table_mut() - .push(BucketEntry::new(name))?; + let bucket = self.as_wasi_view().table().push(BucketEntry::new(name))?; Ok(Ok(bucket)) } fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("keyvalue::types::bucket", "drop"); - self.as_wasi_view().table_mut().delete::(rep)?; + self.as_wasi_view().table().delete::(rep)?; Ok(()) } } @@ -56,7 +53,7 @@ impl HostOutgoingValue for DurableWorkerCtx { record_host_function_call("keyvalue::types::outgoing_value", "new_outgoing_value"); let outgoing_value = self .as_wasi_view() - .table_mut() + .table() .push(OutgoingValueEntry::new())?; Ok(outgoing_value) } @@ -76,7 +73,7 @@ impl HostOutgoingValue for DurableWorkerCtx { .body .clone(); let body: Box = Box::new(OutgoingValueEntryStream::new(body)); - let outgoing_value_async_body = self.as_wasi_view().table_mut().push(body)?; + let outgoing_value_async_body = self.as_wasi_view().table().push(body)?; Ok(Ok(outgoing_value_async_body)) } @@ -102,7 +99,7 @@ impl HostOutgoingValue for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("keyvalue::types::outgoing_value", "drop"); self.as_wasi_view() - .table_mut() + .table() .delete::(rep)?; Ok(()) } @@ -144,7 +141,7 @@ impl HostIncomingValue for DurableWorkerCtx { .clone(); let input_stream: InputStream = InputStream::Host(Box::new(IncomingValueEntryStream::new(body))); - let incoming_value_async_body = self.as_wasi_view().table_mut().push(input_stream)?; + let incoming_value_async_body = self.as_wasi_view().table().push(input_stream)?; Ok(Ok(incoming_value_async_body)) } @@ -166,7 +163,7 @@ impl HostIncomingValue for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("keyvalue::types::incoming_value", "drop"); self.as_wasi_view() - .table_mut() + .table() .delete::(rep)?; Ok(()) } @@ -175,6 +172,77 @@ impl HostIncomingValue for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} +#[async_trait] +impl HostIncomingValue for &mut DurableWorkerCtx { + async fn incoming_value_consume_sync( + &mut self, + self_: Resource, + ) -> anyhow::Result>> { + (*self).incoming_value_consume_sync(self_).await + } + + async fn incoming_value_consume_async( + &mut self, + self_: Resource, + ) -> anyhow::Result, Resource>> { + (*self).incoming_value_consume_async(self_).await + } + + async fn incoming_value_size( + &mut self, + self_: Resource, + ) -> anyhow::Result>> { + (*self).incoming_value_size(self_).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingValue::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutgoingValue for &mut DurableWorkerCtx { + async fn new_outgoing_value(&mut self) -> anyhow::Result> { + (*self).new_outgoing_value().await + } + + async fn outgoing_value_write_body_async( + &mut self, + self_: Resource, + ) -> anyhow::Result, Resource>> { + (*self).outgoing_value_write_body_async(self_).await + } + + async fn outgoing_value_write_body_sync( + &mut self, + self_: Resource, + value: OutgoingValueBodySync, + ) -> anyhow::Result>> { + (*self).outgoing_value_write_body_sync(self_, value).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingValue::drop(*self, rep) + } +} + +#[async_trait] +impl HostBucket for &mut DurableWorkerCtx { + async fn open_bucket( + &mut self, + name: String, + ) -> anyhow::Result, Resource>> { + (*self).open_bucket(name).await + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostBucket::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} + pub struct BucketEntry { pub name: String, } diff --git a/golem-worker-executor-base/src/durable_host/logging/logging.rs b/golem-worker-executor-base/src/durable_host/logging/logging.rs index 77ea5bbdf1..5ed6d8fc44 100644 --- a/golem-worker-executor-base/src/durable_host/logging/logging.rs +++ b/golem-worker-executor-base/src/durable_host/logging/logging.rs @@ -44,3 +44,10 @@ impl Host for DurableWorkerCtx { } } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn log(&mut self, level: Level, context: String, message: String) -> anyhow::Result<()> { + (*self).log(level, context, message).await + } +} diff --git a/golem-worker-executor-base/src/durable_host/mod.rs b/golem-worker-executor-base/src/durable_host/mod.rs index 01f8ed8fae..81f3f25dab 100644 --- a/golem-worker-executor-base/src/durable_host/mod.rs +++ b/golem-worker-executor-base/src/durable_host/mod.rs @@ -20,7 +20,7 @@ use std::error::Error; use std::fmt::{Debug, Display, Formatter}; use std::ops::Add; use std::string::FromUtf8Error; -use std::sync::{Arc, RwLock, Weak}; +use std::sync::{Arc, Mutex, RwLock, Weak}; use std::time::{Duration, Instant}; use crate::error::GolemError; @@ -43,7 +43,6 @@ use crate::workerctx::{ }; use anyhow::anyhow; use async_trait::async_trait; -use cap_std::ambient_authority; use chrono::{DateTime, Utc}; use golem_common::config::RetryConfig; use golem_common::model::oplog::{OplogEntry, OplogIndex, UpdateDescription, WrappedFunctionType}; @@ -57,13 +56,14 @@ use golem_wasm_rpc::wasmtime::ResourceStore; use golem_wasm_rpc::{Uri, Value}; use tempfile::TempDir; use tracing::{debug, info, span, warn, Instrument, Level}; -use wasmtime::component::{Instance, Resource, ResourceAny}; +use wasmtime::component::{Instance, ResourceAny}; use wasmtime::AsContextMut; -use wasmtime_wasi::preview2::{I32Exit, ResourceTable, Stderr, Subscribe, WasiCtx, WasiView}; +use wasmtime_wasi::{I32Exit, ResourceTable, Stderr, Subscribe, WasiCtx, WasiView}; +use wasmtime_wasi_http::body::HyperOutgoingBody; use wasmtime_wasi_http::types::{ - default_send_request, HostFutureIncomingResponse, OutgoingRequest, + default_send_request, HostFutureIncomingResponse, OutgoingRequestConfig, }; -use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView}; +use wasmtime_wasi_http::{HttpResult, WasiHttpCtx, WasiHttpView}; use crate::durable_host::io::{ManagedStdErr, ManagedStdIn, ManagedStdOut}; use crate::durable_host::wasm_rpc::UriExtensions; @@ -98,8 +98,8 @@ use golem_common::retries::get_delay; /// Partial implementation of the WorkerCtx interfaces for adding durable execution to workers. pub struct DurableWorkerCtx { - table: ResourceTable, - wasi: WasiCtx, + table: Arc>, // Required because of the dropped Sync constraints in https://github.com/bytecodealliance/wasmtime/pull/7802 + wasi: Arc>, // Required because of the dropped Sync constraints in https://github.com/bytecodealliance/wasmtime/pull/7802 wasi_http: WasiHttpCtx, pub owned_worker_id: OwnedWorkerId, pub public_state: PublicDurableWorkerState, @@ -138,8 +138,6 @@ impl DurableWorkerCtx { "Created temporary file system root at {:?}", temp_dir.path() ); - let root_dir = cap_std::fs::Dir::open_ambient_dir(temp_dir.path(), ambient_authority()) - .map_err(|e| GolemError::runtime(format!("Failed to open temporary directory: {e}")))?; debug!( "Worker {} initialized with deleted regions {}", @@ -156,7 +154,6 @@ impl DurableWorkerCtx { wasi_host::create_context( &worker_config.args, &worker_config.env, - root_dir, temp_dir.path().to_path_buf(), stdin, stdout, @@ -164,10 +161,10 @@ impl DurableWorkerCtx { |duration| anyhow!(SuspendForSleep(duration)), config.suspend.suspend_after, |wasi, table| { - let wasi_http = WasiHttpCtx; + let wasi_http = WasiHttpCtx::new(); DurableWorkerCtx { - table, - wasi, + table: Arc::new(Mutex::new(table)), + wasi: Arc::new(Mutex::new(wasi)), wasi_http, owned_worker_id: owned_worker_id.clone(), public_state: PublicDurableWorkerState { @@ -201,8 +198,18 @@ impl DurableWorkerCtx { .map_err(|e| GolemError::runtime(format!("Could not create WASI context: {e}"))) } - pub fn get_public_state(&self) -> &PublicDurableWorkerState { - &self.public_state + fn table(&mut self) -> &mut ResourceTable { + Arc::get_mut(&mut self.table) + .expect("ResourceTable is shared and cannot be borrowed mutably") + .get_mut() + .expect("ResourceTable mutex must never fail") + } + + fn ctx(&mut self) -> &mut WasiCtx { + Arc::get_mut(&mut self.wasi) + .expect("WasiCtx is shared and cannot be borrowed mutably") + .get_mut() + .expect("WasiCtx mutex must never fail") } pub fn worker_id(&self) -> &WorkerId { @@ -1704,20 +1711,12 @@ impl Error for SuspendForSleep {} // This wrapper forces the compiler to choose the wasmtime_wasi implementations for T: WasiView impl<'a, Ctx: WorkerCtx> WasiView for DurableWorkerCtxWasiView<'a, Ctx> { - fn table(&self) -> &ResourceTable { - &self.0.table - } - - fn table_mut(&mut self) -> &mut ResourceTable { - &mut self.0.table - } - - fn ctx(&self) -> &WasiCtx { - &self.0.wasi + fn table(&mut self) -> &mut ResourceTable { + self.0.table() } - fn ctx_mut(&mut self) -> &mut WasiCtx { - &mut self.0.wasi + fn ctx(&mut self) -> &mut WasiCtx { + self.0.ctx() } } @@ -1727,13 +1726,17 @@ impl<'a, Ctx: WorkerCtx> WasiHttpView for DurableWorkerCtxWasiHttpView<'a, Ctx> } fn table(&mut self) -> &mut ResourceTable { - &mut self.0.table + Arc::get_mut(&mut self.0.table) + .expect("ResourceTable is shared and cannot be borrowed mutably") + .get_mut() + .expect("ResourceTable mutex must never fail") } fn send_request( &mut self, - request: OutgoingRequest, - ) -> anyhow::Result> + request: hyper::Request, + config: OutgoingRequestConfig, + ) -> HttpResult where Self: Sized, { @@ -1742,12 +1745,9 @@ impl<'a, Ctx: WorkerCtx> WasiHttpView for DurableWorkerCtxWasiHttpView<'a, Ctx> // FutureIncomingResponse because it is possible that there wasn't any response recorded in the oplog. // If that is the case, the request has to be sent as soon as we get into live mode and trying to await // or poll the response future. - let fut = self - .table() - .push(HostFutureIncomingResponse::deferred(request))?; - Ok(fut) + Ok(HostFutureIncomingResponse::deferred(request, config)) } else { - default_send_request(self, request) + Ok(default_send_request(request, config)) } } } diff --git a/golem-worker-executor-base/src/durable_host/random/insecure.rs b/golem-worker-executor-base/src/durable_host/random/insecure.rs index fc694a9145..497a8c018e 100644 --- a/golem-worker-executor-base/src/durable_host/random/insecure.rs +++ b/golem-worker-executor-base/src/durable_host/random/insecure.rs @@ -19,7 +19,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::random::insecure::Host; +use wasmtime_wasi::bindings::random::insecure::Host; #[async_trait] impl Host for DurableWorkerCtx { @@ -49,3 +49,14 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get_insecure_random_bytes(&mut self, len: u64) -> anyhow::Result> { + (*self).get_insecure_random_bytes(len).await + } + + async fn get_insecure_random_u64(&mut self) -> anyhow::Result { + (*self).get_insecure_random_u64().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/random/insecure_seed.rs b/golem-worker-executor-base/src/durable_host/random/insecure_seed.rs index bb3e72f149..9dd65753a2 100644 --- a/golem-worker-executor-base/src/durable_host/random/insecure_seed.rs +++ b/golem-worker-executor-base/src/durable_host/random/insecure_seed.rs @@ -19,7 +19,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::random::insecure_seed::Host; +use wasmtime_wasi::bindings::random::insecure_seed::Host; #[async_trait] impl Host for DurableWorkerCtx { @@ -34,3 +34,10 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn insecure_seed(&mut self) -> anyhow::Result<(u64, u64)> { + (*self).insecure_seed().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/random/random.rs b/golem-worker-executor-base/src/durable_host/random/random.rs index a0e809aa73..c449191c21 100644 --- a/golem-worker-executor-base/src/durable_host/random/random.rs +++ b/golem-worker-executor-base/src/durable_host/random/random.rs @@ -19,7 +19,7 @@ use crate::durable_host::{Durability, DurableWorkerCtx}; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::wasi::random::random::Host; +use wasmtime_wasi::bindings::random::random::Host; #[async_trait] impl Host for DurableWorkerCtx { @@ -47,3 +47,14 @@ impl Host for DurableWorkerCtx { .await } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn get_random_bytes(&mut self, len: u64) -> anyhow::Result> { + (*self).get_random_bytes(len).await + } + + async fn get_random_u64(&mut self) -> anyhow::Result { + (*self).get_random_u64().await + } +} diff --git a/golem-worker-executor-base/src/durable_host/serialized.rs b/golem-worker-executor-base/src/durable_host/serialized.rs index a716ed5b48..375ab93ce6 100644 --- a/golem-worker-executor-base/src/durable_host/serialized.rs +++ b/golem-worker-executor-base/src/durable_host/serialized.rs @@ -19,9 +19,9 @@ use anyhow::anyhow; use bincode::{Decode, Encode}; use std::ops::Add; use std::time::{Duration, SystemTime}; -use wasmtime_wasi::preview2::bindings::sockets::ip_name_lookup::IpAddress; -use wasmtime_wasi::preview2::bindings::{filesystem, sockets}; -use wasmtime_wasi::preview2::{FsError, SocketError, StreamError}; +use wasmtime_wasi::bindings::sockets::ip_name_lookup::IpAddress; +use wasmtime_wasi::bindings::{filesystem, sockets}; +use wasmtime_wasi::{FsError, SocketError, StreamError}; #[derive(Debug, Clone, Encode, Decode)] pub struct SerializableDateTime { @@ -29,10 +29,8 @@ pub struct SerializableDateTime { nanoseconds: u32, } -impl From - for SerializableDateTime -{ - fn from(value: wasmtime_wasi::preview2::bindings::clocks::wall_clock::Datetime) -> Self { +impl From for SerializableDateTime { + fn from(value: wasmtime_wasi::bindings::clocks::wall_clock::Datetime) -> Self { Self { seconds: value.seconds, nanoseconds: value.nanoseconds, @@ -40,9 +38,7 @@ impl From } } -impl From - for wasmtime_wasi::preview2::bindings::clocks::wall_clock::Datetime -{ +impl From for wasmtime_wasi::bindings::clocks::wall_clock::Datetime { fn from(value: SerializableDateTime) -> Self { Self { seconds: value.seconds, @@ -552,15 +548,14 @@ mod tests { use std::ops::Add; use std::time::{Duration, SystemTime}; use uuid::Uuid; - use wasmtime_wasi::preview2::bindings::sockets::network::IpAddress; - use wasmtime_wasi::preview2::bindings::{filesystem, sockets}; - use wasmtime_wasi::preview2::{FsError, SocketError, StreamError}; + use wasmtime_wasi::bindings::sockets::network::IpAddress; + use wasmtime_wasi::bindings::{filesystem, sockets}; + use wasmtime_wasi::{FsError, SocketError, StreamError}; fn datetime_strat( - ) -> impl Strategy - { + ) -> impl Strategy { (0..(u64::MAX / 1_000_000_000), 0..999_999_999u32).prop_map(|(seconds, nanoseconds)| { - wasmtime_wasi::preview2::bindings::clocks::wall_clock::Datetime { + wasmtime_wasi::bindings::clocks::wall_clock::Datetime { seconds, nanoseconds, } @@ -736,7 +731,7 @@ mod tests { #[test] fn roundtrip_wall_clock_datetime(value in datetime_strat()) { let serialized: SerializableDateTime = value.into(); - let result: wasmtime_wasi::preview2::bindings::clocks::wall_clock::Datetime = serialized.into(); + let result: wasmtime_wasi::bindings::clocks::wall_clock::Datetime = serialized.into(); prop_assert_eq!(value.seconds, result.seconds); prop_assert_eq!(value.nanoseconds, result.nanoseconds); } diff --git a/golem-worker-executor-base/src/durable_host/sockets/instance_network.rs b/golem-worker-executor-base/src/durable_host/sockets/instance_network.rs index 3df95b4fe6..4d889bb571 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/instance_network.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/instance_network.rs @@ -18,7 +18,7 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::instance_network::{Host, Network}; +use wasmtime_wasi::bindings::sockets::instance_network::{Host, Network}; #[async_trait] impl Host for DurableWorkerCtx { @@ -27,3 +27,10 @@ impl Host for DurableWorkerCtx { Host::instance_network(&mut self.as_wasi_view()) } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn instance_network(&mut self) -> anyhow::Result> { + (*self).instance_network() + } +} diff --git a/golem-worker-executor-base/src/durable_host/sockets/ip_name_lookup.rs b/golem-worker-executor-base/src/durable_host/sockets/ip_name_lookup.rs index e25917fb24..14db5b3c08 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/ip_name_lookup.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/ip_name_lookup.rs @@ -21,11 +21,11 @@ use crate::error::GolemError; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; use golem_common::model::oplog::WrappedFunctionType; -use wasmtime_wasi::preview2::bindings::sockets::network::ErrorCode; -use wasmtime_wasi::preview2::bindings::wasi::sockets::ip_name_lookup::{ +use wasmtime_wasi::bindings::sockets::ip_name_lookup::{ Host, HostResolveAddressStream, IpAddress, Network, Pollable, ResolveAddressStream, }; -use wasmtime_wasi::preview2::{SocketError, Subscribe}; +use wasmtime_wasi::bindings::sockets::network::ErrorCode; +use wasmtime_wasi::{SocketError, Subscribe}; #[async_trait] impl HostResolveAddressStream for DurableWorkerCtx { @@ -78,7 +78,39 @@ impl Host for DurableWorkerCtx { .await; let stream = ResolveAddressStream::Done(Ok(addresses?.into_iter())); - Ok(self.table.push(stream)?) + Ok(self.table().push(stream)?) + } +} + +#[async_trait] +impl HostResolveAddressStream for &mut DurableWorkerCtx { + fn resolve_next_address( + &mut self, + self_: Resource, + ) -> Result, SocketError> { + (*self).resolve_next_address(self_) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + (*self).subscribe(self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + async fn resolve_addresses( + &mut self, + network: Resource, + name: String, + ) -> Result, SocketError> { + (*self).resolve_addresses(network, name).await } } @@ -88,7 +120,7 @@ async fn resolve_and_drain_addresses( name: String, ) -> Result, SocketError> { let stream = Host::resolve_addresses(&mut ctx.as_wasi_view(), network, name).await?; - let stream = ctx.table.delete(stream)?; + let stream = ctx.table().delete(stream)?; let addresses = drain_resolve_address_stream(stream).await?; Ok(addresses) } diff --git a/golem-worker-executor-base/src/durable_host/sockets/network.rs b/golem-worker-executor-base/src/durable_host/sockets/network.rs index 3998044ed6..9c825a14fc 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/network.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/network.rs @@ -18,10 +18,8 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::network::{ - ErrorCode, Host, HostNetwork, Network, -}; -use wasmtime_wasi::preview2::SocketError; +use wasmtime_wasi::bindings::sockets::network::{ErrorCode, Host, HostNetwork, Network}; +use wasmtime_wasi::SocketError; impl HostNetwork for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { @@ -37,3 +35,16 @@ impl Host for DurableWorkerCtx { Host::convert_error_code(&mut self.as_wasi_view(), err) } } + +impl HostNetwork for &mut DurableWorkerCtx { + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn convert_error_code(&mut self, err: SocketError) -> anyhow::Result { + (*self).convert_error_code(err) + } +} diff --git a/golem-worker-executor-base/src/durable_host/sockets/tcp.rs b/golem-worker-executor-base/src/durable_host/sockets/tcp.rs index 86b2846cca..c6634e648b 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/tcp.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/tcp.rs @@ -18,11 +18,11 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::tcp::{ +use wasmtime_wasi::bindings::sockets::tcp::{ Duration, Host, HostTcpSocket, InputStream, IpAddressFamily, IpSocketAddress, Network, OutputStream, Pollable, ShutdownType, TcpSocket, }; -use wasmtime_wasi::preview2::SocketError; +use wasmtime_wasi::SocketError; #[async_trait] impl HostTcpSocket for DurableWorkerCtx { @@ -238,3 +238,189 @@ impl HostTcpSocket for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostTcpSocket for &mut DurableWorkerCtx { + fn start_bind( + &mut self, + self_: Resource, + network: Resource, + local_address: IpSocketAddress, + ) -> Result<(), SocketError> { + (*self).start_bind(self_, network, local_address) + } + + fn finish_bind(&mut self, self_: Resource) -> Result<(), SocketError> { + (*self).finish_bind(self_) + } + + fn start_connect( + &mut self, + self_: Resource, + network: Resource, + remote_address: IpSocketAddress, + ) -> Result<(), SocketError> { + (*self).start_connect(self_, network, remote_address) + } + + fn finish_connect( + &mut self, + self_: Resource, + ) -> Result<(Resource, Resource), SocketError> { + (*self).finish_connect(self_) + } + + fn start_listen(&mut self, self_: Resource) -> Result<(), SocketError> { + (*self).start_listen(self_) + } + + fn finish_listen(&mut self, self_: Resource) -> Result<(), SocketError> { + (*self).finish_listen(self_) + } + + fn accept( + &mut self, + self_: Resource, + ) -> Result< + ( + Resource, + Resource, + Resource, + ), + SocketError, + > { + (*self).accept(self_) + } + + fn local_address( + &mut self, + self_: Resource, + ) -> Result { + (*self).local_address(self_) + } + + fn remote_address( + &mut self, + self_: Resource, + ) -> Result { + (*self).remote_address(self_) + } + + fn is_listening(&mut self, self_: Resource) -> anyhow::Result { + (*self).is_listening(self_) + } + + fn address_family(&mut self, self_: Resource) -> anyhow::Result { + (*self).address_family(self_) + } + + fn set_listen_backlog_size( + &mut self, + self_: Resource, + value: u64, + ) -> Result<(), SocketError> { + (*self).set_listen_backlog_size(self_, value) + } + + fn keep_alive_enabled(&mut self, self_: Resource) -> Result { + (*self).keep_alive_enabled(self_) + } + + fn set_keep_alive_enabled( + &mut self, + self_: Resource, + value: bool, + ) -> Result<(), SocketError> { + (*self).set_keep_alive_enabled(self_, value) + } + + fn keep_alive_idle_time( + &mut self, + self_: Resource, + ) -> Result { + (*self).keep_alive_idle_time(self_) + } + + fn set_keep_alive_idle_time( + &mut self, + self_: Resource, + value: Duration, + ) -> Result<(), SocketError> { + (*self).set_keep_alive_idle_time(self_, value) + } + + fn keep_alive_interval(&mut self, self_: Resource) -> Result { + (*self).keep_alive_interval(self_) + } + + fn set_keep_alive_interval( + &mut self, + self_: Resource, + value: Duration, + ) -> Result<(), SocketError> { + (*self).set_keep_alive_interval(self_, value) + } + + fn keep_alive_count(&mut self, self_: Resource) -> Result { + (*self).keep_alive_count(self_) + } + + fn set_keep_alive_count( + &mut self, + self_: Resource, + value: u32, + ) -> Result<(), SocketError> { + (*self).set_keep_alive_count(self_, value) + } + + fn hop_limit(&mut self, self_: Resource) -> Result { + (*self).hop_limit(self_) + } + + fn set_hop_limit(&mut self, self_: Resource, value: u8) -> Result<(), SocketError> { + (*self).set_hop_limit(self_, value) + } + + fn receive_buffer_size(&mut self, self_: Resource) -> Result { + (*self).receive_buffer_size(self_) + } + + fn set_receive_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> Result<(), SocketError> { + (*self).set_receive_buffer_size(self_, value) + } + + fn send_buffer_size(&mut self, self_: Resource) -> Result { + (*self).send_buffer_size(self_) + } + + fn set_send_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> Result<(), SocketError> { + (*self).set_send_buffer_size(self_, value) + } + + fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { + (*self).subscribe(self_) + } + + fn shutdown( + &mut self, + self_: Resource, + shutdown_type: ShutdownType, + ) -> Result<(), SocketError> { + (*self).shutdown(self_, shutdown_type) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + (*self).drop(rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/sockets/tcp_create_socket.rs b/golem-worker-executor-base/src/durable_host/sockets/tcp_create_socket.rs index 38eddf65e2..9b17304bd8 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/tcp_create_socket.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/tcp_create_socket.rs @@ -18,10 +18,8 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::tcp_create_socket::{ - Host, IpAddressFamily, TcpSocket, -}; -use wasmtime_wasi::preview2::SocketError; +use wasmtime_wasi::bindings::sockets::tcp_create_socket::{Host, IpAddressFamily, TcpSocket}; +use wasmtime_wasi::SocketError; #[async_trait] impl Host for DurableWorkerCtx { @@ -33,3 +31,13 @@ impl Host for DurableWorkerCtx { Host::create_tcp_socket(&mut self.as_wasi_view(), address_family) } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn create_tcp_socket( + &mut self, + address_family: IpAddressFamily, + ) -> Result, SocketError> { + (*self).create_tcp_socket(address_family) + } +} diff --git a/golem-worker-executor-base/src/durable_host/sockets/udp.rs b/golem-worker-executor-base/src/durable_host/sockets/udp.rs index 4f8dbe44bd..d2bd8e5960 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/udp.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/udp.rs @@ -18,12 +18,12 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::udp::{ +use wasmtime_wasi::bindings::sockets::udp::{ Host, HostIncomingDatagramStream, HostOutgoingDatagramStream, HostUdpSocket, IncomingDatagram, IncomingDatagramStream, IpAddressFamily, IpSocketAddress, Network, OutgoingDatagram, OutgoingDatagramStream, Pollable, UdpSocket, }; -use wasmtime_wasi::preview2::SocketError; +use wasmtime_wasi::SocketError; impl HostUdpSocket for DurableWorkerCtx { fn start_bind( @@ -185,3 +185,146 @@ impl HostOutgoingDatagramStream for DurableWorkerCtx { #[async_trait] impl Host for DurableWorkerCtx {} + +#[async_trait] +impl HostUdpSocket for &mut DurableWorkerCtx { + fn start_bind( + &mut self, + self_: Resource, + network: Resource, + local_address: IpSocketAddress, + ) -> Result<(), SocketError> { + (*self).start_bind(self_, network, local_address) + } + + fn finish_bind(&mut self, self_: Resource) -> Result<(), SocketError> { + (*self).finish_bind(self_) + } + + fn stream( + &mut self, + self_: Resource, + remote_address: Option, + ) -> Result< + ( + Resource, + Resource, + ), + SocketError, + > { + (*self).stream(self_, remote_address) + } + + fn local_address( + &mut self, + self_: Resource, + ) -> Result { + (*self).local_address(self_) + } + + fn remote_address( + &mut self, + self_: Resource, + ) -> Result { + (*self).remote_address(self_) + } + + fn address_family(&mut self, self_: Resource) -> anyhow::Result { + (*self).address_family(self_) + } + + fn unicast_hop_limit(&mut self, self_: Resource) -> Result { + (*self).unicast_hop_limit(self_) + } + + fn set_unicast_hop_limit( + &mut self, + self_: Resource, + value: u8, + ) -> Result<(), SocketError> { + (*self).set_unicast_hop_limit(self_, value) + } + + fn receive_buffer_size(&mut self, self_: Resource) -> Result { + (*self).receive_buffer_size(self_) + } + + fn set_receive_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> Result<(), SocketError> { + (*self).set_receive_buffer_size(self_, value) + } + + fn send_buffer_size(&mut self, self_: Resource) -> Result { + (*self).send_buffer_size(self_) + } + + fn set_send_buffer_size( + &mut self, + self_: Resource, + value: u64, + ) -> Result<(), SocketError> { + (*self).set_send_buffer_size(self_, value) + } + + fn subscribe(&mut self, self_: Resource) -> anyhow::Result> { + HostUdpSocket::subscribe(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostUdpSocket::drop(*self, rep) + } +} + +#[async_trait] +impl HostOutgoingDatagramStream for &mut DurableWorkerCtx { + fn check_send(&mut self, self_: Resource) -> Result { + (*self).check_send(self_) + } + + fn send( + &mut self, + self_: Resource, + datagrams: Vec, + ) -> Result { + (*self).send(self_, datagrams) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostOutgoingDatagramStream::subscribe(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostOutgoingDatagramStream::drop(*self, rep) + } +} + +#[async_trait] +impl HostIncomingDatagramStream for &mut DurableWorkerCtx { + fn receive( + &mut self, + self_: Resource, + max_results: u64, + ) -> Result, SocketError> { + (*self).receive(self_, max_results) + } + + fn subscribe( + &mut self, + self_: Resource, + ) -> anyhow::Result> { + HostIncomingDatagramStream::subscribe(*self, self_) + } + + fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { + HostIncomingDatagramStream::drop(*self, rep) + } +} + +#[async_trait] +impl Host for &mut DurableWorkerCtx {} diff --git a/golem-worker-executor-base/src/durable_host/sockets/udp_create_socket.rs b/golem-worker-executor-base/src/durable_host/sockets/udp_create_socket.rs index 8ba9fc6c85..e6690a1dc3 100644 --- a/golem-worker-executor-base/src/durable_host/sockets/udp_create_socket.rs +++ b/golem-worker-executor-base/src/durable_host/sockets/udp_create_socket.rs @@ -18,10 +18,8 @@ use wasmtime::component::Resource; use crate::durable_host::DurableWorkerCtx; use crate::metrics::wasm::record_host_function_call; use crate::workerctx::WorkerCtx; -use wasmtime_wasi::preview2::bindings::wasi::sockets::udp_create_socket::{ - Host, IpAddressFamily, UdpSocket, -}; -use wasmtime_wasi::preview2::SocketError; +use wasmtime_wasi::bindings::sockets::udp_create_socket::{Host, IpAddressFamily, UdpSocket}; +use wasmtime_wasi::SocketError; #[async_trait] impl Host for DurableWorkerCtx { @@ -33,3 +31,13 @@ impl Host for DurableWorkerCtx { Host::create_udp_socket(&mut self.as_wasi_view(), address_family) } } + +#[async_trait] +impl Host for &mut DurableWorkerCtx { + fn create_udp_socket( + &mut self, + address_family: IpAddressFamily, + ) -> Result, SocketError> { + (*self).create_udp_socket(address_family) + } +} diff --git a/golem-worker-executor-base/src/durable_host/wasm_rpc/mod.rs b/golem-worker-executor-base/src/durable_host/wasm_rpc/mod.rs index 78b34d21b9..d58be8a327 100644 --- a/golem-worker-executor-base/src/durable_host/wasm_rpc/mod.rs +++ b/golem-worker-executor-base/src/durable_host/wasm_rpc/mod.rs @@ -28,7 +28,7 @@ use std::str::FromStr; use tracing::{debug, error}; use uuid::Uuid; use wasmtime::component::Resource; -use wasmtime_wasi::preview2::bindings::cli::environment::Host; +use wasmtime_wasi::bindings::cli::environment::Host; #[async_trait] impl HostWasmRpc for DurableWorkerCtx { @@ -40,7 +40,7 @@ impl HostWasmRpc for DurableWorkerCtx { let remote_worker_id = OwnedWorkerId::new(&self.owned_worker_id.account_id, &remote_worker_id); let demand = self.rpc().create_demand(&remote_worker_id).await; - let entry = self.table.push(WasmRpcEntry { + let entry = self.table().push(WasmRpcEntry { payload: Box::new(WasmRpcEntryPayload { demand, remote_worker_id, @@ -63,7 +63,7 @@ impl HostWasmRpc for DurableWorkerCtx { ) -> anyhow::Result> { record_host_function_call("golem::rpc::wasm-rpc", "invoke-and-await"); - let entry = self.table.get(&self_)?; + let entry = self.table().get(&self_)?; let payload = entry.payload.downcast_ref::().unwrap(); let remote_worker_id = payload.remote_worker_id.clone(); @@ -129,7 +129,7 @@ impl HostWasmRpc for DurableWorkerCtx { ) -> anyhow::Result> { record_host_function_call("golem::rpc::wasm-rpc", "invoke"); - let entry = self.table.get(&self_)?; + let entry = self.table().get(&self_)?; let payload = entry.payload.downcast_ref::().unwrap(); let remote_worker_id = payload.remote_worker_id.clone(); @@ -187,7 +187,7 @@ impl HostWasmRpc for DurableWorkerCtx { fn drop(&mut self, rep: Resource) -> anyhow::Result<()> { record_host_function_call("golem::rpc::wasm-rpc", "drop"); - let _ = self.table.delete(rep)?; + let _ = self.table().delete(rep)?; Ok(()) } } diff --git a/golem-worker-executor-base/src/invocation.rs b/golem-worker-executor-base/src/invocation.rs index 3b6ef366cf..3b24a5c7ca 100644 --- a/golem-worker-executor-base/src/invocation.rs +++ b/golem-worker-executor-base/src/invocation.rs @@ -369,10 +369,11 @@ async fn invoke( match results { Ok(results) => { + let types = function.results(&store); let mut output: Vec = Vec::new(); - for result in results.iter() { + for (val, typ) in results.iter().zip(types.iter()) { let result_value = - encode_output(result, store.data_mut()).map_err(GolemError::from)?; + encode_output(val, typ, store.data_mut()).map_err(GolemError::from)?; output.push(result_value); } diff --git a/golem-worker-executor-base/src/metrics.rs b/golem-worker-executor-base/src/metrics.rs index fe6e66fe9d..a90f421426 100644 --- a/golem-worker-executor-base/src/metrics.rs +++ b/golem-worker-executor-base/src/metrics.rs @@ -30,7 +30,7 @@ lazy_static! { pub fn register_all() -> Registry { VERSION_INFO - .with_label_values(&[version(), wasmtime_runtime::VERSION]) + .with_label_values(&[version(), wasmtime::VERSION]) .inc(); default_registry().clone() diff --git a/golem-worker-executor-base/src/preview2/mod.rs b/golem-worker-executor-base/src/preview2/mod.rs index 89bd56983a..e542871517 100644 --- a/golem-worker-executor-base/src/preview2/mod.rs +++ b/golem-worker-executor-base/src/preview2/mod.rs @@ -14,7 +14,7 @@ include!(concat!(env!("OUT_DIR"), "/preview2_mod.rs")); -pub type InputStream = wasmtime_wasi::preview2::InputStream; -pub type OutputStream = wasmtime_wasi::preview2::OutputStream; +pub type InputStream = wasmtime_wasi::InputStream; +pub type OutputStream = wasmtime_wasi::OutputStream; -pub type Pollable = wasmtime_wasi::preview2::Pollable; +pub type Pollable = wasmtime_wasi::Pollable; diff --git a/golem-worker-executor-base/src/storage/blob/s3.rs b/golem-worker-executor-base/src/storage/blob/s3.rs index 301bc2ba9e..9036ef7ae5 100644 --- a/golem-worker-executor-base/src/storage/blob/s3.rs +++ b/golem-worker-executor-base/src/storage/blob/s3.rs @@ -39,7 +39,7 @@ impl S3BlobStorage { let region = config.region.clone(); let mut config_builder = - aws_config::defaults(BehaviorVersion::v2023_11_09()).region(Region::new(region)); + aws_config::defaults(BehaviorVersion::v2024_03_28()).region(Region::new(region)); if let Some(endpoint_url) = &config.aws_endpoint_url { info!( diff --git a/golem-worker-executor-base/src/wasi_host/helpers/clocks.rs b/golem-worker-executor-base/src/wasi_host/helpers/clocks.rs index ff202979cf..c4fa4c4643 100644 --- a/golem-worker-executor-base/src/wasi_host/helpers/clocks.rs +++ b/golem-worker-executor-base/src/wasi_host/helpers/clocks.rs @@ -15,7 +15,7 @@ use cap_std::time::SystemClock; use cap_std::{ambient_authority, AmbientAuthority}; use cap_time_ext::SystemClockExt; -use wasmtime_wasi::preview2::HostMonotonicClock; +use wasmtime_wasi::HostMonotonicClock; /// Using a SystemClock as a monotonic clock so instants are reusable between persisted executions pub struct MonotonicClock { diff --git a/golem-worker-executor-base/src/wasi_host/logging/logging.rs b/golem-worker-executor-base/src/wasi_host/logging/logging.rs index 2b3d80c674..8d817c7e64 100644 --- a/golem-worker-executor-base/src/wasi_host/logging/logging.rs +++ b/golem-worker-executor-base/src/wasi_host/logging/logging.rs @@ -14,7 +14,7 @@ use async_trait::async_trait; use tracing::debug; -use wasmtime_wasi::preview2::WasiView; +use wasmtime_wasi::WasiView; use crate::preview2::wasi::logging::logging::{Host, Level}; diff --git a/golem-worker-executor-base/src/wasi_host/mod.rs b/golem-worker-executor-base/src/wasi_host/mod.rs index 66ac89d2bd..885f6a1589 100644 --- a/golem-worker-executor-base/src/wasi_host/mod.rs +++ b/golem-worker-executor-base/src/wasi_host/mod.rs @@ -15,12 +15,11 @@ use std::path::PathBuf; use std::time::Duration; -use cap_std::fs::Dir; - +use crate::durable_host::DurableWorkerCtx; +use crate::workerctx::WorkerCtx; use wasmtime::component::Linker; use wasmtime::Engine; -use wasmtime_wasi::preview2::bindings::wasi; -use wasmtime_wasi::preview2::{ +use wasmtime_wasi::{ DirPerms, FilePerms, ResourceTable, StdinStream, StdoutStream, WasiCtx, WasiCtxBuilder, }; @@ -28,96 +27,60 @@ pub mod helpers; pub mod logging; pub mod managed_stdio; -pub fn create_linker( +pub fn create_linker( engine: &Engine, - get: impl Fn(&mut T) -> &mut U + Send + Sync + Copy + 'static, -) -> wasmtime::Result> + get: F, +) -> wasmtime::Result> where - T: Send, - U: Send - + crate::preview2::wasi::blobstore::blobstore::Host - + crate::preview2::wasi::blobstore::container::Host - + crate::preview2::wasi::blobstore::types::Host - + wasi::cli::environment::Host - + wasi::cli::exit::Host - + wasi::cli::stderr::Host - + wasi::cli::stdin::Host - + wasi::cli::stdout::Host - + wasi::cli::terminal_input::Host - + wasi::cli::terminal_output::Host - + wasi::cli::terminal_stderr::Host - + wasi::cli::terminal_stdin::Host - + wasi::cli::terminal_stdout::Host - + wasi::clocks::monotonic_clock::Host - + wasi::clocks::wall_clock::Host - + wasi::filesystem::preopens::Host - + wasi::filesystem::types::Host - + wasmtime_wasi_http::bindings::http::outgoing_handler::Host - + wasmtime_wasi_http::bindings::http::types::Host - + wasi::io::error::Host - + wasi::io::streams::Host - + wasi::io::poll::Host - + crate::preview2::wasi::keyvalue::atomic::Host - + crate::preview2::wasi::keyvalue::eventual_batch::Host - + crate::preview2::wasi::keyvalue::cache::Host - + crate::preview2::wasi::keyvalue::eventual::Host - + crate::preview2::wasi::keyvalue::types::Host - + crate::preview2::wasi::keyvalue::wasi_keyvalue_error::Host - + crate::preview2::wasi::logging::logging::Host - + wasi::random::random::Host - + wasi::random::insecure::Host - + wasi::random::insecure_seed::Host - + wasi::sockets::instance_network::Host - + wasi::sockets::ip_name_lookup::Host - + wasi::sockets::network::Host - + wasi::sockets::tcp::Host - + wasi::sockets::tcp_create_socket::Host - + wasi::sockets::udp::Host - + wasi::sockets::udp_create_socket::Host, + F: for<'a> Fn(&'a mut Ctx) -> &'a mut DurableWorkerCtx + Send, + F: Copy + Send + Sync + 'static, { let mut linker = Linker::new(engine); - wasmtime_wasi::preview2::bindings::cli::environment::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::exit::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::stderr::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::stdin::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::stdout::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::terminal_input::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::terminal_output::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::terminal_stderr::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::terminal_stdin::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::cli::terminal_stdout::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::clocks::monotonic_clock::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::clocks::wall_clock::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::filesystem::preopens::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::filesystem::types::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::io::error::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::io::poll::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::io::streams::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::random::random::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::random::insecure::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::random::insecure_seed::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::instance_network::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::ip_name_lookup::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::network::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::tcp::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::tcp_create_socket::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::udp::add_to_linker(&mut linker, get)?; - wasmtime_wasi::preview2::bindings::sockets::udp_create_socket::add_to_linker(&mut linker, get)?; + wasmtime_wasi::bindings::cli::environment::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::exit::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::stderr::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::stdin::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::stdout::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::terminal_input::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::terminal_output::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::terminal_stderr::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::terminal_stdin::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::cli::terminal_stdout::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::clocks::monotonic_clock::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::clocks::wall_clock::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::filesystem::preopens::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::filesystem::types::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::io::error::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::io::poll::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::io::streams::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::random::random::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::random::insecure::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::random::insecure_seed::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::instance_network::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::ip_name_lookup::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::network::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::tcp::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::tcp_create_socket::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::udp::add_to_linker_get_host(&mut linker, get)?; + wasmtime_wasi::bindings::sockets::udp_create_socket::add_to_linker_get_host(&mut linker, get)?; - wasmtime_wasi_http::bindings::wasi::http::outgoing_handler::add_to_linker(&mut linker, get)?; - wasmtime_wasi_http::bindings::wasi::http::types::add_to_linker(&mut linker, get)?; + wasmtime_wasi_http::bindings::wasi::http::outgoing_handler::add_to_linker_get_host( + &mut linker, + get, + )?; + wasmtime_wasi_http::bindings::wasi::http::types::add_to_linker_get_host(&mut linker, get)?; - crate::preview2::wasi::blobstore::blobstore::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::blobstore::container::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::blobstore::types::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::atomic::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::cache::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::eventual::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::eventual_batch::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::types::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::keyvalue::wasi_keyvalue_error::add_to_linker(&mut linker, get)?; - crate::preview2::wasi::logging::logging::add_to_linker(&mut linker, get)?; + crate::preview2::wasi::blobstore::blobstore::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::blobstore::container::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::blobstore::types::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::atomic::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::cache::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::eventual::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::eventual_batch::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::types::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::keyvalue::wasi_keyvalue_error::add_to_linker_get_host(&mut linker, get)?; + crate::preview2::wasi::logging::logging::add_to_linker_get_host(&mut linker, get)?; Ok(linker) } @@ -125,8 +88,7 @@ where pub fn create_context( args: &[impl AsRef], env: &[(impl AsRef, impl AsRef)], - root_dir: Dir, - root_dir_path: PathBuf, + root_dir: PathBuf, stdin: impl StdinStream + Sized + 'static, stdout: impl StdoutStream + Sized + 'static, stderr: impl StdoutStream + Sized + 'static, @@ -145,22 +107,8 @@ where .stdout(stdout) .stderr(stderr) .monotonic_clock(helpers::clocks::monotonic_clock()) - .preopened_dir( - root_dir - .try_clone() - .expect("Failed to clone root directory handle"), - DirPerms::all(), - FilePerms::all(), - "/", - root_dir_path.clone(), - ) - .preopened_dir( - root_dir, - DirPerms::all(), - FilePerms::all(), - ".", - root_dir_path, - ) + .preopened_dir(root_dir.clone(), "/", DirPerms::all(), FilePerms::all())? + .preopened_dir(root_dir, ".", DirPerms::all(), FilePerms::all())? .set_suspend(suspend_threshold, suspend_signal) .allow_ip_name_lookup(true) .build(); diff --git a/golem-worker-executor-base/tests/api.rs b/golem-worker-executor-base/tests/api.rs index 26be1caea3..31232daaa0 100644 --- a/golem-worker-executor-base/tests/api.rs +++ b/golem-worker-executor-base/tests/api.rs @@ -45,7 +45,7 @@ use tokio::time::sleep; use tonic::transport::Body; use tracing::debug; use warp::Filter; -use wasmtime_wasi::preview2::spawn; +use wasmtime_wasi::runtime::spawn; #[tokio::test] #[tracing::instrument] diff --git a/golem-worker-executor-base/tests/blob_storage.rs b/golem-worker-executor-base/tests/blob_storage.rs index 306c0d96c6..d53c497859 100644 --- a/golem-worker-executor-base/tests/blob_storage.rs +++ b/golem-worker-executor-base/tests/blob_storage.rs @@ -16,13 +16,13 @@ use aws_config::meta::region::RegionProviderChain; use aws_config::BehaviorVersion; use aws_sdk_s3::config::Credentials; use aws_sdk_s3::Client; -use golem_common::model::{AccountId, ComponentId}; use once_cell::sync::Lazy; use tempfile::{tempdir, TempDir}; use testcontainers::Container; use testcontainers_modules::minio::MinIO; use uuid::Uuid; +use golem_common::model::{AccountId, ComponentId}; use golem_worker_executor_base::services::golem_config::S3BlobStorageConfig; use golem_worker_executor_base::storage::blob::{ fs, memory, s3, BlobStorage, BlobStorageNamespace, @@ -325,12 +325,12 @@ impl GetBlobStorage for FsTest { } } -struct S3Test<'a> { - _container: Container<'a, MinIO>, +struct S3Test { + _container: Container<'static, MinIO>, storage: s3::S3BlobStorage, } -impl<'a> GetBlobStorage for S3Test<'a> { +impl GetBlobStorage for S3Test { fn get_blob_storage(&self) -> &dyn BlobStorage { &self.storage } diff --git a/golem-worker-executor-base/tests/common/mod.rs b/golem-worker-executor-base/tests/common/mod.rs index cb0f6679d7..7c14b974bf 100644 --- a/golem-worker-executor-base/tests/common/mod.rs +++ b/golem-worker-executor-base/tests/common/mod.rs @@ -646,7 +646,7 @@ impl WorkerCtx for TestWorkerCtx { } fn get_public_state(&self) -> &Self::PublicState { - self.durable_ctx.get_public_state() + &self.durable_ctx.public_state } fn resource_limiter(&mut self) -> &mut dyn ResourceLimiterAsync { @@ -774,18 +774,13 @@ impl Bootstrap for ServerBootstrap { } fn create_wasmtime_linker(&self, engine: &Engine) -> anyhow::Result> { - let mut linker = - create_linker::>(engine, |x| { - &mut x.durable_ctx - })?; - api::host::add_to_linker::>( - &mut linker, - |x| &mut x.durable_ctx, - )?; - golem_wasm_rpc::golem::rpc::types::add_to_linker::< - TestWorkerCtx, - DurableWorkerCtx, - >(&mut linker, |x| &mut x.durable_ctx)?; + let mut linker = create_linker(engine, get_durable_ctx)?; + api::host::add_to_linker_get_host(&mut linker, get_durable_ctx)?; + golem_wasm_rpc::golem::rpc::types::add_to_linker_get_host(&mut linker, get_durable_ctx)?; Ok(linker) } } + +fn get_durable_ctx(ctx: &mut TestWorkerCtx) -> &mut DurableWorkerCtx { + &mut ctx.durable_ctx +} diff --git a/golem-worker-executor-base/tests/wasi.rs b/golem-worker-executor-base/tests/wasi.rs index 9ed724703c..54ad63f78b 100644 --- a/golem-worker-executor-base/tests/wasi.rs +++ b/golem-worker-executor-base/tests/wasi.rs @@ -681,9 +681,8 @@ async fn failing_worker() { check!(result3.is_err()); check!(worker_error_message(&result2.clone().err().unwrap()) .starts_with("Runtime error: error while executing at wasm backtrace:")); - check!( - worker_error_message(&result2.err().unwrap()).contains("!golem:component/api#add") - ); + check!(worker_error_message(&result2.err().unwrap()) + .contains("failing_component.wasm!golem:component/api#add")); check!(worker_error_message(&result3.err().unwrap()).starts_with("Previous invocation failed")); } diff --git a/golem-worker-executor/Cargo.toml b/golem-worker-executor/Cargo.toml index dfd7819828..2d350d660a 100644 --- a/golem-worker-executor/Cargo.toml +++ b/golem-worker-executor/Cargo.toml @@ -38,6 +38,5 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true } uuid = { workspace = true } wasmtime = { workspace = true } -wasmtime-runtime = { workspace = true } wasmtime-wasi = { workspace = true } wasmtime-wasi-http = { workspace = true } diff --git a/golem-worker-executor/src/context.rs b/golem-worker-executor/src/context.rs index 8879bde664..b9c7a3fa71 100644 --- a/golem-worker-executor/src/context.rs +++ b/golem-worker-executor/src/context.rs @@ -322,7 +322,7 @@ impl WorkerCtx for Context { } fn get_public_state(&self) -> &Self::PublicState { - self.durable_ctx.get_public_state() + &self.durable_ctx.public_state } fn resource_limiter(&mut self) -> &mut dyn ResourceLimiterAsync { diff --git a/golem-worker-executor/src/lib.rs b/golem-worker-executor/src/lib.rs index 8395171bc3..66304fbbaf 100644 --- a/golem-worker-executor/src/lib.rs +++ b/golem-worker-executor/src/lib.rs @@ -131,19 +131,17 @@ impl Bootstrap for ServerBootstrap { } fn create_wasmtime_linker(&self, engine: &Engine) -> anyhow::Result> { - let mut linker = - create_linker::>(engine, |x| &mut x.durable_ctx)?; - golem::api::host::add_to_linker::>(&mut linker, |x| { - &mut x.durable_ctx - })?; - golem_wasm_rpc::golem::rpc::types::add_to_linker::>( - &mut linker, - |x| &mut x.durable_ctx, - )?; + let mut linker = create_linker(engine, get_durable_ctx)?; + golem::api::host::add_to_linker_get_host(&mut linker, get_durable_ctx)?; + golem_wasm_rpc::golem::rpc::types::add_to_linker_get_host(&mut linker, get_durable_ctx)?; Ok(linker) } } +fn get_durable_ctx(ctx: &mut Context) -> &mut DurableWorkerCtx { + &mut ctx.durable_ctx +} + pub async fn run( golem_config: GolemConfig, prometheus_registry: Registry, diff --git a/golem-worker-service-base/src/api/custom_http_request_api.rs b/golem-worker-service-base/src/api/custom_http_request_api.rs index 1b1fe394c1..949c063732 100644 --- a/golem-worker-service-base/src/api/custom_http_request_api.rs +++ b/golem-worker-service-base/src/api/custom_http_request_api.rs @@ -1,8 +1,9 @@ +use std::future::Future; use std::sync::Arc; use crate::api_definition::http::HttpApiDefinition; use crate::evaluator::{DefaultEvaluator, Evaluator, WorkerMetadataFetcher}; -use async_trait::async_trait; +use futures_util::FutureExt; use hyper::header::HOST; use poem::http::StatusCode; use poem::{Body, Endpoint, Request, Response}; @@ -115,12 +116,10 @@ impl CustomHttpRequestApi { } } -#[async_trait] impl Endpoint for CustomHttpRequestApi { type Output = Response; - async fn call(&self, req: Request) -> poem::Result { - let result = self.execute(req).await; - Ok(result) + fn call(&self, req: Request) -> impl Future> + Send { + self.execute(req).map(Ok) } } diff --git a/golem-worker-service/src/main.rs b/golem-worker-service/src/main.rs index 81de1cee5f..5e186adbb6 100644 --- a/golem-worker-service/src/main.rs +++ b/golem-worker-service/src/main.rs @@ -5,7 +5,7 @@ use golem_worker_service::{config, grpcapi}; use golem_worker_service_base::app_config::WorkerServiceBaseConfig; use golem_worker_service_base::metrics; use opentelemetry::global; -use opentelemetry_sdk::metrics::MeterProvider; +use opentelemetry_sdk::metrics::MeterProviderBuilder; use poem::listener::TcpListener; use poem::middleware::{OpenTelemetryMetrics, Tracing}; use poem::EndpointExt; @@ -94,7 +94,11 @@ fn init_tracing_metrics() { .build() .unwrap(); - global::set_meter_provider(MeterProvider::builder().with_reader(exporter).build()); + global::set_meter_provider( + MeterProviderBuilder::default() + .with_reader(exporter) + .build(), + ); tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 284465a547..e9f46d097a 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -21,7 +21,7 @@ console-subscriber = { workspace = true } ctor = { workspace = true } golem-wasm-rpc = { workspace = true } plotters = "0.3.6" -poem = { version = "2.0.0", features = ["prometheus", "opentelemetry", "test"] } +poem = { workspace = true } rand = { workspace = true } reqwest = { workspace = true } serde = { workspace = true } diff --git a/openapi/golem-service.yaml b/openapi/golem-service.yaml index ca0550b93b..295c1ddda1 100644 --- a/openapi/golem-service.yaml +++ b/openapi/golem-service.yaml @@ -2178,6 +2178,8 @@ components: type: example: ComponentDownloadFailed type: string + enum: + - ComponentDownloadFailed required: - type - $ref: '#/components/schemas/GolemErrorComponentDownloadFailed' @@ -2188,6 +2190,8 @@ components: type: example: ComponentParseFailed type: string + enum: + - ComponentParseFailed required: - type - $ref: '#/components/schemas/GolemErrorComponentParseFailed' @@ -2198,6 +2202,8 @@ components: type: example: FailedToResumeWorker type: string + enum: + - FailedToResumeWorker required: - type - $ref: '#/components/schemas/GolemErrorFailedToResumeWorker' @@ -2208,6 +2214,8 @@ components: type: example: GetLatestVersionOfComponentFailed type: string + enum: + - GetLatestVersionOfComponentFailed required: - type - $ref: '#/components/schemas/GolemErrorGetLatestVersionOfComponentFailed' @@ -2218,6 +2226,8 @@ components: type: example: Interrupted type: string + enum: + - Interrupted required: - type - $ref: '#/components/schemas/GolemErrorInterrupted' @@ -2228,6 +2238,8 @@ components: type: example: InvalidAccount type: string + enum: + - InvalidAccount required: - type - $ref: '#/components/schemas/GolemErrorInvalidAccount' @@ -2238,6 +2250,8 @@ components: type: example: InvalidRequest type: string + enum: + - InvalidRequest required: - type - $ref: '#/components/schemas/GolemErrorInvalidRequest' @@ -2248,6 +2262,8 @@ components: type: example: InvalidShardId type: string + enum: + - InvalidShardId required: - type - $ref: '#/components/schemas/GolemErrorInvalidShardId' @@ -2258,6 +2274,8 @@ components: type: example: NoValueInMessage type: string + enum: + - NoValueInMessage required: - type - $ref: '#/components/schemas/GolemErrorNoValueInMessage' @@ -2268,6 +2286,8 @@ components: type: example: ParamTypeMismatch type: string + enum: + - ParamTypeMismatch required: - type - $ref: '#/components/schemas/GolemErrorParamTypeMismatch' @@ -2278,6 +2298,8 @@ components: type: example: PreviousInvocationExited type: string + enum: + - PreviousInvocationExited required: - type - $ref: '#/components/schemas/GolemErrorPreviousInvocationExited' @@ -2288,6 +2310,8 @@ components: type: example: PreviousInvocationFailed type: string + enum: + - PreviousInvocationFailed required: - type - $ref: '#/components/schemas/GolemErrorPreviousInvocationFailed' @@ -2298,6 +2322,8 @@ components: type: example: PromiseAlreadyCompleted type: string + enum: + - PromiseAlreadyCompleted required: - type - $ref: '#/components/schemas/GolemErrorPromiseAlreadyCompleted' @@ -2308,6 +2334,8 @@ components: type: example: PromiseDropped type: string + enum: + - PromiseDropped required: - type - $ref: '#/components/schemas/GolemErrorPromiseDropped' @@ -2318,6 +2346,8 @@ components: type: example: PromiseNotFound type: string + enum: + - PromiseNotFound required: - type - $ref: '#/components/schemas/GolemErrorPromiseNotFound' @@ -2328,6 +2358,8 @@ components: type: example: RuntimeError type: string + enum: + - RuntimeError required: - type - $ref: '#/components/schemas/GolemErrorRuntimeError' @@ -2338,6 +2370,8 @@ components: type: example: UnexpectedOplogEntry type: string + enum: + - UnexpectedOplogEntry required: - type - $ref: '#/components/schemas/GolemErrorUnexpectedOplogEntry' @@ -2348,6 +2382,8 @@ components: type: example: Unknown type: string + enum: + - Unknown required: - type - $ref: '#/components/schemas/GolemErrorUnknown' @@ -2358,6 +2394,8 @@ components: type: example: ValueMismatch type: string + enum: + - ValueMismatch required: - type - $ref: '#/components/schemas/GolemErrorValueMismatch' @@ -2368,6 +2406,8 @@ components: type: example: WorkerAlreadyExists type: string + enum: + - WorkerAlreadyExists required: - type - $ref: '#/components/schemas/GolemErrorWorkerAlreadyExists' @@ -2378,6 +2418,8 @@ components: type: example: WorkerCreationFailed type: string + enum: + - WorkerCreationFailed required: - type - $ref: '#/components/schemas/GolemErrorWorkerCreationFailed' @@ -2388,6 +2430,8 @@ components: type: example: WorkerNotFound type: string + enum: + - WorkerNotFound required: - type - $ref: '#/components/schemas/GolemErrorWorkerNotFound' @@ -2577,6 +2621,8 @@ components: type: example: failedUpdate type: string + enum: + - failedUpdate required: - type - $ref: '#/components/schemas/FailedUpdate' @@ -2587,6 +2633,8 @@ components: type: example: pendingUpdate type: string + enum: + - pendingUpdate required: - type - $ref: '#/components/schemas/PendingUpdate' @@ -2597,6 +2645,8 @@ components: type: example: successfulUpdate type: string + enum: + - successfulUpdate required: - type - $ref: '#/components/schemas/SuccessfulUpdate' @@ -2731,6 +2781,8 @@ components: type: example: And type: string + enum: + - And required: - type - $ref: '#/components/schemas/WorkerAndFilter' @@ -2741,6 +2793,8 @@ components: type: example: CreatedAt type: string + enum: + - CreatedAt required: - type - $ref: '#/components/schemas/WorkerCreatedAtFilter' @@ -2751,6 +2805,8 @@ components: type: example: Env type: string + enum: + - Env required: - type - $ref: '#/components/schemas/WorkerEnvFilter' @@ -2761,6 +2817,8 @@ components: type: example: Name type: string + enum: + - Name required: - type - $ref: '#/components/schemas/WorkerNameFilter' @@ -2771,6 +2829,8 @@ components: type: example: Not type: string + enum: + - Not required: - type - $ref: '#/components/schemas/WorkerNotFilter' @@ -2781,6 +2841,8 @@ components: type: example: Or type: string + enum: + - Or required: - type - $ref: '#/components/schemas/WorkerOrFilter' @@ -2791,6 +2853,8 @@ components: type: example: Status type: string + enum: + - Status required: - type - $ref: '#/components/schemas/WorkerStatusFilter' @@ -2801,6 +2865,8 @@ components: type: example: Version type: string + enum: + - Version required: - type - $ref: '#/components/schemas/WorkerVersionFilter' @@ -2901,6 +2967,8 @@ components: type: example: Messages type: string + enum: + - Messages required: - type - $ref: '#/components/schemas/MessagesErrorsBody' @@ -2911,6 +2979,8 @@ components: type: example: Validation type: string + enum: + - Validation required: - type - $ref: '#/components/schemas/ValidationErrorsBody' @@ -3061,6 +3131,8 @@ components: type: example: Function type: string + enum: + - Function required: - type - $ref: '#/components/schemas/ExportFunction' @@ -3071,6 +3143,8 @@ components: type: example: Instance type: string + enum: + - Instance required: - type - $ref: '#/components/schemas/ExportInstance' @@ -3305,6 +3379,8 @@ components: type: example: Bool type: string + enum: + - Bool required: - type - $ref: '#/components/schemas/TypeBool' @@ -3315,6 +3391,8 @@ components: type: example: Chr type: string + enum: + - Chr required: - type - $ref: '#/components/schemas/TypeChr' @@ -3325,6 +3403,8 @@ components: type: example: Enum type: string + enum: + - Enum required: - type - $ref: '#/components/schemas/TypeEnum' @@ -3335,6 +3415,8 @@ components: type: example: F32 type: string + enum: + - F32 required: - type - $ref: '#/components/schemas/TypeF32' @@ -3345,6 +3427,8 @@ components: type: example: F64 type: string + enum: + - F64 required: - type - $ref: '#/components/schemas/TypeF64' @@ -3355,6 +3439,8 @@ components: type: example: Flags type: string + enum: + - Flags required: - type - $ref: '#/components/schemas/TypeFlags' @@ -3365,6 +3451,8 @@ components: type: example: Handle type: string + enum: + - Handle required: - type - $ref: '#/components/schemas/TypeHandle' @@ -3375,6 +3463,8 @@ components: type: example: List type: string + enum: + - List required: - type - $ref: '#/components/schemas/TypeList' @@ -3385,6 +3475,8 @@ components: type: example: Option type: string + enum: + - Option required: - type - $ref: '#/components/schemas/TypeOption' @@ -3395,6 +3487,8 @@ components: type: example: Record type: string + enum: + - Record required: - type - $ref: '#/components/schemas/TypeRecord' @@ -3405,6 +3499,8 @@ components: type: example: Result type: string + enum: + - Result required: - type - $ref: '#/components/schemas/TypeResult' @@ -3415,6 +3511,8 @@ components: type: example: S16 type: string + enum: + - S16 required: - type - $ref: '#/components/schemas/TypeS16' @@ -3425,6 +3523,8 @@ components: type: example: S32 type: string + enum: + - S32 required: - type - $ref: '#/components/schemas/TypeS32' @@ -3435,6 +3535,8 @@ components: type: example: S64 type: string + enum: + - S64 required: - type - $ref: '#/components/schemas/TypeS64' @@ -3445,6 +3547,8 @@ components: type: example: S8 type: string + enum: + - S8 required: - type - $ref: '#/components/schemas/TypeS8' @@ -3455,6 +3559,8 @@ components: type: example: Str type: string + enum: + - Str required: - type - $ref: '#/components/schemas/TypeStr' @@ -3465,6 +3571,8 @@ components: type: example: Tuple type: string + enum: + - Tuple required: - type - $ref: '#/components/schemas/TypeTuple' @@ -3475,6 +3583,8 @@ components: type: example: U16 type: string + enum: + - U16 required: - type - $ref: '#/components/schemas/TypeU16' @@ -3485,6 +3595,8 @@ components: type: example: U32 type: string + enum: + - U32 required: - type - $ref: '#/components/schemas/TypeU32' @@ -3495,6 +3607,8 @@ components: type: example: U64 type: string + enum: + - U64 required: - type - $ref: '#/components/schemas/TypeU64' @@ -3505,6 +3619,8 @@ components: type: example: U8 type: string + enum: + - U8 required: - type - $ref: '#/components/schemas/TypeU8' @@ -3515,6 +3631,8 @@ components: type: example: Variant type: string + enum: + - Variant required: - type - $ref: '#/components/schemas/TypeVariant' diff --git a/test-components/auction-example/Cargo.lock b/test-components/auction-example/Cargo.lock index b12515ddc1..8804aa146f 100644 --- a/test-components/auction-example/Cargo.lock +++ b/test-components/auction-example/Cargo.lock @@ -24,7 +24,7 @@ dependencies = [ "once_cell", "rand", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -34,7 +34,7 @@ dependencies = [ "once_cell", "rand", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -42,7 +42,7 @@ name = "auction-stub" version = "0.0.1" dependencies = [ "golem-wasm-rpc", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -116,12 +116,12 @@ dependencies = [ [[package]] name = "golem-wasm-rpc" -version = "0.0.25" +version = "0.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b188cc053d5bf31ea81ffa3f52d6a195d29ed839951e25fdbc12a4a43f6b03" +checksum = "5ae26028226e258a3cfa04cd35b6e1fdcde4d86037ee7df4f1ec9dfc537447b7" dependencies = [ "prost-build", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -136,15 +136,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys", -] - [[package]] name = "indexmap" version = "2.2.2" @@ -237,9 +228,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -247,9 +238,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck", @@ -264,14 +255,13 @@ dependencies = [ "regex", "syn", "tempfile", - "which", ] [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools", @@ -282,9 +272,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -445,18 +435,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -524,10 +502,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags 2.4.2", ] diff --git a/test-components/auction-example/auction-registry/Cargo.toml b/test-components/auction-example/auction-registry/Cargo.toml index 0b2a2bf690..3b7e6c132a 100644 --- a/test-components/auction-example/auction-registry/Cargo.toml +++ b/test-components/auction-example/auction-registry/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] once_cell = "1.19.0" rand = "0.8.5" uuid = { version = "1.7.0", features = ["v4", "serde"] } -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/auction-example/auction-registry/src/bindings.rs b/test-components/auction-example/auction-registry/src/bindings.rs index 45ef224779..860c789bae 100644 --- a/test-components/auction-example/auction-registry/src/bindings.rs +++ b/test-components/auction-example/auction-registry/src/bindings.rs @@ -1,2207 +1,2899 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod auction { - pub mod auction { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - #[derive(Clone)] - pub struct BidderId { - pub bidder_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for BidderId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("BidderId").field("bidder-id", &self.bidder_id).finish() - } - } - #[derive(Clone)] - pub struct AuctionId { - pub auction_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for AuctionId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AuctionId").field("auction-id", &self.auction_id).finish() - } - } - pub type Deadline = u64; - #[derive(Clone)] - pub struct Auction { - pub auction_id: AuctionId, - pub name: wit_bindgen::rt::string::String, - pub description: wit_bindgen::rt::string::String, - pub limit_price: f32, - pub expiration: Deadline, - } - impl ::core::fmt::Debug for Auction { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Auction").field("auction-id", &self.auction_id).field("name", &self.name).field("description", &self.description).field("limit-price", &self.limit_price).field("expiration", &self.expiration).finish() - } - } - #[derive(Clone, Copy)] - pub enum BidResult{ - AuctionExpired, - PriceTooLow, - Success, - } - impl ::core::fmt::Debug for BidResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - BidResult::AuctionExpired => { - f.debug_tuple("BidResult::AuctionExpired").finish() - } - BidResult::PriceTooLow => { - f.debug_tuple("BidResult::PriceTooLow").finish() - } - BidResult::Success => { - f.debug_tuple("BidResult::Success").finish() - } - } - } - } - /// an alternative interface for hosting multiple auctions in a single worker - - #[derive(Debug)] - #[repr(transparent)] - pub struct RunningAuction{ - handle: wit_bindgen::rt::Resource, - } - - impl RunningAuction{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for RunningAuction{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[resource-drop]running-auction"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - pub fn initialize(auction: &Auction,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "initialize"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ){ unreachable!() } - wit_import(ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn bid(bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "bid"] - fn wit_import(_: i32, _: i32, _: f32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1, wit_bindgen::rt::as_f32(price)); - let v2 = match ret { - 0 => { - BidResult::AuctionExpired - } - 1 => { - BidResult::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - BidResult::Success + #[allow(dead_code)] + pub mod auction { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[derive(Clone)] + pub struct BidderId { + pub bidder_id: _rt::String, } - }; - v2 - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn close_auction() -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "close-auction"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), + impl ::core::fmt::Debug for BidderId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BidderId") + .field("bidder-id", &self.bidder_id) + .finish() } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn new(auction: &Auction,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[constructor]running-auction"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32; } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import(ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - RunningAuction::from_handle(ret as u32) - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn bid(&self,bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[method]running-auction.bid"] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32; + #[derive(Clone)] + pub struct AuctionId { + pub auction_id: _rt::String, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr1, len1, wit_bindgen::rt::as_f32(price)); - let v2 = match ret { - 0 => { - BidResult::AuctionExpired - } - 1 => { - BidResult::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - BidResult::Success - } - }; - v2 - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn close(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[method]running-auction.close"] - fn wit_import(_: i32, _: i32, ); + impl ::core::fmt::Debug for AuctionId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AuctionId") + .field("auction-id", &self.auction_id) + .finish() + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + pub type Deadline = u64; + #[derive(Clone)] + pub struct Auction { + pub auction_id: AuctionId, + pub name: _rt::String, + pub description: _rt::String, + pub limit_price: f32, + pub expiration: Deadline, } - } - } - } - - } - - } - pub mod auction_stub { - - #[allow(clippy::all)] - pub mod stub_auction { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - pub type BidderId = super::super::super::auction::auction::api::BidderId; - pub type Auction = super::super::super::auction::auction::api::Auction; - pub type BidResult = super::super::super::auction::auction::api::BidResult; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Api{ - handle: wit_bindgen::rt::Resource, - } - - impl Api{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Api{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-drop]api"] - fn drop(_: u32); + impl ::core::fmt::Debug for Auction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Auction") + .field("auction-id", &self.auction_id) + .field("name", &self.name) + .field("description", &self.description) + .field("limit-price", &self.limit_price) + .field("expiration", &self.expiration) + .finish() + } } - - drop(_handle); - } - } - } - - - #[derive(Debug)] - #[repr(transparent)] - pub struct RunningAuction{ - handle: wit_bindgen::rt::Resource, - } - - impl RunningAuction{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for RunningAuction{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-drop]running-auction"] - fn drop(_: u32); + #[derive(Clone, Copy)] + pub enum BidResult { + AuctionExpired, + PriceTooLow, + Success, } - - drop(_handle); - } - } - } - - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::golem::rpc::types::Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[constructor]api"] - fn wit_import(_: i32, _: i32, ) -> i32; + impl ::core::fmt::Debug for BidResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + BidResult::AuctionExpired => { + f.debug_tuple("BidResult::AuctionExpired").finish() + } + BidResult::PriceTooLow => f.debug_tuple("BidResult::PriceTooLow").finish(), + BidResult::Success => f.debug_tuple("BidResult::Success").finish(), + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - Api::from_handle(ret as u32) - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn blocking_initialize(&self,auction: &Auction,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::auction::auction::api::Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]api.blocking-initialize"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ); + /// an alternative interface for hosting multiple auctions in a single worker + + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuction { + handle: _rt::Resource, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn initialize(&self,auction: &Auction,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::auction::auction::api::Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]api.initialize"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ); + + impl RunningAuction { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn bid(&self,bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::auction::auction::api::BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]api.bid"] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32; + + unsafe impl _rt::WasmResource for RunningAuction { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[resource-drop]running-auction"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr1, len1, wit_bindgen::rt::as_f32(price)); - use super::super::super::auction::auction::api::BidResult as V2; - let v2 = match ret { - 0 => { - V2::AuctionExpired - } - 1 => { - V2::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - V2::Success - } - }; - v2 - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn close_auction(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]api.close-auction"] - fn wit_import(_: i32, _: i32, ); + + #[allow(unused_unsafe, clippy::all)] + pub fn initialize(auction: &Auction) { + unsafe { + let Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "initialize"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) { + unreachable!() + } + wit_import( + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - super::super::super::auction::auction::api::BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + #[allow(unused_unsafe, clippy::all)] + pub fn bid(bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "bid"] + fn wit_import(_: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1, _rt::as_f32(&price)); + let v2 = match ret { + 0 => BidResult::AuctionExpired, + 1 => BidResult::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + BidResult::Success + } + }; + v2 + } } - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,auction: &Auction,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::golem::rpc::types::Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let super::super::super::auction::auction::api::Auction{ auction_id:auction_id2, name:name2, description:description2, limit_price:limit_price2, expiration:expiration2, } = auction; - let super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id3, } = auction_id2; - let vec4 = auction_id3; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = name2; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - let vec6 = description2; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[constructor]running-auction"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32; + #[allow(unused_unsafe, clippy::all)] + pub fn close_auction() -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "close-auction"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1, ptr4, len4, ptr5, len5, ptr6, len6, wit_bindgen::rt::as_f32(limit_price2), wit_bindgen::rt::as_i64(expiration2)); - RunningAuction::from_handle(ret as u32) - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn bid(&self,bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::auction::auction::api::BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]running-auction.bid"] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32; + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn new(auction: &Auction) -> Self { + unsafe { + let Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[constructor]running-auction"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + RunningAuction::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr1, len1, wit_bindgen::rt::as_f32(price)); - use super::super::super::auction::auction::api::BidResult as V2; - let v2 = match ret { - 0 => { - V2::AuctionExpired - } - 1 => { - V2::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - V2::Success - } - }; - v2 - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn close(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[method]running-auction.close"] - fn wit_import(_: i32, _: i32, ); + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn bid(&self, bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[method]running-auction.bid"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + ptr1.cast_mut(), + len1, + _rt::as_f32(&price), + ); + let v2 = match ret { + 0 => BidResult::AuctionExpired, + 1 => BidResult::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + BidResult::Success + } + }; + v2 + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - super::super::super::auction::auction::api::BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn close(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[method]running-auction.close"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } } - } - } - - } -} -pub mod golem { - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - Handle((Uri,u64,)), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() + #[allow(dead_code)] + pub mod auction_stub { + #[allow(dead_code, clippy::all)] + pub mod stub_auction { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + pub type BidderId = super::super::super::auction::auction::api::BidderId; + pub type Auction = super::super::super::auction::auction::api::Auction; + pub type BidResult = super::super::super::auction::auction::api::BidResult; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Api { + handle: _rt::Resource, } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() + + impl Api { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() + + unsafe impl _rt::WasmResource for Api { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[resource-drop]api"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() + + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuction { + handle: _rt::Resource, } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() + + impl RunningAuction { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() + + unsafe impl _rt::WasmResource for RunningAuction { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[resource-drop]running-auction"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() + + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let super::super::super::golem::rpc::types::Uri { value: value0 } = + location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[constructor]api"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + Api::from_handle(ret as u32) + } + } } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn blocking_initialize(&self, auction: &Auction) { + unsafe { + let super::super::super::auction::auction::api::Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]api.blocking-initialize"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + } + } } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn initialize(&self, auction: &Auction) { + unsafe { + let super::super::super::auction::auction::api::Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]api.initialize"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + } + } } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn bid(&self, bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let super::super::super::auction::auction::api::BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]api.bid"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + ptr1.cast_mut(), + len1, + _rt::as_f32(&price), + ); + use super::super::super::auction::auction::api::BidResult as V2; + let v2 = match ret { + 0 => V2::AuctionExpired, + 1 => V2::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + V2::Success + } + }; + v2 + } + } } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn close_auction(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]api.close-auction"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + super::super::super::auction::auction::api::BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri, auction: &Auction) -> Self { + unsafe { + let super::super::super::golem::rpc::types::Uri { value: value0 } = + location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let super::super::super::auction::auction::api::Auction { + auction_id: auction_id2, + name: name2, + description: description2, + limit_price: limit_price2, + expiration: expiration2, + } = auction; + let super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id3, + } = auction_id2; + let vec4 = auction_id3; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = name2; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + let vec6 = description2; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[constructor]running-auction"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + ptr1.cast_mut(), + len1, + ptr4.cast_mut(), + len4, + ptr5.cast_mut(), + len5, + ptr6.cast_mut(), + len6, + _rt::as_f32(limit_price2), + _rt::as_i64(expiration2), + ); + RunningAuction::from_handle(ret as u32) + } + } } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn bid(&self, bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let super::super::super::auction::auction::api::BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]running-auction.bid"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + ptr1.cast_mut(), + len1, + _rt::as_f32(&price), + ); + use super::super::super::auction::auction::api::BidResult as V2; + let v2 = match ret { + 0 => V2::AuctionExpired, + 1 => V2::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + V2::Success + } + }; + v2 + } + } } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn close(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction-stub/stub-auction")] + extern "C" { + #[link_name = "[method]running-auction.close"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + super::super::super::auction::auction::api::BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() + } + } +} +#[allow(dead_code)] +pub mod golem { + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + Handle((Uri, u64)), } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + WitNode::Handle(e) => f.debug_tuple("WitNode::Handle").field(e).finish(), + } + } } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } } - WitNode::Handle(e) => { - f.debug_tuple("WitNode::Handle").field(e).finish() + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, - } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } + } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); } - } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); - } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l14 { - 0 => { - let e = { - let l15 = *((ptr13 + 4) as *const i32); - let l16 = *((ptr13 + 8) as *const i32); - let base62 = l15; - let len62 = l16; - let mut result62 = Vec::with_capacity(len62 as usize); - for i in 0..len62 { - let base = base62 + i * 24; - let e62 = { - let l17 = i32::from(*((base + 0) as *const u8)); - let v61 = match l17 { - 0 => { - let e61 = { - let l18 = *((base + 8) as *const i32); - let l19 = *((base + 12) as *const i32); - let len20 = l19 as usize; - - Vec::from_raw_parts(l18 as *mut _, len20, len20) - }; - WitNode::RecordValue(e61) - } - 1 => { - let e61 = { - let l21 = *((base + 8) as *const i32); - let l22 = i32::from(*((base + 12) as *const u8)); - - (l21 as u32, match l22 { + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = { + let l15 = *ptr13.add(4).cast::<*mut u8>(); + let l16 = *ptr13.add(8).cast::(); + let base62 = l15; + let len62 = l16; + let mut result62 = _rt::Vec::with_capacity(len62); + for i in 0..len62 { + let base = base62.add(i * 24); + let e62 = { + let l17 = i32::from(*base.add(0).cast::()); + let v61 = match l17 { + 0 => { + let e61 = { + let l18 = *base.add(8).cast::<*mut u8>(); + let l19 = *base.add(12).cast::(); + let len20 = l19; + + _rt::Vec::from_raw_parts( + l18.cast(), + len20, + len20, + ) + }; + WitNode::RecordValue(e61) + } + 1 => { + let e61 = + { + let l21 = *base.add(8).cast::(); + let l22 = i32::from( + *base.add(12).cast::(), + ); + + (l21 as u32, match l22 { 0 => None, 1 => { let e = { - let l23 = *((base + 16) as *const i32); - + let l23 = *base.add(16).cast::(); + l23 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }) - }; - WitNode::VariantValue(e61) - } - 2 => { - let e61 = { - let l24 = *((base + 8) as *const i32); - - l24 as u32 - }; - WitNode::EnumValue(e61) - } - 3 => { - let e61 = { - let l25 = *((base + 8) as *const i32); - let l26 = *((base + 12) as *const i32); - let base28 = l25; - let len28 = l26; - let mut result28 = Vec::with_capacity(len28 as usize); - for i in 0..len28 { - let base = base28 + i * 1; - let e28 = { - let l27 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l27 as u8) - }; - result28.push(e28); - } - wit_bindgen::rt::dealloc(base28, (len28 as usize) * 1, 1); - - result28 - }; - WitNode::FlagsValue(e61) - } - 4 => { - let e61 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::TupleValue(e61) - } - 5 => { - let e61 = { - let l32 = *((base + 8) as *const i32); - let l33 = *((base + 12) as *const i32); - let len34 = l33 as usize; - - Vec::from_raw_parts(l32 as *mut _, len34, len34) - }; - WitNode::ListValue(e61) - } - 6 => { - let e61 = { - let l35 = i32::from(*((base + 8) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((base + 12) as *const i32); - - l36 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e61) - } - 7 => { - let e61 = { - let l37 = i32::from(*((base + 8) as *const u8)); - - match l37 { - 0 => { - let e = { - let l38 = i32::from(*((base + 12) as *const u8)); - - match l38 { + }; + WitNode::VariantValue(e61) + } + 2 => { + let e61 = { + let l24 = *base.add(8).cast::(); + + l24 as u32 + }; + WitNode::EnumValue(e61) + } + 3 => { + let e61 = { + let l25 = *base.add(8).cast::<*mut u8>(); + let l26 = *base.add(12).cast::(); + let base28 = l25; + let len28 = l26; + let mut result28 = + _rt::Vec::with_capacity(len28); + for i in 0..len28 { + let base = base28.add(i * 1); + let e28 = { + let l27 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l27 as u8) + }; + result28.push(e28); + } + _rt::cabi_dealloc(base28, len28 * 1, 1); + + result28 + }; + WitNode::FlagsValue(e61) + } + 4 => { + let e61 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::TupleValue(e61) + } + 5 => { + let e61 = { + let l32 = *base.add(8).cast::<*mut u8>(); + let l33 = *base.add(12).cast::(); + let len34 = l33; + + _rt::Vec::from_raw_parts( + l32.cast(), + len34, + len34, + ) + }; + WitNode::ListValue(e61) + } + 6 => { + let e61 = { + let l35 = + i32::from(*base.add(8).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = + *base.add(12).cast::(); + + l36 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e61) + } + 7 => { + let e61 = { + let l37 = + i32::from(*base.add(8).cast::()); + + match l37 { + 0 => { + let e = { + let l38 = i32::from( + *base.add(12).cast::(), + ); + + match l38 { 0 => None, 1 => { let e = { - let l39 = *((base + 16) as *const i32); - + let l39 = *base.add(16).cast::(); + l39 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l40 = i32::from(*((base + 12) as *const u8)); - - match l40 { + }; + Ok(e) + } + 1 => { + let e = { + let l40 = i32::from( + *base.add(12).cast::(), + ); + + match l40 { 0 => None, 1 => { let e = { - let l41 = *((base + 16) as *const i32); - + let l41 = *base.add(16).cast::(); + l41 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e61) + } + 8 => { + let e61 = { + let l42 = + i32::from(*base.add(8).cast::()); + + l42 as u8 + }; + WitNode::PrimU8(e61) + } + 9 => { + let e61 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as u16 + }; + WitNode::PrimU16(e61) + } + 10 => { + let e61 = { + let l44 = *base.add(8).cast::(); + + l44 as u32 + }; + WitNode::PrimU32(e61) + } + 11 => { + let e61 = { + let l45 = *base.add(8).cast::(); + + l45 as u64 + }; + WitNode::PrimU64(e61) + } + 12 => { + let e61 = { + let l46 = + i32::from(*base.add(8).cast::()); + + l46 as i8 + }; + WitNode::PrimS8(e61) + } + 13 => { + let e61 = { + let l47 = + i32::from(*base.add(8).cast::()); + + l47 as i16 + }; + WitNode::PrimS16(e61) + } + 14 => { + let e61 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimS32(e61) + } + 15 => { + let e61 = { + let l49 = *base.add(8).cast::(); + + l49 + }; + WitNode::PrimS64(e61) + } + 16 => { + let e61 = { + let l50 = *base.add(8).cast::(); + + l50 + }; + WitNode::PrimFloat32(e61) + } + 17 => { + let e61 = { + let l51 = *base.add(8).cast::(); + + l51 + }; + WitNode::PrimFloat64(e61) + } + 18 => { + let e61 = { + let l52 = *base.add(8).cast::(); + + _rt::char_lift(l52 as u32) + }; + WitNode::PrimChar(e61) + } + 19 => { + let e61 = { + let l53 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l53 as u8) + }; + WitNode::PrimBool(e61) + } + 20 => { + let e61 = { + let l54 = *base.add(8).cast::<*mut u8>(); + let l55 = *base.add(12).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + WitNode::PrimString(e61) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e61 = { + let l57 = *base.add(8).cast::<*mut u8>(); + let l58 = *base.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + let l60 = *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift(bytes59), + }, + l60 as u64, + ) + }; + WitNode::Handle(e61) + } + }; + + v61 + }; + result62.push(e62); + } + _rt::cabi_dealloc(base62, len62 * 24, 8); + + WitValue { nodes: result62 } + }; + Ok(e) + } + 1 => { + let e = { + let l63 = i32::from(*ptr13.add(4).cast::()); + let v76 = match l63 { + 0 => { + let e76 = { + let l64 = *ptr13.add(8).cast::<*mut u8>(); + let l65 = *ptr13.add(12).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts( + l64.cast(), + len66, + len66, + ); + + _rt::string_lift(bytes66) + }; + RpcError::ProtocolError(e76) + } + 1 => { + let e76 = { + let l67 = *ptr13.add(8).cast::<*mut u8>(); + let l68 = *ptr13.add(12).cast::(); + let len69 = l68; + let bytes69 = _rt::Vec::from_raw_parts( + l67.cast(), + len69, + len69, + ); + + _rt::string_lift(bytes69) + }; + RpcError::Denied(e76) + } + 2 => { + let e76 = { + let l70 = *ptr13.add(8).cast::<*mut u8>(); + let l71 = *ptr13.add(12).cast::(); + let len72 = l71; + let bytes72 = _rt::Vec::from_raw_parts( + l70.cast(), + len72, + len72, + ); + + _rt::string_lift(bytes72) + }; + RpcError::NotFound(e76) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e76 = { + let l73 = *ptr13.add(8).cast::<*mut u8>(); + let l74 = *ptr13.add(12).cast::(); + let len75 = l74; + let bytes75 = _rt::Vec::from_raw_parts( + l73.cast(), + len75, + len75, + ); + + _rt::string_lift(bytes75) + }; + RpcError::RemoteInternalError(e76) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e61) - } - 8 => { - let e61 = { - let l42 = i32::from(*((base + 8) as *const u8)); - - l42 as u8 - }; - WitNode::PrimU8(e61) - } - 9 => { - let e61 = { - let l43 = i32::from(*((base + 8) as *const u16)); - - l43 as u16 - }; - WitNode::PrimU16(e61) - } - 10 => { - let e61 = { - let l44 = *((base + 8) as *const i32); - - l44 as u32 - }; - WitNode::PrimU32(e61) - } - 11 => { - let e61 = { - let l45 = *((base + 8) as *const i64); - - l45 as u64 - }; - WitNode::PrimU64(e61) - } - 12 => { - let e61 = { - let l46 = i32::from(*((base + 8) as *const i8)); - - l46 as i8 - }; - WitNode::PrimS8(e61) - } - 13 => { - let e61 = { - let l47 = i32::from(*((base + 8) as *const i16)); - - l47 as i16 - }; - WitNode::PrimS16(e61) - } - 14 => { - let e61 = { - let l48 = *((base + 8) as *const i32); - - l48 - }; - WitNode::PrimS32(e61) - } - 15 => { - let e61 = { - let l49 = *((base + 8) as *const i64); - - l49 - }; - WitNode::PrimS64(e61) - } - 16 => { - let e61 = { - let l50 = *((base + 8) as *const f32); - - l50 - }; - WitNode::PrimFloat32(e61) - } - 17 => { - let e61 = { - let l51 = *((base + 8) as *const f64); - - l51 - }; - WitNode::PrimFloat64(e61) - } - 18 => { - let e61 = { - let l52 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l52 as u32) - }; - WitNode::PrimChar(e61) - } - 19 => { - let e61 = { - let l53 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l53 as u8) - }; - WitNode::PrimBool(e61) - } - 20 => { - let e61 = { - let l54 = *((base + 8) as *const i32); - let l55 = *((base + 12) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - WitNode::PrimString(e61) - } - n => { - debug_assert_eq!(n, 21, "invalid enum discriminant"); - let e61 = { - let l57 = *((base + 8) as *const i32); - let l58 = *((base + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - let l60 = *((base + 16) as *const i64); - - (Uri{ - value: wit_bindgen::rt::string_lift(bytes59), - }, l60 as u64) }; - WitNode::Handle(e61) - } + + v76 }; - - v61 - }; - result62.push(e62); + Err(e) } - wit_bindgen::rt::dealloc(base62, (len62 as usize) * 24, 8); - - WitValue{ - nodes: result62, - } - }; - Ok(e) + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = { - let l63 = i32::from(*((ptr13 + 4) as *const u8)); - let v76 = match l63 { - 0 => { - let e76 = { - let l64 = *((ptr13 + 8) as *const i32); - let l65 = *((ptr13 + 12) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) - }; - RpcError::ProtocolError(e76) - } - 1 => { - let e76 = { - let l67 = *((ptr13 + 8) as *const i32); - let l68 = *((ptr13 + 12) as *const i32); - let len69 = l68 as usize; - let bytes69 = Vec::from_raw_parts(l67 as *mut _, len69, len69); - - wit_bindgen::rt::string_lift(bytes69) - }; - RpcError::Denied(e76) - } - 2 => { - let e76 = { - let l70 = *((ptr13 + 8) as *const i32); - let l71 = *((ptr13 + 12) as *const i32); - let len72 = l71 as usize; - let bytes72 = Vec::from_raw_parts(l70 as *mut _, len72, len72); - - wit_bindgen::rt::string_lift(bytes72) - }; - RpcError::NotFound(e76) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e76 = { - let l73 = *((ptr13 + 8) as *const i32); - let l74 = *((ptr13 + 12) as *const i32); - let len75 = l74 as usize; - let bytes75 = Vec::from_raw_parts(l73 as *mut _, len75, len75); - - wit_bindgen::rt::string_lift(bytes75) - }; - RpcError::RemoteInternalError(e76) - } - }; - - v76 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke(&self,function_name: &str,function_params: &[WitValue],) -> Result<(),RpcError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result<(), RpcError> { unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; - { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - } + ::core::ptr::null_mut() } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } } - } } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); - } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l14 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l15 = i32::from(*((ptr13 + 4) as *const u8)); - let v28 = match l15 { + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(4).cast::()); + let v28 = match l15 { 0 => { - let e28 = { - let l16 = *((ptr13 + 8) as *const i32); - let l17 = *((ptr13 + 12) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) - }; - RpcError::ProtocolError(e28) + let e28 = { + let l16 = *ptr13.add(8).cast::<*mut u8>(); + let l17 = *ptr13.add(12).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, + ); + + _rt::string_lift(bytes18) + }; + RpcError::ProtocolError(e28) } 1 => { - let e28 = { - let l19 = *((ptr13 + 8) as *const i32); - let l20 = *((ptr13 + 12) as *const i32); - let len21 = l20 as usize; - let bytes21 = Vec::from_raw_parts(l19 as *mut _, len21, len21); - - wit_bindgen::rt::string_lift(bytes21) - }; - RpcError::Denied(e28) + let e28 = { + let l19 = *ptr13.add(8).cast::<*mut u8>(); + let l20 = *ptr13.add(12).cast::(); + let len21 = l20; + let bytes21 = _rt::Vec::from_raw_parts( + l19.cast(), + len21, + len21, + ); + + _rt::string_lift(bytes21) + }; + RpcError::Denied(e28) } 2 => { - let e28 = { - let l22 = *((ptr13 + 8) as *const i32); - let l23 = *((ptr13 + 12) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) - }; - RpcError::NotFound(e28) + let e28 = { + let l22 = *ptr13.add(8).cast::<*mut u8>(); + let l23 = *ptr13.add(12).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts( + l22.cast(), + len24, + len24, + ); + + _rt::string_lift(bytes24) + }; + RpcError::NotFound(e28) } n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e28 = { - let l25 = *((ptr13 + 8) as *const i32); - let l26 = *((ptr13 + 12) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) - }; - RpcError::RemoteInternalError(e28) + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e28 = { + let l25 = *ptr13.add(8).cast::<*mut u8>(); + let l26 = *ptr13.add(12).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts( + l25.cast(), + len27, + len27, + ); + + _rt::string_lift(bytes27) + }; + RpcError::RemoteInternalError(e28) } - }; - - v28 }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + + v28 + }; + Err(e) } - } - + _ => _rt::invalid_enum_discriminant(), } - - } } - pub mod exports { - pub mod auction { - pub mod registry { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type BidderId = super::super::super::super::auction::auction::api::BidderId; - pub type AuctionId = super::super::super::super::auction::auction::api::AuctionId; - pub type Deadline = super::super::super::super::auction::auction::api::Deadline; - pub type Auction = super::super::super::super::auction::auction::api::Auction; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:registry/api#create-bidder"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_bidder(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::create_bidder(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - let super::super::super::super::auction::auction::api::BidderId{ bidder_id:bidder_id4, } = result2; - let vec5 = (bidder_id4.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((ptr3 + 4) as *mut i32) = len5; - *((ptr3 + 0) as *mut i32) = ptr5; - ptr3 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:registry/api#create-bidder"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_bidder(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:registry/api#create-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_auction(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: f32,arg5: i64,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::create_auction(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1), arg4, arg5 as u64); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - let super::super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id4, } = result2; - let vec5 = (auction_id4.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((ptr3 + 4) as *mut i32) = len5; - *((ptr3 + 0) as *mut i32) = ptr5; - ptr3 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:registry/api#create-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_auction(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:registry/api#get-auctions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_auctions() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_auctions(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec7 = result0; - let len7 = vec7.len() as i32; - let layout7 = alloc::Layout::from_size_align_unchecked(vec7.len() * 40, 8); - let result7 = if layout7.size() != 0 - { - let ptr = alloc::alloc(layout7); - if ptr.is_null() - { - alloc::handle_alloc_error(layout7); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec7.into_iter().enumerate() { - let base = result7 as i32 + (i as i32) * 40; - { - let super::super::super::super::auction::auction::api::Auction{ auction_id:auction_id2, name:name2, description:description2, limit_price:limit_price2, expiration:expiration2, } = e; - let super::super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id3, } = auction_id2; - let vec4 = (auction_id3.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 4) as *mut i32) = len4; - *((base + 0) as *mut i32) = ptr4; - let vec5 = (name2.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - let vec6 = (description2.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - ::core::mem::forget(vec6); - *((base + 20) as *mut i32) = len6; - *((base + 16) as *mut i32) = ptr6; - *((base + 24) as *mut f32) = wit_bindgen::rt::as_f32(limit_price2); - *((base + 32) as *mut i64) = wit_bindgen::rt::as_i64(expiration2); - } - } - *((ptr1 + 4) as *mut i32) = len7; - *((ptr1 + 0) as *mut i32) = result7 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:registry/api#get-auctions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_auctions(arg0: i32,) { - let l6 = *((arg0 + 0) as *const i32); - let l7 = *((arg0 + 4) as *const i32); - let base8 = l6; - let len8 = l7; - for i in 0..len8 { - let base = base8 + i *40; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 8) as *const i32); - let l3 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); - let l4 = *((base + 16) as *const i32); - let l5 = *((base + 20) as *const i32); - wit_bindgen::rt::dealloc(l4, (l5) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base8, (len8 as usize) * 40, 8); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:registry/api#create-auction-res"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_auction_res(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: f32,arg5: i64,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::create_auction_res(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1), arg4, arg5 as u64); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - let super::super::super::super::auction::auction::api::AuctionId{ auction_id:auction_id4, } = result2; - let vec5 = (auction_id4.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((ptr3 + 4) as *mut i32) = len5; - *((ptr3 + 0) as *mut i32) = ptr5; - ptr3 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:registry/api#create-auction-res"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_auction_res(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn create_bidder(name: wit_bindgen::rt::string::String,address: wit_bindgen::rt::string::String,) -> BidderId; - fn create_auction(name: wit_bindgen::rt::string::String,description: wit_bindgen::rt::string::String,limit_price: f32,expiration: Deadline,) -> AuctionId; - fn get_auctions() -> wit_bindgen::rt::vec::Vec::; - fn create_auction_res(name: wit_bindgen::rt::string::String,description: wit_bindgen::rt::string::String,limit_price: f32,expiration: Deadline,) -> AuctionId; - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - - } - } - } - + } + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod auction { + #[allow(dead_code)] + pub mod registry { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type BidderId = super::super::super::super::auction::auction::api::BidderId; + pub type AuctionId = super::super::super::super::auction::auction::api::AuctionId; + pub type Deadline = super::super::super::super::auction::auction::api::Deadline; + pub type Auction = super::super::super::super::auction::auction::api::Auction; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_bidder_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = + T::create_bidder(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + let super::super::super::super::auction::auction::api::BidderId { + bidder_id: bidder_id4, + } = result2; + let vec5 = (bidder_id4.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *ptr3.add(4).cast::() = len5; + *ptr3.add(0).cast::<*mut u8>() = ptr5.cast_mut(); + ptr3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_create_bidder(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_auction_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: f32, + arg5: i64, + ) -> *mut u8 { #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:auction-registry"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2932] = [3, 0, 16, 97, 117, 99, 116, 105, 111, 110, 45, 114, 101, 103, 105, 115, 116, 114, 121, 0, 97, 115, 109, 13, 0, 1, 0, 7, 191, 4, 1, 65, 8, 1, 66, 11, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 3, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 0, 2, 3, 0, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 2, 3, 0, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 2, 3, 0, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 2, 3, 0, 0, 7, 97, 117, 99, 116, 105, 111, 110, 1, 66, 16, 2, 3, 2, 1, 1, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 2, 3, 2, 1, 2, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 3, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 2, 3, 2, 1, 4, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 64, 2, 4, 110, 97, 109, 101, 115, 7, 97, 100, 100, 114, 101, 115, 115, 115, 0, 1, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 98, 105, 100, 100, 101, 114, 1, 8, 1, 64, 4, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 0, 3, 4, 0, 14, 99, 114, 101, 97, 116, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 9, 1, 112, 7, 1, 64, 0, 0, 10, 4, 0, 12, 103, 101, 116, 45, 97, 117, 99, 116, 105, 111, 110, 115, 1, 11, 4, 0, 18, 99, 114, 101, 97, 116, 101, 45, 97, 117, 99, 116, 105, 111, 110, 45, 114, 101, 115, 1, 9, 4, 1, 20, 97, 117, 99, 116, 105, 111, 110, 58, 114, 101, 103, 105, 115, 116, 114, 121, 47, 97, 112, 105, 5, 5, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 151, 17, 1, 65, 2, 1, 65, 14, 1, 66, 29, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 17, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 3, 0, 18, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 19, 1, 104, 17, 1, 112, 14, 1, 106, 1, 14, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 22, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 23, 1, 106, 0, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 24, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 1, 25, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 26, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 10, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 0, 11, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 12, 1, 104, 10, 1, 64, 3, 4, 115, 101, 108, 102, 13, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 14, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 13, 0, 15, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 16, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 1, 0, 4, 0, 10, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 2, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 3, 98, 105, 100, 1, 18, 1, 64, 0, 0, 15, 4, 0, 13, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 19, 3, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 1, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 2, 3, 0, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 2, 3, 0, 1, 8, 100, 101, 97, 100, 108, 105, 110, 101, 2, 3, 0, 1, 7, 97, 117, 99, 116, 105, 111, 110, 2, 3, 0, 1, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 1, 66, 34, 2, 3, 2, 1, 2, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 4, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 4, 2, 3, 2, 1, 5, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 6, 2, 3, 2, 1, 6, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 8, 2, 3, 2, 1, 7, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 12, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 14, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 15, 1, 104, 12, 1, 64, 2, 4, 115, 101, 108, 102, 16, 7, 97, 117, 99, 116, 105, 111, 110, 9, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 3, 4, 115, 101, 108, 102, 16, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 15, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 105, 100, 1, 18, 1, 107, 3, 1, 64, 1, 4, 115, 101, 108, 102, 16, 0, 19, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 20, 1, 105, 13, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 7, 97, 117, 99, 116, 105, 111, 110, 9, 0, 21, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 22, 1, 104, 13, 1, 64, 3, 4, 115, 101, 108, 102, 23, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 24, 1, 64, 1, 4, 115, 101, 108, 102, 23, 0, 19, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 25, 3, 1, 33, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 5, 8, 1, 66, 16, 2, 3, 2, 1, 3, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 2, 3, 2, 1, 4, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 5, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 2, 3, 2, 1, 6, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 64, 2, 4, 110, 97, 109, 101, 115, 7, 97, 100, 100, 114, 101, 115, 115, 115, 0, 1, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 98, 105, 100, 100, 101, 114, 1, 8, 1, 64, 4, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 0, 3, 4, 0, 14, 99, 114, 101, 97, 116, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 9, 1, 112, 7, 1, 64, 0, 0, 10, 4, 0, 12, 103, 101, 116, 45, 97, 117, 99, 116, 105, 111, 110, 115, 1, 11, 4, 0, 18, 99, 114, 101, 97, 116, 101, 45, 97, 117, 99, 116, 105, 111, 110, 45, 114, 101, 115, 1, 9, 4, 1, 20, 97, 117, 99, 116, 105, 111, 110, 58, 114, 101, 103, 105, 115, 116, 114, 121, 47, 97, 112, 105, 5, 9, 4, 1, 33, 97, 117, 99, 116, 105, 111, 110, 58, 114, 101, 103, 105, 115, 116, 114, 121, 47, 97, 117, 99, 116, 105, 111, 110, 45, 114, 101, 103, 105, 115, 116, 114, 121, 4, 0, 11, 22, 1, 0, 16, 97, 117, 99, 116, 105, 111, 110, 45, 114, 101, 103, 105, 115, 116, 114, 121, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::create_auction( + _rt::string_lift(bytes0), + _rt::string_lift(bytes1), + arg4, + arg5 as u64, + ); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + let super::super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id4, + } = result2; + let vec5 = (auction_id4.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *ptr3.add(4).cast::() = len5; + *ptr3.add(0).cast::<*mut u8>() = ptr5.cast_mut(); + ptr3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_create_auction(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_auctions_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_auctions(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec7 = result0; + let len7 = vec7.len(); + let layout7 = _rt::alloc::Layout::from_size_align_unchecked(vec7.len() * 40, 8); + let result7 = if layout7.size() != 0 { + let ptr = _rt::alloc::alloc(layout7).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout7); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec7.into_iter().enumerate() { + let base = result7.add(i * 40); + { + let super::super::super::super::auction::auction::api::Auction { + auction_id: auction_id2, + name: name2, + description: description2, + limit_price: limit_price2, + expiration: expiration2, + } = e; + let super::super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id3, + } = auction_id2; + let vec4 = (auction_id3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(4).cast::() = len4; + *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + let vec5 = (name2.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + let vec6 = (description2.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *base.add(20).cast::() = len6; + *base.add(16).cast::<*mut u8>() = ptr6.cast_mut(); + *base.add(24).cast::() = _rt::as_f32(limit_price2); + *base.add(32).cast::() = _rt::as_i64(expiration2); + } + } + *ptr1.add(4).cast::() = len7; + *ptr1.add(0).cast::<*mut u8>() = result7; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_auctions(arg0: *mut u8) { + let l6 = *arg0.add(0).cast::<*mut u8>(); + let l7 = *arg0.add(4).cast::(); + let base8 = l6; + let len8 = l7; + for i in 0..len8 { + let base = base8.add(i * 40); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(8).cast::<*mut u8>(); + let l3 = *base.add(12).cast::(); + _rt::cabi_dealloc(l2, l3, 1); + let l4 = *base.add(16).cast::<*mut u8>(); + let l5 = *base.add(20).cast::(); + _rt::cabi_dealloc(l4, l5, 1); + } + } + _rt::cabi_dealloc(base8, len8 * 40, 8); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_auction_res_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: f32, + arg5: i64, + ) -> *mut u8 { #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::create_auction_res( + _rt::string_lift(bytes0), + _rt::string_lift(bytes1), + arg4, + arg5 as u64, + ); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + let super::super::super::super::auction::auction::api::AuctionId { + auction_id: auction_id4, + } = result2; + let vec5 = (auction_id4.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *ptr3.add(4).cast::() = len5; + *ptr3.add(0).cast::<*mut u8>() = ptr5.cast_mut(); + ptr3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_create_auction_res(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + pub trait Guest { + fn create_bidder(name: _rt::String, address: _rt::String) -> BidderId; + fn create_auction( + name: _rt::String, + description: _rt::String, + limit_price: f32, + expiration: Deadline, + ) -> AuctionId; + fn get_auctions() -> _rt::Vec; + fn create_auction_res( + name: _rt::String, + description: _rt::String, + limit_price: f32, + expiration: Deadline, + ) -> AuctionId; + } + #[doc(hidden)] + + macro_rules! __export_auction_registry_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "auction:registry/api#create-bidder"] + unsafe extern "C" fn export_create_bidder(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_create_bidder_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_auction:registry/api#create-bidder"] + unsafe extern "C" fn _post_return_create_bidder(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_bidder::<$ty>(arg0) + } + #[export_name = "auction:registry/api#create-auction"] + unsafe extern "C" fn export_create_auction(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: f32,arg5: i64,) -> *mut u8 { + $($path_to_types)*::_export_create_auction_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + #[export_name = "cabi_post_auction:registry/api#create-auction"] + unsafe extern "C" fn _post_return_create_auction(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_auction::<$ty>(arg0) + } + #[export_name = "auction:registry/api#get-auctions"] + unsafe extern "C" fn export_get_auctions() -> *mut u8 { + $($path_to_types)*::_export_get_auctions_cabi::<$ty>() + } + #[export_name = "cabi_post_auction:registry/api#get-auctions"] + unsafe extern "C" fn _post_return_get_auctions(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_auctions::<$ty>(arg0) + } + #[export_name = "auction:registry/api#create-auction-res"] + unsafe extern "C" fn export_create_auction_res(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: f32,arg5: i64,) -> *mut u8 { + $($path_to_types)*::_export_create_auction_res_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + #[export_name = "cabi_post_auction:registry/api#create-auction-res"] + unsafe extern "C" fn _post_return_create_auction_res(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_auction_res::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_auction_registry_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_auction_registry_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::auction::registry::api::__export_auction_registry_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::auction::registry::api); + ) + } +#[doc(inline)] +pub(crate) use __export_auction_registry_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:auction-registry:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2334] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x97\x11\x01A\x02\x01\ +A\x0e\x01B\x1d\x01z\x04\0\x0anode-index\x03\0\0\x01r\x01\x05values\x04\0\x03uri\x03\ +\0\x02\x01p\x01\x01k\x01\x01o\x02y\x05\x01p\x7f\x01j\x01\x05\x01\x05\x01o\x02\x03\ +w\x01q\x16\x0crecord-value\x01\x04\0\x0dvariant-value\x01\x06\0\x0aenum-value\x01\ +y\0\x0bflags-value\x01\x07\0\x0btuple-value\x01\x04\0\x0alist-value\x01\x04\0\x0c\ +option-value\x01\x05\0\x0cresult-value\x01\x08\0\x07prim-u8\x01}\0\x08prim-u16\x01\ +{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\0\x08prim-s16\x01|\0\x08\ +prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\0\x0cprim-float64\x01u\0\ +\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-string\x01s\0\x06handle\x01\x09\ +\0\x04\0\x08wit-node\x03\0\x0a\x01p\x0b\x01r\x01\x05nodes\x0c\x04\0\x09wit-value\ +\x03\0\x0d\x01q\x04\x0eprotocol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\ +\x15remote-internal-error\x01s\0\x04\0\x09rpc-error\x03\0\x0f\x04\0\x08wasm-rpc\x03\ +\x01\x01i\x11\x01@\x01\x08location\x03\0\x12\x04\0\x15[constructor]wasm-rpc\x01\x13\ +\x01h\x11\x01p\x0e\x01j\x01\x0e\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0f\ +function-params\x15\0\x16\x04\0![method]wasm-rpc.invoke-and-await\x01\x17\x01j\0\ +\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0ffunction-params\x15\0\x18\x04\ +\0\x17[method]wasm-rpc.invoke\x01\x19\x03\x01\x15golem:rpc/types@0.1.0\x05\0\x01\ +B\x1a\x01r\x01\x09bidder-ids\x04\0\x09bidder-id\x03\0\0\x01r\x01\x0aauction-ids\x04\ +\0\x0aauction-id\x03\0\x02\x01w\x04\0\x08deadline\x03\0\x04\x01r\x05\x0aauction-\ +id\x03\x04names\x0bdescriptions\x0blimit-pricev\x0aexpiration\x05\x04\0\x07aucti\ +on\x03\0\x06\x01q\x03\x0fauction-expired\0\0\x0dprice-too-low\0\0\x07success\0\0\ +\x04\0\x0abid-result\x03\0\x08\x04\0\x0frunning-auction\x03\x01\x01i\x0a\x01@\x01\ +\x07auction\x07\0\x0b\x04\0\x1c[constructor]running-auction\x01\x0c\x01h\x0a\x01\ +@\x03\x04self\x0d\x09bidder-id\x01\x05pricev\0\x09\x04\0\x1b[method]running-auct\ +ion.bid\x01\x0e\x01k\x01\x01@\x01\x04self\x0d\0\x0f\x04\0\x1d[method]running-auc\ +tion.close\x01\x10\x01@\x01\x07auction\x07\x01\0\x04\0\x0ainitialize\x01\x11\x01\ +@\x02\x09bidder-id\x01\x05pricev\0\x09\x04\0\x03bid\x01\x12\x01@\0\0\x0f\x04\0\x0d\ +close-auction\x01\x13\x03\x01\x13auction:auction/api\x05\x01\x02\x03\0\0\x03uri\x02\ +\x03\0\x01\x09bidder-id\x02\x03\0\x01\x0aauction-id\x02\x03\0\x01\x08deadline\x02\ +\x03\0\x01\x07auction\x02\x03\0\x01\x0abid-result\x01B\"\x02\x03\x02\x01\x02\x04\ +\0\x03uri\x03\0\0\x02\x03\x02\x01\x03\x04\0\x09bidder-id\x03\0\x02\x02\x03\x02\x01\ +\x04\x04\0\x0aauction-id\x03\0\x04\x02\x03\x02\x01\x05\x04\0\x08deadline\x03\0\x06\ +\x02\x03\x02\x01\x06\x04\0\x07auction\x03\0\x08\x02\x03\x02\x01\x07\x04\0\x0abid\ +-result\x03\0\x0a\x04\0\x03api\x03\x01\x04\0\x0frunning-auction\x03\x01\x01i\x0c\ +\x01@\x01\x08location\x01\0\x0e\x04\0\x10[constructor]api\x01\x0f\x01h\x0c\x01@\x02\ +\x04self\x10\x07auction\x09\x01\0\x04\0\x1f[method]api.blocking-initialize\x01\x11\ +\x04\0\x16[method]api.initialize\x01\x11\x01@\x03\x04self\x10\x09bidder-id\x03\x05\ +pricev\0\x0b\x04\0\x0f[method]api.bid\x01\x12\x01k\x03\x01@\x01\x04self\x10\0\x13\ +\x04\0\x19[method]api.close-auction\x01\x14\x01i\x0d\x01@\x02\x08location\x01\x07\ +auction\x09\0\x15\x04\0\x1c[constructor]running-auction\x01\x16\x01h\x0d\x01@\x03\ +\x04self\x17\x09bidder-id\x03\x05pricev\0\x0b\x04\0\x1b[method]running-auction.b\ +id\x01\x18\x01@\x01\x04self\x17\0\x13\x04\0\x1d[method]running-auction.close\x01\ +\x19\x03\x01!auction:auction-stub/stub-auction\x05\x08\x01B\x10\x02\x03\x02\x01\x03\ +\x04\0\x09bidder-id\x03\0\0\x02\x03\x02\x01\x04\x04\0\x0aauction-id\x03\0\x02\x02\ +\x03\x02\x01\x05\x04\0\x08deadline\x03\0\x04\x02\x03\x02\x01\x06\x04\0\x07auctio\ +n\x03\0\x06\x01@\x02\x04names\x07addresss\0\x01\x04\0\x0dcreate-bidder\x01\x08\x01\ +@\x04\x04names\x0bdescriptions\x0blimit-pricev\x0aexpiration\x05\0\x03\x04\0\x0e\ +create-auction\x01\x09\x01p\x07\x01@\0\0\x0a\x04\0\x0cget-auctions\x01\x0b\x04\0\ +\x12create-auction-res\x01\x09\x04\x01\x14auction:registry/api\x05\x09\x04\x01!a\ +uction:registry/auction-registry\x04\0\x0b\x16\x01\0\x10auction-registry\x03\0\0\ +\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bind\ +gen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/auction-example/auction-registry/src/lib.rs b/test-components/auction-example/auction-registry/src/lib.rs index 244e82b393..78b2bfd31d 100644 --- a/test-components/auction-example/auction-registry/src/lib.rs +++ b/test-components/auction-example/auction-registry/src/lib.rs @@ -75,3 +75,5 @@ impl Guest for Component { }) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/auction-example/auction-stub/Cargo.toml b/test-components/auction-example/auction-stub/Cargo.toml index d6ed3f72e9..6d081fc1ee 100644 --- a/test-components/auction-example/auction-stub/Cargo.toml +++ b/test-components/auction-example/auction-stub/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "auction-stub" -edition = "2021" version = "0.0.1" +edition = "2021" [package.metadata.component] package = "auction:auction" @@ -17,14 +17,13 @@ path = "wit/deps/auction_auction" path = "wit/deps/wasm-rpc" [dependencies.golem-wasm-rpc] -version = "0.0.25" +version = "0.0.29" features = ["stub"] default-features = false -[dependencies.wit-bindgen] -version = "0.17.0" -features = ["realloc"] -default-features = false +[dependencies.wit-bindgen-rt] +version = "0.26.0" +features = ["bitflags"] [lib] path = "src/lib.rs" diff --git a/test-components/auction-example/auction-stub/src/bindings.rs b/test-components/auction-example/auction-stub/src/bindings.rs index bc23c83356..879d99412d 100644 --- a/test-components/auction-example/auction-stub/src/bindings.rs +++ b/test-components/auction-example/auction-stub/src/bindings.rs @@ -1,2057 +1,2862 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod auction { - pub mod auction { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - #[derive(Clone)] - pub struct BidderId { - pub bidder_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for BidderId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("BidderId").field("bidder-id", &self.bidder_id).finish() - } - } - #[derive(Clone)] - pub struct AuctionId { - pub auction_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for AuctionId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AuctionId").field("auction-id", &self.auction_id).finish() - } - } - pub type Deadline = u64; - #[derive(Clone)] - pub struct Auction { - pub auction_id: AuctionId, - pub name: wit_bindgen::rt::string::String, - pub description: wit_bindgen::rt::string::String, - pub limit_price: f32, - pub expiration: Deadline, - } - impl ::core::fmt::Debug for Auction { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Auction").field("auction-id", &self.auction_id).field("name", &self.name).field("description", &self.description).field("limit-price", &self.limit_price).field("expiration", &self.expiration).finish() - } - } - #[derive(Clone, Copy)] - pub enum BidResult{ - AuctionExpired, - PriceTooLow, - Success, - } - impl ::core::fmt::Debug for BidResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - BidResult::AuctionExpired => { - f.debug_tuple("BidResult::AuctionExpired").finish() - } - BidResult::PriceTooLow => { - f.debug_tuple("BidResult::PriceTooLow").finish() - } - BidResult::Success => { - f.debug_tuple("BidResult::Success").finish() - } - } - } - } - /// an alternative interface for hosting multiple auctions in a single worker - - #[derive(Debug)] - #[repr(transparent)] - pub struct RunningAuction{ - handle: wit_bindgen::rt::Resource, - } - - impl RunningAuction{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for RunningAuction{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[resource-drop]running-auction"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - pub fn initialize(auction: &Auction,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "initialize"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ){ unreachable!() } - wit_import(ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn bid(bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "bid"] - fn wit_import(_: i32, _: i32, _: f32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1, wit_bindgen::rt::as_f32(price)); - let v2 = match ret { - 0 => { - BidResult::AuctionExpired - } - 1 => { - BidResult::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - BidResult::Success - } - }; - v2 - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn close_auction() -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "close-auction"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn new(auction: &Auction,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Auction{ auction_id:auction_id0, name:name0, description:description0, limit_price:limit_price0, expiration:expiration0, } = auction; - let AuctionId{ auction_id:auction_id1, } = auction_id0; - let vec2 = auction_id1; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec3 = name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - let vec4 = description0; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[constructor]running-auction"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: f32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import(ptr2, len2, ptr3, len3, ptr4, len4, wit_bindgen::rt::as_f32(limit_price0), wit_bindgen::rt::as_i64(expiration0)); - RunningAuction::from_handle(ret as u32) - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn bid(&self,bidder_id: &BidderId,price: f32,) -> BidResult{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let BidderId{ bidder_id:bidder_id0, } = bidder_id; - let vec1 = bidder_id0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - + #[allow(dead_code)] + pub mod auction { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[method]running-auction.bid"] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32; + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[derive(Clone)] + pub struct BidderId { + pub bidder_id: _rt::String, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: f32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr1, len1, wit_bindgen::rt::as_f32(price)); - let v2 = match ret { - 0 => { - BidResult::AuctionExpired - } - 1 => { - BidResult::PriceTooLow - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - BidResult::Success - } - }; - v2 - } - } - } - impl RunningAuction { - #[allow(unused_unsafe, clippy::all)] - pub fn close(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "auction:auction/api")] - extern "C" { - #[link_name = "[method]running-auction.close"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes4), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl ::core::fmt::Debug for BidderId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BidderId") + .field("bidder-id", &self.bidder_id) + .finish() + } } - } - } - } - - } - - } -} -pub mod golem { - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - Handle((Uri,u64,)), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() + #[derive(Clone)] + pub struct AuctionId { + pub auction_id: _rt::String, } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() + impl ::core::fmt::Debug for AuctionId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AuctionId") + .field("auction-id", &self.auction_id) + .finish() + } } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() + pub type Deadline = u64; + #[derive(Clone)] + pub struct Auction { + pub auction_id: AuctionId, + pub name: _rt::String, + pub description: _rt::String, + pub limit_price: f32, + pub expiration: Deadline, } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() + impl ::core::fmt::Debug for Auction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Auction") + .field("auction-id", &self.auction_id) + .field("name", &self.name) + .field("description", &self.description) + .field("limit-price", &self.limit_price) + .field("expiration", &self.expiration) + .finish() + } } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() + #[derive(Clone, Copy)] + pub enum BidResult { + AuctionExpired, + PriceTooLow, + Success, } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() + impl ::core::fmt::Debug for BidResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + BidResult::AuctionExpired => { + f.debug_tuple("BidResult::AuctionExpired").finish() + } + BidResult::PriceTooLow => f.debug_tuple("BidResult::PriceTooLow").finish(), + BidResult::Success => f.debug_tuple("BidResult::Success").finish(), + } + } } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() + /// an alternative interface for hosting multiple auctions in a single worker + + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuction { + handle: _rt::Resource, } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() + + impl RunningAuction { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() + + unsafe impl _rt::WasmResource for RunningAuction { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[resource-drop]running-auction"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() + + #[allow(unused_unsafe, clippy::all)] + pub fn initialize(auction: &Auction) { + unsafe { + let Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "initialize"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) { + unreachable!() + } + wit_import( + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + } } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() + #[allow(unused_unsafe, clippy::all)] + pub fn bid(bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "bid"] + fn wit_import(_: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1, _rt::as_f32(&price)); + let v2 = match ret { + 0 => BidResult::AuctionExpired, + 1 => BidResult::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + BidResult::Success + } + }; + v2 + } } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() + #[allow(unused_unsafe, clippy::all)] + pub fn close_auction() -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "close-auction"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn new(auction: &Auction) -> Self { + unsafe { + let Auction { + auction_id: auction_id0, + name: name0, + description: description0, + limit_price: limit_price0, + expiration: expiration0, + } = auction; + let AuctionId { + auction_id: auction_id1, + } = auction_id0; + let vec2 = auction_id1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec3 = name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let vec4 = description0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[constructor]running-auction"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: f32, + _: i64, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + ptr2.cast_mut(), + len2, + ptr3.cast_mut(), + len3, + ptr4.cast_mut(), + len4, + _rt::as_f32(limit_price0), + _rt::as_i64(expiration0), + ); + RunningAuction::from_handle(ret as u32) + } + } } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn bid(&self, bidder_id: &BidderId, price: f32) -> BidResult { + unsafe { + let BidderId { + bidder_id: bidder_id0, + } = bidder_id; + let vec1 = bidder_id0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[method]running-auction.bid"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: f32) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + ptr1.cast_mut(), + len1, + _rt::as_f32(&price), + ); + let v2 = match ret { + 0 => BidResult::AuctionExpired, + 1 => BidResult::PriceTooLow, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + BidResult::Success + } + }; + v2 + } + } } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() + impl RunningAuction { + #[allow(unused_unsafe, clippy::all)] + pub fn close(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "auction:auction/api")] + extern "C" { + #[link_name = "[method]running-auction.close"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + BidderId { + bidder_id: _rt::string_lift(bytes4), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() + } + } +} +#[allow(dead_code)] +pub mod golem { + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + Handle((Uri, u64)), } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + WitNode::Handle(e) => f.debug_tuple("WitNode::Handle").field(e).finish(), + } + } } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } } - WitNode::Handle(e) => { - f.debug_tuple("WitNode::Handle").field(e).finish() + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, - } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } + } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); } - } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); } - - } - match l14 { - 0 => { - let e = { - let l15 = *((ptr13 + 4) as *const i32); - let l16 = *((ptr13 + 8) as *const i32); - let base62 = l15; - let len62 = l16; - let mut result62 = Vec::with_capacity(len62 as usize); - for i in 0..len62 { - let base = base62 + i * 24; - let e62 = { - let l17 = i32::from(*((base + 0) as *const u8)); - let v61 = match l17 { - 0 => { - let e61 = { - let l18 = *((base + 8) as *const i32); - let l19 = *((base + 12) as *const i32); - let len20 = l19 as usize; - - Vec::from_raw_parts(l18 as *mut _, len20, len20) - }; - WitNode::RecordValue(e61) - } - 1 => { - let e61 = { - let l21 = *((base + 8) as *const i32); - let l22 = i32::from(*((base + 12) as *const u8)); - - (l21 as u32, match l22 { + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = { + let l15 = *ptr13.add(4).cast::<*mut u8>(); + let l16 = *ptr13.add(8).cast::(); + let base62 = l15; + let len62 = l16; + let mut result62 = _rt::Vec::with_capacity(len62); + for i in 0..len62 { + let base = base62.add(i * 24); + let e62 = { + let l17 = i32::from(*base.add(0).cast::()); + let v61 = match l17 { + 0 => { + let e61 = { + let l18 = *base.add(8).cast::<*mut u8>(); + let l19 = *base.add(12).cast::(); + let len20 = l19; + + _rt::Vec::from_raw_parts( + l18.cast(), + len20, + len20, + ) + }; + WitNode::RecordValue(e61) + } + 1 => { + let e61 = + { + let l21 = *base.add(8).cast::(); + let l22 = i32::from( + *base.add(12).cast::(), + ); + + (l21 as u32, match l22 { 0 => None, 1 => { let e = { - let l23 = *((base + 16) as *const i32); - + let l23 = *base.add(16).cast::(); + l23 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }) - }; - WitNode::VariantValue(e61) - } - 2 => { - let e61 = { - let l24 = *((base + 8) as *const i32); - - l24 as u32 - }; - WitNode::EnumValue(e61) - } - 3 => { - let e61 = { - let l25 = *((base + 8) as *const i32); - let l26 = *((base + 12) as *const i32); - let base28 = l25; - let len28 = l26; - let mut result28 = Vec::with_capacity(len28 as usize); - for i in 0..len28 { - let base = base28 + i * 1; - let e28 = { - let l27 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l27 as u8) - }; - result28.push(e28); - } - wit_bindgen::rt::dealloc(base28, (len28 as usize) * 1, 1); - - result28 - }; - WitNode::FlagsValue(e61) - } - 4 => { - let e61 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::TupleValue(e61) - } - 5 => { - let e61 = { - let l32 = *((base + 8) as *const i32); - let l33 = *((base + 12) as *const i32); - let len34 = l33 as usize; - - Vec::from_raw_parts(l32 as *mut _, len34, len34) - }; - WitNode::ListValue(e61) - } - 6 => { - let e61 = { - let l35 = i32::from(*((base + 8) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((base + 12) as *const i32); - - l36 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e61) - } - 7 => { - let e61 = { - let l37 = i32::from(*((base + 8) as *const u8)); - - match l37 { - 0 => { - let e = { - let l38 = i32::from(*((base + 12) as *const u8)); - - match l38 { + }; + WitNode::VariantValue(e61) + } + 2 => { + let e61 = { + let l24 = *base.add(8).cast::(); + + l24 as u32 + }; + WitNode::EnumValue(e61) + } + 3 => { + let e61 = { + let l25 = *base.add(8).cast::<*mut u8>(); + let l26 = *base.add(12).cast::(); + let base28 = l25; + let len28 = l26; + let mut result28 = + _rt::Vec::with_capacity(len28); + for i in 0..len28 { + let base = base28.add(i * 1); + let e28 = { + let l27 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l27 as u8) + }; + result28.push(e28); + } + _rt::cabi_dealloc(base28, len28 * 1, 1); + + result28 + }; + WitNode::FlagsValue(e61) + } + 4 => { + let e61 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::TupleValue(e61) + } + 5 => { + let e61 = { + let l32 = *base.add(8).cast::<*mut u8>(); + let l33 = *base.add(12).cast::(); + let len34 = l33; + + _rt::Vec::from_raw_parts( + l32.cast(), + len34, + len34, + ) + }; + WitNode::ListValue(e61) + } + 6 => { + let e61 = { + let l35 = + i32::from(*base.add(8).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = + *base.add(12).cast::(); + + l36 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e61) + } + 7 => { + let e61 = { + let l37 = + i32::from(*base.add(8).cast::()); + + match l37 { + 0 => { + let e = { + let l38 = i32::from( + *base.add(12).cast::(), + ); + + match l38 { 0 => None, 1 => { let e = { - let l39 = *((base + 16) as *const i32); - + let l39 = *base.add(16).cast::(); + l39 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l40 = i32::from(*((base + 12) as *const u8)); - - match l40 { + }; + Ok(e) + } + 1 => { + let e = { + let l40 = i32::from( + *base.add(12).cast::(), + ); + + match l40 { 0 => None, 1 => { let e = { - let l41 = *((base + 16) as *const i32); - + let l41 = *base.add(16).cast::(); + l41 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e61) - } - 8 => { - let e61 = { - let l42 = i32::from(*((base + 8) as *const u8)); - - l42 as u8 - }; - WitNode::PrimU8(e61) - } - 9 => { - let e61 = { - let l43 = i32::from(*((base + 8) as *const u16)); - - l43 as u16 - }; - WitNode::PrimU16(e61) - } - 10 => { - let e61 = { - let l44 = *((base + 8) as *const i32); - - l44 as u32 - }; - WitNode::PrimU32(e61) - } - 11 => { - let e61 = { - let l45 = *((base + 8) as *const i64); - - l45 as u64 - }; - WitNode::PrimU64(e61) - } - 12 => { - let e61 = { - let l46 = i32::from(*((base + 8) as *const i8)); - - l46 as i8 - }; - WitNode::PrimS8(e61) - } - 13 => { - let e61 = { - let l47 = i32::from(*((base + 8) as *const i16)); - - l47 as i16 - }; - WitNode::PrimS16(e61) - } - 14 => { - let e61 = { - let l48 = *((base + 8) as *const i32); - - l48 - }; - WitNode::PrimS32(e61) - } - 15 => { - let e61 = { - let l49 = *((base + 8) as *const i64); - - l49 - }; - WitNode::PrimS64(e61) - } - 16 => { - let e61 = { - let l50 = *((base + 8) as *const f32); - - l50 - }; - WitNode::PrimFloat32(e61) - } - 17 => { - let e61 = { - let l51 = *((base + 8) as *const f64); - - l51 - }; - WitNode::PrimFloat64(e61) - } - 18 => { - let e61 = { - let l52 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l52 as u32) - }; - WitNode::PrimChar(e61) - } - 19 => { - let e61 = { - let l53 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l53 as u8) - }; - WitNode::PrimBool(e61) - } - 20 => { - let e61 = { - let l54 = *((base + 8) as *const i32); - let l55 = *((base + 12) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - WitNode::PrimString(e61) - } - n => { - debug_assert_eq!(n, 21, "invalid enum discriminant"); - let e61 = { - let l57 = *((base + 8) as *const i32); - let l58 = *((base + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - let l60 = *((base + 16) as *const i64); - - (Uri{ - value: wit_bindgen::rt::string_lift(bytes59), - }, l60 as u64) - }; - WitNode::Handle(e61) - } + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e61) + } + 8 => { + let e61 = { + let l42 = + i32::from(*base.add(8).cast::()); + + l42 as u8 + }; + WitNode::PrimU8(e61) + } + 9 => { + let e61 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as u16 + }; + WitNode::PrimU16(e61) + } + 10 => { + let e61 = { + let l44 = *base.add(8).cast::(); + + l44 as u32 + }; + WitNode::PrimU32(e61) + } + 11 => { + let e61 = { + let l45 = *base.add(8).cast::(); + + l45 as u64 + }; + WitNode::PrimU64(e61) + } + 12 => { + let e61 = { + let l46 = + i32::from(*base.add(8).cast::()); + + l46 as i8 + }; + WitNode::PrimS8(e61) + } + 13 => { + let e61 = { + let l47 = + i32::from(*base.add(8).cast::()); + + l47 as i16 + }; + WitNode::PrimS16(e61) + } + 14 => { + let e61 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimS32(e61) + } + 15 => { + let e61 = { + let l49 = *base.add(8).cast::(); + + l49 + }; + WitNode::PrimS64(e61) + } + 16 => { + let e61 = { + let l50 = *base.add(8).cast::(); + + l50 + }; + WitNode::PrimFloat32(e61) + } + 17 => { + let e61 = { + let l51 = *base.add(8).cast::(); + + l51 + }; + WitNode::PrimFloat64(e61) + } + 18 => { + let e61 = { + let l52 = *base.add(8).cast::(); + + _rt::char_lift(l52 as u32) + }; + WitNode::PrimChar(e61) + } + 19 => { + let e61 = { + let l53 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l53 as u8) + }; + WitNode::PrimBool(e61) + } + 20 => { + let e61 = { + let l54 = *base.add(8).cast::<*mut u8>(); + let l55 = *base.add(12).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + WitNode::PrimString(e61) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e61 = { + let l57 = *base.add(8).cast::<*mut u8>(); + let l58 = *base.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + let l60 = *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift(bytes59), + }, + l60 as u64, + ) + }; + WitNode::Handle(e61) + } + }; + + v61 + }; + result62.push(e62); + } + _rt::cabi_dealloc(base62, len62 * 24, 8); + + WitValue { nodes: result62 } }; - - v61 - }; - result62.push(e62); - } - wit_bindgen::rt::dealloc(base62, (len62 as usize) * 24, 8); - - WitValue{ - nodes: result62, + Ok(e) } - }; - Ok(e) - } - 1 => { - let e = { - let l63 = i32::from(*((ptr13 + 4) as *const u8)); - let v76 = match l63 { - 0 => { - let e76 = { - let l64 = *((ptr13 + 8) as *const i32); - let l65 = *((ptr13 + 12) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) - }; - RpcError::ProtocolError(e76) - } - 1 => { - let e76 = { - let l67 = *((ptr13 + 8) as *const i32); - let l68 = *((ptr13 + 12) as *const i32); - let len69 = l68 as usize; - let bytes69 = Vec::from_raw_parts(l67 as *mut _, len69, len69); - - wit_bindgen::rt::string_lift(bytes69) - }; - RpcError::Denied(e76) - } - 2 => { - let e76 = { - let l70 = *((ptr13 + 8) as *const i32); - let l71 = *((ptr13 + 12) as *const i32); - let len72 = l71 as usize; - let bytes72 = Vec::from_raw_parts(l70 as *mut _, len72, len72); - - wit_bindgen::rt::string_lift(bytes72) - }; - RpcError::NotFound(e76) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e76 = { - let l73 = *((ptr13 + 8) as *const i32); - let l74 = *((ptr13 + 12) as *const i32); - let len75 = l74 as usize; - let bytes75 = Vec::from_raw_parts(l73 as *mut _, len75, len75); - - wit_bindgen::rt::string_lift(bytes75) + 1 => { + let e = { + let l63 = i32::from(*ptr13.add(4).cast::()); + let v76 = match l63 { + 0 => { + let e76 = { + let l64 = *ptr13.add(8).cast::<*mut u8>(); + let l65 = *ptr13.add(12).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts( + l64.cast(), + len66, + len66, + ); + + _rt::string_lift(bytes66) + }; + RpcError::ProtocolError(e76) + } + 1 => { + let e76 = { + let l67 = *ptr13.add(8).cast::<*mut u8>(); + let l68 = *ptr13.add(12).cast::(); + let len69 = l68; + let bytes69 = _rt::Vec::from_raw_parts( + l67.cast(), + len69, + len69, + ); + + _rt::string_lift(bytes69) + }; + RpcError::Denied(e76) + } + 2 => { + let e76 = { + let l70 = *ptr13.add(8).cast::<*mut u8>(); + let l71 = *ptr13.add(12).cast::(); + let len72 = l71; + let bytes72 = _rt::Vec::from_raw_parts( + l70.cast(), + len72, + len72, + ); + + _rt::string_lift(bytes72) + }; + RpcError::NotFound(e76) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e76 = { + let l73 = *ptr13.add(8).cast::<*mut u8>(); + let l74 = *ptr13.add(12).cast::(); + let len75 = l74; + let bytes75 = _rt::Vec::from_raw_parts( + l73.cast(), + len75, + len75, + ); + + _rt::string_lift(bytes75) + }; + RpcError::RemoteInternalError(e76) + } + }; + + v76 }; - RpcError::RemoteInternalError(e76) - } - }; - - v76 - }; - Err(e) + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke(&self,function_name: &str,function_params: &[WitValue],) -> Result<(),RpcError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result<(), RpcError> { unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; + } else { { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; - { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - } + ::core::ptr::null_mut() } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } } - } } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); - } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l14 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l15 = i32::from(*((ptr13 + 4) as *const u8)); - let v28 = match l15 { + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(4).cast::()); + let v28 = match l15 { 0 => { - let e28 = { - let l16 = *((ptr13 + 8) as *const i32); - let l17 = *((ptr13 + 12) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) - }; - RpcError::ProtocolError(e28) + let e28 = { + let l16 = *ptr13.add(8).cast::<*mut u8>(); + let l17 = *ptr13.add(12).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, + ); + + _rt::string_lift(bytes18) + }; + RpcError::ProtocolError(e28) } 1 => { - let e28 = { - let l19 = *((ptr13 + 8) as *const i32); - let l20 = *((ptr13 + 12) as *const i32); - let len21 = l20 as usize; - let bytes21 = Vec::from_raw_parts(l19 as *mut _, len21, len21); - - wit_bindgen::rt::string_lift(bytes21) - }; - RpcError::Denied(e28) + let e28 = { + let l19 = *ptr13.add(8).cast::<*mut u8>(); + let l20 = *ptr13.add(12).cast::(); + let len21 = l20; + let bytes21 = _rt::Vec::from_raw_parts( + l19.cast(), + len21, + len21, + ); + + _rt::string_lift(bytes21) + }; + RpcError::Denied(e28) } 2 => { - let e28 = { - let l22 = *((ptr13 + 8) as *const i32); - let l23 = *((ptr13 + 12) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) - }; - RpcError::NotFound(e28) + let e28 = { + let l22 = *ptr13.add(8).cast::<*mut u8>(); + let l23 = *ptr13.add(12).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts( + l22.cast(), + len24, + len24, + ); + + _rt::string_lift(bytes24) + }; + RpcError::NotFound(e28) } n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e28 = { - let l25 = *((ptr13 + 8) as *const i32); - let l26 = *((ptr13 + 12) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) - }; - RpcError::RemoteInternalError(e28) + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e28 = { + let l25 = *ptr13.add(8).cast::<*mut u8>(); + let l26 = *ptr13.add(12).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts( + l25.cast(), + len27, + len27, + ); + + _rt::string_lift(bytes27) + }; + RpcError::RemoteInternalError(e28) } - }; - - v28 }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + + v28 + }; + Err(e) } - } - + _ => _rt::invalid_enum_discriminant(), } - - } } - pub mod exports { - pub mod auction { - pub mod auction_stub { - - #[allow(clippy::all)] - pub mod stub_auction { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type Uri = super::super::super::super::golem::rpc::types::Uri; - pub type BidderId = super::super::super::super::auction::auction::api::BidderId; - pub type Auction = super::super::super::super::auction::auction::api::Auction; - pub type BidResult = super::super::super::super::auction::auction::api::BidResult; - - pub use super::super::super::super::super::Api as Api; - const _: () = { - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[dtor]api"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Api{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-new]api"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-rep]api"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } + } + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod auction { + #[allow(dead_code)] + pub mod auction_stub { + #[allow(dead_code, clippy::all)] + pub mod stub_auction { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type Uri = super::super::super::super::golem::rpc::types::Uri; + pub type BidderId = super::super::super::super::auction::auction::api::BidderId; + pub type Auction = super::super::super::super::auction::auction::api::Auction; + pub type BidResult = super::super::super::super::auction::auction::api::BidResult; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Api { + handle: _rt::Resource, + } + + type _ApiRep = Option; + + impl Api { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Api`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ApiRep = Some(val); + let ptr: *mut _ApiRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestApi` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), } - pub type OwnApi = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Api{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-drop]api"] - fn drop(_: u32); - } - - drop(_handle); - } - } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ApiRep); + } + + fn as_ptr(&self) -> *mut _ApiRep { + Api::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Api`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ApiBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Api>, + } + + impl<'a> ApiBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ApiRep { + Api::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Api { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-drop]api"] + fn drop(_: u32); } - - - pub use super::super::super::super::super::RunningAuction as RunningAuction; - const _: () = { - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[dtor]running-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for RunningAuction{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-new]running-auction"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-rep]running-auction"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuction { + handle: _rt::Resource, + } + + type _RunningAuctionRep = Option; + + impl RunningAuction { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `RunningAuction`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _RunningAuctionRep = Some(val); + let ptr: *mut _RunningAuctionRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestRunningAuction` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), } - pub type OwnRunningAuction = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for RunningAuction{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction-stub/stub-auction")] - extern "C" { - #[link_name = "[resource-drop]running-auction"] - fn drop(_: u32); - } - - drop(_handle); - } - } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _RunningAuctionRep); + } + + fn as_ptr(&self) -> *mut _RunningAuctionRep { + RunningAuction::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`RunningAuction`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuctionBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a RunningAuction>, + } + + impl<'a> RunningAuctionBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _RunningAuctionRep { + RunningAuction::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for RunningAuction { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-drop]running-auction"] + fn drop(_: u32); } - - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[constructor]api"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_api(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = OwnApi::new(<_ApiImpl as GuestApi>::new(super::super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes0), - })); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]api.blocking-initialize"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_blocking_initialize(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: f32,arg8: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let len1 = arg4 as usize; - let bytes1 = Vec::from_raw_parts(arg3 as *mut _, len1, len1); - let len2 = arg6 as usize; - let bytes2 = Vec::from_raw_parts(arg5 as *mut _, len2, len2); - <_ApiImpl as GuestApi>::blocking_initialize(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), super::super::super::super::auction::auction::api::Auction{ - auction_id: super::super::super::super::auction::auction::api::AuctionId{ - auction_id: wit_bindgen::rt::string_lift(bytes0), - }, - name: wit_bindgen::rt::string_lift(bytes1), - description: wit_bindgen::rt::string_lift(bytes2), - limit_price: arg7, - expiration: arg8 as u64, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]api.initialize"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_initialize(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: f32,arg8: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let len1 = arg4 as usize; - let bytes1 = Vec::from_raw_parts(arg3 as *mut _, len1, len1); - let len2 = arg6 as usize; - let bytes2 = Vec::from_raw_parts(arg5 as *mut _, len2, len2); - <_ApiImpl as GuestApi>::initialize(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), super::super::super::super::auction::auction::api::Auction{ - auction_id: super::super::super::super::auction::auction::api::AuctionId{ - auction_id: wit_bindgen::rt::string_lift(bytes0), - }, - name: wit_bindgen::rt::string_lift(bytes1), - description: wit_bindgen::rt::string_lift(bytes2), - limit_price: arg7, - expiration: arg8 as u64, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]api.bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_bid(arg0: i32,arg1: i32,arg2: i32,arg3: f32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let result1 = <_ApiImpl as GuestApi>::bid(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), super::super::super::super::auction::auction::api::BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes0), - }, arg3); - use super::super::super::super::auction::auction::api::BidResult as V2; - let result3 = match result1 { - V2::AuctionExpired=> { - 0i32 - } - V2::PriceTooLow=> { - 1i32 - } - V2::Success=> { - 2i32 - } - }; - result3 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]api.close-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_close_auction(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_ApiImpl as GuestApi>::close_auction(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Some(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let super::super::super::super::auction::auction::api::BidderId{ bidder_id:bidder_id2, } = e; - let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:auction-stub/stub-auction#[method]api.close-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_api_close_auction(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[constructor]running-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_running_auction(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,arg8: f32,arg9: i64,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let len2 = arg5 as usize; - let bytes2 = Vec::from_raw_parts(arg4 as *mut _, len2, len2); - let len3 = arg7 as usize; - let bytes3 = Vec::from_raw_parts(arg6 as *mut _, len3, len3); - let result4 = OwnRunningAuction::new(<_RunningAuctionImpl as GuestRunningAuction>::new(super::super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes0), - }, super::super::super::super::auction::auction::api::Auction{ - auction_id: super::super::super::super::auction::auction::api::AuctionId{ - auction_id: wit_bindgen::rt::string_lift(bytes1), - }, - name: wit_bindgen::rt::string_lift(bytes2), - description: wit_bindgen::rt::string_lift(bytes3), - limit_price: arg8, - expiration: arg9 as u64, - })); - wit_bindgen::rt::Resource::into_handle(result4) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]running-auction.bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_running_auction_bid(arg0: i32,arg1: i32,arg2: i32,arg3: f32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let result1 = <_RunningAuctionImpl as GuestRunningAuction>::bid(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), super::super::super::super::auction::auction::api::BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes0), - }, arg3); - use super::super::super::super::auction::auction::api::BidResult as V2; - let result3 = match result1 { - V2::AuctionExpired=> { - 0i32 - } - V2::PriceTooLow=> { - 1i32 - } - V2::Success=> { - 2i32 - } - }; - result3 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction-stub/stub-auction#[method]running-auction.close"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_running_auction_close(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_RunningAuctionImpl as GuestRunningAuction>::close(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Some(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let super::super::super::super::auction::auction::api::BidderId{ bidder_id:bidder_id2, } = e; - let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:auction-stub/stub-auction#[method]running-auction.close"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_running_auction_close(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - use super::super::super::super::super::Api as _ApiImpl; - pub trait GuestApi { - fn new(location: Uri,) -> Self; - fn blocking_initialize(&self,auction: Auction,); - fn initialize(&self,auction: Auction,); - fn bid(&self,bidder_id: BidderId,price: f32,) -> BidResult; - fn close_auction(&self,) -> Option; + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_api_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = + Api::new(T::new(super::super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes0), + })); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_blocking_initialize_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: *mut u8, + arg4: usize, + arg5: *mut u8, + arg6: usize, + arg7: f32, + arg8: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let len1 = arg4; + let bytes1 = _rt::Vec::from_raw_parts(arg3.cast(), len1, len1); + let len2 = arg6; + let bytes2 = _rt::Vec::from_raw_parts(arg5.cast(), len2, len2); + T::blocking_initialize( + ApiBorrow::lift(arg0 as u32 as usize).get(), + super::super::super::super::auction::auction::api::Auction { + auction_id: + super::super::super::super::auction::auction::api::AuctionId { + auction_id: _rt::string_lift(bytes0), + }, + name: _rt::string_lift(bytes1), + description: _rt::string_lift(bytes2), + limit_price: arg7, + expiration: arg8 as u64, + }, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_initialize_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: *mut u8, + arg4: usize, + arg5: *mut u8, + arg6: usize, + arg7: f32, + arg8: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let len1 = arg4; + let bytes1 = _rt::Vec::from_raw_parts(arg3.cast(), len1, len1); + let len2 = arg6; + let bytes2 = _rt::Vec::from_raw_parts(arg5.cast(), len2, len2); + T::initialize( + ApiBorrow::lift(arg0 as u32 as usize).get(), + super::super::super::super::auction::auction::api::Auction { + auction_id: + super::super::super::super::auction::auction::api::AuctionId { + auction_id: _rt::string_lift(bytes0), + }, + name: _rt::string_lift(bytes1), + description: _rt::string_lift(bytes2), + limit_price: arg7, + expiration: arg8 as u64, + }, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_bid_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: f32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let result1 = T::bid( + ApiBorrow::lift(arg0 as u32 as usize).get(), + super::super::super::super::auction::auction::api::BidderId { + bidder_id: _rt::string_lift(bytes0), + }, + arg3, + ); + use super::super::super::super::auction::auction::api::BidResult as V2; + let result3 = match result1 { + V2::AuctionExpired => 0i32, + V2::PriceTooLow => 1i32, + V2::Success => 2i32, + }; + result3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_close_auction_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::close_auction(ApiBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let super::super::super::super::auction::auction::api::BidderId { + bidder_id: bidder_id2, + } = e; + let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_api_close_auction(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_running_auction_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: *mut u8, + arg5: usize, + arg6: *mut u8, + arg7: usize, + arg8: f32, + arg9: i64, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let len2 = arg5; + let bytes2 = _rt::Vec::from_raw_parts(arg4.cast(), len2, len2); + let len3 = arg7; + let bytes3 = _rt::Vec::from_raw_parts(arg6.cast(), len3, len3); + let result4 = RunningAuction::new(T::new( + super::super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes0), + }, + super::super::super::super::auction::auction::api::Auction { + auction_id: + super::super::super::super::auction::auction::api::AuctionId { + auction_id: _rt::string_lift(bytes1), + }, + name: _rt::string_lift(bytes2), + description: _rt::string_lift(bytes3), + limit_price: arg8, + expiration: arg9 as u64, + }, + )); + (result4).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_running_auction_bid_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: f32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let result1 = T::bid( + RunningAuctionBorrow::lift(arg0 as u32 as usize).get(), + super::super::super::super::auction::auction::api::BidderId { + bidder_id: _rt::string_lift(bytes0), + }, + arg3, + ); + use super::super::super::super::auction::auction::api::BidResult as V2; + let result3 = match result1 { + V2::AuctionExpired => 0i32, + V2::PriceTooLow => 1i32, + V2::Success => 2i32, + }; + result3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_running_auction_close_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::close(RunningAuctionBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let super::super::super::super::auction::auction::api::BidderId { + bidder_id: bidder_id2, + } = e; + let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_running_auction_close( + arg0: *mut u8, + ) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + type Api: GuestApi; + type RunningAuction: GuestRunningAuction; + } + pub trait GuestApi: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-new]api"] + fn new(_: *mut u8) -> u32; } - use super::super::super::super::super::RunningAuction as _RunningAuctionImpl; - pub trait GuestRunningAuction { - fn new(location: Uri,auction: Auction,) -> Self; - fn bid(&self,bidder_id: BidderId,price: f32,) -> BidResult; - fn close(&self,) -> Option; + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-rep]api"] + fn rep(_: u32) -> *mut u8; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - + unsafe { rep(handle) } } - } } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:wasm-rpc-stub-auction"] + + fn new(location: Uri) -> Self; + fn blocking_initialize(&self, auction: Auction); + fn initialize(&self, auction: Auction); + fn bid(&self, bidder_id: BidderId, price: f32) -> BidResult; + fn close_auction(&self) -> Option; + } + pub trait GuestRunningAuction: 'static { #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3565] = [3, 0, 21, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 0, 97, 115, 109, 13, 0, 1, 0, 7, 160, 11, 1, 65, 12, 1, 66, 18, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 11, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 3, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 1, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 2, 3, 0, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 2, 3, 0, 1, 8, 100, 101, 97, 100, 108, 105, 110, 101, 2, 3, 0, 1, 7, 97, 117, 99, 116, 105, 111, 110, 2, 3, 0, 1, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 1, 66, 34, 2, 3, 2, 1, 2, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 4, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 4, 2, 3, 2, 1, 5, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 6, 2, 3, 2, 1, 6, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 8, 2, 3, 2, 1, 7, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 12, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 14, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 15, 1, 104, 12, 1, 64, 2, 4, 115, 101, 108, 102, 16, 7, 97, 117, 99, 116, 105, 111, 110, 9, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 3, 4, 115, 101, 108, 102, 16, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 15, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 105, 100, 1, 18, 1, 107, 3, 1, 64, 1, 4, 115, 101, 108, 102, 16, 0, 19, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 20, 1, 105, 13, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 7, 97, 117, 99, 116, 105, 111, 110, 9, 0, 21, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 22, 1, 104, 13, 1, 64, 3, 4, 115, 101, 108, 102, 23, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 24, 1, 64, 1, 4, 115, 101, 108, 102, 23, 0, 19, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 25, 4, 1, 33, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 5, 8, 11, 18, 1, 0, 12, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 3, 0, 0, 7, 156, 15, 1, 65, 2, 1, 65, 12, 1, 66, 29, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 17, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 3, 0, 18, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 19, 1, 104, 17, 1, 112, 14, 1, 106, 1, 14, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 22, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 23, 1, 106, 0, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 24, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 1, 25, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 26, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 10, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 0, 11, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 12, 1, 104, 10, 1, 64, 3, 4, 115, 101, 108, 102, 13, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 14, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 13, 0, 15, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 16, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 1, 0, 4, 0, 10, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 2, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 3, 98, 105, 100, 1, 18, 1, 64, 0, 0, 15, 4, 0, 13, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 19, 3, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 1, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 2, 3, 0, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 2, 3, 0, 1, 8, 100, 101, 97, 100, 108, 105, 110, 101, 2, 3, 0, 1, 7, 97, 117, 99, 116, 105, 111, 110, 2, 3, 0, 1, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 1, 66, 34, 2, 3, 2, 1, 2, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 4, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 4, 2, 3, 2, 1, 5, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 6, 2, 3, 2, 1, 6, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 8, 2, 3, 2, 1, 7, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 12, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 14, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 15, 1, 104, 12, 1, 64, 2, 4, 115, 101, 108, 102, 16, 7, 97, 117, 99, 116, 105, 111, 110, 9, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 3, 4, 115, 101, 108, 102, 16, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 15, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 105, 100, 1, 18, 1, 107, 3, 1, 64, 1, 4, 115, 101, 108, 102, 16, 0, 19, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 20, 1, 105, 13, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 7, 97, 117, 99, 116, 105, 111, 110, 9, 0, 21, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 22, 1, 104, 13, 1, 64, 3, 4, 115, 101, 108, 102, 23, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 5, 112, 114, 105, 99, 101, 118, 0, 11, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 24, 1, 64, 1, 4, 115, 101, 108, 102, 23, 0, 19, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 25, 4, 1, 33, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 5, 8, 4, 1, 42, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 45, 115, 116, 117, 98, 47, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 4, 0, 11, 27, 1, 0, 21, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 97, 117, 99, 116, 105, 111, 110, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-new]running-auction"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]auction:auction-stub/stub-auction" + )] + extern "C" { + #[link_name = "[resource-rep]running-auction"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(location: Uri, auction: Auction) -> Self; + fn bid(&self, bidder_id: BidderId, price: f32) -> BidResult; + fn close(&self) -> Option; + } + #[doc(hidden)] + + macro_rules! __export_auction_auction_stub_stub_auction_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "auction:auction-stub/stub-auction#[constructor]api"] + unsafe extern "C" fn export_constructor_api(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_constructor_api_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1) + } + #[export_name = "auction:auction-stub/stub-auction#[method]api.blocking-initialize"] + unsafe extern "C" fn export_method_api_blocking_initialize(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,arg5: *mut u8,arg6: usize,arg7: f32,arg8: i64,) { + $($path_to_types)*::_export_method_api_blocking_initialize_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) + } + #[export_name = "auction:auction-stub/stub-auction#[method]api.initialize"] + unsafe extern "C" fn export_method_api_initialize(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,arg5: *mut u8,arg6: usize,arg7: f32,arg8: i64,) { + $($path_to_types)*::_export_method_api_initialize_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) + } + #[export_name = "auction:auction-stub/stub-auction#[method]api.bid"] + unsafe extern "C" fn export_method_api_bid(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: f32,) -> i32 { + $($path_to_types)*::_export_method_api_bid_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1, arg2, arg3) + } + #[export_name = "auction:auction-stub/stub-auction#[method]api.close-auction"] + unsafe extern "C" fn export_method_api_close_auction(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_api_close_auction_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0) + } + #[export_name = "cabi_post_auction:auction-stub/stub-auction#[method]api.close-auction"] + unsafe extern "C" fn _post_return_method_api_close_auction(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_api_close_auction::<<$ty as $($path_to_types)*::Guest>::Api>(arg0) + } + #[export_name = "auction:auction-stub/stub-auction#[constructor]running-auction"] + unsafe extern "C" fn export_constructor_running_auction(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,arg8: f32,arg9: i64,) -> i32 { + $($path_to_types)*::_export_constructor_running_auction_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + } + #[export_name = "auction:auction-stub/stub-auction#[method]running-auction.bid"] + unsafe extern "C" fn export_method_running_auction_bid(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: f32,) -> i32 { + $($path_to_types)*::_export_method_running_auction_bid_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0, arg1, arg2, arg3) + } + #[export_name = "auction:auction-stub/stub-auction#[method]running-auction.close"] + unsafe extern "C" fn export_method_running_auction_close(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_running_auction_close_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0) + } + #[export_name = "cabi_post_auction:auction-stub/stub-auction#[method]running-auction.close"] + unsafe extern "C" fn _post_return_method_running_auction_close(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_running_auction_close::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "auction:auction-stub/stub-auction#[dtor]api"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Api::dtor::< + <$ty as $($path_to_types)*::Guest>::Api + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "auction:auction-stub/stub-auction#[dtor]running-auction"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::RunningAuction::dtor::< + <$ty as $($path_to_types)*::Guest>::RunningAuction + >(rep) + } + }; + + };); + } + #[doc(hidden)] + pub(crate) use __export_auction_auction_stub_stub_auction_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_wasm_rpc_stub_auction_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::auction::auction_stub::stub_auction::__export_auction_auction_stub_stub_auction_cabi!($ty with_types_in $($path_to_types_root)*::exports::auction::auction_stub::stub_auction); + ) + } +#[doc(inline)] +pub(crate) use __export_wasm_rpc_stub_auction_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:wasm-rpc-stub-auction:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2088] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9c\x0f\x01A\x02\x01\ +A\x0c\x01B\x1d\x01z\x04\0\x0anode-index\x03\0\0\x01r\x01\x05values\x04\0\x03uri\x03\ +\0\x02\x01p\x01\x01k\x01\x01o\x02y\x05\x01p\x7f\x01j\x01\x05\x01\x05\x01o\x02\x03\ +w\x01q\x16\x0crecord-value\x01\x04\0\x0dvariant-value\x01\x06\0\x0aenum-value\x01\ +y\0\x0bflags-value\x01\x07\0\x0btuple-value\x01\x04\0\x0alist-value\x01\x04\0\x0c\ +option-value\x01\x05\0\x0cresult-value\x01\x08\0\x07prim-u8\x01}\0\x08prim-u16\x01\ +{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\0\x08prim-s16\x01|\0\x08\ +prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\0\x0cprim-float64\x01u\0\ +\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-string\x01s\0\x06handle\x01\x09\ +\0\x04\0\x08wit-node\x03\0\x0a\x01p\x0b\x01r\x01\x05nodes\x0c\x04\0\x09wit-value\ +\x03\0\x0d\x01q\x04\x0eprotocol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\ +\x15remote-internal-error\x01s\0\x04\0\x09rpc-error\x03\0\x0f\x04\0\x08wasm-rpc\x03\ +\x01\x01i\x11\x01@\x01\x08location\x03\0\x12\x04\0\x15[constructor]wasm-rpc\x01\x13\ +\x01h\x11\x01p\x0e\x01j\x01\x0e\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0f\ +function-params\x15\0\x16\x04\0![method]wasm-rpc.invoke-and-await\x01\x17\x01j\0\ +\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0ffunction-params\x15\0\x18\x04\ +\0\x17[method]wasm-rpc.invoke\x01\x19\x03\x01\x15golem:rpc/types@0.1.0\x05\0\x01\ +B\x1a\x01r\x01\x09bidder-ids\x04\0\x09bidder-id\x03\0\0\x01r\x01\x0aauction-ids\x04\ +\0\x0aauction-id\x03\0\x02\x01w\x04\0\x08deadline\x03\0\x04\x01r\x05\x0aauction-\ +id\x03\x04names\x0bdescriptions\x0blimit-pricev\x0aexpiration\x05\x04\0\x07aucti\ +on\x03\0\x06\x01q\x03\x0fauction-expired\0\0\x0dprice-too-low\0\0\x07success\0\0\ +\x04\0\x0abid-result\x03\0\x08\x04\0\x0frunning-auction\x03\x01\x01i\x0a\x01@\x01\ +\x07auction\x07\0\x0b\x04\0\x1c[constructor]running-auction\x01\x0c\x01h\x0a\x01\ +@\x03\x04self\x0d\x09bidder-id\x01\x05pricev\0\x09\x04\0\x1b[method]running-auct\ +ion.bid\x01\x0e\x01k\x01\x01@\x01\x04self\x0d\0\x0f\x04\0\x1d[method]running-auc\ +tion.close\x01\x10\x01@\x01\x07auction\x07\x01\0\x04\0\x0ainitialize\x01\x11\x01\ +@\x02\x09bidder-id\x01\x05pricev\0\x09\x04\0\x03bid\x01\x12\x01@\0\0\x0f\x04\0\x0d\ +close-auction\x01\x13\x03\x01\x13auction:auction/api\x05\x01\x02\x03\0\0\x03uri\x02\ +\x03\0\x01\x09bidder-id\x02\x03\0\x01\x0aauction-id\x02\x03\0\x01\x08deadline\x02\ +\x03\0\x01\x07auction\x02\x03\0\x01\x0abid-result\x01B\"\x02\x03\x02\x01\x02\x04\ +\0\x03uri\x03\0\0\x02\x03\x02\x01\x03\x04\0\x09bidder-id\x03\0\x02\x02\x03\x02\x01\ +\x04\x04\0\x0aauction-id\x03\0\x04\x02\x03\x02\x01\x05\x04\0\x08deadline\x03\0\x06\ +\x02\x03\x02\x01\x06\x04\0\x07auction\x03\0\x08\x02\x03\x02\x01\x07\x04\0\x0abid\ +-result\x03\0\x0a\x04\0\x03api\x03\x01\x04\0\x0frunning-auction\x03\x01\x01i\x0c\ +\x01@\x01\x08location\x01\0\x0e\x04\0\x10[constructor]api\x01\x0f\x01h\x0c\x01@\x02\ +\x04self\x10\x07auction\x09\x01\0\x04\0\x1f[method]api.blocking-initialize\x01\x11\ +\x04\0\x16[method]api.initialize\x01\x11\x01@\x03\x04self\x10\x09bidder-id\x03\x05\ +pricev\0\x0b\x04\0\x0f[method]api.bid\x01\x12\x01k\x03\x01@\x01\x04self\x10\0\x13\ +\x04\0\x19[method]api.close-auction\x01\x14\x01i\x0d\x01@\x02\x08location\x01\x07\ +auction\x09\0\x15\x04\0\x1c[constructor]running-auction\x01\x16\x01h\x0d\x01@\x03\ +\x04self\x17\x09bidder-id\x03\x05pricev\0\x0b\x04\0\x1b[method]running-auction.b\ +id\x01\x18\x01@\x01\x04self\x17\0\x13\x04\0\x1d[method]running-auction.close\x01\ +\x19\x04\x01!auction:auction-stub/stub-auction\x05\x08\x04\x01*auction:auction-s\ +tub/wasm-rpc-stub-auction\x04\0\x0b\x1b\x01\0\x15wasm-rpc-stub-auction\x03\0\0\0\ +G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindge\ +n-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/auction-example/auction-stub/src/lib.rs b/test-components/auction-example/auction-stub/src/lib.rs index e81095611e..1fc3bd0358 100644 --- a/test-components/auction-example/auction-stub/src/lib.rs +++ b/test-components/auction-example/auction-stub/src/lib.rs @@ -20,6 +20,11 @@ impl RunningAuction { } } } +struct Component; +impl crate::bindings::exports::auction::auction_stub::stub_auction::Guest for Component { + type Api = crate::Api; + type RunningAuction = crate::RunningAuction; +} impl crate::bindings::exports::auction::auction_stub::stub_auction::GuestApi for Api { fn new(location: crate::bindings::golem::rpc::types::Uri) -> Self { let location = golem_wasm_rpc::Uri { @@ -290,3 +295,4 @@ impl Drop for RunningAuction { .expect("Failed to invoke remote drop"); } } +bindings::export!(Component with_types_in bindings); diff --git a/test-components/auction-example/auction/Cargo.toml b/test-components/auction-example/auction/Cargo.toml index 1a4d2afae9..e3faeef0f4 100644 --- a/test-components/auction-example/auction/Cargo.toml +++ b/test-components/auction-example/auction/Cargo.toml @@ -11,9 +11,7 @@ crate-type = ["cdylib"] once_cell = "1.17.1" rand = { version = "0.8.5" } uuid = { version = "1.4.1", features = ["v4"] } -wit-bindgen = { version = "0.17.0", default-features = false, features = [ - "realloc", -] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/auction-example/auction/src/bindings.rs b/test-components/auction-example/auction/src/bindings.rs index aac5089f36..bbdd205794 100644 --- a/test-components/auction-example/auction/src/bindings.rs +++ b/test-components/auction-example/auction/src/bindings.rs @@ -1,450 +1,703 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod auction { + #[allow(dead_code)] pub mod auction { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - #[derive(Clone)] - pub struct BidderId { - pub bidder_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for BidderId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("BidderId").field("bidder-id", &self.bidder_id).finish() - } - } - #[derive(Clone)] - pub struct AuctionId { - pub auction_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for AuctionId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AuctionId").field("auction-id", &self.auction_id).finish() - } - } - pub type Deadline = u64; - #[derive(Clone)] - pub struct Auction { - pub auction_id: AuctionId, - pub name: wit_bindgen::rt::string::String, - pub description: wit_bindgen::rt::string::String, - pub limit_price: f32, - pub expiration: Deadline, - } - impl ::core::fmt::Debug for Auction { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Auction").field("auction-id", &self.auction_id).field("name", &self.name).field("description", &self.description).field("limit-price", &self.limit_price).field("expiration", &self.expiration).finish() - } - } - #[derive(Clone, Copy)] - pub enum BidResult{ - AuctionExpired, - PriceTooLow, - Success, - } - impl ::core::fmt::Debug for BidResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - BidResult::AuctionExpired => { - f.debug_tuple("BidResult::AuctionExpired").finish() - } - BidResult::PriceTooLow => { - f.debug_tuple("BidResult::PriceTooLow").finish() - } - BidResult::Success => { - f.debug_tuple("BidResult::Success").finish() - } + #[allow(dead_code)] + pub mod auction { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[derive(Clone)] + pub struct BidderId { + pub bidder_id: _rt::String, + } + impl ::core::fmt::Debug for BidderId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BidderId") + .field("bidder-id", &self.bidder_id) + .finish() + } + } + #[derive(Clone)] + pub struct AuctionId { + pub auction_id: _rt::String, + } + impl ::core::fmt::Debug for AuctionId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AuctionId") + .field("auction-id", &self.auction_id) + .finish() + } + } + pub type Deadline = u64; + #[derive(Clone)] + pub struct Auction { + pub auction_id: AuctionId, + pub name: _rt::String, + pub description: _rt::String, + pub limit_price: f32, + pub expiration: Deadline, + } + impl ::core::fmt::Debug for Auction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Auction") + .field("auction-id", &self.auction_id) + .field("name", &self.name) + .field("description", &self.description) + .field("limit-price", &self.limit_price) + .field("expiration", &self.expiration) + .finish() + } + } + #[derive(Clone, Copy)] + pub enum BidResult { + AuctionExpired, + PriceTooLow, + Success, + } + impl ::core::fmt::Debug for BidResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + BidResult::AuctionExpired => { + f.debug_tuple("BidResult::AuctionExpired").finish() + } + BidResult::PriceTooLow => { + f.debug_tuple("BidResult::PriceTooLow").finish() + } + BidResult::Success => f.debug_tuple("BidResult::Success").finish(), + } + } + } + /// an alternative interface for hosting multiple auctions in a single worker + + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuction { + handle: _rt::Resource, + } + + type _RunningAuctionRep = Option; + + impl RunningAuction { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `RunningAuction`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _RunningAuctionRep = Some(val); + let ptr: *mut _RunningAuctionRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestRunningAuction` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _RunningAuctionRep); + } + + fn as_ptr(&self) -> *mut _RunningAuctionRep { + RunningAuction::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`RunningAuction`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct RunningAuctionBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a RunningAuction>, + } + + impl<'a> RunningAuctionBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _RunningAuctionRep { + RunningAuction::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for RunningAuction { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]auction:auction/api")] + extern "C" { + #[link_name = "[resource-drop]running-auction"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_initialize_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: *mut u8, + arg5: usize, + arg6: f32, + arg7: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let len2 = arg5; + let bytes2 = _rt::Vec::from_raw_parts(arg4.cast(), len2, len2); + T::initialize(Auction { + auction_id: AuctionId { + auction_id: _rt::string_lift(bytes0), + }, + name: _rt::string_lift(bytes1), + description: _rt::string_lift(bytes2), + limit_price: arg6, + expiration: arg7 as u64, + }); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_bid_cabi( + arg0: *mut u8, + arg1: usize, + arg2: f32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::bid( + BidderId { + bidder_id: _rt::string_lift(bytes0), + }, + arg2, + ); + let result2 = match result1 { + BidResult::AuctionExpired => 0i32, + BidResult::PriceTooLow => 1i32, + BidResult::Success => 2i32, + }; + result2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_close_auction_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::close_auction(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let BidderId { + bidder_id: bidder_id2, + } = e; + let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_close_auction(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_running_auction_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: *mut u8, + arg5: usize, + arg6: f32, + arg7: i64, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let len2 = arg5; + let bytes2 = _rt::Vec::from_raw_parts(arg4.cast(), len2, len2); + let result3 = RunningAuction::new(T::new(Auction { + auction_id: AuctionId { + auction_id: _rt::string_lift(bytes0), + }, + name: _rt::string_lift(bytes1), + description: _rt::string_lift(bytes2), + limit_price: arg6, + expiration: arg7 as u64, + })); + (result3).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_running_auction_bid_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: f32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let result1 = T::bid( + RunningAuctionBorrow::lift(arg0 as u32 as usize).get(), + BidderId { + bidder_id: _rt::string_lift(bytes0), + }, + arg3, + ); + let result2 = match result1 { + BidResult::AuctionExpired => 0i32, + BidResult::PriceTooLow => 1i32, + BidResult::Success => 2i32, + }; + result2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_running_auction_close_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::close(RunningAuctionBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let BidderId { + bidder_id: bidder_id2, + } = e; + let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_running_auction_close( + arg0: *mut u8, + ) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + type RunningAuction: GuestRunningAuction; + fn initialize(auction: Auction); + fn bid(bidder_id: BidderId, price: f32) -> BidResult; + fn close_auction() -> Option; + } + pub trait GuestRunningAuction: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]auction:auction/api")] + extern "C" { + #[link_name = "[resource-new]running-auction"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]auction:auction/api")] + extern "C" { + #[link_name = "[resource-rep]running-auction"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(auction: Auction) -> Self; + fn bid(&self, bidder_id: BidderId, price: f32) -> BidResult; + fn close(&self) -> Option; + } + #[doc(hidden)] + + macro_rules! __export_auction_auction_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "auction:auction/api#initialize"] + unsafe extern "C" fn export_initialize(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: f32,arg7: i64,) { + $($path_to_types)*::_export_initialize_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + } + #[export_name = "auction:auction/api#bid"] + unsafe extern "C" fn export_bid(arg0: *mut u8,arg1: usize,arg2: f32,) -> i32 { + $($path_to_types)*::_export_bid_cabi::<$ty>(arg0, arg1, arg2) + } + #[export_name = "auction:auction/api#close-auction"] + unsafe extern "C" fn export_close_auction() -> *mut u8 { + $($path_to_types)*::_export_close_auction_cabi::<$ty>() + } + #[export_name = "cabi_post_auction:auction/api#close-auction"] + unsafe extern "C" fn _post_return_close_auction(arg0: *mut u8,) { + $($path_to_types)*::__post_return_close_auction::<$ty>(arg0) + } + #[export_name = "auction:auction/api#[constructor]running-auction"] + unsafe extern "C" fn export_constructor_running_auction(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: f32,arg7: i64,) -> i32 { + $($path_to_types)*::_export_constructor_running_auction_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + } + #[export_name = "auction:auction/api#[method]running-auction.bid"] + unsafe extern "C" fn export_method_running_auction_bid(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: f32,) -> i32 { + $($path_to_types)*::_export_method_running_auction_bid_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0, arg1, arg2, arg3) + } + #[export_name = "auction:auction/api#[method]running-auction.close"] + unsafe extern "C" fn export_method_running_auction_close(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_running_auction_close_cabi::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0) + } + #[export_name = "cabi_post_auction:auction/api#[method]running-auction.close"] + unsafe extern "C" fn _post_return_method_running_auction_close(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_running_auction_close::<<$ty as $($path_to_types)*::Guest>::RunningAuction>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "auction:auction/api#[dtor]running-auction"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::RunningAuction::dtor::< + <$ty as $($path_to_types)*::Guest>::RunningAuction + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub(crate) use __export_auction_auction_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - } } - /// an alternative interface for hosting multiple auctions in a single worker - - pub use super::super::super::super::super::RunningAuction as RunningAuction; - const _: () = { - #[doc(hidden)] - #[export_name = "auction:auction/api#[dtor]running-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for RunningAuction{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction/api")] - extern "C" { - #[link_name = "[resource-new]running-auction"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction/api")] - extern "C" { - #[link_name = "[resource-rep]running-auction"] - fn rep(_: u32) -> usize; - } - rep(_handle) + } +} +mod _rt { + pub use alloc_crate::string::String; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, } - } } - pub type OwnRunningAuction = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for RunningAuction{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]auction:auction/api")] - extern "C" { - #[link_name = "[resource-drop]running-auction"] - fn drop(_: u32); - } - - drop(_handle); - } - } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) } - - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#initialize"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_initialize(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: f32,arg7: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let len2 = arg5 as usize; - let bytes2 = Vec::from_raw_parts(arg4 as *mut _, len2, len2); - <_GuestImpl as Guest>::initialize(Auction{ - auction_id: AuctionId{ - auction_id: wit_bindgen::rt::string_lift(bytes0), - }, - name: wit_bindgen::rt::string_lift(bytes1), - description: wit_bindgen::rt::string_lift(bytes2), - limit_price: arg6, - expiration: arg7 as u64, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_bid(arg0: i32,arg1: i32,arg2: f32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::bid(BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes0), - }, arg2); - let result2 = match result1 { - BidResult::AuctionExpired=> { - 0i32 - } - BidResult::PriceTooLow=> { - 1i32 - } - BidResult::Success=> { - 2i32 - } - }; - result2 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#close-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_close_auction() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::close_auction(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Some(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let BidderId{ bidder_id:bidder_id2, } = e; - let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:auction/api#close-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_close_auction(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#[constructor]running-auction"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_running_auction(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: f32,arg7: i64,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let len2 = arg5 as usize; - let bytes2 = Vec::from_raw_parts(arg4 as *mut _, len2, len2); - let result3 = OwnRunningAuction::new(<_RunningAuctionImpl as GuestRunningAuction>::new(Auction{ - auction_id: AuctionId{ - auction_id: wit_bindgen::rt::string_lift(bytes0), - }, - name: wit_bindgen::rt::string_lift(bytes1), - description: wit_bindgen::rt::string_lift(bytes2), - limit_price: arg6, - expiration: arg7 as u64, - })); - wit_bindgen::rt::Resource::into_handle(result3) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#[method]running-auction.bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_running_auction_bid(arg0: i32,arg1: i32,arg2: i32,arg3: f32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let result1 = <_RunningAuctionImpl as GuestRunningAuction>::bid(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), BidderId{ - bidder_id: wit_bindgen::rt::string_lift(bytes0), - }, arg3); - let result2 = match result1 { - BidResult::AuctionExpired=> { - 0i32 - } - BidResult::PriceTooLow=> { - 1i32 - } - BidResult::Success=> { - 2i32 - } - }; - result2 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "auction:auction/api#[method]running-auction.close"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_running_auction_close(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_RunningAuctionImpl as GuestRunningAuction>::close(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Some(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let BidderId{ bidder_id:bidder_id2, } = e; - let vec3 = (bidder_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_auction:auction/api#[method]running-auction.close"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_running_auction_close(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn initialize(auction: Auction,); - fn bid(bidder_id: BidderId,price: f32,) -> BidResult; - fn close_auction() -> Option; } - use super::super::super::super::super::RunningAuction as _RunningAuctionImpl; - pub trait GuestRunningAuction { - fn new(auction: Auction,) -> Self; - fn bid(&self,bidder_id: BidderId,price: f32,) -> BidResult; - fn close(&self,) -> Option; + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + extern crate alloc as alloc_crate; + pub use alloc_crate::alloc; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_auction_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::auction::auction::api::__export_auction_auction_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::auction::auction::api); + ) } +#[doc(inline)] +pub(crate) use __export_auction_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:auction"] +#[link_section = "component-type:wit-bindgen:0.25.0:auction:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1319] = [3, 0, 7, 97, 117, 99, 116, 105, 111, 110, 0, 97, 115, 109, 13, 0, 1, 0, 7, 250, 3, 1, 65, 2, 1, 66, 26, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 10, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 0, 11, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 12, 1, 104, 10, 1, 64, 3, 4, 115, 101, 108, 102, 13, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 14, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 13, 0, 15, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 16, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 1, 0, 4, 0, 10, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 2, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 3, 98, 105, 100, 1, 18, 1, 64, 0, 0, 15, 4, 0, 13, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 19, 4, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 153, 4, 1, 65, 2, 1, 65, 2, 1, 66, 26, 1, 114, 1, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 115, 4, 0, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 3, 0, 0, 1, 114, 1, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 115, 4, 0, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 0, 2, 1, 119, 4, 0, 8, 100, 101, 97, 100, 108, 105, 110, 101, 3, 0, 4, 1, 114, 5, 10, 97, 117, 99, 116, 105, 111, 110, 45, 105, 100, 3, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 11, 108, 105, 109, 105, 116, 45, 112, 114, 105, 99, 101, 118, 10, 101, 120, 112, 105, 114, 97, 116, 105, 111, 110, 5, 4, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 0, 6, 1, 113, 3, 15, 97, 117, 99, 116, 105, 111, 110, 45, 101, 120, 112, 105, 114, 101, 100, 0, 0, 13, 112, 114, 105, 99, 101, 45, 116, 111, 111, 45, 108, 111, 119, 0, 0, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 8, 4, 0, 15, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 3, 1, 1, 105, 10, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 0, 11, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 1, 12, 1, 104, 10, 1, 64, 3, 4, 115, 101, 108, 102, 13, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 98, 105, 100, 1, 14, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 13, 0, 15, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 46, 99, 108, 111, 115, 101, 1, 16, 1, 64, 1, 7, 97, 117, 99, 116, 105, 111, 110, 7, 1, 0, 4, 0, 10, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 1, 17, 1, 64, 2, 9, 98, 105, 100, 100, 101, 114, 45, 105, 100, 1, 5, 112, 114, 105, 99, 101, 118, 0, 9, 4, 0, 3, 98, 105, 100, 1, 18, 1, 64, 0, 0, 15, 4, 0, 13, 99, 108, 111, 115, 101, 45, 97, 117, 99, 116, 105, 111, 110, 1, 19, 4, 1, 19, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 112, 105, 5, 0, 4, 1, 23, 97, 117, 99, 116, 105, 111, 110, 58, 97, 117, 99, 116, 105, 111, 110, 47, 97, 117, 99, 116, 105, 111, 110, 4, 0, 11, 13, 1, 0, 7, 97, 117, 99, 116, 105, 111, 110, 3, 2, 0, 0, 151, 1, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 105, 110, 116, 101, 114, 102, 97, 99, 101, 115, 34, 58, 123, 34, 97, 112, 105, 34, 58, 123, 34, 116, 121, 112, 101, 115, 34, 58, 123, 34, 114, 117, 110, 110, 105, 110, 103, 45, 97, 117, 99, 116, 105, 111, 110, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 97, 110, 32, 97, 108, 116, 101, 114, 110, 97, 116, 105, 118, 101, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 32, 102, 111, 114, 32, 104, 111, 115, 116, 105, 110, 103, 32, 109, 117, 108, 116, 105, 112, 108, 101, 32, 97, 117, 99, 116, 105, 111, 110, 115, 32, 105, 110, 32, 97, 32, 115, 105, 110, 103, 108, 101, 32, 119, 111, 114, 107, 101, 114, 34, 125, 125, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 663] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x99\x04\x01A\x02\x01\ +A\x02\x01B\x1a\x01r\x01\x09bidder-ids\x04\0\x09bidder-id\x03\0\0\x01r\x01\x0aauc\ +tion-ids\x04\0\x0aauction-id\x03\0\x02\x01w\x04\0\x08deadline\x03\0\x04\x01r\x05\ +\x0aauction-id\x03\x04names\x0bdescriptions\x0blimit-pricev\x0aexpiration\x05\x04\ +\0\x07auction\x03\0\x06\x01q\x03\x0fauction-expired\0\0\x0dprice-too-low\0\0\x07\ +success\0\0\x04\0\x0abid-result\x03\0\x08\x04\0\x0frunning-auction\x03\x01\x01i\x0a\ +\x01@\x01\x07auction\x07\0\x0b\x04\0\x1c[constructor]running-auction\x01\x0c\x01\ +h\x0a\x01@\x03\x04self\x0d\x09bidder-id\x01\x05pricev\0\x09\x04\0\x1b[method]run\ +ning-auction.bid\x01\x0e\x01k\x01\x01@\x01\x04self\x0d\0\x0f\x04\0\x1d[method]ru\ +nning-auction.close\x01\x10\x01@\x01\x07auction\x07\x01\0\x04\0\x0ainitialize\x01\ +\x11\x01@\x02\x09bidder-id\x01\x05pricev\0\x09\x04\0\x03bid\x01\x12\x01@\0\0\x0f\ +\x04\0\x0dclose-auction\x01\x13\x04\x01\x13auction:auction/api\x05\0\x04\x01\x17\ +auction:auction/auction\x04\0\x0b\x0d\x01\0\x07auction\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/auction-example/auction/src/lib.rs b/test-components/auction-example/auction/src/lib.rs index a324ed2daa..769dfc1eb3 100644 --- a/test-components/auction-example/auction/src/lib.rs +++ b/test-components/auction-example/auction/src/lib.rs @@ -3,16 +3,16 @@ mod model; mod bindings; -use std::cell::RefCell; use bindings::*; use exports::auction::auction::api::{ - Guest, Auction as WitAuction, BidResult as WitBidResult, BidderId as WitBidderId, + Auction as WitAuction, BidResult as WitBidResult, BidderId as WitBidderId, Guest, }; use once_cell::sync::Lazy; +use std::cell::RefCell; -use model::*; use crate::auction_logic::now; use crate::bindings::exports::auction::auction::api::GuestRunningAuction; +use model::*; struct Component; @@ -43,6 +43,8 @@ impl Guest for Component { fn close_auction() -> Option { with_state(|state| auction_logic::close_auction(state).map(|bidder_id| bidder_id.into())) } + + type RunningAuction = crate::RunningAuction; } pub struct RunningAuction { @@ -79,9 +81,14 @@ impl GuestRunningAuction for RunningAuction { fn close(&self) -> Option { if now() >= self.auction.expiration.deadline { - self.winning_bid.borrow().clone().map(|(bidder_id, _)| bidder_id.into()) + self.winning_bid + .borrow() + .clone() + .map(|(bidder_id, _)| bidder_id.into()) } else { None } } -} \ No newline at end of file +} + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/auction-example/stubgen.sh b/test-components/auction-example/stubgen.sh index 795d1504c6..257f815806 100755 --- a/test-components/auction-example/stubgen.sh +++ b/test-components/auction-example/stubgen.sh @@ -2,7 +2,7 @@ set -uox pipefail rm -rf auction-stub -wasm-rpc-stubgen generate --source-wit-root auction/wit --dest-crate-root auction-stub --wasm-rpc-path-override ../../../wasm-rpc/wasm-rpc +wasm-rpc-stubgen generate --source-wit-root auction/wit --dest-crate-root auction-stub rm -rf auction-registry/wit/deps mkdir -pv auction-registry/wit/deps cp -rv auction-stub/wit/deps/* auction-registry/wit/deps diff --git a/test-components/auction.wasm b/test-components/auction.wasm index 21f97a2d9d..91e7610756 100755 Binary files a/test-components/auction.wasm and b/test-components/auction.wasm differ diff --git a/test-components/auction_registry_composed.wasm b/test-components/auction_registry_composed.wasm index 1f02bd7231..88c3c65169 100644 Binary files a/test-components/auction_registry_composed.wasm and b/test-components/auction_registry_composed.wasm differ diff --git a/test-components/blob-store-service.wasm b/test-components/blob-store-service.wasm index af010fbf05..71cce88e90 100755 Binary files a/test-components/blob-store-service.wasm and b/test-components/blob-store-service.wasm differ diff --git a/test-components/blob-store-service/Cargo.lock b/test-components/blob-store-service/Cargo.lock index b6425de12f..37fc5246db 100644 --- a/test-components/blob-store-service/Cargo.lock +++ b/test-components/blob-store-service/Cargo.lock @@ -12,14 +12,14 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" name = "blob-store-service" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/blob-store-service/cargo.toml b/test-components/blob-store-service/cargo.toml index ff00201768..e572720b3f 100644 --- a/test-components/blob-store-service/cargo.toml +++ b/test-components/blob-store-service/cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/blob-store-service/src/bindings.rs b/test-components/blob-store-service/src/bindings.rs index 3d5604d1d4..5bc9038b8f 100644 --- a/test-components/blob-store-service/src/bindings.rs +++ b/test-components/blob-store-service/src/bindings.rs @@ -1,2935 +1,3234 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod wasi { - pub mod blobstore { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - /// name of a container, a collection of objects. - /// The container name may be any valid UTF-8 string. - pub type ContainerName = wit_bindgen::rt::string::String; - /// name of an object within a container - /// The object name may be any valid UTF-8 string. - pub type ObjectName = wit_bindgen::rt::string::String; - /// TODO: define timestamp to include seconds since - /// Unix epoch and nanoseconds - /// https://github.com/WebAssembly/wasi-blob-store/issues/7 - pub type Timestamp = u64; - /// size of an object, in bytes - pub type ObjectSize = u64; - pub type Error = wit_bindgen::rt::string::String; - /// information about a container - #[derive(Clone)] - pub struct ContainerMetadata { - /// the container's name - pub name: ContainerName, - /// date and time container was created - pub created_at: Timestamp, - } - impl ::core::fmt::Debug for ContainerMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ContainerMetadata").field("name", &self.name).field("created-at", &self.created_at).finish() - } - } - /// information about an object - #[derive(Clone)] - pub struct ObjectMetadata { - /// the object's name - pub name: ObjectName, - /// the object's parent container - pub container: ContainerName, - /// date and time the object was created - pub created_at: Timestamp, - /// size of the object, in bytes - pub size: ObjectSize, - } - impl ::core::fmt::Debug for ObjectMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ObjectMetadata").field("name", &self.name).field("container", &self.container).field("created-at", &self.created_at).field("size", &self.size).finish() - } - } - /// identifier for an object that includes its container name - #[derive(Clone)] - pub struct ObjectId { - pub container: ContainerName, - pub object: ObjectName, - } - impl ::core::fmt::Debug for ObjectId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ObjectId").field("container", &self.container).field("object", &self.object).finish() - } - } - /// A data is the data stored in a data blob. The value can be of any type - /// that can be represented in a byte array. It provides a way to write the value - /// to the output-stream defined in the `wasi-io` interface. - /// Soon: switch to `resource value { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingValue{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingValue{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingValue{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[resource-drop]outgoing-value"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// A incoming-value is a wrapper around a value. It provides a way to read the value - /// from the input-stream defined in the `wasi-io` interface. - /// - /// The incoming-value provides two ways to consume the value: - /// 1. `incoming-value-consume-sync` consumes the value synchronously and returns the - /// value as a list of bytes. - /// 2. `incoming-value-consume-async` consumes the value asynchronously and returns the - /// value as an input-stream. - /// Soon: switch to `resource incoming-value { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingValue{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingValue{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingValue{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[resource-drop]incoming-value"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - pub type IncomingValueAsyncBody = InputStream; - pub type IncomingValueSyncBody = wit_bindgen::rt::vec::Vec::; - impl OutgoingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn new_outgoing_value() -> OutgoingValue{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[static]outgoing-value.new-outgoing-value"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - OutgoingValue::from_handle(ret as u32) - } - } - } - impl OutgoingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn outgoing_value_write_body(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[method]outgoing-value.outgoing-value-write-body"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn incoming_value_consume_sync(&self,) -> Result{ - - #[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; + #[allow(dead_code)] + pub mod blobstore { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[method]incoming-value.incoming-value-consume-sync"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = *((ptr0 + 4) as *const i32); - let l6 = *((ptr0 + 8) as *const i32); - let len7 = l6 as usize; - let bytes7 = Vec::from_raw_parts(l5 as *mut _, len7, len7); - - wit_bindgen::rt::string_lift(bytes7) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + /// name of a container, a collection of objects. + /// The container name may be any valid UTF-8 string. + pub type ContainerName = _rt::String; + /// name of an object within a container + /// The object name may be any valid UTF-8 string. + pub type ObjectName = _rt::String; + /// TODO: define timestamp to include seconds since + /// Unix epoch and nanoseconds + /// https://github.com/WebAssembly/wasi-blob-store/issues/7 + pub type Timestamp = u64; + /// size of an object, in bytes + pub type ObjectSize = u64; + pub type Error = _rt::String; + /// information about a container + #[derive(Clone)] + pub struct ContainerMetadata { + /// the container's name + pub name: ContainerName, + /// date and time container was created + pub created_at: Timestamp, + } + impl ::core::fmt::Debug for ContainerMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ContainerMetadata") + .field("name", &self.name) + .field("created-at", &self.created_at) + .finish() + } + } + /// information about an object + #[derive(Clone)] + pub struct ObjectMetadata { + /// the object's name + pub name: ObjectName, + /// the object's parent container + pub container: ContainerName, + /// date and time the object was created + pub created_at: Timestamp, + /// size of the object, in bytes + pub size: ObjectSize, + } + impl ::core::fmt::Debug for ObjectMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectMetadata") + .field("name", &self.name) + .field("container", &self.container) + .field("created-at", &self.created_at) + .field("size", &self.size) + .finish() + } + } + /// identifier for an object that includes its container name + #[derive(Clone)] + pub struct ObjectId { + pub container: ContainerName, + pub object: ObjectName, + } + impl ::core::fmt::Debug for ObjectId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectId") + .field("container", &self.container) + .field("object", &self.object) + .finish() + } + } + /// A data is the data stored in a data blob. The value can be of any type + /// that can be represented in a byte array. It provides a way to write the value + /// to the output-stream defined in the `wasi-io` interface. + /// Soon: switch to `resource value { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingValue { + handle: _rt::Resource, + } + + impl OutgoingValue { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingValue { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[resource-drop]outgoing-value"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// A incoming-value is a wrapper around a value. It provides a way to read the value + /// from the input-stream defined in the `wasi-io` interface. + /// + /// The incoming-value provides two ways to consume the value: + /// 1. `incoming-value-consume-sync` consumes the value synchronously and returns the + /// value as a list of bytes. + /// 2. `incoming-value-consume-async` consumes the value asynchronously and returns the + /// value as an input-stream. + /// Soon: switch to `resource incoming-value { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingValue { + handle: _rt::Resource, + } + + impl IncomingValue { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingValue { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[resource-drop]incoming-value"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub type IncomingValueAsyncBody = InputStream; + pub type IncomingValueSyncBody = _rt::Vec; + impl OutgoingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn new_outgoing_value() -> OutgoingValue { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[static]outgoing-value.new-outgoing-value"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + OutgoingValue::from_handle(ret as u32) + } + } + } + impl OutgoingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn outgoing_value_write_body(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[method]outgoing-value.outgoing-value-write-body"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn incoming_value_consume_sync(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[method]incoming-value.incoming-value-consume-sync"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = *ptr0.add(4).cast::<*mut u8>(); + let l6 = *ptr0.add(8).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + + _rt::string_lift(bytes7) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn incoming_value_consume_async( + &self, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[method]incoming-value.incoming-value-consume-async"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle( + l2 as u32, + ) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr0.add(4).cast::<*mut u8>(); + let l4 = *ptr0.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn size(&self) -> u64 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/types")] + extern "C" { + #[link_name = "[method]incoming-value.size"] + fn wit_import(_: i32) -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i64 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u64 + } + } + } } - } - impl IncomingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn incoming_value_consume_async(&self,) -> Result{ - - #[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; + + #[allow(dead_code, clippy::all)] + pub mod container { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[method]incoming-value.incoming-value-consume-async"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr0 + 4) as *const i32); - let l4 = *((ptr0 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type ContainerMetadata = + super::super::super::wasi::blobstore::types::ContainerMetadata; + pub type Error = super::super::super::wasi::blobstore::types::Error; + pub type IncomingValue = super::super::super::wasi::blobstore::types::IncomingValue; + pub type ObjectMetadata = super::super::super::wasi::blobstore::types::ObjectMetadata; + pub type ObjectName = super::super::super::wasi::blobstore::types::ObjectName; + pub type OutgoingValue = super::super::super::wasi::blobstore::types::OutgoingValue; + /// this defines the `container` resource + + #[derive(Debug)] + #[repr(transparent)] + pub struct Container { + handle: _rt::Resource, + } + + impl Container { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Container { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[resource-drop]container"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// this defines the `stream-object-names` resource which is a representation of stream + + #[derive(Debug)] + #[repr(transparent)] + pub struct StreamObjectNames { + handle: _rt::Resource, + } + + impl StreamObjectNames { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for StreamObjectNames { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[resource-drop]stream-object-names"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// returns container name + pub fn name(&self) -> Result<_rt::String, Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.name"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = *ptr0.add(4).cast::<*mut u8>(); + let l6 = *ptr0.add(8).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + + _rt::string_lift(bytes7) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// returns container metadata + pub fn info(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.info"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::<*mut u8>(); + let l3 = *ptr0.add(12).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + let l5 = *ptr0.add(16).cast::(); + + super::super::super::wasi::blobstore::types::ContainerMetadata { + name: _rt::string_lift(bytes4), + created_at: l5 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l6 = *ptr0.add(8).cast::<*mut u8>(); + let l7 = *ptr0.add(12).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + _rt::string_lift(bytes8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// retrieves an object or portion of an object, as a resource. + /// Start and end offsets are inclusive. + /// Once a data-blob resource has been created, the underlying bytes are held by the blobstore service for the lifetime + /// of the data-blob resource, even if the object they came from is later deleted. + pub fn get_data( + &self, + name: &ObjectName, + start: u64, + end: u64, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.get-data"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + _rt::as_i64(&start), + _rt::as_i64(&end), + ptr1, + ); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::blobstore::types::IncomingValue::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::<*mut u8>(); + let l5 = *ptr1.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// creates or replaces an object with the data blob. + pub fn write_data( + &self, + name: &ObjectName, + data: &OutgoingValue, + ) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.write-data"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + (data).handle() as i32, + ptr1, + ); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// returns list of objects in the container. Order is undefined. + pub fn list_objects(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.list-objects"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + StreamObjectNames::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr0.add(4).cast::<*mut u8>(); + let l4 = *ptr0.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// deletes object. + /// does not return error if object did not exist. + pub fn delete_object(&self, name: &ObjectName) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.delete-object"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// deletes multiple objects in the container + pub fn delete_objects(&self, names: &[ObjectName]) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec1 = names; + let len1 = vec1.len(); + let layout1 = + _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 8); + { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + *base.add(4).cast::() = len0; + *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + } + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.delete-objects"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, result1, len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr2.add(4).cast::<*mut u8>(); + let l5 = *ptr2.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// returns true if the object exists in this container + pub fn has_object(&self, name: &ObjectName) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.has-object"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::<*mut u8>(); + let l5 = *ptr1.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// returns metadata for the object + pub fn object_info(&self, name: &ObjectName) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.object-info"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::<*mut u8>(); + let l4 = *ptr1.add(12).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *ptr1.add(16).cast::<*mut u8>(); + let l7 = *ptr1.add(20).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + let l9 = *ptr1.add(24).cast::(); + let l10 = *ptr1.add(32).cast::(); + + super::super::super::wasi::blobstore::types::ObjectMetadata { + name: _rt::string_lift(bytes5), + container: _rt::string_lift(bytes8), + created_at: l9 as u64, + size: l10 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l11 = *ptr1.add(8).cast::<*mut u8>(); + let l12 = *ptr1.add(12).cast::(); + let len13 = l12; + let bytes13 = + _rt::Vec::from_raw_parts(l11.cast(), len13, len13); + + _rt::string_lift(bytes13) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Container { + #[allow(unused_unsafe, clippy::all)] + /// removes all objects within the container, leaving the container empty. + pub fn clear(&self) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]container.clear"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl StreamObjectNames { + #[allow(unused_unsafe, clippy::all)] + /// reads the next number of objects from the stream + /// + /// This function returns the list of objects read, and a boolean indicating if the end of the stream was reached. + pub fn read_stream_object_names( + &self, + len: u64, + ) -> Result<(_rt::Vec, bool), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]stream-object-names.read-stream-object-names"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + let bytes6 = + _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + let l8 = i32::from(*ptr0.add(12).cast::()); + + (result7, _rt::bool_lift(l8 as u8)) + }; + Ok(e) + } + 1 => { + let e = { + let l9 = *ptr0.add(4).cast::<*mut u8>(); + let l10 = *ptr0.add(8).cast::(); + let len11 = l10; + let bytes11 = _rt::Vec::from_raw_parts(l9.cast(), len11, len11); + + _rt::string_lift(bytes11) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl StreamObjectNames { + #[allow(unused_unsafe, clippy::all)] + /// skip the next number of objects in the stream + /// + /// This function returns the number of objects skipped, and a boolean indicating if the end of the stream was reached. + pub fn skip_stream_object_names(&self, num: u64) -> Result<(u64, bool), Error> { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/container")] + extern "C" { + #[link_name = "[method]stream-object-names.skip-stream-object-names"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&num), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + let l3 = i32::from(*ptr0.add(16).cast::()); + + (l2 as u64, _rt::bool_lift(l3 as u8)) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr0.add(8).cast::<*mut u8>(); + let l5 = *ptr0.add(12).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } } - } - impl IncomingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn size(&self,) -> u64{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(dead_code, clippy::all)] + pub mod blobstore { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/types")] - extern "C" { - #[link_name = "[method]incoming-value.size"] - fn wit_import(_: i32, ) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i64{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u64 - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Container = super::super::super::wasi::blobstore::container::Container; + pub type Error = super::super::super::wasi::blobstore::types::Error; + pub type ContainerName = super::super::super::wasi::blobstore::types::ContainerName; + pub type ObjectId = super::super::super::wasi::blobstore::types::ObjectId; + #[allow(unused_unsafe, clippy::all)] + /// creates a new empty container + pub fn create_container(name: &ContainerName) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "create-container"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::blobstore::container::Container::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::<*mut u8>(); + let l5 = *ptr1.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// retrieves a container by name + pub fn get_container(name: &ContainerName) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "get-container"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::blobstore::container::Container::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::<*mut u8>(); + let l5 = *ptr1.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// deletes a container and all objects within it + pub fn delete_container(name: &ContainerName) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "delete-container"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// returns true if the container exists + pub fn container_exists(name: &ContainerName) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "container-exists"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::<*mut u8>(); + let l5 = *ptr1.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// copies (duplicates) an object, to the same or a different container. + /// returns an error if the target container does not exist. + /// overwrites destination object if it already existed. + pub fn copy_object(src: &ObjectId, dest: &ObjectId) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let super::super::super::wasi::blobstore::types::ObjectId { + container: container0, + object: object0, + } = src; + let vec1 = container0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = object0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let super::super::super::wasi::blobstore::types::ObjectId { + container: container3, + object: object3, + } = dest; + let vec4 = container3; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = object3; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + let ptr6 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "copy-object"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + ptr1.cast_mut(), + len1, + ptr2.cast_mut(), + len2, + ptr4.cast_mut(), + len4, + ptr5.cast_mut(), + len5, + ptr6, + ); + let l7 = i32::from(*ptr6.add(0).cast::()); + match l7 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l8 = *ptr6.add(4).cast::<*mut u8>(); + let l9 = *ptr6.add(8).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// moves or renames an object, to the same or a different container + /// returns an error if the destination container does not exist. + /// overwrites destination object if it already existed. + pub fn move_object(src: &ObjectId, dest: &ObjectId) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let super::super::super::wasi::blobstore::types::ObjectId { + container: container0, + object: object0, + } = src; + let vec1 = container0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = object0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let super::super::super::wasi::blobstore::types::ObjectId { + container: container3, + object: object3, + } = dest; + let vec4 = container3; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = object3; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + let ptr6 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:blobstore/blobstore")] + extern "C" { + #[link_name = "move-object"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + ptr1.cast_mut(), + len1, + ptr2.cast_mut(), + len2, + ptr4.cast_mut(), + len4, + ptr5.cast_mut(), + len5, + ptr6, + ); + let l7 = i32::from(*ptr6.add(0).cast::()); + match l7 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l8 = *ptr6.add(4).cast::<*mut u8>(); + let l9 = *ptr6.add(8).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - - - #[allow(clippy::all)] - pub mod container { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type ContainerMetadata = super::super::super::wasi::blobstore::types::ContainerMetadata; - pub type Error = super::super::super::wasi::blobstore::types::Error; - pub type IncomingValue = super::super::super::wasi::blobstore::types::IncomingValue; - pub type ObjectMetadata = super::super::super::wasi::blobstore::types::ObjectMetadata; - pub type ObjectName = super::super::super::wasi::blobstore::types::ObjectName; - pub type OutgoingValue = super::super::super::wasi::blobstore::types::OutgoingValue; - /// this defines the `container` resource - - #[derive(Debug)] - #[repr(transparent)] - pub struct Container{ - handle: wit_bindgen::rt::Resource, - } - - impl Container{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Container{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[resource-drop]container"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// this defines the `stream-object-names` resource which is a representation of stream - - #[derive(Debug)] - #[repr(transparent)] - pub struct StreamObjectNames{ - handle: wit_bindgen::rt::Resource, - } - - impl StreamObjectNames{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for StreamObjectNames{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[resource-drop]stream-object-names"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// returns container name - pub fn name(&self,) -> Result{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.name"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = *((ptr0 + 4) as *const i32); - let l6 = *((ptr0 + 8) as *const i32); - let len7 = l6 as usize; - let bytes7 = Vec::from_raw_parts(l5 as *mut _, len7, len7); - - wit_bindgen::rt::string_lift(bytes7) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// returns container metadata - pub fn info(&self,) -> Result{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.info"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i32); - let l3 = *((ptr0 + 12) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - let l5 = *((ptr0 + 16) as *const i64); - - super::super::super::wasi::blobstore::types::ContainerMetadata{ - name: wit_bindgen::rt::string_lift(bytes4), - created_at: l5 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = *((ptr0 + 8) as *const i32); - let l7 = *((ptr0 + 12) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - - wit_bindgen::rt::string_lift(bytes8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// retrieves an object or portion of an object, as a resource. - /// Start and end offsets are inclusive. - /// Once a data-blob resource has been created, the underlying bytes are held by the blobstore service for the lifetime - /// of the data-blob resource, even if the object they came from is later deleted. - pub fn get_data(&self,name: &ObjectName,start: u64,end: u64,) -> Result{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.get-data"] - fn wit_import(_: i32, _: i32, _: i32, _: i64, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, wit_bindgen::rt::as_i64(start), wit_bindgen::rt::as_i64(end), ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::blobstore::types::IncomingValue::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - let l5 = *((ptr1 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// creates or replaces an object with the data blob. - pub fn write_data(&self,name: &ObjectName,data: &OutgoingValue,) -> Result<(),Error>{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.write-data"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, (data).handle() as i32, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - let l4 = *((ptr1 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// returns list of objects in the container. Order is undefined. - pub fn list_objects(&self,) -> Result{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.list-objects"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - StreamObjectNames::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr0 + 4) as *const i32); - let l4 = *((ptr0 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// deletes object. - /// does not return error if object did not exist. - pub fn delete_object(&self,name: &ObjectName,) -> Result<(),Error>{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.delete-object"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - let l4 = *((ptr1 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// deletes multiple objects in the container - pub fn delete_objects(&self,names: &[ObjectName],) -> Result<(),Error>{ - - #[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 vec1 = names; - let len1 = vec1.len() as i32; - let layout1 = alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = if layout1.size() != 0 - { - let ptr = alloc::alloc(layout1); - if ptr.is_null() - { - alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1 as i32 + (i as i32) * 8; - { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - *((base + 4) as *mut i32) = len0; - *((base + 0) as *mut i32) = ptr0; - } - } - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.delete-objects"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, result1 as i32, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - if layout1.size() != 0 { - alloc::dealloc(result1, layout1); - } - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr2 + 4) as *const i32); - let l5 = *((ptr2 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// returns true if the object exists in this container - pub fn has_object(&self,name: &ObjectName,) -> Result{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.has-object"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - - wit_bindgen::rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - let l5 = *((ptr1 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// returns metadata for the object - pub fn object_info(&self,name: &ObjectName,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.object-info"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 8) as *const i32); - let l4 = *((ptr1 + 12) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((ptr1 + 16) as *const i32); - let l7 = *((ptr1 + 20) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - let l9 = *((ptr1 + 24) as *const i64); - let l10 = *((ptr1 + 32) as *const i64); - - super::super::super::wasi::blobstore::types::ObjectMetadata{ - name: wit_bindgen::rt::string_lift(bytes5), - container: wit_bindgen::rt::string_lift(bytes8), - created_at: l9 as u64, - size: l10 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l11 = *((ptr1 + 8) as *const i32); - let l12 = *((ptr1 + 12) as *const i32); - let len13 = l12 as usize; - let bytes13 = Vec::from_raw_parts(l11 as *mut _, len13, len13); - - wit_bindgen::rt::string_lift(bytes13) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Container { - #[allow(unused_unsafe, clippy::all)] - /// removes all objects within the container, leaving the container empty. - pub fn clear(&self,) -> Result<(),Error>{ - - #[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; + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]container.clear"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, + } + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } } - } - impl StreamObjectNames { - #[allow(unused_unsafe, clippy::all)] - /// reads the next number of objects from the stream - /// - /// This function returns the list of objects read, and a boolean indicating if the end of the stream was reached. - pub fn read_stream_object_names(&self,len: u64,) -> Result<(wit_bindgen::rt::vec::Vec::,bool,),Error>{ - - #[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; + + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]stream-object-names.read-stream-object-names"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base7 = l2; - let len7 = l3; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 8; - let e7 = { - let l4 = *((base + 0) as *const i32); - let l5 = *((base + 4) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } + } + } + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = in_; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 8, 4); - let l8 = i32::from(*((ptr0 + 12) as *const u8)); - - (result7, wit_bindgen::rt::bool_lift(l8 as u8)) - }; - Ok(e) - } - 1 => { - let e = { - let l9 = *((ptr0 + 4) as *const i32); - let l10 = *((ptr0 + 8) as *const i32); - let len11 = l10 as usize; - let bytes11 = Vec::from_raw_parts(l9 as *mut _, len11, len11); - - wit_bindgen::rt::string_lift(bytes11) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + for (i, e) in vec0.into_iter().enumerate() { + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } + } + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + if layout0.size() != 0 { + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } } - } - impl StreamObjectNames { - #[allow(unused_unsafe, clippy::all)] - /// skip the next number of objects in the stream - /// - /// This function returns the number of objects skipped, and a boolean indicating if the end of the stream was reached. - pub fn skip_stream_object_names(&self,num: u64,) -> Result<(u64,bool,),Error>{ - - #[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; + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/container")] - extern "C" { - #[link_name = "[method]stream-object-names.skip-stream-object-names"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(num), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - - (l2 as u64, wit_bindgen::rt::bool_lift(l3 as u8)) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr0 + 8) as *const i32); - let l5 = *((ptr0 + 12) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, + } + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => f + .debug_tuple("StreamError::LastOperationFailed") + .field(e) + .finish(), + StreamError::Closed => f.debug_tuple("StreamError::Closed").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 input bytestream. + /// + /// `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` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream { + handle: _rt::Resource, + } + + impl InputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for InputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// An output bytestream. + /// + /// `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` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream { + handle: _rt::Resource, + } + + impl OutputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, 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. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self, src: &InputStream, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice( + &self, + src: &InputStream, + len: u64, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } } - } - } - - - #[allow(clippy::all)] - pub mod blobstore { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Container = super::super::super::wasi::blobstore::container::Container; - pub type Error = super::super::super::wasi::blobstore::types::Error; - pub type ContainerName = super::super::super::wasi::blobstore::types::ContainerName; - pub type ObjectId = super::super::super::wasi::blobstore::types::ObjectId; - #[allow(unused_unsafe, clippy::all)] - /// creates a new empty container - pub fn create_container(name: &ContainerName,) -> Result{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "create-container"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::blobstore::container::Container::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - let l5 = *((ptr1 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// retrieves a container by name - pub fn get_container(name: &ContainerName,) -> Result{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "get-container"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::blobstore::container::Container::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - let l5 = *((ptr1 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// deletes a container and all objects within it - pub fn delete_container(name: &ContainerName,) -> Result<(),Error>{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "delete-container"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - let l4 = *((ptr1 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// returns true if the container exists - pub fn container_exists(name: &ContainerName,) -> Result{ - - #[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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "container-exists"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - - wit_bindgen::rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - let l5 = *((ptr1 + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// copies (duplicates) an object, to the same or a different container. - /// returns an error if the target container does not exist. - /// overwrites destination object if it already existed. - pub fn copy_object(src: &ObjectId,dest: &ObjectId,) -> Result<(),Error>{ - - #[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 super::super::super::wasi::blobstore::types::ObjectId{ container:container0, object:object0, } = src; - let vec1 = container0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let vec2 = object0; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let super::super::super::wasi::blobstore::types::ObjectId{ container:container3, object:object3, } = dest; - let vec4 = container3; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = object3; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - let ptr6 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "copy-object"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr1, len1, ptr2, len2, ptr4, len4, ptr5, len5, ptr6); - let l7 = i32::from(*((ptr6 + 0) as *const u8)); - match l7 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l8 = *((ptr6 + 4) as *const i32); - let l9 = *((ptr6 + 8) as *const i32); - let len10 = l9 as usize; - let bytes10 = Vec::from_raw_parts(l8 as *mut _, len10, len10); - - wit_bindgen::rt::string_lift(bytes10) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// moves or renames an object, to the same or a different container - /// returns an error if the destination container does not exist. - /// overwrites destination object if it already existed. - pub fn move_object(src: &ObjectId,dest: &ObjectId,) -> Result<(),Error>{ - - #[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 super::super::super::wasi::blobstore::types::ObjectId{ container:container0, object:object0, } = src; - let vec1 = container0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let vec2 = object0; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let super::super::super::wasi::blobstore::types::ObjectId{ container:container3, object:object3, } = dest; - let vec4 = container3; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = object3; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - let ptr6 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:blobstore/blobstore")] - extern "C" { - #[link_name = "move-object"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr1, len1, ptr2, len2, ptr4, len4, ptr5, len5, ptr6); - let l7 = i32::from(*((ptr6 + 0) as *const u8)); - match l7 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l8 = *((ptr6 + 4) as *const i32); - let l9 = *((ptr6 + 8) as *const i32); - let len10 = l9 as usize; - let bytes10 = Vec::from_raw_parts(l8 as *mut _, len10, len10); - - wit_bindgen::rt::string_lift(bytes10) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_container_cabi(arg0: *mut u8, arg1: usize) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::create_container(_rt::string_lift(bytes0)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_container_exists_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::container_exists(_rt::string_lift(bytes0)); + match result1 { + true => 1, + false => 0, + } + } + pub trait Guest { + fn create_container(container_name: _rt::String); + fn container_exists(container_name: _rt::String) -> bool; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#create-container"] + unsafe extern "C" fn export_create_container(arg0: *mut u8,arg1: usize,) { + $($path_to_types)*::_export_create_container_cabi::<$ty>(arg0, arg1) + } + #[export_name = "golem:it/api#container-exists"] + unsafe extern "C" fn export_container_exists(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_container_exists_cabi::<$ty>(arg0, arg1) + } + };); } - - } - pub mod io { - - #[allow(clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + } } - } - } - - - #[allow(clippy::all)] - pub mod poll { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(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 len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } - } - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - if layout0.size() != 0 { - alloc::dealloc(result0, layout0); - } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } - } - +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, } - - - #[allow(clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An error for input-stream and output-stream operations. - pub enum StreamError{ - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() - } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").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 input bytestream. - /// - /// `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` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl InputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for InputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `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` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl OutputStream{ + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) } - + #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, 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. - /// The created `pollable` is a child resource of the `input-stream`. - /// Implementations may trap if the `input-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + + impl Drop for Resource { + fn drop(&mut self) { unsafe { - - #[repr(align(4))] - struct RetArea([u8; 12]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), } - } + } else { + val != 0 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 } - - } } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#create-container"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_container(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::create_container(wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#container-exists"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_container_exists(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::container_exists(wit_bindgen::rt::string_lift(bytes0)); - match result1 { true => 1, false => 0 } - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn create_container(container_name: wit_bindgen::rt::string::String,); - fn container_exists(container_name: wit_bindgen::rt::string::String,) -> bool; - } - - } - + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() } - } } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:blob-store-service"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3743] = [3, 0, 18, 98, 108, 111, 98, 45, 115, 116, 111, 114, 101, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 107, 1, 65, 2, 1, 66, 4, 1, 64, 1, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 115, 1, 0, 4, 0, 16, 99, 114, 101, 97, 116, 101, 45, 99, 111, 110, 116, 97, 105, 110, 101, 114, 1, 0, 1, 64, 1, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 115, 0, 127, 4, 0, 16, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 101, 120, 105, 115, 116, 115, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 147, 27, 1, 65, 2, 1, 65, 27, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 111, 45, 100, 101, 98, 117, 103, 45, 115, 116, 114, 105, 110, 103, 1, 2, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 0, 5, 101, 114, 114, 111, 114, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 40, 2, 3, 2, 1, 2, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 7, 1, 112, 125, 1, 106, 1, 10, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 11, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 1, 12, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 114, 101, 97, 100, 1, 12, 1, 106, 1, 119, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 107, 105, 112, 1, 14, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 107, 105, 112, 1, 14, 1, 105, 3, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 15, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 16, 1, 104, 8, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 13, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 99, 104, 101, 99, 107, 45, 119, 114, 105, 116, 101, 1, 18, 1, 106, 0, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 17, 8, 99, 111, 110, 116, 101, 110, 116, 115, 10, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 1, 20, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 20, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 102, 108, 117, 115, 104, 1, 21, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 102, 108, 117, 115, 104, 1, 21, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 15, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 22, 1, 64, 2, 4, 115, 101, 108, 102, 17, 3, 108, 101, 110, 119, 0, 19, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 1, 23, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 23, 1, 64, 3, 4, 115, 101, 108, 102, 17, 3, 115, 114, 99, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 112, 108, 105, 99, 101, 1, 24, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 112, 108, 105, 99, 101, 1, 24, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 4, 2, 3, 0, 2, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 2, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 43, 2, 3, 2, 1, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 0, 2, 3, 2, 1, 6, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 1, 115, 4, 0, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 3, 0, 4, 1, 115, 4, 0, 11, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 3, 0, 6, 1, 119, 4, 0, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 3, 0, 8, 1, 119, 4, 0, 11, 111, 98, 106, 101, 99, 116, 45, 115, 105, 122, 101, 3, 0, 10, 1, 115, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 12, 1, 114, 2, 4, 110, 97, 109, 101, 5, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 9, 4, 0, 18, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 14, 1, 114, 4, 4, 110, 97, 109, 101, 7, 9, 99, 111, 110, 116, 97, 105, 110, 101, 114, 5, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 9, 4, 115, 105, 122, 101, 11, 4, 0, 15, 111, 98, 106, 101, 99, 116, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 16, 1, 114, 2, 9, 99, 111, 110, 116, 97, 105, 110, 101, 114, 5, 6, 111, 98, 106, 101, 99, 116, 7, 4, 0, 9, 111, 98, 106, 101, 99, 116, 45, 105, 100, 3, 0, 18, 4, 0, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 1, 4, 0, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 1, 4, 0, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 97, 115, 121, 110, 99, 45, 98, 111, 100, 121, 3, 0, 1, 1, 112, 125, 4, 0, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 115, 121, 110, 99, 45, 98, 111, 100, 121, 3, 0, 23, 1, 105, 20, 1, 64, 0, 0, 25, 4, 0, 41, 91, 115, 116, 97, 116, 105, 99, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 1, 26, 1, 104, 20, 1, 105, 3, 1, 106, 1, 28, 0, 1, 64, 1, 4, 115, 101, 108, 102, 27, 0, 29, 4, 0, 48, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 119, 114, 105, 116, 101, 45, 98, 111, 100, 121, 1, 30, 1, 104, 21, 1, 106, 1, 24, 1, 13, 1, 64, 1, 4, 115, 101, 108, 102, 31, 0, 32, 4, 0, 50, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 99, 111, 110, 115, 117, 109, 101, 45, 115, 121, 110, 99, 1, 33, 1, 105, 22, 1, 106, 1, 34, 1, 13, 1, 64, 1, 4, 115, 101, 108, 102, 31, 0, 35, 4, 0, 51, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 99, 111, 110, 115, 117, 109, 101, 45, 97, 115, 121, 110, 99, 1, 36, 1, 64, 1, 4, 115, 101, 108, 102, 31, 0, 119, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 115, 105, 122, 101, 1, 37, 3, 1, 20, 119, 97, 115, 105, 58, 98, 108, 111, 98, 115, 116, 111, 114, 101, 47, 116, 121, 112, 101, 115, 5, 7, 2, 3, 0, 3, 18, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 2, 3, 0, 3, 5, 101, 114, 114, 111, 114, 2, 3, 0, 3, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 2, 3, 0, 3, 15, 111, 98, 106, 101, 99, 116, 45, 109, 101, 116, 97, 100, 97, 116, 97, 2, 3, 0, 3, 11, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 2, 3, 0, 3, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 1, 66, 59, 2, 3, 2, 1, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 0, 2, 3, 2, 1, 6, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 8, 4, 0, 18, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 4, 2, 3, 2, 1, 9, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 6, 2, 3, 2, 1, 10, 4, 0, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 8, 2, 3, 2, 1, 11, 4, 0, 15, 111, 98, 106, 101, 99, 116, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 10, 2, 3, 2, 1, 12, 4, 0, 11, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 3, 0, 12, 2, 3, 2, 1, 13, 4, 0, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 14, 4, 0, 9, 99, 111, 110, 116, 97, 105, 110, 101, 114, 3, 1, 4, 0, 19, 115, 116, 114, 101, 97, 109, 45, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 3, 1, 1, 104, 16, 1, 106, 1, 115, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 18, 0, 19, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 110, 97, 109, 101, 1, 20, 1, 106, 1, 5, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 18, 0, 21, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 105, 110, 102, 111, 1, 22, 1, 105, 9, 1, 106, 1, 23, 1, 7, 1, 64, 4, 4, 115, 101, 108, 102, 18, 4, 110, 97, 109, 101, 13, 5, 115, 116, 97, 114, 116, 119, 3, 101, 110, 100, 119, 0, 24, 4, 0, 26, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 103, 101, 116, 45, 100, 97, 116, 97, 1, 25, 1, 104, 15, 1, 106, 0, 1, 7, 1, 64, 3, 4, 115, 101, 108, 102, 18, 4, 110, 97, 109, 101, 13, 4, 100, 97, 116, 97, 26, 0, 27, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 119, 114, 105, 116, 101, 45, 100, 97, 116, 97, 1, 28, 1, 105, 17, 1, 106, 1, 29, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 18, 0, 30, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 108, 105, 115, 116, 45, 111, 98, 106, 101, 99, 116, 115, 1, 31, 1, 64, 2, 4, 115, 101, 108, 102, 18, 4, 110, 97, 109, 101, 13, 0, 27, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 100, 101, 108, 101, 116, 101, 45, 111, 98, 106, 101, 99, 116, 1, 32, 1, 112, 13, 1, 64, 2, 4, 115, 101, 108, 102, 18, 5, 110, 97, 109, 101, 115, 33, 0, 27, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 100, 101, 108, 101, 116, 101, 45, 111, 98, 106, 101, 99, 116, 115, 1, 34, 1, 106, 1, 127, 1, 7, 1, 64, 2, 4, 115, 101, 108, 102, 18, 4, 110, 97, 109, 101, 13, 0, 35, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 104, 97, 115, 45, 111, 98, 106, 101, 99, 116, 1, 36, 1, 106, 1, 11, 1, 7, 1, 64, 2, 4, 115, 101, 108, 102, 18, 4, 110, 97, 109, 101, 13, 0, 37, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 111, 98, 106, 101, 99, 116, 45, 105, 110, 102, 111, 1, 38, 1, 64, 1, 4, 115, 101, 108, 102, 18, 0, 27, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 110, 116, 97, 105, 110, 101, 114, 46, 99, 108, 101, 97, 114, 1, 39, 1, 104, 17, 1, 111, 2, 33, 127, 1, 106, 1, 41, 1, 7, 1, 64, 2, 4, 115, 101, 108, 102, 40, 3, 108, 101, 110, 119, 0, 42, 4, 0, 52, 91, 109, 101, 116, 104, 111, 100, 93, 115, 116, 114, 101, 97, 109, 45, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 46, 114, 101, 97, 100, 45, 115, 116, 114, 101, 97, 109, 45, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 1, 43, 1, 111, 2, 119, 127, 1, 106, 1, 44, 1, 7, 1, 64, 2, 4, 115, 101, 108, 102, 40, 3, 110, 117, 109, 119, 0, 45, 4, 0, 52, 91, 109, 101, 116, 104, 111, 100, 93, 115, 116, 114, 101, 97, 109, 45, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 46, 115, 107, 105, 112, 45, 115, 116, 114, 101, 97, 109, 45, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 1, 46, 3, 1, 24, 119, 97, 115, 105, 58, 98, 108, 111, 98, 115, 116, 111, 114, 101, 47, 99, 111, 110, 116, 97, 105, 110, 101, 114, 5, 14, 2, 3, 0, 4, 9, 99, 111, 110, 116, 97, 105, 110, 101, 114, 2, 3, 0, 3, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 2, 3, 0, 3, 9, 111, 98, 106, 101, 99, 116, 45, 105, 100, 1, 66, 22, 2, 3, 2, 1, 15, 4, 0, 9, 99, 111, 110, 116, 97, 105, 110, 101, 114, 3, 0, 0, 2, 3, 2, 1, 9, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 2, 2, 3, 2, 1, 16, 4, 0, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 3, 0, 4, 2, 3, 2, 1, 17, 4, 0, 9, 111, 98, 106, 101, 99, 116, 45, 105, 100, 3, 0, 6, 1, 105, 1, 1, 106, 1, 8, 1, 3, 1, 64, 1, 4, 110, 97, 109, 101, 5, 0, 9, 4, 0, 16, 99, 114, 101, 97, 116, 101, 45, 99, 111, 110, 116, 97, 105, 110, 101, 114, 1, 10, 4, 0, 13, 103, 101, 116, 45, 99, 111, 110, 116, 97, 105, 110, 101, 114, 1, 10, 1, 106, 0, 1, 3, 1, 64, 1, 4, 110, 97, 109, 101, 5, 0, 11, 4, 0, 16, 100, 101, 108, 101, 116, 101, 45, 99, 111, 110, 116, 97, 105, 110, 101, 114, 1, 12, 1, 106, 1, 127, 1, 3, 1, 64, 1, 4, 110, 97, 109, 101, 5, 0, 13, 4, 0, 16, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 101, 120, 105, 115, 116, 115, 1, 14, 1, 64, 2, 3, 115, 114, 99, 7, 4, 100, 101, 115, 116, 7, 0, 11, 4, 0, 11, 99, 111, 112, 121, 45, 111, 98, 106, 101, 99, 116, 1, 15, 4, 0, 11, 109, 111, 118, 101, 45, 111, 98, 106, 101, 99, 116, 1, 15, 3, 1, 24, 119, 97, 115, 105, 58, 98, 108, 111, 98, 115, 116, 111, 114, 101, 47, 98, 108, 111, 98, 115, 116, 111, 114, 101, 5, 18, 1, 66, 4, 1, 64, 1, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 115, 1, 0, 4, 0, 16, 99, 114, 101, 97, 116, 101, 45, 99, 111, 110, 116, 97, 105, 110, 101, 114, 1, 0, 1, 64, 1, 14, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 110, 97, 109, 101, 115, 0, 127, 4, 0, 16, 99, 111, 110, 116, 97, 105, 110, 101, 114, 45, 101, 120, 105, 115, 116, 115, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 19, 4, 1, 27, 103, 111, 108, 101, 109, 58, 105, 116, 47, 98, 108, 111, 98, 45, 115, 116, 111, 114, 101, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 24, 1, 0, 18, 98, 108, 111, 98, 45, 115, 116, 111, 114, 101, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_blob_store_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_blob_store_service_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:blob-store-service:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3612] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x93\x1b\x01A\x02\x01\ +A\x1b\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\0\x1d[m\ +ethod]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\0\x01B\x0a\ +\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[method]po\ +llable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollable.block\x01\ +\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\x01\x12wa\ +si:io/poll@0.2.0\x05\x01\x02\x03\0\0\x05error\x02\x03\0\x01\x08pollable\x01B(\x02\ +\x03\x02\x01\x02\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\ +\0\x02\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0c\ +stream-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\ +\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19\ +[method]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\ +\x01j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-str\ +eam.skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\x0e\x01i\x03\x01@\ +\x01\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\x01\x10\x01h\x08\x01\ +@\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-write\x01\x12\x01j\0\x01\ +\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b[method]output-stream.w\ +rite\x01\x14\x04\0.[method]output-stream.blocking-write-and-flush\x01\x14\x01@\x01\ +\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\x01\x15\x04\0$[method]ou\ +tput-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]o\ +utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method\ +]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ +eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ +method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ +\x18\x03\x01\x15wasi:io/streams@0.2.0\x05\x04\x02\x03\0\x02\x0cinput-stream\x02\x03\ +\0\x02\x0doutput-stream\x01B+\x02\x03\x02\x01\x05\x04\0\x0cinput-stream\x03\0\0\x02\ +\x03\x02\x01\x06\x04\0\x0doutput-stream\x03\0\x02\x01s\x04\0\x0econtainer-name\x03\ +\0\x04\x01s\x04\0\x0bobject-name\x03\0\x06\x01w\x04\0\x09timestamp\x03\0\x08\x01\ +w\x04\0\x0bobject-size\x03\0\x0a\x01s\x04\0\x05error\x03\0\x0c\x01r\x02\x04name\x05\ +\x0acreated-at\x09\x04\0\x12container-metadata\x03\0\x0e\x01r\x04\x04name\x07\x09\ +container\x05\x0acreated-at\x09\x04size\x0b\x04\0\x0fobject-metadata\x03\0\x10\x01\ +r\x02\x09container\x05\x06object\x07\x04\0\x09object-id\x03\0\x12\x04\0\x0eoutgo\ +ing-value\x03\x01\x04\0\x0eincoming-value\x03\x01\x04\0\x19incoming-value-async-\ +body\x03\0\x01\x01p}\x04\0\x18incoming-value-sync-body\x03\0\x17\x01i\x14\x01@\0\ +\0\x19\x04\0)[static]outgoing-value.new-outgoing-value\x01\x1a\x01h\x14\x01i\x03\ +\x01j\x01\x1c\0\x01@\x01\x04self\x1b\0\x1d\x04\00[method]outgoing-value.outgoing\ +-value-write-body\x01\x1e\x01h\x15\x01j\x01\x18\x01\x0d\x01@\x01\x04self\x1f\0\x20\ +\x04\02[method]incoming-value.incoming-value-consume-sync\x01!\x01i\x16\x01j\x01\ +\"\x01\x0d\x01@\x01\x04self\x1f\0#\x04\03[method]incoming-value.incoming-value-c\ +onsume-async\x01$\x01@\x01\x04self\x1f\0w\x04\0\x1b[method]incoming-value.size\x01\ +%\x03\x01\x14wasi:blobstore/types\x05\x07\x02\x03\0\x03\x12container-metadata\x02\ +\x03\0\x03\x05error\x02\x03\0\x03\x0eincoming-value\x02\x03\0\x03\x0fobject-meta\ +data\x02\x03\0\x03\x0bobject-name\x02\x03\0\x03\x0eoutgoing-value\x01B;\x02\x03\x02\ +\x01\x05\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x06\x04\0\x0doutput-strea\ +m\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x12container-metadata\x03\0\x04\x02\x03\x02\ +\x01\x09\x04\0\x05error\x03\0\x06\x02\x03\x02\x01\x0a\x04\0\x0eincoming-value\x03\ +\0\x08\x02\x03\x02\x01\x0b\x04\0\x0fobject-metadata\x03\0\x0a\x02\x03\x02\x01\x0c\ +\x04\0\x0bobject-name\x03\0\x0c\x02\x03\x02\x01\x0d\x04\0\x0eoutgoing-value\x03\0\ +\x0e\x04\0\x09container\x03\x01\x04\0\x13stream-object-names\x03\x01\x01h\x10\x01\ +j\x01s\x01\x07\x01@\x01\x04self\x12\0\x13\x04\0\x16[method]container.name\x01\x14\ +\x01j\x01\x05\x01\x07\x01@\x01\x04self\x12\0\x15\x04\0\x16[method]container.info\ +\x01\x16\x01i\x09\x01j\x01\x17\x01\x07\x01@\x04\x04self\x12\x04name\x0d\x05start\ +w\x03endw\0\x18\x04\0\x1a[method]container.get-data\x01\x19\x01h\x0f\x01j\0\x01\x07\ +\x01@\x03\x04self\x12\x04name\x0d\x04data\x1a\0\x1b\x04\0\x1c[method]container.w\ +rite-data\x01\x1c\x01i\x11\x01j\x01\x1d\x01\x07\x01@\x01\x04self\x12\0\x1e\x04\0\ +\x1e[method]container.list-objects\x01\x1f\x01@\x02\x04self\x12\x04name\x0d\0\x1b\ +\x04\0\x1f[method]container.delete-object\x01\x20\x01p\x0d\x01@\x02\x04self\x12\x05\ +names!\0\x1b\x04\0\x20[method]container.delete-objects\x01\"\x01j\x01\x7f\x01\x07\ +\x01@\x02\x04self\x12\x04name\x0d\0#\x04\0\x1c[method]container.has-object\x01$\x01\ +j\x01\x0b\x01\x07\x01@\x02\x04self\x12\x04name\x0d\0%\x04\0\x1d[method]container\ +.object-info\x01&\x01@\x01\x04self\x12\0\x1b\x04\0\x17[method]container.clear\x01\ +'\x01h\x11\x01o\x02!\x7f\x01j\x01)\x01\x07\x01@\x02\x04self(\x03lenw\0*\x04\04[m\ +ethod]stream-object-names.read-stream-object-names\x01+\x01o\x02w\x7f\x01j\x01,\x01\ +\x07\x01@\x02\x04self(\x03numw\0-\x04\04[method]stream-object-names.skip-stream-\ +object-names\x01.\x03\x01\x18wasi:blobstore/container\x05\x0e\x02\x03\0\x04\x09c\ +ontainer\x02\x03\0\x03\x0econtainer-name\x02\x03\0\x03\x09object-id\x01B\x16\x02\ +\x03\x02\x01\x0f\x04\0\x09container\x03\0\0\x02\x03\x02\x01\x09\x04\0\x05error\x03\ +\0\x02\x02\x03\x02\x01\x10\x04\0\x0econtainer-name\x03\0\x04\x02\x03\x02\x01\x11\ +\x04\0\x09object-id\x03\0\x06\x01i\x01\x01j\x01\x08\x01\x03\x01@\x01\x04name\x05\ +\0\x09\x04\0\x10create-container\x01\x0a\x04\0\x0dget-container\x01\x0a\x01j\0\x01\ +\x03\x01@\x01\x04name\x05\0\x0b\x04\0\x10delete-container\x01\x0c\x01j\x01\x7f\x01\ +\x03\x01@\x01\x04name\x05\0\x0d\x04\0\x10container-exists\x01\x0e\x01@\x02\x03sr\ +c\x07\x04dest\x07\0\x0b\x04\0\x0bcopy-object\x01\x0f\x04\0\x0bmove-object\x01\x0f\ +\x03\x01\x18wasi:blobstore/blobstore\x05\x12\x01B\x04\x01@\x01\x0econtainer-name\ +s\x01\0\x04\0\x10create-container\x01\0\x01@\x01\x0econtainer-names\0\x7f\x04\0\x10\ +container-exists\x01\x01\x04\x01\x0cgolem:it/api\x05\x13\x04\x01\x1bgolem:it/blo\ +b-store-service\x04\0\x0b\x18\x01\0\x12blob-store-service\x03\0\0\0G\x09producer\ +s\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.2\ +5.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/blob-store-service/src/lib.rs b/test-components/blob-store-service/src/lib.rs index 037305f53c..9cebc1cbe2 100644 --- a/test-components/blob-store-service/src/lib.rs +++ b/test-components/blob-store-service/src/lib.rs @@ -16,3 +16,5 @@ impl Guest for Component { container_exists(&container_name).unwrap() } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/c-1.wasm b/test-components/c-1.wasm index 70d08785aa..d605c6ab68 100644 Binary files a/test-components/c-1.wasm and b/test-components/c-1.wasm differ diff --git a/test-components/c-1/main.c b/test-components/c-1/main.c index b4742e8b0e..62790dd1e2 100644 --- a/test-components/c-1/main.c +++ b/test-components/c-1/main.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include "c_api1.h" diff --git a/test-components/caller_composed.wasm b/test-components/caller_composed.wasm index 78b28ffbad..912a4da173 100644 Binary files a/test-components/caller_composed.wasm and b/test-components/caller_composed.wasm differ diff --git a/test-components/clock-service.wasm b/test-components/clock-service.wasm index 905aa53576..ae72ffe19b 100755 Binary files a/test-components/clock-service.wasm and b/test-components/clock-service.wasm differ diff --git a/test-components/clock-service/Cargo.lock b/test-components/clock-service/Cargo.lock index 90f2983ff5..a64a27044a 100644 --- a/test-components/clock-service/Cargo.lock +++ b/test-components/clock-service/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/clock-service/cargo.toml b/test-components/clock-service/cargo.toml index 65eea8cfc4..ff7a57cbae 100644 --- a/test-components/clock-service/cargo.toml +++ b/test-components/clock-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/clock-service/src/bindings.rs b/test-components/clock-service/src/bindings.rs index eddc3ba529..b6f4258cb1 100644 --- a/test-components/clock-service/src/bindings.rs +++ b/test-components/clock-service/src/bindings.rs @@ -1,96 +1,141 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_sleep_cabi(arg0: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::sleep(arg0 as u64); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Ok(_) => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(8).cast::() = len2; + *ptr1.add(4).cast::<*mut u8>() = ptr2.cast_mut(); + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_sleep(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + fn sleep(secs: u64) -> Result<(), _rt::String>; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "golem:it/api#sleep"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_sleep(arg0: i64,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::sleep(arg0 as u64); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Ok(_) => { { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 8) as *mut i32) = len2; - *((ptr1 + 4) as *mut i32) = ptr2; - } }, - };ptr1 + unsafe extern "C" fn export_sleep(arg0: i64,) -> *mut u8 { + $($path_to_types)*::_export_sleep_cabi::<$ty>(arg0) } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#sleep"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_sleep(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + #[export_name = "cabi_post_golem:it/api#sleep"] + unsafe extern "C" fn _post_return_sleep(arg0: *mut u8,) { + $($path_to_types)*::__post_return_sleep::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn sleep(secs: u64,) -> Result<(),wit_bindgen::rt::string::String>; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_clock_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_clock_service_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:clock-service"] +#[link_section = "component-type:wit-bindgen:0.25.0:clock-service:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 278] = [3, 0, 13, 99, 108, 111, 99, 107, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 49, 1, 65, 2, 1, 66, 3, 1, 106, 0, 1, 115, 1, 64, 1, 4, 115, 101, 99, 115, 119, 0, 0, 4, 0, 5, 115, 108, 101, 101, 112, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 79, 1, 65, 2, 1, 65, 2, 1, 66, 3, 1, 106, 0, 1, 115, 1, 64, 1, 4, 115, 101, 99, 115, 119, 0, 0, 4, 0, 5, 115, 108, 101, 101, 112, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 22, 103, 111, 108, 101, 109, 58, 105, 116, 47, 99, 108, 111, 99, 107, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 19, 1, 0, 13, 99, 108, 111, 99, 107, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 210] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07O\x01A\x02\x01A\x02\x01\ +B\x03\x01j\0\x01s\x01@\x01\x04secsw\0\0\x04\0\x05sleep\x01\x01\x04\x01\x0cgolem:\ +it/api\x05\0\x04\x01\x16golem:it/clock-service\x04\0\x0b\x13\x01\0\x0dclock-serv\ +ice\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10\ +wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/clock-service/src/lib.rs b/test-components/clock-service/src/lib.rs index c9c08bb586..1f91be5c6a 100644 --- a/test-components/clock-service/src/lib.rs +++ b/test-components/clock-service/src/lib.rs @@ -14,3 +14,5 @@ impl Guest for Component { Ok(()) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/clocks.wasm b/test-components/clocks.wasm index ee7be62bdf..bbe2005dad 100755 Binary files a/test-components/clocks.wasm and b/test-components/clocks.wasm differ diff --git a/test-components/clocks/Cargo.lock b/test-components/clocks/Cargo.lock index 069719efc3..36555b9a76 100644 --- a/test-components/clocks/Cargo.lock +++ b/test-components/clocks/Cargo.lock @@ -19,7 +19,7 @@ name = "golem-it-clocks" version = "0.0.1" dependencies = [ "time", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -112,10 +112,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/clocks/Cargo.toml b/test-components/clocks/Cargo.toml index 81f706fc80..4894f267d0 100644 --- a/test-components/clocks/Cargo.toml +++ b/test-components/clocks/Cargo.toml @@ -12,7 +12,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } time = { version = "0.3.21", features = ["formatting"] } [package.metadata.component] diff --git a/test-components/clocks/src/bindings.rs b/test-components/clocks/src/bindings.rs index 191a9c57b1..491b508468 100644 --- a/test-components/clocks/src/bindings.rs +++ b/test-components/clocks/src/bindings.rs @@ -1,98 +1,146 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let (t2_0, t2_1, t2_2, ) = result0; - *((ptr1 + 0) as *mut f64) = wit_bindgen::rt::as_f64(t2_0); - *((ptr1 + 8) as *mut f64) = wit_bindgen::rt::as_f64(t2_1); +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let (t2_0, t2_1, t2_2) = result0; + *ptr1.add(0).cast::() = _rt::as_f64(t2_0); + *ptr1.add(8).cast::() = _rt::as_f64(t2_1); let vec3 = (t2_2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); ::core::mem::forget(vec3); - *((ptr1 + 20) as *mut i32) = len3; - *((ptr1 + 16) as *mut i32) = ptr3; + *ptr1.add(20).cast::() = len3; + *ptr1.add(16).cast::<*mut u8>() = ptr3.cast_mut(); ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = *((arg0 + 16) as *const i32); - let l1 = *((arg0 + 20) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; -}; -const _: () = { - - #[doc(hidden)] - #[export_name = "sleep-for"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_sleep_for(arg0: f64,) -> f64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::sleep_for(arg0); - wit_bindgen::rt::as_f64(result0) - } -}; -use super::Component as _GuestImpl; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = *arg0.add(16).cast::<*mut u8>(); + let l1 = *arg0.add(20).cast::(); + _rt::cabi_dealloc(l0, l1, 1); +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_sleep_for_cabi(arg0: f64) -> f64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::sleep_for(arg0); + _rt::as_f64(result0) +} pub trait Guest { - fn run() -> (f64,f64,wit_bindgen::rt::string::String,); - fn sleep_for(seconds: f64,) -> f64; + fn run() -> (f64, f64, _rt::String); + fn sleep_for(seconds: f64) -> f64; } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_clocks_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + #[export_name = "sleep-for"] + unsafe extern "C" fn export_sleep_for(arg0: f64,) -> f64 { + $($path_to_types)*::_export_sleep_for_cabi::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_clocks_cabi; #[repr(align(8))] -struct _RetArea([u8; 24]); -static mut _RET_AREA: _RetArea = _RetArea([0; 24]); +struct _RetArea([::core::mem::MaybeUninit; 24]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_clocks_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_clocks_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_clocks_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:clocks"] +#[link_section = "component-type:wit-bindgen:0.25.0:clocks:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 196] = [3, 0, 6, 99, 108, 111, 99, 107, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 73, 1, 65, 2, 1, 65, 5, 1, 111, 3, 117, 117, 115, 1, 64, 0, 0, 0, 4, 0, 3, 114, 117, 110, 1, 1, 1, 64, 1, 7, 115, 101, 99, 111, 110, 100, 115, 117, 0, 117, 4, 0, 9, 115, 108, 101, 101, 112, 45, 102, 111, 114, 1, 2, 4, 1, 15, 103, 111, 108, 101, 109, 58, 105, 116, 47, 99, 108, 111, 99, 107, 115, 4, 0, 11, 12, 1, 0, 6, 99, 108, 111, 99, 107, 115, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 197] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07I\x01A\x02\x01A\x05\x01\ +o\x03uus\x01@\0\0\0\x04\0\x03run\x01\x01\x01@\x01\x07secondsu\0u\x04\0\x09sleep-\ +for\x01\x02\x04\x01\x0fgolem:it/clocks\x04\0\x0b\x0c\x01\0\x06clocks\x03\0\0\0G\x09\ +producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rus\ +t\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/clocks/src/lib.rs b/test-components/clocks/src/lib.rs index 37b27e3f47..2692074873 100644 --- a/test-components/clocks/src/lib.rs +++ b/test-components/clocks/src/lib.rs @@ -30,3 +30,5 @@ impl Guest for Component { elapsed } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/counters.wasm b/test-components/counters.wasm index 367e44d1b7..49084bbd73 100755 Binary files a/test-components/counters.wasm and b/test-components/counters.wasm differ diff --git a/test-components/csharp-1.wasm b/test-components/csharp-1.wasm index 9b66644909..9ffa8d24ae 100644 Binary files a/test-components/csharp-1.wasm and b/test-components/csharp-1.wasm differ diff --git a/test-components/directories.wasm b/test-components/directories.wasm index a952f8009e..7f7328d386 100755 Binary files a/test-components/directories.wasm and b/test-components/directories.wasm differ diff --git a/test-components/directories/Cargo.lock b/test-components/directories/Cargo.lock index b31643a58b..8ed295643b 100644 --- a/test-components/directories/Cargo.lock +++ b/test-components/directories/Cargo.lock @@ -56,7 +56,7 @@ name = "golem-it-directories" version = "0.0.1" dependencies = [ "fs", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -91,10 +91,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/directories/Cargo.toml b/test-components/directories/Cargo.toml index f976323963..85014f0968 100644 --- a/test-components/directories/Cargo.toml +++ b/test-components/directories/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } fs = "0.0.5" [package.metadata.component.target] diff --git a/test-components/directories/src/bindings.rs b/test-components/directories/src/bindings.rs index 04e26c2282..0048a8ca9f 100644 --- a/test-components/directories/src/bindings.rs +++ b/test-components/directories/src/bindings.rs @@ -1,145 +1,268 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let (t2_0, t2_1, t2_2, t2_3, ) = result0; - *((ptr1 + 0) as *mut i32) = wit_bindgen::rt::as_i32(t2_0); +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let (t2_0, t2_1, t2_2, t2_3) = result0; + *ptr1.add(0).cast::() = _rt::as_i32(t2_0); let vec5 = t2_1; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 12, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 12, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 12; - { - let (t3_0, t3_1, ) = e; - let vec4 = (t3_0.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 4) as *mut i32) = len4; - *((base + 0) as *mut i32) = ptr4; - *((base + 8) as *mut u8) = (match t3_1 { true => 1, false => 0 }) as u8; - } - } - *((ptr1 + 8) as *mut i32) = len5; - *((ptr1 + 4) as *mut i32) = result5 as i32; + let base = result5.add(i * 12); + { + let (t3_0, t3_1) = e; + let vec4 = (t3_0.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(4).cast::() = len4; + *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + *base.add(8).cast::() = (match t3_1 { + true => 1, + false => 0, + }) as u8; + } + } + *ptr1.add(8).cast::() = len5; + *ptr1.add(4).cast::<*mut u8>() = result5; let vec8 = t2_2; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 12, 4); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked(vec8.len() * 12, 4); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 12; - { - let (t6_0, t6_1, ) = e; - let vec7 = (t6_0.into_bytes()).into_boxed_slice(); - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - ::core::mem::forget(vec7); - *((base + 4) as *mut i32) = len7; - *((base + 0) as *mut i32) = ptr7; - *((base + 8) as *mut u8) = (match t6_1 { true => 1, false => 0 }) as u8; - } - } - *((ptr1 + 16) as *mut i32) = len8; - *((ptr1 + 12) as *mut i32) = result8 as i32; - *((ptr1 + 20) as *mut i32) = wit_bindgen::rt::as_i32(t2_3); + let base = result8.add(i * 12); + { + let (t6_0, t6_1) = e; + let vec7 = (t6_0.into_bytes()).into_boxed_slice(); + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + ::core::mem::forget(vec7); + *base.add(4).cast::() = len7; + *base.add(0).cast::<*mut u8>() = ptr7.cast_mut(); + *base.add(8).cast::() = (match t6_1 { + true => 1, + false => 0, + }) as u8; + } + } + *ptr1.add(16).cast::() = len8; + *ptr1.add(12).cast::<*mut u8>() = result8; + *ptr1.add(20).cast::() = _rt::as_i32(t2_3); ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l2 = *((arg0 + 4) as *const i32); - let l3 = *((arg0 + 8) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *12; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l2 = *arg0.add(4).cast::<*mut u8>(); + let l3 = *arg0.add(8).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 12); { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 12, 4); - let l7 = *((arg0 + 12) as *const i32); - let l8 = *((arg0 + 16) as *const i32); - let base9 = l7; - let len9 = l8; - for i in 0..len9 { - let base = base9 + i *12; + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 12, 4); + let l7 = *arg0.add(12).cast::<*mut u8>(); + let l8 = *arg0.add(16).cast::(); + let base9 = l7; + let len9 = l8; + for i in 0..len9 { + let base = base9.add(i * 12); { - let l5 = *((base + 0) as *const i32); - let l6 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l5, (l6) as usize, 1); + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base.add(4).cast::(); + _rt::cabi_dealloc(l5, l6, 1); } - } - wit_bindgen::rt::dealloc(base9, (len9 as usize) * 12, 4); } - }; -}; -use super::Component as _GuestImpl; + _rt::cabi_dealloc(base9, len9 * 12, 4); +} pub trait Guest { - fn run() -> (u32,wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,bool,)>,wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,bool,)>,u32,); + fn run() -> ( + u32, + _rt::Vec<(_rt::String, bool)>, + _rt::Vec<(_rt::String, bool)>, + u32, + ); } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_directories_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_directories_cabi; #[repr(align(4))] -struct _RetArea([u8; 24]); -static mut _RET_AREA: _RetArea = _RetArea([0; 24]); +struct _RetArea([::core::mem::MaybeUninit; 24]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_directories_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_directories_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_directories_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:directories"] +#[link_section = "component-type:wit-bindgen:0.25.0:directories:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 192] = [3, 0, 11, 100, 105, 114, 101, 99, 116, 111, 114, 105, 101, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 59, 1, 65, 2, 1, 65, 5, 1, 111, 2, 115, 127, 1, 112, 0, 1, 111, 4, 121, 1, 1, 121, 1, 64, 0, 0, 2, 4, 0, 3, 114, 117, 110, 1, 3, 4, 1, 20, 103, 111, 108, 101, 109, 58, 105, 116, 47, 100, 105, 114, 101, 99, 116, 111, 114, 105, 101, 115, 4, 0, 11, 17, 1, 0, 11, 100, 105, 114, 101, 99, 116, 111, 114, 105, 101, 115, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 188] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07;\x01A\x02\x01A\x05\x01\ +o\x02s\x7f\x01p\0\x01o\x04y\x01\x01y\x01@\0\0\x02\x04\0\x03run\x01\x03\x04\x01\x14\ +golem:it/directories\x04\0\x0b\x11\x01\0\x0bdirectories\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/directories/src/lib.rs b/test-components/directories/src/lib.rs index 5515b7f381..76e637297e 100644 --- a/test-components/directories/src/lib.rs +++ b/test-components/directories/src/lib.rs @@ -40,3 +40,5 @@ impl Guest for Component { (count1 as u32, root_entries, test_entries, count2 as u32) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/environment-service.wasm b/test-components/environment-service.wasm index a57a0187f7..51329ff307 100755 Binary files a/test-components/environment-service.wasm and b/test-components/environment-service.wasm differ diff --git a/test-components/environment-service/Cargo.lock b/test-components/environment-service/Cargo.lock index 5a0b6f9421..500e74bd9b 100644 --- a/test-components/environment-service/Cargo.lock +++ b/test-components/environment-service/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/environment-service/cargo.toml b/test-components/environment-service/cargo.toml index ef666b1ff2..600efb8ed4 100644 --- a/test-components/environment-service/cargo.toml +++ b/test-components/environment-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/environment-service/src/bindings.rs b/test-components/environment-service/src/bindings.rs index 0b8c6f4754..cdbcd71885 100644 --- a/test-components/environment-service/src/bindings.rs +++ b/test-components/environment-service/src/bindings.rs @@ -1,247 +1,282 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-environment"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_environment() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_environment(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Ok(e) => { { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - let vec5 = e; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let vec4 = (t2_1.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = ptr4; - } + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_environment_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_environment(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Ok(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + let vec5 = e; + let len5 = vec5.len(); + let layout5 = + _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec4 = (t2_1.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + } + } + *ptr1.add(8).cast::() = len5; + *ptr1.add(4).cast::<*mut u8>() = result5; + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec6 = (e.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *ptr1.add(8).cast::() = len6; + *ptr1.add(4).cast::<*mut u8>() = ptr6.cast_mut(); + } + }; + ptr1 } - *((ptr1 + 8) as *mut i32) = len5; - *((ptr1 + 4) as *mut i32) = result5 as i32; - } }, - Err(e) => { { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec6 = (e.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - ::core::mem::forget(vec6); - *((ptr1 + 8) as *mut i32) = len6; - *((ptr1 + 4) as *mut i32) = ptr6; - } }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-environment"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_environment(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => { - let l5 = *((arg0 + 4) as *const i32); - let l6 = *((arg0 + 8) as *const i32); - let base7 = l5; - let len7 = l6; - for i in 0..len7 { - let base = base7 + i *16; - { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - let l3 = *((base + 8) as *const i32); - let l4 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l3, (l4) as usize, 1); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_environment(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => { + let l5 = *arg0.add(4).cast::<*mut u8>(); + let l6 = *arg0.add(8).cast::(); + let base7 = l5; + let len7 = l6; + for i in 0..len7 { + let base = base7.add(i * 16); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(8).cast::<*mut u8>(); + let l4 = *base.add(12).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + } + } + _rt::cabi_dealloc(base7, len7 * 16, 4); + } + _ => { + let l8 = *arg0.add(4).cast::<*mut u8>(); + let l9 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l8, l9, 1); + } } - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 16, 4); - }, - _ => { - let l8 = *((arg0 + 4) as *const i32); - let l9 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l8, (l9) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-arguments"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_arguments() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_arguments(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - Ok(e) => { { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - let vec3 = e; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 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) * 8; - { - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((base + 4) as *mut i32) = len2; - *((base + 0) as *mut i32) = ptr2; - } } - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = result3 as i32; - } }, - Err(e) => { { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr1 + 8) as *mut i32) = len4; - *((ptr1 + 4) as *mut i32) = ptr4; - } }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-arguments"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_arguments(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => { - let l3 = *((arg0 + 4) as *const i32); - let l4 = *((arg0 + 8) as *const i32); - let base5 = l3; - let len5 = l4; - for i in 0..len5 { - let base = base5 + i *8; - { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_arguments_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_arguments(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Ok(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + let vec3 = e; + let len3 = vec3.len(); + let layout3 = + _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = result3; + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr1.add(8).cast::() = len4; + *ptr1.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_arguments(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => { + let l3 = *arg0.add(4).cast::<*mut u8>(); + let l4 = *arg0.add(8).cast::(); + let base5 = l3; + let len5 = l4; + for i in 0..len5 { + let base = base5.add(i * 8); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + _rt::cabi_dealloc(base5, len5 * 8, 4); + } + _ => { + let l6 = *arg0.add(4).cast::<*mut u8>(); + let l7 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l6, l7, 1); + } } - } - wit_bindgen::rt::dealloc(base5, (len5 as usize) * 8, 4); - }, - _ => { - let l6 = *((arg0 + 4) as *const i32); - let l7 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l6, (l7) as usize, 1); - }, - } + } + pub trait Guest { + fn get_environment() -> Result<_rt::Vec<(_rt::String, _rt::String)>, _rt::String>; + fn get_arguments() -> Result<_rt::Vec<_rt::String>, _rt::String>; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#get-environment"] + unsafe extern "C" fn export_get_environment() -> *mut u8 { + $($path_to_types)*::_export_get_environment_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#get-environment"] + unsafe extern "C" fn _post_return_get_environment(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_environment::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-arguments"] + unsafe extern "C" fn export_get_arguments() -> *mut u8 { + $($path_to_types)*::_export_get_arguments_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#get-arguments"] + unsafe extern "C" fn _post_return_get_arguments(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_arguments::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn get_environment() -> Result,wit_bindgen::rt::string::String>; - fn get_arguments() -> Result,wit_bindgen::rt::string::String>; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_environment_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_environment_service_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:environment-service"] +#[link_section = "component-type:wit-bindgen:0.25.0:environment-service:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 387] = [3, 0, 19, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 94, 1, 65, 2, 1, 66, 9, 1, 111, 2, 115, 115, 1, 112, 0, 1, 106, 1, 1, 1, 115, 1, 64, 0, 0, 2, 4, 0, 15, 103, 101, 116, 45, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 1, 3, 1, 112, 115, 1, 106, 1, 4, 1, 115, 1, 64, 0, 0, 5, 4, 0, 13, 103, 101, 116, 45, 97, 114, 103, 117, 109, 101, 110, 116, 115, 1, 6, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 130, 1, 1, 65, 2, 1, 65, 2, 1, 66, 9, 1, 111, 2, 115, 115, 1, 112, 0, 1, 106, 1, 1, 1, 115, 1, 64, 0, 0, 2, 4, 0, 15, 103, 101, 116, 45, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 1, 3, 1, 112, 115, 1, 106, 1, 4, 1, 115, 1, 64, 0, 0, 5, 4, 0, 13, 103, 101, 116, 45, 97, 114, 103, 117, 109, 101, 110, 116, 115, 1, 6, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 28, 103, 111, 108, 101, 109, 58, 105, 116, 47, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 25, 1, 0, 19, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 268] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x82\x01\x01A\x02\x01\ +A\x02\x01B\x09\x01o\x02ss\x01p\0\x01j\x01\x01\x01s\x01@\0\0\x02\x04\0\x0fget-env\ +ironment\x01\x03\x01ps\x01j\x01\x04\x01s\x01@\0\0\x05\x04\0\x0dget-arguments\x01\ +\x06\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x1cgolem:it/environment-service\x04\0\ +\x0b\x19\x01\0\x13environment-service\x03\0\0\0G\x09producers\x01\x0cprocessed-b\ +y\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/environment-service/src/lib.rs b/test-components/environment-service/src/lib.rs index a918154fab..43e0bfc7aa 100644 --- a/test-components/environment-service/src/lib.rs +++ b/test-components/environment-service/src/lib.rs @@ -15,3 +15,5 @@ impl Guest for Component { Ok(args().collect::>()) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/failing-component.wasm b/test-components/failing-component.wasm index 9d57ebff46..0b146263a7 100755 Binary files a/test-components/failing-component.wasm and b/test-components/failing-component.wasm differ diff --git a/test-components/failing-component/Cargo.lock b/test-components/failing-component/Cargo.lock index 1a2fce9db0..4fc95be086 100644 --- a/test-components/failing-component/Cargo.lock +++ b/test-components/failing-component/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "failing-component" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/failing-component/Cargo.toml b/test-components/failing-component/Cargo.toml index 3b7a819ffc..0ab9a21563 100644 --- a/test-components/failing-component/Cargo.toml +++ b/test-components/failing-component/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = false # we want debug symbols for testing that error response contains usable call stack [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/failing-component/src/bindings.rs b/test-components/failing-component/src/bindings.rs index cf00ce128b..9fb2c58445 100644 --- a/test-components/failing-component/src/bindings.rs +++ b/test-components/failing-component/src/bindings.rs @@ -1,85 +1,136 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod component { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#add"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_add(arg0: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::add(arg0 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get(); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn add(value: u64,); - fn get() -> u64; + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod component { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_add_cabi(arg0: i64) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::add(arg0 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get(); + _rt::as_i64(result0) + } + pub trait Guest { + fn add(value: u64); + fn get() -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_component_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:component/api#add"] + unsafe extern "C" fn export_add(arg0: i64,) { + $($path_to_types)*::_export_add_cabi::<$ty>(arg0) + } + #[export_name = "golem:component/api#get"] + unsafe extern "C" fn export_get() -> i64 { + $($path_to_types)*::_export_get_cabi::<$ty>() + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_component_api_cabi; + } + } + } +} +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() } - - } - } - } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_failing_component_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::component::api::__export_golem_component_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::component::api); + ) } +#[doc(inline)] +pub(crate) use __export_failing_component_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:failing-component"] +#[link_section = "component-type:wit-bindgen:0.25.0:failing-component:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 474] = [3, 0, 17, 102, 97, 105, 108, 105, 110, 103, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 63, 1, 65, 2, 1, 66, 4, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 3, 97, 100, 100, 1, 0, 1, 64, 0, 0, 119, 4, 0, 3, 103, 101, 116, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 104, 1, 65, 2, 1, 65, 2, 1, 66, 4, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 3, 97, 100, 100, 1, 0, 1, 64, 0, 0, 119, 4, 0, 3, 103, 101, 116, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 4, 1, 33, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 102, 97, 105, 108, 105, 110, 103, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 4, 0, 11, 23, 1, 0, 17, 102, 97, 105, 108, 105, 110, 103, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 3, 2, 0, 0, 164, 1, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 105, 110, 116, 101, 114, 102, 97, 99, 101, 115, 34, 58, 123, 34, 97, 112, 105, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 83, 101, 101, 32, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 87, 101, 98, 65, 115, 115, 101, 109, 98, 108, 121, 47, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 109, 111, 100, 101, 108, 47, 98, 108, 111, 98, 47, 109, 97, 105, 110, 47, 100, 101, 115, 105, 103, 110, 47, 109, 118, 112, 47, 87, 73, 84, 46, 109, 100, 32, 102, 111, 114, 32, 109, 111, 114, 101, 32, 100, 101, 116, 97, 105, 108, 115, 32, 97, 98, 111, 117, 116, 32, 116, 104, 101, 32, 87, 73, 84, 32, 115, 121, 110, 116, 97, 120, 34, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 239] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07h\x01A\x02\x01A\x02\x01\ +B\x04\x01@\x01\x05valuew\x01\0\x04\0\x03add\x01\0\x01@\0\0w\x04\0\x03get\x01\x01\ +\x04\x01\x13golem:component/api\x05\0\x04\x01!golem:component/failing-component\x04\ +\0\x0b\x17\x01\0\x11failing-component\x03\0\0\0G\x09producers\x01\x0cprocessed-b\ +y\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/failing-component/src/lib.rs b/test-components/failing-component/src/lib.rs index d43c568b0d..b43d1d324a 100644 --- a/test-components/failing-component/src/lib.rs +++ b/test-components/failing-component/src/lib.rs @@ -36,3 +36,5 @@ impl Guest for Component { with_state(|state| state.total) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/file-service.wasm b/test-components/file-service.wasm index c8857beeaa..2514bcfc04 100755 Binary files a/test-components/file-service.wasm and b/test-components/file-service.wasm differ diff --git a/test-components/file-service/Cargo.lock b/test-components/file-service/Cargo.lock index 7825ecf8ae..83012a5d12 100644 --- a/test-components/file-service/Cargo.lock +++ b/test-components/file-service/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/file-service/cargo.toml b/test-components/file-service/cargo.toml index acdf942a7c..8911b237dc 100644 --- a/test-components/file-service/cargo.toml +++ b/test-components/file-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/file-service/src/bindings.rs b/test-components/file-service/src/bindings.rs index fa54623932..4df49d45bc 100644 --- a/test-components/file-service/src/bindings.rs +++ b/test-components/file-service/src/bindings.rs @@ -1,462 +1,470 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod wall_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A time and date in seconds plus nanoseconds. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Datetime { - pub seconds: u64, - pub nanoseconds: u32, - } - impl ::core::fmt::Debug for Datetime { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Datetime").field("seconds", &self.seconds).field("nanoseconds", &self.nanoseconds).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// This clock is not monotonic, therefore calling this function repeatedly - /// will not necessarily produce a sequence of non-decreasing values. - /// - /// The returned timestamps represent the number of seconds since - /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], - /// also known as [Unix Time]. - /// - /// The nanoseconds field of the output is always less than 1000000000. - /// - /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 - /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time - pub fn now() -> Datetime{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { - #[link_name = "now"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i32); - Datetime{ - seconds: l1 as u64, - nanoseconds: l2 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. - /// - /// The nanoseconds field of the output is always less than 1000000000. - pub fn resolution() -> Datetime{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { - #[link_name = "resolution"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i32); - Datetime{ - seconds: l1 as u64, - nanoseconds: l2 as u32, - } + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod wall_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + /// A time and date in seconds plus nanoseconds. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Datetime { + pub seconds: u64, + pub nanoseconds: u32, + } + impl ::core::fmt::Debug for Datetime { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Datetime") + .field("seconds", &self.seconds) + .field("nanoseconds", &self.nanoseconds) + .finish() + } + } + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The returned timestamps represent the number of seconds since + /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], + /// also known as [Unix Time]. + /// + /// The nanoseconds field of the output is always less than 1000000000. + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + pub fn now() -> Datetime { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + extern "C" { + #[link_name = "now"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Datetime { + seconds: l1 as u64, + nanoseconds: l2 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. + /// + /// The nanoseconds field of the output is always less than 1000000000. + pub fn resolution() -> Datetime { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + extern "C" { + #[link_name = "resolution"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Datetime { + seconds: l1 as u64, + nanoseconds: l2 as u32, + } + } + } } - } - } - - } - pub mod filesystem { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type Error = super::super::super::wasi::io::streams::Error; - pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; - /// File size or length of a region within a file. - pub type Filesize = u64; - /// The type of a filesystem object referenced by a descriptor. - /// - /// Note: This was called `filetype` in earlier versions of WASI. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum DescriptorType { - /// The type of the descriptor or file is unknown or is different from - /// any of the other types specified. - Unknown, - /// The descriptor refers to a block device inode. - BlockDevice, - /// The descriptor refers to a character device inode. - CharacterDevice, - /// The descriptor refers to a directory inode. - Directory, - /// The descriptor refers to a named pipe. - Fifo, - /// The file refers to a symbolic link inode. - SymbolicLink, - /// The descriptor refers to a regular file inode. - RegularFile, - /// The descriptor refers to a socket. - Socket, - } - impl ::core::fmt::Debug for DescriptorType { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - DescriptorType::Unknown => { - f.debug_tuple("DescriptorType::Unknown").finish() + #[allow(dead_code)] + pub mod filesystem { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type Error = super::super::super::wasi::io::streams::Error; + pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; + /// File size or length of a region within a file. + pub type Filesize = u64; + /// The type of a filesystem object referenced by a descriptor. + /// + /// Note: This was called `filetype` in earlier versions of WASI. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum DescriptorType { + /// The type of the descriptor or file is unknown or is different from + /// any of the other types specified. + Unknown, + /// The descriptor refers to a block device inode. + BlockDevice, + /// The descriptor refers to a character device inode. + CharacterDevice, + /// The descriptor refers to a directory inode. + Directory, + /// The descriptor refers to a named pipe. + Fifo, + /// The file refers to a symbolic link inode. + SymbolicLink, + /// The descriptor refers to a regular file inode. + RegularFile, + /// The descriptor refers to a socket. + Socket, } - DescriptorType::BlockDevice => { - f.debug_tuple("DescriptorType::BlockDevice").finish() + impl ::core::fmt::Debug for DescriptorType { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + DescriptorType::Unknown => { + f.debug_tuple("DescriptorType::Unknown").finish() + } + DescriptorType::BlockDevice => { + f.debug_tuple("DescriptorType::BlockDevice").finish() + } + DescriptorType::CharacterDevice => { + f.debug_tuple("DescriptorType::CharacterDevice").finish() + } + DescriptorType::Directory => { + f.debug_tuple("DescriptorType::Directory").finish() + } + DescriptorType::Fifo => f.debug_tuple("DescriptorType::Fifo").finish(), + DescriptorType::SymbolicLink => { + f.debug_tuple("DescriptorType::SymbolicLink").finish() + } + DescriptorType::RegularFile => { + f.debug_tuple("DescriptorType::RegularFile").finish() + } + DescriptorType::Socket => f.debug_tuple("DescriptorType::Socket").finish(), + } + } } - DescriptorType::CharacterDevice => { - f.debug_tuple("DescriptorType::CharacterDevice").finish() + + impl DescriptorType { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> DescriptorType { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => DescriptorType::Unknown, + 1 => DescriptorType::BlockDevice, + 2 => DescriptorType::CharacterDevice, + 3 => DescriptorType::Directory, + 4 => DescriptorType::Fifo, + 5 => DescriptorType::SymbolicLink, + 6 => DescriptorType::RegularFile, + 7 => DescriptorType::Socket, + + _ => panic!("invalid enum discriminant"), + } + } } - DescriptorType::Directory => { - f.debug_tuple("DescriptorType::Directory").finish() + + wit_bindgen_rt::bitflags::bitflags! { + /// Descriptor flags. + /// + /// Note: This was called `fdflags` in earlier versions of WASI. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct DescriptorFlags: u8 { + /// Read mode: Data can be read. + const READ = 1 << 0; + /// Write mode: Data can be written to. + const WRITE = 1 << 1; + /// Request that writes be performed according to synchronized I/O file + /// integrity completion. The data stored in the file and the file's + /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const FILE_INTEGRITY_SYNC = 1 << 2; + /// Request that writes be performed according to synchronized I/O data + /// integrity completion. Only the data stored in the file is + /// synchronized. This is similar to `O_DSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const DATA_INTEGRITY_SYNC = 1 << 3; + /// Requests that reads be performed at the same level of integrety + /// requested for writes. This is similar to `O_RSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const REQUESTED_WRITE_SYNC = 1 << 4; + /// Mutating directories mode: Directory contents may be mutated. + /// + /// When this flag is unset on a descriptor, operations using the + /// descriptor which would create, rename, delete, modify the data or + /// metadata of filesystem objects, or obtain another handle which + /// would permit any of those, shall fail with `error-code::read-only` if + /// they would otherwise succeed. + /// + /// This may only be set on directories. + const MUTATE_DIRECTORY = 1 << 5; + } } - DescriptorType::Fifo => { - f.debug_tuple("DescriptorType::Fifo").finish() + wit_bindgen_rt::bitflags::bitflags! { + /// Flags determining the method of how paths are resolved. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct PathFlags: u8 { + /// As long as the resolved path corresponds to a symbolic link, it is + /// expanded. + const SYMLINK_FOLLOW = 1 << 0; + } } - DescriptorType::SymbolicLink => { - f.debug_tuple("DescriptorType::SymbolicLink").finish() + wit_bindgen_rt::bitflags::bitflags! { + /// Open flags used by `open-at`. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct OpenFlags: u8 { + /// Create file if it does not exist, similar to `O_CREAT` in POSIX. + const CREATE = 1 << 0; + /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. + const DIRECTORY = 1 << 1; + /// Fail if file already exists, similar to `O_EXCL` in POSIX. + const EXCLUSIVE = 1 << 2; + /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. + const TRUNCATE = 1 << 3; + } } - DescriptorType::RegularFile => { - f.debug_tuple("DescriptorType::RegularFile").finish() + /// Number of hard links to an inode. + pub type LinkCount = u64; + /// File attributes. + /// + /// Note: This was called `filestat` in earlier versions of WASI. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct DescriptorStat { + /// File type. + pub type_: DescriptorType, + /// Number of hard links to the file. + pub link_count: LinkCount, + /// For regular files, the file size in bytes. For symbolic links, the + /// length in bytes of the pathname contained in the symbolic link. + pub size: Filesize, + /// Last data access timestamp. + /// + /// If the `option` is none, the platform doesn't maintain an access + /// timestamp for this file. + pub data_access_timestamp: Option, + /// Last data modification timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// modification timestamp for this file. + pub data_modification_timestamp: Option, + /// Last file status-change timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// status-change timestamp for this file. + pub status_change_timestamp: Option, } - DescriptorType::Socket => { - f.debug_tuple("DescriptorType::Socket").finish() + impl ::core::fmt::Debug for DescriptorStat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DescriptorStat") + .field("type", &self.type_) + .field("link-count", &self.link_count) + .field("size", &self.size) + .field("data-access-timestamp", &self.data_access_timestamp) + .field( + "data-modification-timestamp", + &self.data_modification_timestamp, + ) + .field("status-change-timestamp", &self.status_change_timestamp) + .finish() + } } - } - } - } - - impl DescriptorType{ - pub(crate) unsafe fn _lift(val: u8) -> DescriptorType{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => DescriptorType::Unknown, - 1 => DescriptorType::BlockDevice, - 2 => DescriptorType::CharacterDevice, - 3 => DescriptorType::Directory, - 4 => DescriptorType::Fifo, - 5 => DescriptorType::SymbolicLink, - 6 => DescriptorType::RegularFile, - 7 => DescriptorType::Socket, - - _ => panic!("invalid enum discriminant"), - } - } - } - - wit_bindgen::bitflags::bitflags! { - /// Descriptor flags. - /// - /// Note: This was called `fdflags` in earlier versions of WASI. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct DescriptorFlags: u8 { - /// Read mode: Data can be read. - const READ = 1 << 0; - /// Write mode: Data can be written to. - const WRITE = 1 << 1; - /// Request that writes be performed according to synchronized I/O file - /// integrity completion. The data stored in the file and the file's - /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const FILE_INTEGRITY_SYNC = 1 << 2; - /// Request that writes be performed according to synchronized I/O data - /// integrity completion. Only the data stored in the file is - /// synchronized. This is similar to `O_DSYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const DATA_INTEGRITY_SYNC = 1 << 3; - /// Requests that reads be performed at the same level of integrety - /// requested for writes. This is similar to `O_RSYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const REQUESTED_WRITE_SYNC = 1 << 4; - /// Mutating directories mode: Directory contents may be mutated. - /// - /// When this flag is unset on a descriptor, operations using the - /// descriptor which would create, rename, delete, modify the data or - /// metadata of filesystem objects, or obtain another handle which - /// would permit any of those, shall fail with `error-code::read-only` if - /// they would otherwise succeed. - /// - /// This may only be set on directories. - const MUTATE_DIRECTORY = 1 << 5; - } - } - wit_bindgen::bitflags::bitflags! { - /// Flags determining the method of how paths are resolved. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct PathFlags: u8 { - /// As long as the resolved path corresponds to a symbolic link, it is - /// expanded. - const SYMLINK_FOLLOW = 1 << 0; - } - } - wit_bindgen::bitflags::bitflags! { - /// Open flags used by `open-at`. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct OpenFlags: u8 { - /// Create file if it does not exist, similar to `O_CREAT` in POSIX. - const CREATE = 1 << 0; - /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. - const DIRECTORY = 1 << 1; - /// Fail if file already exists, similar to `O_EXCL` in POSIX. - const EXCLUSIVE = 1 << 2; - /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. - const TRUNCATE = 1 << 3; - } - } - /// Number of hard links to an inode. - pub type LinkCount = u64; - /// File attributes. - /// - /// Note: This was called `filestat` in earlier versions of WASI. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct DescriptorStat { - /// File type. - pub type_: DescriptorType, - /// Number of hard links to the file. - pub link_count: LinkCount, - /// For regular files, the file size in bytes. For symbolic links, the - /// length in bytes of the pathname contained in the symbolic link. - pub size: Filesize, - /// Last data access timestamp. - /// - /// If the `option` is none, the platform doesn't maintain an access - /// timestamp for this file. - pub data_access_timestamp: Option, - /// Last data modification timestamp. - /// - /// If the `option` is none, the platform doesn't maintain a - /// modification timestamp for this file. - pub data_modification_timestamp: Option, - /// Last file status-change timestamp. - /// - /// If the `option` is none, the platform doesn't maintain a - /// status-change timestamp for this file. - pub status_change_timestamp: Option, - } - impl ::core::fmt::Debug for DescriptorStat { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DescriptorStat").field("type", &self.type_).field("link-count", &self.link_count).field("size", &self.size).field("data-access-timestamp", &self.data_access_timestamp).field("data-modification-timestamp", &self.data_modification_timestamp).field("status-change-timestamp", &self.status_change_timestamp).finish() - } - } - /// When setting a timestamp, this gives the value to set it to. - #[derive(Clone, Copy)] - pub enum NewTimestamp{ - /// Leave the timestamp set to its previous value. - NoChange, - /// Set the timestamp to the current time of the system clock associated - /// with the filesystem. - Now, - /// Set the timestamp to the given value. - Timestamp(Datetime), - } - impl ::core::fmt::Debug for NewTimestamp { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - NewTimestamp::NoChange => { - f.debug_tuple("NewTimestamp::NoChange").finish() + /// When setting a timestamp, this gives the value to set it to. + #[derive(Clone, Copy)] + pub enum NewTimestamp { + /// Leave the timestamp set to its previous value. + NoChange, + /// Set the timestamp to the current time of the system clock associated + /// with the filesystem. + Now, + /// Set the timestamp to the given value. + Timestamp(Datetime), } - NewTimestamp::Now => { - f.debug_tuple("NewTimestamp::Now").finish() + impl ::core::fmt::Debug for NewTimestamp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + NewTimestamp::NoChange => f.debug_tuple("NewTimestamp::NoChange").finish(), + NewTimestamp::Now => f.debug_tuple("NewTimestamp::Now").finish(), + NewTimestamp::Timestamp(e) => { + f.debug_tuple("NewTimestamp::Timestamp").field(e).finish() + } + } + } } - NewTimestamp::Timestamp(e) => { - f.debug_tuple("NewTimestamp::Timestamp").field(e).finish() + /// A directory entry. + #[derive(Clone)] + pub struct DirectoryEntry { + /// The type of the file referred to by this directory entry. + pub type_: DescriptorType, + /// The name of the object. + pub name: _rt::String, } - } - } - } - /// A directory entry. - #[derive(Clone)] - pub struct DirectoryEntry { - /// The type of the file referred to by this directory entry. - pub type_: DescriptorType, - /// The name of the object. - pub name: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for DirectoryEntry { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DirectoryEntry").field("type", &self.type_).field("name", &self.name).finish() - } - } - /// Error codes returned by functions, similar to `errno` in POSIX. - /// Not all of these error codes are returned by the functions provided by this - /// API; some are used in higher-level library layers, and others are provided - /// merely for alignment with POSIX. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum ErrorCode { - /// Permission denied, similar to `EACCES` in POSIX. - Access, - /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. - WouldBlock, - /// Connection already in progress, similar to `EALREADY` in POSIX. - Already, - /// Bad descriptor, similar to `EBADF` in POSIX. - BadDescriptor, - /// Device or resource busy, similar to `EBUSY` in POSIX. - Busy, - /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. - Deadlock, - /// Storage quota exceeded, similar to `EDQUOT` in POSIX. - Quota, - /// File exists, similar to `EEXIST` in POSIX. - Exist, - /// File too large, similar to `EFBIG` in POSIX. - FileTooLarge, - /// Illegal byte sequence, similar to `EILSEQ` in POSIX. - IllegalByteSequence, - /// Operation in progress, similar to `EINPROGRESS` in POSIX. - InProgress, - /// Interrupted function, similar to `EINTR` in POSIX. - Interrupted, - /// Invalid argument, similar to `EINVAL` in POSIX. - Invalid, - /// I/O error, similar to `EIO` in POSIX. - Io, - /// Is a directory, similar to `EISDIR` in POSIX. - IsDirectory, - /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. - Loop, - /// Too many links, similar to `EMLINK` in POSIX. - TooManyLinks, - /// Message too large, similar to `EMSGSIZE` in POSIX. - MessageSize, - /// Filename too long, similar to `ENAMETOOLONG` in POSIX. - NameTooLong, - /// No such device, similar to `ENODEV` in POSIX. - NoDevice, - /// No such file or directory, similar to `ENOENT` in POSIX. - NoEntry, - /// No locks available, similar to `ENOLCK` in POSIX. - NoLock, - /// Not enough space, similar to `ENOMEM` in POSIX. - InsufficientMemory, - /// No space left on device, similar to `ENOSPC` in POSIX. - InsufficientSpace, - /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. - NotDirectory, - /// Directory not empty, similar to `ENOTEMPTY` in POSIX. - NotEmpty, - /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. - NotRecoverable, - /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. - Unsupported, - /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. - NoTty, - /// No such device or address, similar to `ENXIO` in POSIX. - NoSuchDevice, - /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. - Overflow, - /// Operation not permitted, similar to `EPERM` in POSIX. - NotPermitted, - /// Broken pipe, similar to `EPIPE` in POSIX. - Pipe, - /// Read-only file system, similar to `EROFS` in POSIX. - ReadOnly, - /// Invalid seek, similar to `ESPIPE` in POSIX. - InvalidSeek, - /// Text file busy, similar to `ETXTBSY` in POSIX. - TextFileBusy, - /// Cross-device link, similar to `EXDEV` in POSIX. - CrossDevice, - } - impl ErrorCode{ - pub fn name(&self) -> &'static str { - match self { - ErrorCode::Access => "access", - ErrorCode::WouldBlock => "would-block", - ErrorCode::Already => "already", - ErrorCode::BadDescriptor => "bad-descriptor", - ErrorCode::Busy => "busy", - ErrorCode::Deadlock => "deadlock", - ErrorCode::Quota => "quota", - ErrorCode::Exist => "exist", - ErrorCode::FileTooLarge => "file-too-large", - ErrorCode::IllegalByteSequence => "illegal-byte-sequence", - ErrorCode::InProgress => "in-progress", - ErrorCode::Interrupted => "interrupted", - ErrorCode::Invalid => "invalid", - ErrorCode::Io => "io", - ErrorCode::IsDirectory => "is-directory", - ErrorCode::Loop => "loop", - ErrorCode::TooManyLinks => "too-many-links", - ErrorCode::MessageSize => "message-size", - ErrorCode::NameTooLong => "name-too-long", - ErrorCode::NoDevice => "no-device", - ErrorCode::NoEntry => "no-entry", - ErrorCode::NoLock => "no-lock", - ErrorCode::InsufficientMemory => "insufficient-memory", - ErrorCode::InsufficientSpace => "insufficient-space", - ErrorCode::NotDirectory => "not-directory", - ErrorCode::NotEmpty => "not-empty", - ErrorCode::NotRecoverable => "not-recoverable", - ErrorCode::Unsupported => "unsupported", - ErrorCode::NoTty => "no-tty", - ErrorCode::NoSuchDevice => "no-such-device", - ErrorCode::Overflow => "overflow", - ErrorCode::NotPermitted => "not-permitted", - ErrorCode::Pipe => "pipe", - ErrorCode::ReadOnly => "read-only", - ErrorCode::InvalidSeek => "invalid-seek", - ErrorCode::TextFileBusy => "text-file-busy", - ErrorCode::CrossDevice => "cross-device", - } - } - pub fn message(&self) -> &'static str { - match self { + impl ::core::fmt::Debug for DirectoryEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DirectoryEntry") + .field("type", &self.type_) + .field("name", &self.name) + .finish() + } + } + /// Error codes returned by functions, similar to `errno` in POSIX. + /// Not all of these error codes are returned by the functions provided by this + /// API; some are used in higher-level library layers, and others are provided + /// merely for alignment with POSIX. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum ErrorCode { + /// Permission denied, similar to `EACCES` in POSIX. + Access, + /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. + WouldBlock, + /// Connection already in progress, similar to `EALREADY` in POSIX. + Already, + /// Bad descriptor, similar to `EBADF` in POSIX. + BadDescriptor, + /// Device or resource busy, similar to `EBUSY` in POSIX. + Busy, + /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. + Deadlock, + /// Storage quota exceeded, similar to `EDQUOT` in POSIX. + Quota, + /// File exists, similar to `EEXIST` in POSIX. + Exist, + /// File too large, similar to `EFBIG` in POSIX. + FileTooLarge, + /// Illegal byte sequence, similar to `EILSEQ` in POSIX. + IllegalByteSequence, + /// Operation in progress, similar to `EINPROGRESS` in POSIX. + InProgress, + /// Interrupted function, similar to `EINTR` in POSIX. + Interrupted, + /// Invalid argument, similar to `EINVAL` in POSIX. + Invalid, + /// I/O error, similar to `EIO` in POSIX. + Io, + /// Is a directory, similar to `EISDIR` in POSIX. + IsDirectory, + /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. + Loop, + /// Too many links, similar to `EMLINK` in POSIX. + TooManyLinks, + /// Message too large, similar to `EMSGSIZE` in POSIX. + MessageSize, + /// Filename too long, similar to `ENAMETOOLONG` in POSIX. + NameTooLong, + /// No such device, similar to `ENODEV` in POSIX. + NoDevice, + /// No such file or directory, similar to `ENOENT` in POSIX. + NoEntry, + /// No locks available, similar to `ENOLCK` in POSIX. + NoLock, + /// Not enough space, similar to `ENOMEM` in POSIX. + InsufficientMemory, + /// No space left on device, similar to `ENOSPC` in POSIX. + InsufficientSpace, + /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. + NotDirectory, + /// Directory not empty, similar to `ENOTEMPTY` in POSIX. + NotEmpty, + /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. + NotRecoverable, + /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. + Unsupported, + /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. + NoTty, + /// No such device or address, similar to `ENXIO` in POSIX. + NoSuchDevice, + /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. + Overflow, + /// Operation not permitted, similar to `EPERM` in POSIX. + NotPermitted, + /// Broken pipe, similar to `EPIPE` in POSIX. + Pipe, + /// Read-only file system, similar to `EROFS` in POSIX. + ReadOnly, + /// Invalid seek, similar to `ESPIPE` in POSIX. + InvalidSeek, + /// Text file busy, similar to `ETXTBSY` in POSIX. + TextFileBusy, + /// Cross-device link, similar to `EXDEV` in POSIX. + CrossDevice, + } + impl ErrorCode { + pub fn name(&self) -> &'static str { + match self { + ErrorCode::Access => "access", + ErrorCode::WouldBlock => "would-block", + ErrorCode::Already => "already", + ErrorCode::BadDescriptor => "bad-descriptor", + ErrorCode::Busy => "busy", + ErrorCode::Deadlock => "deadlock", + ErrorCode::Quota => "quota", + ErrorCode::Exist => "exist", + ErrorCode::FileTooLarge => "file-too-large", + ErrorCode::IllegalByteSequence => "illegal-byte-sequence", + ErrorCode::InProgress => "in-progress", + ErrorCode::Interrupted => "interrupted", + ErrorCode::Invalid => "invalid", + ErrorCode::Io => "io", + ErrorCode::IsDirectory => "is-directory", + ErrorCode::Loop => "loop", + ErrorCode::TooManyLinks => "too-many-links", + ErrorCode::MessageSize => "message-size", + ErrorCode::NameTooLong => "name-too-long", + ErrorCode::NoDevice => "no-device", + ErrorCode::NoEntry => "no-entry", + ErrorCode::NoLock => "no-lock", + ErrorCode::InsufficientMemory => "insufficient-memory", + ErrorCode::InsufficientSpace => "insufficient-space", + ErrorCode::NotDirectory => "not-directory", + ErrorCode::NotEmpty => "not-empty", + ErrorCode::NotRecoverable => "not-recoverable", + ErrorCode::Unsupported => "unsupported", + ErrorCode::NoTty => "no-tty", + ErrorCode::NoSuchDevice => "no-such-device", + ErrorCode::Overflow => "overflow", + ErrorCode::NotPermitted => "not-permitted", + ErrorCode::Pipe => "pipe", + ErrorCode::ReadOnly => "read-only", + ErrorCode::InvalidSeek => "invalid-seek", + ErrorCode::TextFileBusy => "text-file-busy", + ErrorCode::CrossDevice => "cross-device", + } + } + pub fn message(&self) -> &'static str { + match self { ErrorCode::Access => "Permission denied, similar to `EACCES` in POSIX.", ErrorCode::WouldBlock => "Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.", ErrorCode::Already => "Connection already in progress, similar to `EALREADY` in POSIX.", @@ -495,4246 +503,4667 @@ pub mod wasi { ErrorCode::TextFileBusy => "Text file busy, similar to `ETXTBSY` in POSIX.", ErrorCode::CrossDevice => "Cross-device link, similar to `EXDEV` in POSIX.", } - } - } - impl ::core::fmt::Debug for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for ErrorCode{} - - impl ErrorCode{ - pub(crate) unsafe fn _lift(val: u8) -> ErrorCode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => ErrorCode::Access, - 1 => ErrorCode::WouldBlock, - 2 => ErrorCode::Already, - 3 => ErrorCode::BadDescriptor, - 4 => ErrorCode::Busy, - 5 => ErrorCode::Deadlock, - 6 => ErrorCode::Quota, - 7 => ErrorCode::Exist, - 8 => ErrorCode::FileTooLarge, - 9 => ErrorCode::IllegalByteSequence, - 10 => ErrorCode::InProgress, - 11 => ErrorCode::Interrupted, - 12 => ErrorCode::Invalid, - 13 => ErrorCode::Io, - 14 => ErrorCode::IsDirectory, - 15 => ErrorCode::Loop, - 16 => ErrorCode::TooManyLinks, - 17 => ErrorCode::MessageSize, - 18 => ErrorCode::NameTooLong, - 19 => ErrorCode::NoDevice, - 20 => ErrorCode::NoEntry, - 21 => ErrorCode::NoLock, - 22 => ErrorCode::InsufficientMemory, - 23 => ErrorCode::InsufficientSpace, - 24 => ErrorCode::NotDirectory, - 25 => ErrorCode::NotEmpty, - 26 => ErrorCode::NotRecoverable, - 27 => ErrorCode::Unsupported, - 28 => ErrorCode::NoTty, - 29 => ErrorCode::NoSuchDevice, - 30 => ErrorCode::Overflow, - 31 => ErrorCode::NotPermitted, - 32 => ErrorCode::Pipe, - 33 => ErrorCode::ReadOnly, - 34 => ErrorCode::InvalidSeek, - 35 => ErrorCode::TextFileBusy, - 36 => ErrorCode::CrossDevice, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// File or memory access pattern advisory information. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Advice { - /// The application has no advice to give on its behavior with respect - /// to the specified data. - Normal, - /// The application expects to access the specified data sequentially - /// from lower offsets to higher offsets. - Sequential, - /// The application expects to access the specified data in a random - /// order. - Random, - /// The application expects to access the specified data in the near - /// future. - WillNeed, - /// The application expects that it will not access the specified data - /// in the near future. - DontNeed, - /// The application expects to access the specified data once and then - /// not reuse it thereafter. - NoReuse, - } - impl ::core::fmt::Debug for Advice { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Advice::Normal => { - f.debug_tuple("Advice::Normal").finish() - } - Advice::Sequential => { - f.debug_tuple("Advice::Sequential").finish() + } } - Advice::Random => { - f.debug_tuple("Advice::Random").finish() + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ErrorCode") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } } - Advice::WillNeed => { - f.debug_tuple("Advice::WillNeed").finish() + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } } - Advice::DontNeed => { - f.debug_tuple("Advice::DontNeed").finish() + + impl std::error::Error for ErrorCode {} + + impl ErrorCode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> ErrorCode { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => ErrorCode::Access, + 1 => ErrorCode::WouldBlock, + 2 => ErrorCode::Already, + 3 => ErrorCode::BadDescriptor, + 4 => ErrorCode::Busy, + 5 => ErrorCode::Deadlock, + 6 => ErrorCode::Quota, + 7 => ErrorCode::Exist, + 8 => ErrorCode::FileTooLarge, + 9 => ErrorCode::IllegalByteSequence, + 10 => ErrorCode::InProgress, + 11 => ErrorCode::Interrupted, + 12 => ErrorCode::Invalid, + 13 => ErrorCode::Io, + 14 => ErrorCode::IsDirectory, + 15 => ErrorCode::Loop, + 16 => ErrorCode::TooManyLinks, + 17 => ErrorCode::MessageSize, + 18 => ErrorCode::NameTooLong, + 19 => ErrorCode::NoDevice, + 20 => ErrorCode::NoEntry, + 21 => ErrorCode::NoLock, + 22 => ErrorCode::InsufficientMemory, + 23 => ErrorCode::InsufficientSpace, + 24 => ErrorCode::NotDirectory, + 25 => ErrorCode::NotEmpty, + 26 => ErrorCode::NotRecoverable, + 27 => ErrorCode::Unsupported, + 28 => ErrorCode::NoTty, + 29 => ErrorCode::NoSuchDevice, + 30 => ErrorCode::Overflow, + 31 => ErrorCode::NotPermitted, + 32 => ErrorCode::Pipe, + 33 => ErrorCode::ReadOnly, + 34 => ErrorCode::InvalidSeek, + 35 => ErrorCode::TextFileBusy, + 36 => ErrorCode::CrossDevice, + + _ => panic!("invalid enum discriminant"), + } + } } - Advice::NoReuse => { - f.debug_tuple("Advice::NoReuse").finish() + + /// File or memory access pattern advisory information. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Advice { + /// The application has no advice to give on its behavior with respect + /// to the specified data. + Normal, + /// The application expects to access the specified data sequentially + /// from lower offsets to higher offsets. + Sequential, + /// The application expects to access the specified data in a random + /// order. + Random, + /// The application expects to access the specified data in the near + /// future. + WillNeed, + /// The application expects that it will not access the specified data + /// in the near future. + DontNeed, + /// The application expects to access the specified data once and then + /// not reuse it thereafter. + NoReuse, } - } - } - } - - impl Advice{ - pub(crate) unsafe fn _lift(val: u8) -> Advice{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Advice::Normal, - 1 => Advice::Sequential, - 2 => Advice::Random, - 3 => Advice::WillNeed, - 4 => Advice::DontNeed, - 5 => Advice::NoReuse, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// A 128-bit hash value, split into parts because wasm doesn't have a - /// 128-bit integer type. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct MetadataHashValue { - /// 64 bits of a 128-bit hash value. - pub lower: u64, - /// Another 64 bits of a 128-bit hash value. - pub upper: u64, - } - impl ::core::fmt::Debug for MetadataHashValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("MetadataHashValue").field("lower", &self.lower).field("upper", &self.upper).finish() - } - } - /// A descriptor is a reference to a filesystem object, which may be a file, - /// directory, named pipe, special file, or other object on which filesystem - /// calls may be made. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Descriptor{ - handle: wit_bindgen::rt::Resource, - } - - impl Descriptor{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Descriptor{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]descriptor"] - fn drop(_: u32); + impl ::core::fmt::Debug for Advice { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Advice::Normal => f.debug_tuple("Advice::Normal").finish(), + Advice::Sequential => f.debug_tuple("Advice::Sequential").finish(), + Advice::Random => f.debug_tuple("Advice::Random").finish(), + Advice::WillNeed => f.debug_tuple("Advice::WillNeed").finish(), + Advice::DontNeed => f.debug_tuple("Advice::DontNeed").finish(), + Advice::NoReuse => f.debug_tuple("Advice::NoReuse").finish(), + } + } } - - drop(_handle); - } - } - } - - /// A stream of directory entries. - - #[derive(Debug)] - #[repr(transparent)] - pub struct DirectoryEntryStream{ - handle: wit_bindgen::rt::Resource, - } - - impl DirectoryEntryStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for DirectoryEntryStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]directory-entry-stream"] - fn drop(_: u32); + + impl Advice { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Advice { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Advice::Normal, + 1 => Advice::Sequential, + 2 => Advice::Random, + 3 => Advice::WillNeed, + 4 => Advice::DontNeed, + 5 => Advice::NoReuse, + + _ => panic!("invalid enum discriminant"), + } + } } - - drop(_handle); - } - } - } - - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for reading from a file, if available. - /// - /// May fail with an error-code describing why the file cannot be read. - /// - /// Multiple read, write, and append streams may be active on the same open - /// file and they do not interfere with each other. - /// - /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. - pub fn read_via_stream(&self,offset: Filesize,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read-via-stream"] - fn wit_import(_: i32, _: i64, _: i32, ); + + /// A 128-bit hash value, split into parts because wasm doesn't have a + /// 128-bit integer type. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct MetadataHashValue { + /// 64 bits of a 128-bit hash value. + pub lower: u64, + /// Another 64 bits of a 128-bit hash value. + pub upper: u64, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(offset), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl ::core::fmt::Debug for MetadataHashValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MetadataHashValue") + .field("lower", &self.lower) + .field("upper", &self.upper) + .finish() + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for writing to a file, if available. - /// - /// May fail with an error-code describing why the file cannot be written. - /// - /// Note: This allows using `write-stream`, which is similar to `write` in - /// POSIX. - pub fn write_via_stream(&self,offset: Filesize,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.write-via-stream"] - fn wit_import(_: i32, _: i64, _: i32, ); + /// A descriptor is a reference to a filesystem object, which may be a file, + /// directory, named pipe, special file, or other object on which filesystem + /// calls may be made. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Descriptor { + handle: _rt::Resource, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(offset), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + impl Descriptor { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for appending to a file, if available. - /// - /// May fail with an error-code describing why the file cannot be appended. - /// - /// Note: This allows using `write-stream`, which is similar to `write` with - /// `O_APPEND` in in POSIX. - pub fn append_via_stream(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.append-via-stream"] - fn wit_import(_: i32, _: i32, ); + + unsafe impl _rt::WasmResource for Descriptor { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]descriptor"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + /// A stream of directory entries. + + #[derive(Debug)] + #[repr(transparent)] + pub struct DirectoryEntryStream { + handle: _rt::Resource, } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Provide file advisory information on a descriptor. - /// - /// This is similar to `posix_fadvise` in POSIX. - pub fn advise(&self,offset: Filesize,length: Filesize,advice: Advice,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.advise"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: i32, ); + + impl DirectoryEntryStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(offset), wit_bindgen::rt::as_i64(length), advice.clone() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + unsafe impl _rt::WasmResource for DirectoryEntryStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]directory-entry-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Synchronize the data of a file to disk. - /// - /// This function succeeds with no effect if the file descriptor is not - /// opened for writing. - /// - /// Note: This is similar to `fdatasync` in POSIX. - pub fn sync_data(&self,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.sync-data"] - fn wit_import(_: i32, _: i32, ); + + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for reading from a file, if available. + /// + /// May fail with an error-code describing why the file cannot be read. + /// + /// Multiple read, write, and append streams may be active on the same open + /// file and they do not interfere with each other. + /// + /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. + pub fn read_via_stream(&self, offset: Filesize) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read-via-stream"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle( + l2 as u32, + ) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for writing to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be written. + /// + /// Note: This allows using `write-stream`, which is similar to `write` in + /// POSIX. + pub fn write_via_stream( + &self, + offset: Filesize, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.write-via-stream"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Get flags associated with a descriptor. - /// - /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. - /// - /// Note: This returns the value that was the `fs_flags` value returned - /// from `fdstat_get` in earlier versions of WASI. - pub fn get_flags(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.get-flags"] - fn wit_import(_: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for appending to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be appended. + /// + /// Note: This allows using `write-stream`, which is similar to `write` with + /// `O_APPEND` in in POSIX. + pub fn append_via_stream(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.append-via-stream"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - DescriptorFlags::empty() | DescriptorFlags::from_bits_retain(((l2 as u8) << 0) as _) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Provide file advisory information on a descriptor. + /// + /// This is similar to `posix_fadvise` in POSIX. + pub fn advise( + &self, + offset: Filesize, + length: Filesize, + advice: Advice, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.advise"] + fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + _rt::as_i64(offset), + _rt::as_i64(length), + advice.clone() as i32, + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Get the dynamic type of a descriptor. - /// - /// Note: This returns the same value as the `type` field of the `fd-stat` - /// returned by `stat`, `stat-at` and similar. - /// - /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided - /// by `fstat` in POSIX. - /// - /// Note: This returns the value that was the `fs_filetype` value returned - /// from `fdstat_get` in earlier versions of WASI. - pub fn get_type(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.get-type"] - fn wit_import(_: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fdatasync` in POSIX. + pub fn sync_data(&self) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.sync-data"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - DescriptorType::_lift(l2 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Get flags associated with a descriptor. + /// + /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + /// + /// Note: This returns the value that was the `fs_flags` value returned + /// from `fdstat_get` in earlier versions of WASI. + pub fn get_flags(&self) -> Result { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.get-flags"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + DescriptorFlags::empty() + | DescriptorFlags::from_bits_retain(((l2 as u8) << 0) as _) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the size of an open file. If this increases the file's size, the - /// extra bytes are filled with zeros. - /// - /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. - pub fn set_size(&self,size: Filesize,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-size"] - fn wit_import(_: i32, _: i64, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Get the dynamic type of a descriptor. + /// + /// Note: This returns the same value as the `type` field of the `fd-stat` + /// returned by `stat`, `stat-at` and similar. + /// + /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided + /// by `fstat` in POSIX. + /// + /// Note: This returns the value that was the `fs_filetype` value returned + /// from `fdstat_get` in earlier versions of WASI. + pub fn get_type(&self) -> Result { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.get-type"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + DescriptorType::_lift(l2 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(size), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the size of an open file. If this increases the file's size, the + /// extra bytes are filled with zeros. + /// + /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. + pub fn set_size(&self, size: Filesize) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-size"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(size), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the timestamps of an open file or directory. - /// - /// Note: This is similar to `futimens` in POSIX. - /// - /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. - pub fn set_times(&self,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let (result1_0,result1_1,result1_2,) = match data_access_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; - - (2i32, wit_bindgen::rt::as_i64(seconds0), wit_bindgen::rt::as_i32(nanoseconds0)) - }, - }; - let (result3_0,result3_1,result3_2,) = match data_modification_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; - - (2i32, wit_bindgen::rt::as_i64(seconds2), wit_bindgen::rt::as_i32(nanoseconds2)) - }, - }; - let ptr4 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-times"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of an open file or directory. + /// + /// Note: This is similar to `futimens` in POSIX. + /// + /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. + pub fn set_times( + &self, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let (result1_0, result1_1, result1_2) = match data_access_timestamp { + NewTimestamp::NoChange => (0i32, 0i64, 0i32), + NewTimestamp::Now => (1i32, 0i64, 0i32), + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds0, + nanoseconds: nanoseconds0, + } = e; + + (2i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) + } + }; + let (result3_0, result3_1, result3_2) = match data_modification_timestamp { + NewTimestamp::NoChange => (0i32, 0i64, 0i32), + NewTimestamp::Now => (1i32, 0i64, 0i32), + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds2, + nanoseconds: nanoseconds2, + } = e; + + (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) + } + }; + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-times"] + fn wit_import( + _: i32, + _: i32, + _: i64, + _: i32, + _: i32, + _: i64, + _: i32, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: i64, + _: i32, + _: i32, + _: i64, + _: i32, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + result1_0, + result1_1, + result1_2, + result3_0, + result3_1, + result3_2, + ptr4, + ); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr4.add(1).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, result1_0, result1_1, result1_2, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*((ptr4 + 0) as *const u8)); - match l5 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr4 + 1) as *const u8)); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read from a descriptor, without using and updating the descriptor's offset. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool which, when true, indicates that the end of the + /// file was reached. The returned list will contain up to `length` bytes; it + /// may return fewer than requested, if the end of the file is reached or + /// if the I/O operation is interrupted. + /// + /// In the future, this may change to return a `stream`. + /// + /// Note: This is similar to `pread` in POSIX. + pub fn read( + &self, + length: Filesize, + offset: Filesize, + ) -> Result<(_rt::Vec, bool), ErrorCode> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read"] + fn wit_import(_: i32, _: i64, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + _rt::as_i64(length), + _rt::as_i64(offset), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let l5 = i32::from(*ptr0.add(12).cast::()); + + ( + _rt::Vec::from_raw_parts(l2.cast(), len4, len4), + _rt::bool_lift(l5 as u8), + ) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read from a descriptor, without using and updating the descriptor's offset. - /// - /// This function returns a list of bytes containing the data that was - /// read, along with a bool which, when true, indicates that the end of the - /// file was reached. The returned list will contain up to `length` bytes; it - /// may return fewer than requested, if the end of the file is reached or - /// if the I/O operation is interrupted. - /// - /// In the future, this may change to return a `stream`. - /// - /// Note: This is similar to `pread` in POSIX. - pub fn read(&self,length: Filesize,offset: Filesize,) -> Result<(wit_bindgen::rt::vec::Vec::,bool,),ErrorCode>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Write to a descriptor, without using and updating the descriptor's offset. + /// + /// It is valid to write past the end of a file; the file is extended to the + /// extent of the write, with bytes between the previous end and the start of + /// the write set to zero. + /// + /// In the future, this may change to take a `stream`. + /// + /// Note: This is similar to `pwrite` in POSIX. + pub fn write( + &self, + buffer: &[u8], + offset: Filesize, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = buffer; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + _rt::as_i64(offset), + ptr1, + ); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::(); + + l3 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(8).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(length), wit_bindgen::rt::as_i64(offset), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let l5 = i32::from(*((ptr0 + 12) as *const u8)); - - (Vec::from_raw_parts(l2 as *mut _, len4, len4), wit_bindgen::rt::bool_lift(l5 as u8)) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read directory entries from a directory. + /// + /// On filesystems where directories contain entries referring to themselves + /// and their parents, often named `.` and `..` respectively, these entries + /// are omitted. + /// + /// This always returns a new stream which starts at the beginning of the + /// directory. Multiple streams may be active on the same directory, and they + /// do not interfere with each other. + pub fn read_directory(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read-directory"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + DirectoryEntryStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Write to a descriptor, without using and updating the descriptor's offset. - /// - /// It is valid to write past the end of a file; the file is extended to the - /// extent of the write, with bytes between the previous end and the start of - /// the write set to zero. - /// - /// In the future, this may change to take a `stream`. - /// - /// Note: This is similar to `pwrite` in POSIX. - pub fn write(&self,buffer: &[u8],offset: Filesize,) -> 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 = buffer; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, wit_bindgen::rt::as_i64(offset), ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 8) as *const i64); - - l3 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr1 + 8) as *const u8)); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read directory entries from a directory. - /// - /// On filesystems where directories contain entries referring to themselves - /// and their parents, often named `.` and `..` respectively, these entries - /// are omitted. - /// - /// This always returns a new stream which starts at the beginning of the - /// directory. Multiple streams may be active on the same directory, and they - /// do not interfere with each other. - pub fn read_directory(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read-directory"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - DirectoryEntryStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Synchronize the data and metadata of a file to disk. - /// - /// This function succeeds with no effect if the file descriptor is not - /// opened for writing. - /// - /// Note: This is similar to `fsync` in POSIX. - pub fn sync(&self,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.sync"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a directory. - /// - /// Note: This is similar to `mkdirat` in POSIX. - pub fn create_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.create-directory-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 1) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data and metadata of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fsync` in POSIX. + pub fn sync(&self) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.sync"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return the attributes of an open file or directory. - /// - /// Note: This is similar to `fstat` in POSIX, except that it does not return - /// device and inode information. For testing whether two descriptors refer to - /// the same underlying filesystem object, use `is-same-object`. To obtain - /// additional data that can be used do determine whether a file has been - /// modified, use `metadata-hash`. - /// - /// Note: This was called `fd_filestat_get` in earlier versions of WASI. - pub fn stat(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 104]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.stat"] - fn wit_import(_: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a directory. + /// + /// Note: This is similar to `mkdirat` in POSIX. + pub fn create_directory_at(&self, path: &str) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.create-directory-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - let l5 = i32::from(*((ptr0 + 32) as *const u8)); - let l8 = i32::from(*((ptr0 + 56) as *const u8)); - let l11 = i32::from(*((ptr0 + 80) as *const u8)); - - DescriptorStat{ - type_: DescriptorType::_lift(l2 as u8), - link_count: l3 as u64, - size: l4 as u64, - data_access_timestamp: match l5 { - 0 => None, - 1 => { - let e = { - let l6 = *((ptr0 + 40) as *const i64); - let l7 = *((ptr0 + 48) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of an open file or directory. + /// + /// Note: This is similar to `fstat` in POSIX, except that it does not return + /// device and inode information. For testing whether two descriptors refer to + /// the same underlying filesystem object, use `is-same-object`. To obtain + /// additional data that can be used do determine whether a file has been + /// modified, use `metadata-hash`. + /// + /// Note: This was called `fd_filestat_get` in earlier versions of WASI. + pub fn stat(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 104]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.stat"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + let l5 = i32::from(*ptr0.add(32).cast::()); + let l8 = i32::from(*ptr0.add(56).cast::()); + let l11 = i32::from(*ptr0.add(80).cast::()); + + DescriptorStat { + type_: DescriptorType::_lift(l2 as u8), + link_count: l3 as u64, + size: l4 as u64, + data_access_timestamp: match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0.add(40).cast::(); + let l7 = *ptr0.add(48).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l6 as u64, nanoseconds: l7 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l8 { - 0 => None, - 1 => { - let e = { - let l9 = *((ptr0 + 64) as *const i64); - let l10 = *((ptr0 + 72) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l8 { + 0 => None, + 1 => { + let e = { + let l9 = *ptr0.add(64).cast::(); + let l10 = *ptr0.add(72).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l9 as u64, nanoseconds: l10 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - status_change_timestamp: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *((ptr0 + 88) as *const i64); - let l13 = *((ptr0 + 96) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = *ptr0.add(88).cast::(); + let l13 = *ptr0.add(96).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l12 as u64, nanoseconds: l13 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - Ok(e) - } - 1 => { - let e = { - let l14 = i32::from(*((ptr0 + 8) as *const u8)); - - ErrorCode::_lift(l14 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return the attributes of a file or directory. - /// - /// Note: This is similar to `fstatat` in POSIX, except that it does not - /// return device and inode information. See the `stat` description for a - /// discussion of alternatives. - /// - /// Note: This was called `path_filestat_get` in earlier versions of WASI. - pub fn stat_at(&self,path_flags: PathFlags,path: &str,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 104]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.stat-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ); + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) + } + 1 => { + let e = { + let l14 = i32::from(*ptr0.add(8).cast::()); + + ErrorCode::_lift(l14 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = { - let l4 = i32::from(*((ptr2 + 8) as *const u8)); - let l5 = *((ptr2 + 16) as *const i64); - let l6 = *((ptr2 + 24) as *const i64); - let l7 = i32::from(*((ptr2 + 32) as *const u8)); - let l10 = i32::from(*((ptr2 + 56) as *const u8)); - let l13 = i32::from(*((ptr2 + 80) as *const u8)); - - DescriptorStat{ - type_: DescriptorType::_lift(l4 as u8), - link_count: l5 as u64, - size: l6 as u64, - data_access_timestamp: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = *((ptr2 + 40) as *const i64); - let l9 = *((ptr2 + 48) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of a file or directory. + /// + /// Note: This is similar to `fstatat` in POSIX, except that it does not + /// return device and inode information. See the `stat` description for a + /// discussion of alternatives. + /// + /// Note: This was called `path_filestat_get` in earlier versions of WASI. + pub fn stat_at( + &self, + path_flags: PathFlags, + path: &str, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 104]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.stat-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = i32::from(*ptr2.add(8).cast::()); + let l5 = *ptr2.add(16).cast::(); + let l6 = *ptr2.add(24).cast::(); + let l7 = i32::from(*ptr2.add(32).cast::()); + let l10 = i32::from(*ptr2.add(56).cast::()); + let l13 = i32::from(*ptr2.add(80).cast::()); + + DescriptorStat { + type_: DescriptorType::_lift(l4 as u8), + link_count: l5 as u64, + size: l6 as u64, + data_access_timestamp: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = *ptr2.add(40).cast::(); + let l9 = *ptr2.add(48).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l8 as u64, nanoseconds: l9 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = *((ptr2 + 64) as *const i64); - let l12 = *((ptr2 + 72) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = *ptr2.add(64).cast::(); + let l12 = *ptr2.add(72).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l11 as u64, nanoseconds: l12 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - status_change_timestamp: match l13 { - 0 => None, - 1 => { - let e = { - let l14 = *((ptr2 + 88) as *const i64); - let l15 = *((ptr2 + 96) as *const i32); - - super::super::super::wasi::clocks::wall_clock::Datetime{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l13 { + 0 => None, + 1 => { + let e = { + let l14 = *ptr2.add(88).cast::(); + let l15 = *ptr2.add(96).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ seconds: l14 as u64, nanoseconds: l15 as u32, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - Ok(e) - } - 1 => { - let e = { - let l16 = i32::from(*((ptr2 + 8) as *const u8)); - - ErrorCode::_lift(l16 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the timestamps of a file or directory. - /// - /// Note: This is similar to `utimensat` in POSIX. - /// - /// Note: This was called `path_filestat_set_times` in earlier versions of - /// WASI. - pub fn set_times_at(&self,path_flags: PathFlags,path: &str,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let (result3_0,result3_1,result3_2,) = match data_access_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; - - (2i32, wit_bindgen::rt::as_i64(seconds2), wit_bindgen::rt::as_i32(nanoseconds2)) - }, - }; - let (result5_0,result5_1,result5_2,) = match data_modification_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds4, nanoseconds:nanoseconds4, } = e; - - (2i32, wit_bindgen::rt::as_i64(seconds4), wit_bindgen::rt::as_i32(nanoseconds4)) - }, - }; - let ptr6 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-times-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1, len1, result3_0, result3_1, result3_2, result5_0, result5_1, result5_2, ptr6); - let l7 = i32::from(*((ptr6 + 0) as *const u8)); - match l7 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l8 = i32::from(*((ptr6 + 1) as *const u8)); - - ErrorCode::_lift(l8 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a hard link. - /// - /// Note: This is similar to `linkat` in POSIX. - pub fn link_at(&self,old_path_flags: PathFlags,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let flags0 = old_path_flags; - let vec1 = old_path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let vec2 = new_path; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let ptr3 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.link-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) + } + 1 => { + let e = { + let l16 = i32::from(*ptr2.add(8).cast::()); + + ErrorCode::_lift(l16 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1, len1, (new_descriptor).handle() as i32, ptr2, len2, ptr3); - let l4 = i32::from(*((ptr3 + 0) as *const u8)); - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr3 + 1) as *const u8)); - - ErrorCode::_lift(l5 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of a file or directory. + /// + /// Note: This is similar to `utimensat` in POSIX. + /// + /// Note: This was called `path_filestat_set_times` in earlier versions of + /// WASI. + pub fn set_times_at( + &self, + path_flags: PathFlags, + path: &str, + data_access_timestamp: NewTimestamp, + data_modification_timestamp: NewTimestamp, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let (result3_0, result3_1, result3_2) = match data_access_timestamp { + NewTimestamp::NoChange => (0i32, 0i64, 0i32), + NewTimestamp::Now => (1i32, 0i64, 0i32), + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds2, + nanoseconds: nanoseconds2, + } = e; + + (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) + } + }; + let (result5_0, result5_1, result5_2) = match data_modification_timestamp { + NewTimestamp::NoChange => (0i32, 0i64, 0i32), + NewTimestamp::Now => (1i32, 0i64, 0i32), + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds4, + nanoseconds: nanoseconds4, + } = e; + + (2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4)) + } + }; + let ptr6 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-times-at"] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: i64, + _: i32, + _: i32, + _: i64, + _: i32, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: i64, + _: i32, + _: i32, + _: i64, + _: i32, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + result3_0, + result3_1, + result3_2, + result5_0, + result5_1, + result5_2, + ptr6, + ); + let l7 = i32::from(*ptr6.add(0).cast::()); + match l7 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l8 = i32::from(*ptr6.add(1).cast::()); + + ErrorCode::_lift(l8 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Open a file or directory. - /// - /// The returned descriptor is not guaranteed to be the lowest-numbered - /// descriptor not currently open/ it is randomized to prevent applications - /// from depending on making assumptions about indexes, since this is - /// error-prone in multi-threaded contexts. The returned descriptor is - /// guaranteed to be less than 2**31. - /// - /// If `flags` contains `descriptor-flags::mutate-directory`, and the base - /// descriptor doesn't have `descriptor-flags::mutate-directory` set, - /// `open-at` fails with `error-code::read-only`. - /// - /// If `flags` contains `write` or `mutate-directory`, or `open-flags` - /// contains `truncate` or `create`, and the base descriptor doesn't have - /// `descriptor-flags::mutate-directory` set, `open-at` fails with - /// `error-code::read-only`. - /// - /// Note: This is similar to `openat` in POSIX. - pub fn open_at(&self,path_flags: PathFlags,path: &str,open_flags: OpenFlags,flags: DescriptorFlags,) -> 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 flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let flags2 = open_flags; - let flags3 = flags; - let ptr4 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.open-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a hard link. + /// + /// Note: This is similar to `linkat` in POSIX. + pub fn link_at( + &self, + old_path_flags: PathFlags, + old_path: &str, + new_descriptor: &Descriptor, + new_path: &str, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let flags0 = old_path_flags; + let vec1 = old_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = new_path; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.link-at"] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + (new_descriptor).handle() as i32, + ptr2.cast_mut(), + len2, + ptr3, + ); + let l4 = i32::from(*ptr3.add(0).cast::()); + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(1).cast::()); + + ErrorCode::_lift(l5 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1, len1, (flags2.bits() >> 0) as i32, (flags3.bits() >> 0) as i32, ptr4); - let l5 = i32::from(*((ptr4 + 0) as *const u8)); - match l5 { - 0 => { - let e = { - let l6 = *((ptr4 + 4) as *const i32); - - Descriptor::from_handle(l6 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*((ptr4 + 4) as *const u8)); - - ErrorCode::_lift(l7 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Open a file or directory. + /// + /// The returned descriptor is not guaranteed to be the lowest-numbered + /// descriptor not currently open/ it is randomized to prevent applications + /// from depending on making assumptions about indexes, since this is + /// error-prone in multi-threaded contexts. The returned descriptor is + /// guaranteed to be less than 2**31. + /// + /// If `flags` contains `descriptor-flags::mutate-directory`, and the base + /// descriptor doesn't have `descriptor-flags::mutate-directory` set, + /// `open-at` fails with `error-code::read-only`. + /// + /// If `flags` contains `write` or `mutate-directory`, or `open-flags` + /// contains `truncate` or `create`, and the base descriptor doesn't have + /// `descriptor-flags::mutate-directory` set, `open-at` fails with + /// `error-code::read-only`. + /// + /// Note: This is similar to `openat` in POSIX. + pub fn open_at( + &self, + path_flags: PathFlags, + path: &str, + open_flags: OpenFlags, + flags: DescriptorFlags, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let flags2 = open_flags; + let flags3 = flags; + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.open-at"] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: i32, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: i32, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + (flags2.bits() >> 0) as i32, + (flags3.bits() >> 0) as i32, + ptr4, + ); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::(); + + Descriptor::from_handle(l6 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr4.add(4).cast::()); + + ErrorCode::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read the contents of a symbolic link. - /// - /// If the contents contain an absolute or rooted path in the underlying - /// filesystem, this function fails with `error-code::not-permitted`. - /// - /// Note: This is similar to `readlinkat` in POSIX. - pub fn readlink_at(&self,path: &str,) -> Result{ - - #[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 vec0 = path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.readlink-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read the contents of a symbolic link. + /// + /// If the contents contain an absolute or rooted path in the underlying + /// filesystem, this function fails with `error-code::not-permitted`. + /// + /// Note: This is similar to `readlinkat` in POSIX. + pub fn readlink_at(&self, path: &str) -> Result<_rt::String, ErrorCode> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.readlink-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr1.add(4).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - let l4 = *((ptr1 + 8) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr1 + 4) as *const u8)); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Remove a directory. + /// + /// Return `error-code::not-empty` if the directory is not empty. + /// + /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. + pub fn remove_directory_at(&self, path: &str) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.remove-directory-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Remove a directory. - /// - /// Return `error-code::not-empty` if the directory is not empty. - /// - /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. - pub fn remove_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.remove-directory-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Rename a filesystem object. + /// + /// Note: This is similar to `renameat` in POSIX. + pub fn rename_at( + &self, + old_path: &str, + new_descriptor: &Descriptor, + new_path: &str, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = old_path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = new_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.rename-at"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + (new_descriptor).handle() as i32, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 1) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a symbolic link (also known as a "symlink"). + /// + /// If `old-path` starts with `/`, the function fails with + /// `error-code::not-permitted`. + /// + /// Note: This is similar to `symlinkat` in POSIX. + pub fn symlink_at(&self, old_path: &str, new_path: &str) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = old_path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = new_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.symlink-at"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Rename a filesystem object. - /// - /// Note: This is similar to `renameat` in POSIX. - pub fn rename_at(&self,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = old_path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = new_path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.rename-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Unlink a filesystem object that is not a directory. + /// + /// Return `error-code::is-directory` if the path refers to a directory. + /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. + pub fn unlink_file_at(&self, path: &str) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.unlink-file-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, (new_descriptor).handle() as i32, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr2 + 1) as *const u8)); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Test whether two descriptors refer to the same filesystem object. + /// + /// In POSIX, this corresponds to testing whether the two descriptors have the + /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. + /// wasi-filesystem does not expose device and inode numbers, so this function + /// may be used instead. + pub fn is_same_object(&self, other: &Descriptor) -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.is-same-object"] + fn wit_import(_: i32, _: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, (other).handle() as i32); + _rt::bool_lift(ret as u8) + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a symbolic link (also known as a "symlink"). - /// - /// If `old-path` starts with `/`, the function fails with - /// `error-code::not-permitted`. - /// - /// Note: This is similar to `symlinkat` in POSIX. - pub fn symlink_at(&self,old_path: &str,new_path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = old_path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec1 = new_path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.symlink-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a descriptor. + /// + /// This returns a hash of the last-modification timestamp and file size, and + /// may also include the inode number, device number, birth timestamp, and + /// other metadata fields that may change when the file is modified or + /// replaced. It may also include a secret value chosen by the + /// implementation and not otherwise exposed. + /// + /// Implementations are encourated to provide the following properties: + /// + /// - If the file is not modified or replaced, the computed hash value should + /// usually not change. + /// - If the object is modified or replaced, the computed hash value should + /// usually change. + /// - The inputs to the hash should not be easily computable from the + /// computed hash. + /// + /// However, none of these is required. + pub fn metadata_hash(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.metadata-hash"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + + MetadataHashValue { + lower: l2 as u64, + upper: l3 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr0.add(8).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr2 + 1) as *const u8)); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a directory descriptor and a relative path. + /// + /// This performs the same hash computation as `metadata-hash`. + pub fn metadata_hash_at( + &self, + path_flags: PathFlags, + path: &str, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.metadata-hash-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (flags0.bits() >> 0) as i32, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(8).cast::(); + let l5 = *ptr2.add(16).cast::(); + + MetadataHashValue { + lower: l4 as u64, + upper: l5 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr2.add(8).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Unlink a filesystem object that is not a directory. - /// - /// Return `error-code::is-directory` if the path refers to a directory. - /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. - pub fn unlink_file_at(&self,path: &str,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = path; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.unlink-file-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + impl DirectoryEntryStream { + #[allow(unused_unsafe, clippy::all)] + /// Read a single directory entry from a `directory-entry-stream`. + pub fn read_directory_entry(&self) -> Result, ErrorCode> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 20]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 20]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]directory-entry-stream.read-directory-entry"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let l4 = *ptr0.add(12).cast::<*mut u8>(); + let l5 = *ptr0.add(16).cast::(); + let len6 = l5; + let bytes6 = + _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + DirectoryEntry { + type_: DescriptorType::_lift(l3 as u8), + name: _rt::string_lift(bytes6), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 1) as *const u8)); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + #[allow(unused_unsafe, clippy::all)] + /// Attempts to extract a filesystem-related `error-code` from the stream + /// `error` provided. + /// + /// Stream operations which return `stream-error::last-operation-failed` + /// have a payload with more information about the operation that failed. + /// This payload can be passed through to this function to see if there's + /// filesystem-related information about the error to return. + /// + /// Note that this function is fallible because not all stream-related + /// errors are filesystem-related errors. + pub fn filesystem_error_code(err: &Error) -> Option { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "filesystem-error-code"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((err).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } } - } } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Test whether two descriptors refer to the same filesystem object. - /// - /// In POSIX, this corresponds to testing whether the two descriptors have the - /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. - /// wasi-filesystem does not expose device and inode numbers, so this function - /// may be used instead. - pub fn is_same_object(&self,other: &Descriptor,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(dead_code, clippy::all)] + pub mod preopens { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.is-same-object"] - fn wit_import(_: i32, _: i32, ) -> i32; + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; + #[allow(unused_unsafe, clippy::all)] + /// Return the set of preopened directories, and their path. + pub fn get_directories() -> _rt::Vec<(Descriptor, _rt::String)> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0")] + extern "C" { + #[link_name = "get-directories"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base7 = l1; + let len7 = l2; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 12); + let e7 = { + let l3 = *base.add(0).cast::(); + let l4 = *base.add(4).cast::<*mut u8>(); + let l5 = *base.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + (super::super::super::wasi::filesystem::types::Descriptor::from_handle(l3 as u32), _rt::string_lift(bytes6)) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 12, 4); + result7 + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, (other).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a hash of the metadata associated with a filesystem object referred - /// to by a descriptor. - /// - /// This returns a hash of the last-modification timestamp and file size, and - /// may also include the inode number, device number, birth timestamp, and - /// other metadata fields that may change when the file is modified or - /// replaced. It may also include a secret value chosen by the - /// implementation and not otherwise exposed. - /// - /// Implementations are encourated to provide the following properties: - /// - /// - If the file is not modified or replaced, the computed hash value should - /// usually not change. - /// - If the object is modified or replaced, the computed hash value should - /// usually change. - /// - The inputs to the hash should not be easily computable from the - /// computed hash. - /// - /// However, none of these is required. - pub fn metadata_hash(&self,) -> Result{ - - #[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; + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.metadata-hash"] - fn wit_import(_: i32, _: i32, ); + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - - MetadataHashValue{ - lower: l2 as u64, - upper: l3 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr0 + 8) as *const u8)); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a hash of the metadata associated with a filesystem object referred - /// to by a directory descriptor and a relative path. - /// - /// This performs the same hash computation as `metadata-hash`. - pub fn metadata_hash_at(&self,path_flags: PathFlags,path: &str,) -> Result{ - - #[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 flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.metadata-hash-at"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ); + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = { - let l4 = *((ptr2 + 8) as *const i64); - let l5 = *((ptr2 + 16) as *const i64); - - MetadataHashValue{ - lower: l4 as u64, - upper: l5 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr2 + 8) as *const u8)); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } } - } } - } - impl DirectoryEntryStream { - #[allow(unused_unsafe, clippy::all)] - /// Read a single directory entry from a `directory-entry-stream`. - pub fn read_directory_entry(&self,) -> Result,ErrorCode>{ - - #[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; + + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]directory-entry-stream.read-directory-entry"] - fn wit_import(_: i32, _: i32, ); + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - - match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let l4 = *((ptr0 + 12) as *const i32); - let l5 = *((ptr0 + 16) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - DirectoryEntry{ - type_: DescriptorType::_lift(l3 as u8), - name: wit_bindgen::rt::string_lift(bytes6), - } - }; - Some(e) + + impl Pollable { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*((ptr0 + 4) as *const u8)); - - ErrorCode::_lift(l7 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Attempts to extract a filesystem-related `error-code` from the stream - /// `error` provided. - /// - /// Stream operations which return `stream-error::last-operation-failed` - /// have a payload with more information about the operation that failed. - /// This payload can be passed through to this function to see if there's - /// filesystem-related information about the error to return. - /// - /// Note that this function is fallible because not all stream-related - /// errors are filesystem-related errors. - pub fn filesystem_error_code(err: &Error,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "filesystem-error-code"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((err).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 1) as *const u8)); - - ErrorCode::_lift(l2 as u8) - }; - Some(e) + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - - } - - - #[allow(clippy::all)] - pub mod preopens { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; - #[allow(unused_unsafe, clippy::all)] - /// Return the set of preopened directories, and their path. - pub fn get_directories() -> wit_bindgen::rt::vec::Vec::<(Descriptor,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0")] - extern "C" { - #[link_name = "get-directories"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base7 = l1; - let len7 = l2; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 12; - let e7 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let l5 = *((base + 8) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - (super::super::super::wasi::filesystem::types::Descriptor::from_handle(l3 as u32), wit_bindgen::rt::string_lift(bytes6)) - }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 12, 4); - result7 - } - } - - } - - } - pub mod io { - - #[allow(clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import(_: i32, _: i32, ); + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } - } - } - - } - - - #[allow(clippy::all)] - pub mod poll { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = in_; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec0.into_iter().enumerate() { + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } + } + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + if layout0.size() != 0 { + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(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 len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => f + .debug_tuple("StreamError::LastOperationFailed") + .field(e) + .finish(), + StreamError::Closed => f.debug_tuple("StreamError::Closed").finish(), + } + } } - } - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - if layout0.size() != 0 { - alloc::dealloc(result0, layout0); - } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } - } - - } - - - #[allow(clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An error for input-stream and output-stream operations. - pub enum StreamError{ - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() + impl ::core::fmt::Display for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").finish() + + impl std::error::Error for StreamError {} + /// An input bytestream. + /// + /// `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` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream { + handle: _rt::Resource, } - } - } - } - 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 input bytestream. - /// - /// `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` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl InputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for InputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); + + impl InputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `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` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl OutputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for InputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: i32, ); + + /// An output bytestream. + /// + /// `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` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream { + handle: _rt::Resource, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + + impl OutputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: i32, ); + + unsafe impl _rt::WasmResource for OutputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: i32, ); + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + } + } + impl InputStream { + #[allow(unused_unsafe, 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. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: i32, ); + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } } - } - } - } - impl InputStream { - #[allow(unused_unsafe, 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. - /// The created `pollable` is a child resource of the `input-stream`. - /// Implementations may trap if the `input-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - fn wit_import(_: i32, _: i32, ); + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self, src: &InputStream, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice( + &self, + src: &InputStream, + len: u64, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } } - } } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type Datetime = super::super::super::super::wasi::clocks::wall_clock::Datetime; + pub type MetadataHashValue = + super::super::super::super::wasi::filesystem::types::MetadataHashValue; + #[repr(C)] + #[derive(Clone, Copy)] + pub struct FileInfo { + pub last_modified: Datetime, + pub last_accessed: Datetime, } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + impl ::core::fmt::Debug for FileInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FileInfo") + .field("last-modified", &self.last_modified) + .field("last-accessed", &self.last_accessed) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_read_file_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::read_file(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(8).cast::() = len4; + *ptr2.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } }; - - v5 - }; - Err(e) + ptr2 } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_read_file(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + _ => { + let l3 = *arg0.add(4).cast::<*mut u8>(); + let l4 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + } + } } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_write_file_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::write_file(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Ok(_) => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } }; - - v4 - }; - Err(e) + ptr3 } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_write_file(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_write_file_direct_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = + T::write_file_direct(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Ok(_) => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } }; - - v4 - }; - Err(e) + ptr3 } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_write_file_direct(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_delete_file_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::delete_file(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } }; - - v4 - }; - Err(e) + ptr2 } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: i32, ); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_delete_file(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_file_info_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::get_file_info(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + let FileInfo { + last_modified: last_modified3, + last_accessed: last_accessed3, + } = e; + let super::super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds4, + nanoseconds: nanoseconds4, + } = last_modified3; + *ptr2.add(8).cast::() = _rt::as_i64(seconds4); + *ptr2.add(16).cast::() = _rt::as_i32(nanoseconds4); + let super::super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds5, + nanoseconds: nanoseconds5, + } = last_accessed3; + *ptr2.add(24).cast::() = _rt::as_i64(seconds5); + *ptr2.add(32).cast::() = _rt::as_i32(nanoseconds5); + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec6 = (e.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *ptr2.add(12).cast::() = len6; + *ptr2.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + ptr2 } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_file_info(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(8).cast::<*mut u8>(); + let l2 = *arg0.add(12).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_info_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::get_info(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + let FileInfo { + last_modified: last_modified3, + last_accessed: last_accessed3, + } = e; + let super::super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds4, + nanoseconds: nanoseconds4, + } = last_modified3; + *ptr2.add(8).cast::() = _rt::as_i64(seconds4); + *ptr2.add(16).cast::() = _rt::as_i32(nanoseconds4); + let super::super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: seconds5, + nanoseconds: nanoseconds5, + } = last_accessed3; + *ptr2.add(24).cast::() = _rt::as_i64(seconds5); + *ptr2.add(32).cast::() = _rt::as_i32(nanoseconds5); + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec6 = (e.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *ptr2.add(12).cast::() = len6; + *ptr2.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + ptr2 } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_info(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(8).cast::<*mut u8>(); + let l2 = *arg0.add(12).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_directory_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::create_directory(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + ptr2 } - } - } - } - - } - - } - } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type Datetime = super::super::super::super::wasi::clocks::wall_clock::Datetime; - pub type MetadataHashValue = super::super::super::super::wasi::filesystem::types::MetadataHashValue; - #[repr(C)] - #[derive(Clone, Copy)] - pub struct FileInfo { - pub last_modified: Datetime, - pub last_accessed: Datetime, - } - impl ::core::fmt::Debug for FileInfo { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FileInfo").field("last-modified", &self.last_modified).field("last-accessed", &self.last_accessed).finish() - } - } - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#read-file"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_read_file(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::read_file(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(e) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr2 + 8) as *mut i32) = len4; - *((ptr2 + 4) as *mut i32) = ptr4; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#read-file"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_read_file(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - _ => { - let l3 = *((arg0 + 4) as *const i32); - let l4 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l3, (l4) as usize, 1); - }, - } + pub unsafe fn __post_return_create_directory(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#write-file"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_write_file(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::write_file(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#write-file"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_write_file(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_create_link_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = + T::create_link(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Ok(_) => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + }; + ptr3 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#write-file-direct"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_write_file_direct(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::write_file_direct(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#write-file-direct"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_write_file_direct(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_create_link(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#delete-file"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_delete_file(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::delete_file(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#delete-file"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_delete_file(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_create_sym_link_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = + T::create_sym_link(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Ok(_) => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + }; + ptr3 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-file-info"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_file_info(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::get_file_info(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(e) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - let FileInfo{ last_modified:last_modified3, last_accessed:last_accessed3, } = e; - let super::super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds4, nanoseconds:nanoseconds4, } = last_modified3; - *((ptr2 + 8) as *mut i64) = wit_bindgen::rt::as_i64(seconds4); - *((ptr2 + 16) as *mut i32) = wit_bindgen::rt::as_i32(nanoseconds4); - let super::super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds5, nanoseconds:nanoseconds5, } = last_accessed3; - *((ptr2 + 24) as *mut i64) = wit_bindgen::rt::as_i64(seconds5); - *((ptr2 + 32) as *mut i32) = wit_bindgen::rt::as_i32(nanoseconds5); - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec6 = (e.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - ::core::mem::forget(vec6); - *((ptr2 + 12) as *mut i32) = len6; - *((ptr2 + 8) as *mut i32) = ptr6; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-file-info"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_file_info(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 8) as *const i32); - let l2 = *((arg0 + 12) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_create_sym_link(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-info"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_info(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::get_info(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(e) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - let FileInfo{ last_modified:last_modified3, last_accessed:last_accessed3, } = e; - let super::super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds4, nanoseconds:nanoseconds4, } = last_modified3; - *((ptr2 + 8) as *mut i64) = wit_bindgen::rt::as_i64(seconds4); - *((ptr2 + 16) as *mut i32) = wit_bindgen::rt::as_i32(nanoseconds4); - let super::super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds5, nanoseconds:nanoseconds5, } = last_accessed3; - *((ptr2 + 24) as *mut i64) = wit_bindgen::rt::as_i64(seconds5); - *((ptr2 + 32) as *mut i32) = wit_bindgen::rt::as_i32(nanoseconds5); - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec6 = (e.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - ::core::mem::forget(vec6); - *((ptr2 + 12) as *mut i32) = len6; - *((ptr2 + 8) as *mut i32) = ptr6; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-info"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_info(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 8) as *const i32); - let l2 = *((arg0 + 12) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_remove_directory_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::remove_directory(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#create-directory"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_directory(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::create_directory(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#create-directory"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_directory(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_remove_directory(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#create-link"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_link(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::create_link(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#create-link"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_link(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_remove_file_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::remove_file(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#create-sym-link"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_sym_link(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::create_sym_link(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#create-sym-link"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_sym_link(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_remove_file(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#remove-directory"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_remove_directory(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::remove_directory(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#remove-directory"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_remove_directory(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_rename_file_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = + T::rename_file(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Ok(_) => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + }; + ptr3 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#remove-file"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_remove_file(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::remove_file(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#remove-file"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_remove_file(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_rename_file(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#rename-file"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_rename_file(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::rename_file(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Ok(_) => { { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - } }, - };ptr3 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#rename-file"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_rename_file(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn _export_hash_cabi(arg0: *mut u8, arg1: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::hash(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + let super::super::super::super::wasi::filesystem::types::MetadataHashValue{ lower:lower3, upper:upper3, } = e; + *ptr2.add(8).cast::() = _rt::as_i64(lower3); + *ptr2.add(16).cast::() = _rt::as_i64(upper3); + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(12).cast::() = len4; + *ptr2.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + } + }; + ptr2 } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#hash"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_hash(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::hash(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(e) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - let super::super::super::super::wasi::filesystem::types::MetadataHashValue{ lower:lower3, upper:upper3, } = e; - *((ptr2 + 8) as *mut i64) = wit_bindgen::rt::as_i64(lower3); - *((ptr2 + 16) as *mut i64) = wit_bindgen::rt::as_i64(upper3); - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr2 + 12) as *mut i32) = len4; - *((ptr2 + 8) as *mut i32) = ptr4; - } }, - };ptr2 - } - - const _: () = { #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#hash"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_hash(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 8) as *const i32); - let l2 = *((arg0 + 12) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + pub unsafe fn __post_return_hash(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(8).cast::<*mut u8>(); + let l2 = *arg0.add(12).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn read_file(path: wit_bindgen::rt::string::String,) -> Result; - fn write_file(path: wit_bindgen::rt::string::String,contents: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn write_file_direct(path: wit_bindgen::rt::string::String,contents: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn delete_file(path: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn get_file_info(path: wit_bindgen::rt::string::String,) -> Result; - fn get_info(path: wit_bindgen::rt::string::String,) -> Result; - fn create_directory(path: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn create_link(source: wit_bindgen::rt::string::String,destination: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn create_sym_link(source: wit_bindgen::rt::string::String,destination: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn remove_directory(path: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn remove_file(path: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn rename_file(source: wit_bindgen::rt::string::String,destination: wit_bindgen::rt::string::String,) -> Result<(),wit_bindgen::rt::string::String>; - fn hash(path: wit_bindgen::rt::string::String,) -> Result; + pub trait Guest { + fn read_file(path: _rt::String) -> Result<_rt::String, _rt::String>; + fn write_file( + path: _rt::String, + contents: _rt::String, + ) -> Result<(), _rt::String>; + fn write_file_direct( + path: _rt::String, + contents: _rt::String, + ) -> Result<(), _rt::String>; + fn delete_file(path: _rt::String) -> Result<(), _rt::String>; + fn get_file_info(path: _rt::String) -> Result; + fn get_info(path: _rt::String) -> Result; + fn create_directory(path: _rt::String) -> Result<(), _rt::String>; + fn create_link( + source: _rt::String, + destination: _rt::String, + ) -> Result<(), _rt::String>; + fn create_sym_link( + source: _rt::String, + destination: _rt::String, + ) -> Result<(), _rt::String>; + fn remove_directory(path: _rt::String) -> Result<(), _rt::String>; + fn remove_file(path: _rt::String) -> Result<(), _rt::String>; + fn rename_file( + source: _rt::String, + destination: _rt::String, + ) -> Result<(), _rt::String>; + fn hash(path: _rt::String) -> Result; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#read-file"] + unsafe extern "C" fn export_read_file(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_read_file_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#read-file"] + unsafe extern "C" fn _post_return_read_file(arg0: *mut u8,) { + $($path_to_types)*::__post_return_read_file::<$ty>(arg0) + } + #[export_name = "golem:it/api#write-file"] + unsafe extern "C" fn export_write_file(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_write_file_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#write-file"] + unsafe extern "C" fn _post_return_write_file(arg0: *mut u8,) { + $($path_to_types)*::__post_return_write_file::<$ty>(arg0) + } + #[export_name = "golem:it/api#write-file-direct"] + unsafe extern "C" fn export_write_file_direct(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_write_file_direct_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#write-file-direct"] + unsafe extern "C" fn _post_return_write_file_direct(arg0: *mut u8,) { + $($path_to_types)*::__post_return_write_file_direct::<$ty>(arg0) + } + #[export_name = "golem:it/api#delete-file"] + unsafe extern "C" fn export_delete_file(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_delete_file_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#delete-file"] + unsafe extern "C" fn _post_return_delete_file(arg0: *mut u8,) { + $($path_to_types)*::__post_return_delete_file::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-file-info"] + unsafe extern "C" fn export_get_file_info(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_file_info_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#get-file-info"] + unsafe extern "C" fn _post_return_get_file_info(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_file_info::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-info"] + unsafe extern "C" fn export_get_info(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_info_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#get-info"] + unsafe extern "C" fn _post_return_get_info(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_info::<$ty>(arg0) + } + #[export_name = "golem:it/api#create-directory"] + unsafe extern "C" fn export_create_directory(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_create_directory_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#create-directory"] + unsafe extern "C" fn _post_return_create_directory(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_directory::<$ty>(arg0) + } + #[export_name = "golem:it/api#create-link"] + unsafe extern "C" fn export_create_link(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_create_link_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#create-link"] + unsafe extern "C" fn _post_return_create_link(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_link::<$ty>(arg0) + } + #[export_name = "golem:it/api#create-sym-link"] + unsafe extern "C" fn export_create_sym_link(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_create_sym_link_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#create-sym-link"] + unsafe extern "C" fn _post_return_create_sym_link(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_sym_link::<$ty>(arg0) + } + #[export_name = "golem:it/api#remove-directory"] + unsafe extern "C" fn export_remove_directory(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_remove_directory_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#remove-directory"] + unsafe extern "C" fn _post_return_remove_directory(arg0: *mut u8,) { + $($path_to_types)*::__post_return_remove_directory::<$ty>(arg0) + } + #[export_name = "golem:it/api#remove-file"] + unsafe extern "C" fn export_remove_file(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_remove_file_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#remove-file"] + unsafe extern "C" fn _post_return_remove_file(arg0: *mut u8,) { + $($path_to_types)*::__post_return_remove_file::<$ty>(arg0) + } + #[export_name = "golem:it/api#rename-file"] + unsafe extern "C" fn export_rename_file(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_rename_file_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#rename-file"] + unsafe extern "C" fn _post_return_rename_file(arg0: *mut u8,) { + $($path_to_types)*::__post_return_rename_file::<$ty>(arg0) + } + #[export_name = "golem:it/api#hash"] + unsafe extern "C" fn export_hash(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_hash_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#hash"] + unsafe extern "C" fn _post_return_hash(arg0: *mut u8,) { + $($path_to_types)*::__post_return_hash::<$ty>(arg0) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(8))] + struct _RetArea([::core::mem::MaybeUninit; 40]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 40]); } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(8))] - struct _RetArea([u8; 40]); - static mut _RET_AREA: _RetArea = _RetArea([0; 40]); - - } - } - } } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:file-service"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 7303] = [3, 0, 12, 102, 105, 108, 101, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 217, 16, 1, 65, 19, 1, 66, 2, 1, 114, 2, 7, 115, 101, 99, 111, 110, 100, 115, 119, 11, 110, 97, 110, 111, 115, 101, 99, 111, 110, 100, 115, 121, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 0, 3, 1, 28, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 119, 97, 108, 108, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 1, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 1, 1, 66, 1, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 2, 2, 3, 0, 1, 5, 101, 114, 114, 111, 114, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 9, 2, 3, 2, 1, 3, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 4, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 5, 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, 2, 3, 0, 3, 5, 101, 114, 114, 111, 114, 2, 3, 0, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 1, 66, 35, 2, 3, 2, 1, 6, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 0, 2, 3, 2, 1, 7, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 8, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 4, 2, 3, 2, 1, 9, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 6, 1, 119, 4, 0, 8, 102, 105, 108, 101, 115, 105, 122, 101, 3, 0, 8, 1, 109, 8, 7, 117, 110, 107, 110, 111, 119, 110, 12, 98, 108, 111, 99, 107, 45, 100, 101, 118, 105, 99, 101, 16, 99, 104, 97, 114, 97, 99, 116, 101, 114, 45, 100, 101, 118, 105, 99, 101, 9, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 102, 105, 102, 111, 13, 115, 121, 109, 98, 111, 108, 105, 99, 45, 108, 105, 110, 107, 12, 114, 101, 103, 117, 108, 97, 114, 45, 102, 105, 108, 101, 6, 115, 111, 99, 107, 101, 116, 4, 0, 15, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 116, 121, 112, 101, 3, 0, 10, 1, 110, 6, 4, 114, 101, 97, 100, 5, 119, 114, 105, 116, 101, 19, 102, 105, 108, 101, 45, 105, 110, 116, 101, 103, 114, 105, 116, 121, 45, 115, 121, 110, 99, 19, 100, 97, 116, 97, 45, 105, 110, 116, 101, 103, 114, 105, 116, 121, 45, 115, 121, 110, 99, 20, 114, 101, 113, 117, 101, 115, 116, 101, 100, 45, 119, 114, 105, 116, 101, 45, 115, 121, 110, 99, 16, 109, 117, 116, 97, 116, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 0, 16, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 102, 108, 97, 103, 115, 3, 0, 12, 1, 110, 1, 14, 115, 121, 109, 108, 105, 110, 107, 45, 102, 111, 108, 108, 111, 119, 4, 0, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 3, 0, 14, 1, 110, 4, 6, 99, 114, 101, 97, 116, 101, 9, 100, 105, 114, 101, 99, 116, 111, 114, 121, 9, 101, 120, 99, 108, 117, 115, 105, 118, 101, 8, 116, 114, 117, 110, 99, 97, 116, 101, 4, 0, 10, 111, 112, 101, 110, 45, 102, 108, 97, 103, 115, 3, 0, 16, 1, 119, 4, 0, 10, 108, 105, 110, 107, 45, 99, 111, 117, 110, 116, 3, 0, 18, 1, 107, 7, 1, 114, 6, 4, 116, 121, 112, 101, 11, 10, 108, 105, 110, 107, 45, 99, 111, 117, 110, 116, 19, 4, 115, 105, 122, 101, 9, 21, 100, 97, 116, 97, 45, 97, 99, 99, 101, 115, 115, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 27, 100, 97, 116, 97, 45, 109, 111, 100, 105, 102, 105, 99, 97, 116, 105, 111, 110, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 23, 115, 116, 97, 116, 117, 115, 45, 99, 104, 97, 110, 103, 101, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 4, 0, 15, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 115, 116, 97, 116, 3, 0, 21, 1, 113, 3, 9, 110, 111, 45, 99, 104, 97, 110, 103, 101, 0, 0, 3, 110, 111, 119, 0, 0, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 1, 7, 0, 4, 0, 13, 110, 101, 119, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 3, 0, 23, 1, 114, 2, 4, 116, 121, 112, 101, 11, 4, 110, 97, 109, 101, 115, 4, 0, 15, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 3, 0, 25, 1, 109, 37, 6, 97, 99, 99, 101, 115, 115, 11, 119, 111, 117, 108, 100, 45, 98, 108, 111, 99, 107, 7, 97, 108, 114, 101, 97, 100, 121, 14, 98, 97, 100, 45, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 4, 98, 117, 115, 121, 8, 100, 101, 97, 100, 108, 111, 99, 107, 5, 113, 117, 111, 116, 97, 5, 101, 120, 105, 115, 116, 14, 102, 105, 108, 101, 45, 116, 111, 111, 45, 108, 97, 114, 103, 101, 21, 105, 108, 108, 101, 103, 97, 108, 45, 98, 121, 116, 101, 45, 115, 101, 113, 117, 101, 110, 99, 101, 11, 105, 110, 45, 112, 114, 111, 103, 114, 101, 115, 115, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 7, 105, 110, 118, 97, 108, 105, 100, 2, 105, 111, 12, 105, 115, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 108, 111, 111, 112, 14, 116, 111, 111, 45, 109, 97, 110, 121, 45, 108, 105, 110, 107, 115, 12, 109, 101, 115, 115, 97, 103, 101, 45, 115, 105, 122, 101, 13, 110, 97, 109, 101, 45, 116, 111, 111, 45, 108, 111, 110, 103, 9, 110, 111, 45, 100, 101, 118, 105, 99, 101, 8, 110, 111, 45, 101, 110, 116, 114, 121, 7, 110, 111, 45, 108, 111, 99, 107, 19, 105, 110, 115, 117, 102, 102, 105, 99, 105, 101, 110, 116, 45, 109, 101, 109, 111, 114, 121, 18, 105, 110, 115, 117, 102, 102, 105, 99, 105, 101, 110, 116, 45, 115, 112, 97, 99, 101, 13, 110, 111, 116, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 9, 110, 111, 116, 45, 101, 109, 112, 116, 121, 15, 110, 111, 116, 45, 114, 101, 99, 111, 118, 101, 114, 97, 98, 108, 101, 11, 117, 110, 115, 117, 112, 112, 111, 114, 116, 101, 100, 6, 110, 111, 45, 116, 116, 121, 14, 110, 111, 45, 115, 117, 99, 104, 45, 100, 101, 118, 105, 99, 101, 8, 111, 118, 101, 114, 102, 108, 111, 119, 13, 110, 111, 116, 45, 112, 101, 114, 109, 105, 116, 116, 101, 100, 4, 112, 105, 112, 101, 9, 114, 101, 97, 100, 45, 111, 110, 108, 121, 12, 105, 110, 118, 97, 108, 105, 100, 45, 115, 101, 101, 107, 14, 116, 101, 120, 116, 45, 102, 105, 108, 101, 45, 98, 117, 115, 121, 12, 99, 114, 111, 115, 115, 45, 100, 101, 118, 105, 99, 101, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 27, 1, 109, 6, 6, 110, 111, 114, 109, 97, 108, 10, 115, 101, 113, 117, 101, 110, 116, 105, 97, 108, 6, 114, 97, 110, 100, 111, 109, 9, 119, 105, 108, 108, 45, 110, 101, 101, 100, 9, 100, 111, 110, 116, 45, 110, 101, 101, 100, 8, 110, 111, 45, 114, 101, 117, 115, 101, 4, 0, 6, 97, 100, 118, 105, 99, 101, 3, 0, 29, 1, 114, 2, 5, 108, 111, 119, 101, 114, 119, 5, 117, 112, 112, 101, 114, 119, 4, 0, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 3, 0, 31, 4, 0, 10, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 3, 1, 4, 0, 22, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 45, 115, 116, 114, 101, 97, 109, 3, 1, 3, 1, 27, 119, 97, 115, 105, 58, 102, 105, 108, 101, 115, 121, 115, 116, 101, 109, 47, 116, 121, 112, 101, 115, 64, 48, 46, 50, 46, 48, 5, 10, 2, 3, 0, 4, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 1, 66, 29, 2, 3, 2, 1, 9, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 0, 2, 3, 2, 1, 11, 4, 0, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 3, 0, 2, 1, 114, 2, 13, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 1, 13, 108, 97, 115, 116, 45, 97, 99, 99, 101, 115, 115, 101, 100, 1, 4, 0, 9, 102, 105, 108, 101, 45, 105, 110, 102, 111, 3, 0, 4, 1, 106, 1, 115, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 6, 4, 0, 9, 114, 101, 97, 100, 45, 102, 105, 108, 101, 1, 7, 1, 106, 0, 1, 115, 1, 64, 2, 4, 112, 97, 116, 104, 115, 8, 99, 111, 110, 116, 101, 110, 116, 115, 115, 0, 8, 4, 0, 10, 119, 114, 105, 116, 101, 45, 102, 105, 108, 101, 1, 9, 4, 0, 17, 119, 114, 105, 116, 101, 45, 102, 105, 108, 101, 45, 100, 105, 114, 101, 99, 116, 1, 9, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 8, 4, 0, 11, 100, 101, 108, 101, 116, 101, 45, 102, 105, 108, 101, 1, 10, 1, 106, 1, 5, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 11, 4, 0, 13, 103, 101, 116, 45, 102, 105, 108, 101, 45, 105, 110, 102, 111, 1, 12, 4, 0, 8, 103, 101, 116, 45, 105, 110, 102, 111, 1, 12, 4, 0, 16, 99, 114, 101, 97, 116, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 1, 10, 1, 64, 2, 6, 115, 111, 117, 114, 99, 101, 115, 11, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 115, 0, 8, 4, 0, 11, 99, 114, 101, 97, 116, 101, 45, 108, 105, 110, 107, 1, 13, 4, 0, 15, 99, 114, 101, 97, 116, 101, 45, 115, 121, 109, 45, 108, 105, 110, 107, 1, 13, 4, 0, 16, 114, 101, 109, 111, 118, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 1, 10, 4, 0, 11, 114, 101, 109, 111, 118, 101, 45, 102, 105, 108, 101, 1, 10, 4, 0, 11, 114, 101, 110, 97, 109, 101, 45, 102, 105, 108, 101, 1, 13, 1, 106, 1, 3, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 14, 4, 0, 4, 104, 97, 115, 104, 1, 15, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 12, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 152, 39, 1, 65, 2, 1, 65, 22, 1, 66, 5, 1, 114, 2, 7, 115, 101, 99, 111, 110, 100, 115, 119, 11, 110, 97, 110, 111, 115, 101, 99, 111, 110, 100, 115, 121, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 0, 1, 64, 0, 0, 1, 4, 0, 3, 110, 111, 119, 1, 2, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 2, 3, 1, 28, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 119, 97, 108, 108, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 111, 45, 100, 101, 98, 117, 103, 45, 115, 116, 114, 105, 110, 103, 1, 2, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 1, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 2, 2, 3, 0, 1, 5, 101, 114, 114, 111, 114, 2, 3, 0, 2, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 40, 2, 3, 2, 1, 3, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 4, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 7, 1, 112, 125, 1, 106, 1, 10, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 11, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 1, 12, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 114, 101, 97, 100, 1, 12, 1, 106, 1, 119, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 107, 105, 112, 1, 14, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 107, 105, 112, 1, 14, 1, 105, 3, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 15, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 16, 1, 104, 8, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 13, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 99, 104, 101, 99, 107, 45, 119, 114, 105, 116, 101, 1, 18, 1, 106, 0, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 17, 8, 99, 111, 110, 116, 101, 110, 116, 115, 10, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 1, 20, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 20, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 102, 108, 117, 115, 104, 1, 21, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 102, 108, 117, 115, 104, 1, 21, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 15, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 22, 1, 64, 2, 4, 115, 101, 108, 102, 17, 3, 108, 101, 110, 119, 0, 19, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 1, 23, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 23, 1, 64, 3, 4, 115, 101, 108, 102, 17, 3, 115, 114, 99, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 112, 108, 105, 99, 101, 1, 24, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 112, 108, 105, 99, 101, 1, 24, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 5, 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, 2, 3, 0, 3, 5, 101, 114, 114, 111, 114, 2, 3, 0, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 1, 66, 114, 2, 3, 2, 1, 6, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 0, 2, 3, 2, 1, 7, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 8, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 4, 2, 3, 2, 1, 9, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 6, 1, 119, 4, 0, 8, 102, 105, 108, 101, 115, 105, 122, 101, 3, 0, 8, 1, 109, 8, 7, 117, 110, 107, 110, 111, 119, 110, 12, 98, 108, 111, 99, 107, 45, 100, 101, 118, 105, 99, 101, 16, 99, 104, 97, 114, 97, 99, 116, 101, 114, 45, 100, 101, 118, 105, 99, 101, 9, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 102, 105, 102, 111, 13, 115, 121, 109, 98, 111, 108, 105, 99, 45, 108, 105, 110, 107, 12, 114, 101, 103, 117, 108, 97, 114, 45, 102, 105, 108, 101, 6, 115, 111, 99, 107, 101, 116, 4, 0, 15, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 116, 121, 112, 101, 3, 0, 10, 1, 110, 6, 4, 114, 101, 97, 100, 5, 119, 114, 105, 116, 101, 19, 102, 105, 108, 101, 45, 105, 110, 116, 101, 103, 114, 105, 116, 121, 45, 115, 121, 110, 99, 19, 100, 97, 116, 97, 45, 105, 110, 116, 101, 103, 114, 105, 116, 121, 45, 115, 121, 110, 99, 20, 114, 101, 113, 117, 101, 115, 116, 101, 100, 45, 119, 114, 105, 116, 101, 45, 115, 121, 110, 99, 16, 109, 117, 116, 97, 116, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 0, 16, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 102, 108, 97, 103, 115, 3, 0, 12, 1, 110, 1, 14, 115, 121, 109, 108, 105, 110, 107, 45, 102, 111, 108, 108, 111, 119, 4, 0, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 3, 0, 14, 1, 110, 4, 6, 99, 114, 101, 97, 116, 101, 9, 100, 105, 114, 101, 99, 116, 111, 114, 121, 9, 101, 120, 99, 108, 117, 115, 105, 118, 101, 8, 116, 114, 117, 110, 99, 97, 116, 101, 4, 0, 10, 111, 112, 101, 110, 45, 102, 108, 97, 103, 115, 3, 0, 16, 1, 119, 4, 0, 10, 108, 105, 110, 107, 45, 99, 111, 117, 110, 116, 3, 0, 18, 1, 107, 7, 1, 114, 6, 4, 116, 121, 112, 101, 11, 10, 108, 105, 110, 107, 45, 99, 111, 117, 110, 116, 19, 4, 115, 105, 122, 101, 9, 21, 100, 97, 116, 97, 45, 97, 99, 99, 101, 115, 115, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 27, 100, 97, 116, 97, 45, 109, 111, 100, 105, 102, 105, 99, 97, 116, 105, 111, 110, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 23, 115, 116, 97, 116, 117, 115, 45, 99, 104, 97, 110, 103, 101, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 20, 4, 0, 15, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 45, 115, 116, 97, 116, 3, 0, 21, 1, 113, 3, 9, 110, 111, 45, 99, 104, 97, 110, 103, 101, 0, 0, 3, 110, 111, 119, 0, 0, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 1, 7, 0, 4, 0, 13, 110, 101, 119, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 3, 0, 23, 1, 114, 2, 4, 116, 121, 112, 101, 11, 4, 110, 97, 109, 101, 115, 4, 0, 15, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 3, 0, 25, 1, 109, 37, 6, 97, 99, 99, 101, 115, 115, 11, 119, 111, 117, 108, 100, 45, 98, 108, 111, 99, 107, 7, 97, 108, 114, 101, 97, 100, 121, 14, 98, 97, 100, 45, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 4, 98, 117, 115, 121, 8, 100, 101, 97, 100, 108, 111, 99, 107, 5, 113, 117, 111, 116, 97, 5, 101, 120, 105, 115, 116, 14, 102, 105, 108, 101, 45, 116, 111, 111, 45, 108, 97, 114, 103, 101, 21, 105, 108, 108, 101, 103, 97, 108, 45, 98, 121, 116, 101, 45, 115, 101, 113, 117, 101, 110, 99, 101, 11, 105, 110, 45, 112, 114, 111, 103, 114, 101, 115, 115, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 7, 105, 110, 118, 97, 108, 105, 100, 2, 105, 111, 12, 105, 115, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 4, 108, 111, 111, 112, 14, 116, 111, 111, 45, 109, 97, 110, 121, 45, 108, 105, 110, 107, 115, 12, 109, 101, 115, 115, 97, 103, 101, 45, 115, 105, 122, 101, 13, 110, 97, 109, 101, 45, 116, 111, 111, 45, 108, 111, 110, 103, 9, 110, 111, 45, 100, 101, 118, 105, 99, 101, 8, 110, 111, 45, 101, 110, 116, 114, 121, 7, 110, 111, 45, 108, 111, 99, 107, 19, 105, 110, 115, 117, 102, 102, 105, 99, 105, 101, 110, 116, 45, 109, 101, 109, 111, 114, 121, 18, 105, 110, 115, 117, 102, 102, 105, 99, 105, 101, 110, 116, 45, 115, 112, 97, 99, 101, 13, 110, 111, 116, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 9, 110, 111, 116, 45, 101, 109, 112, 116, 121, 15, 110, 111, 116, 45, 114, 101, 99, 111, 118, 101, 114, 97, 98, 108, 101, 11, 117, 110, 115, 117, 112, 112, 111, 114, 116, 101, 100, 6, 110, 111, 45, 116, 116, 121, 14, 110, 111, 45, 115, 117, 99, 104, 45, 100, 101, 118, 105, 99, 101, 8, 111, 118, 101, 114, 102, 108, 111, 119, 13, 110, 111, 116, 45, 112, 101, 114, 109, 105, 116, 116, 101, 100, 4, 112, 105, 112, 101, 9, 114, 101, 97, 100, 45, 111, 110, 108, 121, 12, 105, 110, 118, 97, 108, 105, 100, 45, 115, 101, 101, 107, 14, 116, 101, 120, 116, 45, 102, 105, 108, 101, 45, 98, 117, 115, 121, 12, 99, 114, 111, 115, 115, 45, 100, 101, 118, 105, 99, 101, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 27, 1, 109, 6, 6, 110, 111, 114, 109, 97, 108, 10, 115, 101, 113, 117, 101, 110, 116, 105, 97, 108, 6, 114, 97, 110, 100, 111, 109, 9, 119, 105, 108, 108, 45, 110, 101, 101, 100, 9, 100, 111, 110, 116, 45, 110, 101, 101, 100, 8, 110, 111, 45, 114, 101, 117, 115, 101, 4, 0, 6, 97, 100, 118, 105, 99, 101, 3, 0, 29, 1, 114, 2, 5, 108, 111, 119, 101, 114, 119, 5, 117, 112, 112, 101, 114, 119, 4, 0, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 3, 0, 31, 4, 0, 10, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 3, 1, 4, 0, 22, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 33, 1, 105, 1, 1, 106, 1, 36, 1, 28, 1, 64, 2, 4, 115, 101, 108, 102, 35, 6, 111, 102, 102, 115, 101, 116, 9, 0, 37, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 97, 100, 45, 118, 105, 97, 45, 115, 116, 114, 101, 97, 109, 1, 38, 1, 105, 3, 1, 106, 1, 39, 1, 28, 1, 64, 2, 4, 115, 101, 108, 102, 35, 6, 111, 102, 102, 115, 101, 116, 9, 0, 40, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 119, 114, 105, 116, 101, 45, 118, 105, 97, 45, 115, 116, 114, 101, 97, 109, 1, 41, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 40, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 97, 112, 112, 101, 110, 100, 45, 118, 105, 97, 45, 115, 116, 114, 101, 97, 109, 1, 42, 1, 106, 0, 1, 28, 1, 64, 4, 4, 115, 101, 108, 102, 35, 6, 111, 102, 102, 115, 101, 116, 9, 6, 108, 101, 110, 103, 116, 104, 9, 6, 97, 100, 118, 105, 99, 101, 30, 0, 43, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 97, 100, 118, 105, 115, 101, 1, 44, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 43, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 121, 110, 99, 45, 100, 97, 116, 97, 1, 45, 1, 106, 1, 13, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 46, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 103, 101, 116, 45, 102, 108, 97, 103, 115, 1, 47, 1, 106, 1, 11, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 48, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 103, 101, 116, 45, 116, 121, 112, 101, 1, 49, 1, 64, 2, 4, 115, 101, 108, 102, 35, 4, 115, 105, 122, 101, 9, 0, 43, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 101, 116, 45, 115, 105, 122, 101, 1, 50, 1, 64, 3, 4, 115, 101, 108, 102, 35, 21, 100, 97, 116, 97, 45, 97, 99, 99, 101, 115, 115, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 24, 27, 100, 97, 116, 97, 45, 109, 111, 100, 105, 102, 105, 99, 97, 116, 105, 111, 110, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 24, 0, 43, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 101, 116, 45, 116, 105, 109, 101, 115, 1, 51, 1, 112, 125, 1, 111, 2, 52, 127, 1, 106, 1, 53, 1, 28, 1, 64, 3, 4, 115, 101, 108, 102, 35, 6, 108, 101, 110, 103, 116, 104, 9, 6, 111, 102, 102, 115, 101, 116, 9, 0, 54, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 97, 100, 1, 55, 1, 106, 1, 9, 1, 28, 1, 64, 3, 4, 115, 101, 108, 102, 35, 6, 98, 117, 102, 102, 101, 114, 52, 6, 111, 102, 102, 115, 101, 116, 9, 0, 56, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 119, 114, 105, 116, 101, 1, 57, 1, 105, 34, 1, 106, 1, 58, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 59, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 97, 100, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 1, 60, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 121, 110, 99, 1, 45, 1, 64, 2, 4, 115, 101, 108, 102, 35, 4, 112, 97, 116, 104, 115, 0, 43, 4, 0, 38, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 99, 114, 101, 97, 116, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 97, 116, 1, 61, 1, 106, 1, 22, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 62, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 116, 97, 116, 1, 63, 1, 64, 3, 4, 115, 101, 108, 102, 35, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 15, 4, 112, 97, 116, 104, 115, 0, 62, 4, 0, 26, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 116, 97, 116, 45, 97, 116, 1, 64, 1, 64, 5, 4, 115, 101, 108, 102, 35, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 15, 4, 112, 97, 116, 104, 115, 21, 100, 97, 116, 97, 45, 97, 99, 99, 101, 115, 115, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 24, 27, 100, 97, 116, 97, 45, 109, 111, 100, 105, 102, 105, 99, 97, 116, 105, 111, 110, 45, 116, 105, 109, 101, 115, 116, 97, 109, 112, 24, 0, 43, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 101, 116, 45, 116, 105, 109, 101, 115, 45, 97, 116, 1, 65, 1, 64, 5, 4, 115, 101, 108, 102, 35, 14, 111, 108, 100, 45, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 15, 8, 111, 108, 100, 45, 112, 97, 116, 104, 115, 14, 110, 101, 119, 45, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 35, 8, 110, 101, 119, 45, 112, 97, 116, 104, 115, 0, 43, 4, 0, 26, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 108, 105, 110, 107, 45, 97, 116, 1, 66, 1, 105, 33, 1, 106, 1, 195, 0, 1, 28, 1, 64, 5, 4, 115, 101, 108, 102, 35, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 15, 4, 112, 97, 116, 104, 115, 10, 111, 112, 101, 110, 45, 102, 108, 97, 103, 115, 17, 5, 102, 108, 97, 103, 115, 13, 0, 196, 0, 4, 0, 26, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 111, 112, 101, 110, 45, 97, 116, 1, 69, 1, 106, 1, 115, 1, 28, 1, 64, 2, 4, 115, 101, 108, 102, 35, 4, 112, 97, 116, 104, 115, 0, 198, 0, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 97, 100, 108, 105, 110, 107, 45, 97, 116, 1, 71, 4, 0, 38, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 109, 111, 118, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 97, 116, 1, 61, 1, 64, 4, 4, 115, 101, 108, 102, 35, 8, 111, 108, 100, 45, 112, 97, 116, 104, 115, 14, 110, 101, 119, 45, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 35, 8, 110, 101, 119, 45, 112, 97, 116, 104, 115, 0, 43, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 114, 101, 110, 97, 109, 101, 45, 97, 116, 1, 72, 1, 64, 3, 4, 115, 101, 108, 102, 35, 8, 111, 108, 100, 45, 112, 97, 116, 104, 115, 8, 110, 101, 119, 45, 112, 97, 116, 104, 115, 0, 43, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 115, 121, 109, 108, 105, 110, 107, 45, 97, 116, 1, 73, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 117, 110, 108, 105, 110, 107, 45, 102, 105, 108, 101, 45, 97, 116, 1, 61, 1, 64, 2, 4, 115, 101, 108, 102, 35, 5, 111, 116, 104, 101, 114, 35, 0, 127, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 105, 115, 45, 115, 97, 109, 101, 45, 111, 98, 106, 101, 99, 116, 1, 74, 1, 106, 1, 32, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 35, 0, 203, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 1, 76, 1, 64, 3, 4, 115, 101, 108, 102, 35, 10, 112, 97, 116, 104, 45, 102, 108, 97, 103, 115, 15, 4, 112, 97, 116, 104, 115, 0, 203, 0, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 46, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 97, 116, 1, 77, 1, 104, 34, 1, 107, 26, 1, 106, 1, 207, 0, 1, 28, 1, 64, 1, 4, 115, 101, 108, 102, 206, 0, 0, 208, 0, 4, 0, 51, 91, 109, 101, 116, 104, 111, 100, 93, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 45, 101, 110, 116, 114, 121, 1, 81, 1, 104, 5, 1, 107, 28, 1, 64, 1, 3, 101, 114, 114, 210, 0, 0, 211, 0, 4, 0, 21, 102, 105, 108, 101, 115, 121, 115, 116, 101, 109, 45, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 1, 84, 3, 1, 27, 119, 97, 115, 105, 58, 102, 105, 108, 101, 115, 121, 115, 116, 101, 109, 47, 116, 121, 112, 101, 115, 64, 48, 46, 50, 46, 48, 5, 10, 2, 3, 0, 4, 10, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 1, 66, 7, 2, 3, 2, 1, 11, 4, 0, 10, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 3, 0, 0, 1, 105, 1, 1, 111, 2, 2, 115, 1, 112, 3, 1, 64, 0, 0, 4, 4, 0, 15, 103, 101, 116, 45, 100, 105, 114, 101, 99, 116, 111, 114, 105, 101, 115, 1, 5, 3, 1, 30, 119, 97, 115, 105, 58, 102, 105, 108, 101, 115, 121, 115, 116, 101, 109, 47, 112, 114, 101, 111, 112, 101, 110, 115, 64, 48, 46, 50, 46, 48, 5, 12, 2, 3, 0, 4, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 1, 66, 29, 2, 3, 2, 1, 9, 4, 0, 8, 100, 97, 116, 101, 116, 105, 109, 101, 3, 0, 0, 2, 3, 2, 1, 13, 4, 0, 19, 109, 101, 116, 97, 100, 97, 116, 97, 45, 104, 97, 115, 104, 45, 118, 97, 108, 117, 101, 3, 0, 2, 1, 114, 2, 13, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 1, 13, 108, 97, 115, 116, 45, 97, 99, 99, 101, 115, 115, 101, 100, 1, 4, 0, 9, 102, 105, 108, 101, 45, 105, 110, 102, 111, 3, 0, 4, 1, 106, 1, 115, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 6, 4, 0, 9, 114, 101, 97, 100, 45, 102, 105, 108, 101, 1, 7, 1, 106, 0, 1, 115, 1, 64, 2, 4, 112, 97, 116, 104, 115, 8, 99, 111, 110, 116, 101, 110, 116, 115, 115, 0, 8, 4, 0, 10, 119, 114, 105, 116, 101, 45, 102, 105, 108, 101, 1, 9, 4, 0, 17, 119, 114, 105, 116, 101, 45, 102, 105, 108, 101, 45, 100, 105, 114, 101, 99, 116, 1, 9, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 8, 4, 0, 11, 100, 101, 108, 101, 116, 101, 45, 102, 105, 108, 101, 1, 10, 1, 106, 1, 5, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 11, 4, 0, 13, 103, 101, 116, 45, 102, 105, 108, 101, 45, 105, 110, 102, 111, 1, 12, 4, 0, 8, 103, 101, 116, 45, 105, 110, 102, 111, 1, 12, 4, 0, 16, 99, 114, 101, 97, 116, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 1, 10, 1, 64, 2, 6, 115, 111, 117, 114, 99, 101, 115, 11, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 115, 0, 8, 4, 0, 11, 99, 114, 101, 97, 116, 101, 45, 108, 105, 110, 107, 1, 13, 4, 0, 15, 99, 114, 101, 97, 116, 101, 45, 115, 121, 109, 45, 108, 105, 110, 107, 1, 13, 4, 0, 16, 114, 101, 109, 111, 118, 101, 45, 100, 105, 114, 101, 99, 116, 111, 114, 121, 1, 10, 4, 0, 11, 114, 101, 109, 111, 118, 101, 45, 102, 105, 108, 101, 1, 10, 4, 0, 11, 114, 101, 110, 97, 109, 101, 45, 102, 105, 108, 101, 1, 13, 1, 106, 1, 3, 1, 115, 1, 64, 1, 4, 112, 97, 116, 104, 115, 0, 14, 4, 0, 4, 104, 97, 115, 104, 1, 15, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 14, 4, 1, 21, 103, 111, 108, 101, 109, 58, 105, 116, 47, 102, 105, 108, 101, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 18, 1, 0, 12, 102, 105, 108, 101, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_file_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_file_service_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:file-service:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 5147] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x98'\x01A\x02\x01A\x16\ +\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01@\0\0\ +\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\x01\x1cwasi:clocks/wal\ +l-clock@0.2.0\x05\0\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0\ +s\x04\0\x1d[method]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\ +\x01\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16\ +[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]polla\ +ble.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\ +\x01\x12wasi:io/poll@0.2.0\x05\x02\x02\x03\0\x01\x05error\x02\x03\0\x02\x08polla\ +ble\x01B(\x02\x03\x02\x01\x03\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x04\x04\0\x08\ +pollable\x03\0\x02\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06close\ +d\0\0\x04\0\x0cstream-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0dout\ +put-stream\x03\x01\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03l\ +enw\0\x0b\x04\0\x19[method]input-stream.read\x01\x0c\x04\0\"[method]input-stream\ +.blocking-read\x01\x0c\x01j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\ +\x19[method]input-stream.skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\ +\x0e\x01i\x03\x01@\x01\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\ +\x01\x10\x01h\x08\x01@\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-w\ +rite\x01\x12\x01j\0\x01\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b\ +[method]output-stream.write\x01\x14\x04\0.[method]output-stream.blocking-write-a\ +nd-flush\x01\x14\x01@\x01\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\ +\x01\x15\x04\0$[method]output-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\ +\0\x0f\x04\0\x1f[method]output-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03\ +lenw\0\x13\x04\0\"[method]output-stream.write-zeroes\x01\x17\x04\05[method]outpu\ +t-stream.blocking-write-zeroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\ +\x03lenw\0\x0d\x04\0\x1c[method]output-stream.splice\x01\x18\x04\0%[method]outpu\ +t-stream.blocking-splice\x01\x18\x03\x01\x15wasi:io/streams@0.2.0\x05\x05\x02\x03\ +\0\x03\x0cinput-stream\x02\x03\0\x03\x0doutput-stream\x02\x03\0\x03\x05error\x02\ +\x03\0\0\x08datetime\x01Br\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\0\x02\ +\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x05e\ +rror\x03\0\x04\x02\x03\x02\x01\x09\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08fil\ +esize\x03\0\x08\x01m\x08\x07unknown\x0cblock-device\x10character-device\x09direc\ +tory\x04fifo\x0dsymbolic-link\x0cregular-file\x06socket\x04\0\x0fdescriptor-type\ +\x03\0\x0a\x01n\x06\x04read\x05write\x13file-integrity-sync\x13data-integrity-sy\ +nc\x14requested-write-sync\x10mutate-directory\x04\0\x10descriptor-flags\x03\0\x0c\ +\x01n\x01\x0esymlink-follow\x04\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09\ +directory\x09exclusive\x08truncate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0al\ +ink-count\x03\0\x12\x01k\x07\x01r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15\ +data-access-timestamp\x14\x1bdata-modification-timestamp\x14\x17status-change-ti\ +mestamp\x14\x04\0\x0fdescriptor-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\ +\0\x09timestamp\x01\x07\0\x04\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04\ +names\x04\0\x0fdirectory-entry\x03\0\x19\x01m%\x06access\x0bwould-block\x07alrea\ +dy\x0ebad-descriptor\x04busy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15\ +illegal-byte-sequence\x0bin-progress\x0binterrupted\x07invalid\x02io\x0cis-direc\ +tory\x04loop\x0etoo-many-links\x0cmessage-size\x0dname-too-long\x09no-device\x08\ +no-entry\x07no-lock\x13insufficient-memory\x12insufficient-space\x0dnot-director\ +y\x09not-empty\x0fnot-recoverable\x0bunsupported\x06no-tty\x0eno-such-device\x08\ +overflow\x0dnot-permitted\x04pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\ +\x0ccross-device\x04\0\x0aerror-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06\ +random\x09will-need\x09dont-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05\ +lowerw\x05upperw\x04\0\x13metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\ +\x04\0\x16directory-entry-stream\x03\x01\x01h!\x01i\x01\x01j\x01$\x01\x1c\x01@\x02\ +\x04self#\x06offset\x09\0%\x04\0\"[method]descriptor.read-via-stream\x01&\x01i\x03\ +\x01j\x01'\x01\x1c\x01@\x02\x04self#\x06offset\x09\0(\x04\0#[method]descriptor.w\ +rite-via-stream\x01)\x01@\x01\x04self#\0(\x04\0$[method]descriptor.append-via-st\ +ream\x01*\x01j\0\x01\x1c\x01@\x04\x04self#\x06offset\x09\x06length\x09\x06advice\ +\x1e\0+\x04\0\x19[method]descriptor.advise\x01,\x01@\x01\x04self#\0+\x04\0\x1c[m\ +ethod]descriptor.sync-data\x01-\x01j\x01\x0d\x01\x1c\x01@\x01\x04self#\0.\x04\0\x1c\ +[method]descriptor.get-flags\x01/\x01j\x01\x0b\x01\x1c\x01@\x01\x04self#\00\x04\0\ +\x1b[method]descriptor.get-type\x011\x01@\x02\x04self#\x04size\x09\0+\x04\0\x1b[\ +method]descriptor.set-size\x012\x01@\x03\x04self#\x15data-access-timestamp\x18\x1b\ +data-modification-timestamp\x18\0+\x04\0\x1c[method]descriptor.set-times\x013\x01\ +p}\x01o\x024\x7f\x01j\x015\x01\x1c\x01@\x03\x04self#\x06length\x09\x06offset\x09\ +\06\x04\0\x17[method]descriptor.read\x017\x01j\x01\x09\x01\x1c\x01@\x03\x04self#\ +\x06buffer4\x06offset\x09\08\x04\0\x18[method]descriptor.write\x019\x01i\"\x01j\x01\ +:\x01\x1c\x01@\x01\x04self#\0;\x04\0![method]descriptor.read-directory\x01<\x04\0\ +\x17[method]descriptor.sync\x01-\x01@\x02\x04self#\x04paths\0+\x04\0&[method]des\ +criptor.create-directory-at\x01=\x01j\x01\x16\x01\x1c\x01@\x01\x04self#\0>\x04\0\ +\x17[method]descriptor.stat\x01?\x01@\x03\x04self#\x0apath-flags\x0f\x04paths\0>\ +\x04\0\x1a[method]descriptor.stat-at\x01@\x01@\x05\x04self#\x0apath-flags\x0f\x04\ +paths\x15data-access-timestamp\x18\x1bdata-modification-timestamp\x18\0+\x04\0\x1f\ +[method]descriptor.set-times-at\x01A\x01@\x05\x04self#\x0eold-path-flags\x0f\x08\ +old-paths\x0enew-descriptor#\x08new-paths\0+\x04\0\x1a[method]descriptor.link-at\ +\x01B\x01i!\x01j\x01\xc3\0\x01\x1c\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x0a\ +open-flags\x11\x05flags\x0d\0\xc4\0\x04\0\x1a[method]descriptor.open-at\x01E\x01\ +j\x01s\x01\x1c\x01@\x02\x04self#\x04paths\0\xc6\0\x04\0\x1e[method]descriptor.re\ +adlink-at\x01G\x04\0&[method]descriptor.remove-directory-at\x01=\x01@\x04\x04sel\ +f#\x08old-paths\x0enew-descriptor#\x08new-paths\0+\x04\0\x1c[method]descriptor.r\ +ename-at\x01H\x01@\x03\x04self#\x08old-paths\x08new-paths\0+\x04\0\x1d[method]de\ +scriptor.symlink-at\x01I\x04\0![method]descriptor.unlink-file-at\x01=\x01@\x02\x04\ +self#\x05other#\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\x01\ +\x1c\x01@\x01\x04self#\0\xcb\0\x04\0\x20[method]descriptor.metadata-hash\x01L\x01\ +@\x03\x04self#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metad\ +ata-hash-at\x01M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\ +\xd0\0\x04\03[method]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01\ +k\x1c\x01@\x01\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\x01\x1b\ +wasi:filesystem/types@0.2.0\x05\x0a\x02\x03\0\x04\x0adescriptor\x01B\x07\x02\x03\ +\x02\x01\x0b\x04\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\ +\x04\x04\0\x0fget-directories\x01\x05\x03\x01\x1ewasi:filesystem/preopens@0.2.0\x05\ +\x0c\x02\x03\0\x04\x13metadata-hash-value\x01B\x1d\x02\x03\x02\x01\x09\x04\0\x08\ +datetime\x03\0\0\x02\x03\x02\x01\x0d\x04\0\x13metadata-hash-value\x03\0\x02\x01r\ +\x02\x0dlast-modified\x01\x0dlast-accessed\x01\x04\0\x09file-info\x03\0\x04\x01j\ +\x01s\x01s\x01@\x01\x04paths\0\x06\x04\0\x09read-file\x01\x07\x01j\0\x01s\x01@\x02\ +\x04paths\x08contentss\0\x08\x04\0\x0awrite-file\x01\x09\x04\0\x11write-file-dir\ +ect\x01\x09\x01@\x01\x04paths\0\x08\x04\0\x0bdelete-file\x01\x0a\x01j\x01\x05\x01\ +s\x01@\x01\x04paths\0\x0b\x04\0\x0dget-file-info\x01\x0c\x04\0\x08get-info\x01\x0c\ +\x04\0\x10create-directory\x01\x0a\x01@\x02\x06sources\x0bdestinations\0\x08\x04\ +\0\x0bcreate-link\x01\x0d\x04\0\x0fcreate-sym-link\x01\x0d\x04\0\x10remove-direc\ +tory\x01\x0a\x04\0\x0bremove-file\x01\x0a\x04\0\x0brename-file\x01\x0d\x01j\x01\x03\ +\x01s\x01@\x01\x04paths\0\x0e\x04\0\x04hash\x01\x0f\x04\x01\x0cgolem:it/api\x05\x0e\ +\x04\x01\x15golem:it/file-service\x04\0\x0b\x12\x01\0\x0cfile-service\x03\0\0\0G\ +\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen\ +-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/file-service/src/lib.rs b/test-components/file-service/src/lib.rs index 6f3177fe4f..999aa287ef 100644 --- a/test-components/file-service/src/lib.rs +++ b/test-components/file-service/src/lib.rs @@ -101,3 +101,5 @@ impl Guest for Component { root.metadata_hash_at(PathFlags::empty(), &path).map_err(|err| err.to_string()) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/file-write-read-delete.wasm b/test-components/file-write-read-delete.wasm index 6636abd4b1..c0b779e805 100755 Binary files a/test-components/file-write-read-delete.wasm and b/test-components/file-write-read-delete.wasm differ diff --git a/test-components/file-write-read-delete/Cargo.lock b/test-components/file-write-read-delete/Cargo.lock index 0293c75e30..ae92ad4fd2 100644 --- a/test-components/file-write-read-delete/Cargo.lock +++ b/test-components/file-write-read-delete/Cargo.lock @@ -56,7 +56,7 @@ name = "golem-it-file-write-read-delete" version = "0.0.1" dependencies = [ "fs", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -91,10 +91,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/file-write-read-delete/Cargo.toml b/test-components/file-write-read-delete/Cargo.toml index faffd1c4c9..c01314d90e 100644 --- a/test-components/file-write-read-delete/Cargo.toml +++ b/test-components/file-write-read-delete/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } fs = "0.0.5" [package.metadata.component.target] diff --git a/test-components/file-write-read-delete/src/bindings.rs b/test-components/file-write-read-delete/src/bindings.rs index dc8b7b90a1..e0ff2eadad 100644 --- a/test-components/file-write-read-delete/src/bindings.rs +++ b/test-components/file-write-read-delete/src/bindings.rs @@ -1,131 +1,174 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let (t2_0, t2_1, t2_2, ) = result0; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let (t2_0, t2_1, t2_2) = result0; match t2_0 { - Some(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); } - }, - };match t2_1 { - Some(e) => { - *((ptr1 + 12) as *mut u8) = (1i32) as u8; - let vec4 = (e.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr1 + 20) as *mut i32) = len4; - *((ptr1 + 16) as *mut i32) = ptr4; - }, - None => { - { - *((ptr1 + 12) as *mut u8) = (0i32) as u8; + None => { + *ptr1.add(0).cast::() = (0i32) as u8; } - }, - };match t2_2 { - Some(e) => { - *((ptr1 + 24) as *mut u8) = (1i32) as u8; - let vec5 = (e.into_bytes()).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((ptr1 + 32) as *mut i32) = len5; - *((ptr1 + 28) as *mut i32) = ptr5; - }, - None => { - { - *((ptr1 + 24) as *mut u8) = (0i32) as u8; + }; + match t2_1 { + Some(e) => { + *ptr1.add(12).cast::() = (1i32) as u8; + let vec4 = (e.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr1.add(20).cast::() = len4; + *ptr1.add(16).cast::<*mut u8>() = ptr4.cast_mut(); } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { + None => { + *ptr1.add(12).cast::() = (0i32) as u8; + } + }; + match t2_2 { + Some(e) => { + *ptr1.add(24).cast::() = (1i32) as u8; + let vec5 = (e.into_bytes()).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *ptr1.add(32).cast::() = len5; + *ptr1.add(28).cast::<*mut u8>() = ptr5.cast_mut(); + } + None => { + *ptr1.add(24).cast::() = (0i32) as u8; + } + }; + ptr1 +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { 0 => (), _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - let l3 = i32::from(*((arg0 + 12) as *const u8)); - match l3 { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + let l3 = i32::from(*arg0.add(12).cast::()); + match l3 { 0 => (), _ => { - let l4 = *((arg0 + 16) as *const i32); - let l5 = *((arg0 + 20) as *const i32); - wit_bindgen::rt::dealloc(l4, (l5) as usize, 1); - }, - } - let l6 = i32::from(*((arg0 + 24) as *const u8)); - match l6 { + let l4 = *arg0.add(16).cast::<*mut u8>(); + let l5 = *arg0.add(20).cast::(); + _rt::cabi_dealloc(l4, l5, 1); + } + } + let l6 = i32::from(*arg0.add(24).cast::()); + match l6 { 0 => (), _ => { - let l7 = *((arg0 + 28) as *const i32); - let l8 = *((arg0 + 32) as *const i32); - wit_bindgen::rt::dealloc(l7, (l8) as usize, 1); - }, - } + let l7 = *arg0.add(28).cast::<*mut u8>(); + let l8 = *arg0.add(32).cast::(); + _rt::cabi_dealloc(l7, l8, 1); + } } - }; -}; -use super::Component as _GuestImpl; +} pub trait Guest { - fn run() -> (Option,Option,Option,); + fn run() -> ( + Option<_rt::String>, + Option<_rt::String>, + Option<_rt::String>, + ); } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_file_write_read_delete_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_file_write_read_delete_cabi; #[repr(align(4))] -struct _RetArea([u8; 36]); -static mut _RET_AREA: _RetArea = _RetArea([0; 36]); +struct _RetArea([::core::mem::MaybeUninit; 36]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 36]); +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_file_write_read_delete_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_file_write_read_delete_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_file_write_read_delete_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:file-write-read-delete"] +#[link_section = "component-type:wit-bindgen:0.25.0:file-write-read-delete:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 219] = [3, 0, 22, 102, 105, 108, 101, 45, 119, 114, 105, 116, 101, 45, 114, 101, 97, 100, 45, 100, 101, 108, 101, 116, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 64, 1, 65, 2, 1, 65, 4, 1, 107, 115, 1, 111, 3, 0, 0, 0, 1, 64, 0, 0, 1, 4, 0, 3, 114, 117, 110, 1, 2, 4, 1, 31, 103, 111, 108, 101, 109, 58, 105, 116, 47, 102, 105, 108, 101, 45, 119, 114, 105, 116, 101, 45, 114, 101, 97, 100, 45, 100, 101, 108, 101, 116, 101, 4, 0, 11, 28, 1, 0, 22, 102, 105, 108, 101, 45, 119, 114, 105, 116, 101, 45, 114, 101, 97, 100, 45, 100, 101, 108, 101, 116, 101, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 204] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07@\x01A\x02\x01A\x04\x01\ +ks\x01o\x03\0\0\0\x01@\0\0\x01\x04\0\x03run\x01\x02\x04\x01\x1fgolem:it/file-wri\ +te-read-delete\x04\0\x0b\x1c\x01\0\x16file-write-read-delete\x03\0\0\0G\x09produ\ +cers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x06\ +0.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/file-write-read-delete/src/lib.rs b/test-components/file-write-read-delete/src/lib.rs index 24f1d63c64..128ab81ef0 100644 --- a/test-components/file-write-read-delete/src/lib.rs +++ b/test-components/file-write-read-delete/src/lib.rs @@ -27,3 +27,5 @@ impl Guest for Component { ) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/flags-service.wasm b/test-components/flags-service.wasm index 9c3c6487b0..f66d9eed05 100755 Binary files a/test-components/flags-service.wasm and b/test-components/flags-service.wasm differ diff --git a/test-components/flags-service/Cargo.lock b/test-components/flags-service/Cargo.lock index 1c4bc2c08f..d06db40457 100644 --- a/test-components/flags-service/Cargo.lock +++ b/test-components/flags-service/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/flags-service/cargo.toml b/test-components/flags-service/cargo.toml index d295870b28..a332f4f2b3 100644 --- a/test-components/flags-service/cargo.toml +++ b/test-components/flags-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/flags-service/src/bindings.rs b/test-components/flags-service/src/bindings.rs index ac5683e712..a0f1267b76 100644 --- a/test-components/flags-service/src/bindings.rs +++ b/test-components/flags-service/src/bindings.rs @@ -1,190 +1,243 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - wit_bindgen::bitflags::bitflags! { - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct Permissions: u8 { - const READ = 1 << 0; - const WRITE = 1 << 1; - const EXEC = 1 << 2; - const CLOSE = 1 << 3; - } + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + wit_bindgen_rt::bitflags::bitflags! { + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct Permissions: u8 { + const READ = 1 << 0; + const WRITE = 1 << 1; + const EXEC = 1 << 2; + const CLOSE = 1 << 3; + } + } + #[derive(Clone)] + pub struct Task { + pub name: _rt::String, + pub permissions: Permissions, + } + impl ::core::fmt::Debug for Task { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Task") + .field("name", &self.name) + .field("permissions", &self.permissions) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_task_cabi( + arg0: *mut u8, + arg1: usize, + arg2: i32, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::create_task(Task { + name: _rt::string_lift(bytes0), + permissions: Permissions::empty() + | Permissions::from_bits_retain(((arg2 as u8) << 0) as _), + }); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + let Task { + name: name3, + permissions: permissions3, + } = result1; + let vec4 = (name3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(4).cast::() = len4; + *ptr2.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + let flags5 = permissions3; + *ptr2.add(8).cast::() = ((flags5.bits() >> 0) as i32) as u8; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_create_task(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_tasks_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_tasks(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec5 = result0; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 12, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 12); + { + let Task { + name: name2, + permissions: permissions2, + } = e; + let vec3 = (name2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let flags4 = permissions2; + *base.add(8).cast::() = ((flags4.bits() >> 0) as i32) as u8; + } + } + *ptr1.add(4).cast::() = len5; + *ptr1.add(0).cast::<*mut u8>() = result5; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_tasks(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 12); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 12, 4); + } + pub trait Guest { + fn create_task(input: Task) -> Task; + fn get_tasks() -> _rt::Vec; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#create-task"] + unsafe extern "C" fn export_create_task(arg0: *mut u8,arg1: usize,arg2: i32,) -> *mut u8 { + $($path_to_types)*::_export_create_task_cabi::<$ty>(arg0, arg1, arg2) } - #[derive(Clone)] - pub struct Task { - pub name: wit_bindgen::rt::string::String, - pub permissions: Permissions, + #[export_name = "cabi_post_golem:it/api#create-task"] + unsafe extern "C" fn _post_return_create_task(arg0: *mut u8,) { + $($path_to_types)*::__post_return_create_task::<$ty>(arg0) } - impl ::core::fmt::Debug for Task { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Task").field("name", &self.name).field("permissions", &self.permissions).finish() - } + #[export_name = "golem:it/api#get-tasks"] + unsafe extern "C" fn export_get_tasks() -> *mut u8 { + $($path_to_types)*::_export_get_tasks_cabi::<$ty>() } - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#create-task"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_task(arg0: i32,arg1: i32,arg2: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::create_task(Task{ - name: wit_bindgen::rt::string_lift(bytes0), - permissions: Permissions::empty() | Permissions::from_bits_retain(((arg2 as u8) << 0) as _), - }); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - let Task{ name:name3, permissions:permissions3, } = result1; - let vec4 = (name3.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr2 + 4) as *mut i32) = len4; - *((ptr2 + 0) as *mut i32) = ptr4; - let flags5 = permissions3; - *((ptr2 + 8) as *mut u8) = ((flags5.bits() >> 0) as i32) as u8; - ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#create-task"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_create_task(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-tasks"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_tasks() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_tasks(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec5 = result0; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 12, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 12; - { - let Task{ name:name2, permissions:permissions2, } = e; - let vec3 = (name2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let flags4 = permissions2; - *((base + 8) as *mut u8) = ((flags4.bits() >> 0) as i32) as u8; - } - } - *((ptr1 + 4) as *mut i32) = len5; - *((ptr1 + 0) as *mut i32) = result5 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-tasks"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_tasks(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *12; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 12, 4); + #[export_name = "cabi_post_golem:it/api#get-tasks"] + unsafe extern "C" fn _post_return_get_tasks(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_tasks::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn create_task(input: Task,) -> Task; - fn get_tasks() -> wit_bindgen::rt::vec::Vec::; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + pub use alloc_crate::string::String; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_flags_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_flags_service_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:flags-service"] +#[link_section = "component-type:wit-bindgen:0.25.0:flags-service:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 476] = [3, 0, 13, 102, 108, 97, 103, 115, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 147, 1, 1, 65, 2, 1, 66, 9, 1, 110, 4, 4, 114, 101, 97, 100, 5, 119, 114, 105, 116, 101, 4, 101, 120, 101, 99, 5, 99, 108, 111, 115, 101, 4, 0, 11, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115, 3, 0, 0, 1, 114, 2, 4, 110, 97, 109, 101, 115, 11, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115, 1, 4, 0, 4, 116, 97, 115, 107, 3, 0, 2, 1, 64, 1, 5, 105, 110, 112, 117, 116, 3, 0, 3, 4, 0, 11, 99, 114, 101, 97, 116, 101, 45, 116, 97, 115, 107, 1, 4, 1, 112, 3, 1, 64, 0, 0, 5, 4, 0, 9, 103, 101, 116, 45, 116, 97, 115, 107, 115, 1, 6, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 177, 1, 1, 65, 2, 1, 65, 2, 1, 66, 9, 1, 110, 4, 4, 114, 101, 97, 100, 5, 119, 114, 105, 116, 101, 4, 101, 120, 101, 99, 5, 99, 108, 111, 115, 101, 4, 0, 11, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115, 3, 0, 0, 1, 114, 2, 4, 110, 97, 109, 101, 115, 11, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115, 1, 4, 0, 4, 116, 97, 115, 107, 3, 0, 2, 1, 64, 1, 5, 105, 110, 112, 117, 116, 3, 0, 3, 4, 0, 11, 99, 114, 101, 97, 116, 101, 45, 116, 97, 115, 107, 1, 4, 1, 112, 3, 1, 64, 0, 0, 5, 4, 0, 9, 103, 101, 116, 45, 116, 97, 115, 107, 115, 1, 6, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 22, 103, 111, 108, 101, 109, 58, 105, 116, 47, 102, 108, 97, 103, 115, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 19, 1, 0, 13, 102, 108, 97, 103, 115, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 309] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb1\x01\x01A\x02\x01\ +A\x02\x01B\x09\x01n\x04\x04read\x05write\x04exec\x05close\x04\0\x0bpermissions\x03\ +\0\0\x01r\x02\x04names\x0bpermissions\x01\x04\0\x04task\x03\0\x02\x01@\x01\x05in\ +put\x03\0\x03\x04\0\x0bcreate-task\x01\x04\x01p\x03\x01@\0\0\x05\x04\0\x09get-ta\ +sks\x01\x06\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x16golem:it/flags-service\x04\0\ +\x0b\x13\x01\0\x0dflags-service\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/flags-service/src/lib.rs b/test-components/flags-service/src/lib.rs index 6204d77617..1b6ebd3dc2 100644 --- a/test-components/flags-service/src/lib.rs +++ b/test-components/flags-service/src/lib.rs @@ -31,3 +31,5 @@ impl Guest for Component { ] } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/golem-rust-tests.wasm b/test-components/golem-rust-tests.wasm index 1c43fe1647..2c12e06788 100755 Binary files a/test-components/golem-rust-tests.wasm and b/test-components/golem-rust-tests.wasm differ diff --git a/test-components/golem-rust-tests/Cargo.lock b/test-components/golem-rust-tests/Cargo.lock index 8c7a99a383..f416ae1f5b 100644 --- a/test-components/golem-rust-tests/Cargo.lock +++ b/test-components/golem-rust-tests/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -19,15 +19,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -44,12 +44,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -70,9 +64,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.95" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -113,9 +107,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -198,9 +192,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -209,22 +203,26 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "golem-rust" -version = "0.0.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528a1a25e41a33e2eb107aade5aca822cdf34f69e842c9546431630f6879dabe" dependencies = [ "golem-rust-macro", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "golem-rust-macro" -version = "0.0.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d3c24dccea11431d77b66f36aed220845729023f7c54cdda2c6a526f8b3ca7" dependencies = [ "heck", "proc-macro2", @@ -239,7 +237,7 @@ dependencies = [ "golem-rust", "golem-rust-macro", "reqwest", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -297,9 +295,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -309,9 +307,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -385,23 +383,17 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -411,9 +403,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -423,9 +415,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -443,11 +435,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -461,9 +452,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -480,7 +471,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.5.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -544,9 +535,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -563,7 +554,7 @@ dependencies = [ [[package]] name = "reqwest" version = "0.11.18" -source = "git+https://github.com/zivergetech/reqwest?branch=update-apr-2024#313324b1c9867e520f537a2205eaf4333f1a5300" +source = "git+https://github.com/zivergetech/reqwest?branch=update-jun-2024#bd7f40be61748668b054742e64e9d10d3ab29014" dependencies = [ "base64", "bytes", @@ -594,14 +585,14 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "winreg", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" @@ -609,7 +600,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -618,9 +609,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" @@ -633,11 +624,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -646,9 +637,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -656,18 +647,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.199" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -676,9 +667,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -718,9 +709,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -756,9 +747,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -781,16 +772,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -847,9 +837,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1112,10 +1102,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ - "bitflags 2.5.0", + "bitflags", ] diff --git a/test-components/golem-rust-tests/Cargo.toml b/test-components/golem-rust-tests/Cargo.toml index b0d8f4b2ae..f1ab9ea4ad 100644 --- a/test-components/golem-rust-tests/Cargo.toml +++ b/test-components/golem-rust-tests/Cargo.toml @@ -13,10 +13,10 @@ opt-level = 's' strip = true [dependencies] -golem-rust = { version = "0.2.2" } -golem-rust-macro = { version = "0.2.2" } -reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-apr-2024", features = ["json"] } -wit-bindgen = { version = "=0.17.0", default-features = false, features = ["realloc"] } +golem-rust = { version = "0.3.0" } +golem-rust-macro = { version = "0.3.0" } +reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-jun-2024", features = ["json"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/golem-rust-tests/src/bindings.rs b/test-components/golem-rust-tests/src/bindings.rs index 6dcf02a8ae..c4ba3ccdad 100644 --- a/test-components/golem-rust-tests/src/bindings.rs +++ b/test-components/golem-rust-tests/src/bindings.rs @@ -1,221 +1,212 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#fail-with-custom-max-retries"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_fail_with_custom_max_retries(arg0: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::fail_with_custom_max_retries(arg0 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#explicit-commit"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_explicit_commit(arg0: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::explicit_commit(arg0 as u8); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#atomic-region"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_atomic_region() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::atomic_region(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#idempotence-flag"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_idempotence_flag(arg0: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::idempotence_flag(wit_bindgen::rt::bool_lift(arg0 as u8)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#persist-nothing"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_persist_nothing() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::persist_nothing(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#fallible-transaction-test"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_fallible_transaction_test() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::fallible_transaction_test(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#infallible-transaction-test"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_infallible_transaction_test() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::infallible_transaction_test(); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn fail_with_custom_max_retries(max_retries: u64,); - fn explicit_commit(replicas: u8,); - fn atomic_region(); - fn idempotence_flag(enabled: bool,); - fn persist_nothing(); - fn fallible_transaction_test() -> u64; - fn infallible_transaction_test() -> u64; + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_fail_with_custom_max_retries_cabi(arg0: i64) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::fail_with_custom_max_retries(arg0 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_explicit_commit_cabi(arg0: i32) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::explicit_commit(arg0 as u8); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_atomic_region_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::atomic_region(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_idempotence_flag_cabi(arg0: i32) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::idempotence_flag(_rt::bool_lift(arg0 as u8)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_persist_nothing_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::persist_nothing(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_fallible_transaction_test_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::fallible_transaction_test(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_infallible_transaction_test_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::infallible_transaction_test(); + _rt::as_i64(result0) + } + pub trait Guest { + fn fail_with_custom_max_retries(max_retries: u64); + fn explicit_commit(replicas: u8); + fn atomic_region(); + fn idempotence_flag(enabled: bool); + fn persist_nothing(); + fn fallible_transaction_test() -> u64; + fn infallible_transaction_test() -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#fail-with-custom-max-retries"] + unsafe extern "C" fn export_fail_with_custom_max_retries(arg0: i64,) { + $($path_to_types)*::_export_fail_with_custom_max_retries_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#explicit-commit"] + unsafe extern "C" fn export_explicit_commit(arg0: i32,) { + $($path_to_types)*::_export_explicit_commit_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#atomic-region"] + unsafe extern "C" fn export_atomic_region() { + $($path_to_types)*::_export_atomic_region_cabi::<$ty>() + } + #[export_name = "golem:it/api#idempotence-flag"] + unsafe extern "C" fn export_idempotence_flag(arg0: i32,) { + $($path_to_types)*::_export_idempotence_flag_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#persist-nothing"] + unsafe extern "C" fn export_persist_nothing() { + $($path_to_types)*::_export_persist_nothing_cabi::<$ty>() + } + #[export_name = "golem:it/api#fallible-transaction-test"] + unsafe extern "C" fn export_fallible_transaction_test() -> i64 { + $($path_to_types)*::_export_fallible_transaction_test_cabi::<$ty>() + } + #[export_name = "golem:it/api#infallible-transaction-test"] + unsafe extern "C" fn export_infallible_transaction_test() -> i64 { + $($path_to_types)*::_export_infallible_transaction_test_cabi::<$ty>() + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + } } - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_golem_rust_tests_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_golem_rust_tests_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:golem-rust-tests"] +#[link_section = "component-type:wit-bindgen:0.25.0:golem-rust-tests:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 699] = [3, 0, 16, 103, 111, 108, 101, 109, 45, 114, 117, 115, 116, 45, 116, 101, 115, 116, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 254, 1, 1, 65, 2, 1, 66, 12, 1, 64, 1, 11, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 119, 1, 0, 4, 0, 28, 102, 97, 105, 108, 45, 119, 105, 116, 104, 45, 99, 117, 115, 116, 111, 109, 45, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 1, 0, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 15, 101, 120, 112, 108, 105, 99, 105, 116, 45, 99, 111, 109, 109, 105, 116, 1, 1, 1, 64, 0, 1, 0, 4, 0, 13, 97, 116, 111, 109, 105, 99, 45, 114, 101, 103, 105, 111, 110, 1, 2, 1, 64, 1, 7, 101, 110, 97, 98, 108, 101, 100, 127, 1, 0, 4, 0, 16, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 102, 108, 97, 103, 1, 3, 4, 0, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 1, 2, 1, 64, 0, 0, 119, 4, 0, 25, 102, 97, 108, 108, 105, 98, 108, 101, 45, 116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 45, 116, 101, 115, 116, 1, 4, 4, 0, 27, 105, 110, 102, 97, 108, 108, 105, 98, 108, 101, 45, 116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 45, 116, 101, 115, 116, 1, 4, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 159, 2, 1, 65, 2, 1, 65, 2, 1, 66, 12, 1, 64, 1, 11, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 119, 1, 0, 4, 0, 28, 102, 97, 105, 108, 45, 119, 105, 116, 104, 45, 99, 117, 115, 116, 111, 109, 45, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 1, 0, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 15, 101, 120, 112, 108, 105, 99, 105, 116, 45, 99, 111, 109, 109, 105, 116, 1, 1, 1, 64, 0, 1, 0, 4, 0, 13, 97, 116, 111, 109, 105, 99, 45, 114, 101, 103, 105, 111, 110, 1, 2, 1, 64, 1, 7, 101, 110, 97, 98, 108, 101, 100, 127, 1, 0, 4, 0, 16, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 102, 108, 97, 103, 1, 3, 4, 0, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 1, 2, 1, 64, 0, 0, 119, 4, 0, 25, 102, 97, 108, 108, 105, 98, 108, 101, 45, 116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 45, 116, 101, 115, 116, 1, 4, 4, 0, 27, 105, 110, 102, 97, 108, 108, 105, 98, 108, 101, 45, 116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 45, 116, 101, 115, 116, 1, 4, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 25, 103, 111, 108, 101, 109, 58, 105, 116, 47, 103, 111, 108, 101, 109, 45, 114, 117, 115, 116, 45, 116, 101, 115, 116, 115, 4, 0, 11, 22, 1, 0, 16, 103, 111, 108, 101, 109, 45, 114, 117, 115, 116, 45, 116, 101, 115, 116, 115, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 422] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9f\x02\x01A\x02\x01\ +A\x02\x01B\x0c\x01@\x01\x0bmax-retriesw\x01\0\x04\0\x1cfail-with-custom-max-retr\ +ies\x01\0\x01@\x01\x08replicas}\x01\0\x04\0\x0fexplicit-commit\x01\x01\x01@\0\x01\ +\0\x04\0\x0datomic-region\x01\x02\x01@\x01\x07enabled\x7f\x01\0\x04\0\x10idempot\ +ence-flag\x01\x03\x04\0\x0fpersist-nothing\x01\x02\x01@\0\0w\x04\0\x19fallible-t\ +ransaction-test\x01\x04\x04\0\x1binfallible-transaction-test\x01\x04\x04\x01\x0c\ +golem:it/api\x05\0\x04\x01\x19golem:it/golem-rust-tests\x04\0\x0b\x16\x01\0\x10g\ +olem-rust-tests\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\ +\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/golem-rust-tests/src/lib.rs b/test-components/golem-rust-tests/src/lib.rs index 5a7dd1864b..2c982c7e33 100644 --- a/test-components/golem-rust-tests/src/lib.rs +++ b/test-components/golem-rust-tests/src/lib.rs @@ -273,3 +273,5 @@ fn read_body(incoming_response: &wasi::http::types::IncomingResponse) -> Vec } body } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/grain-1.wasm b/test-components/grain-1.wasm index 14d1c75ecd..7ffbb9ab21 100644 Binary files a/test-components/grain-1.wasm and b/test-components/grain-1.wasm differ diff --git a/test-components/http-client-2.wasm b/test-components/http-client-2.wasm index 3f962271f8..27200d285c 100755 Binary files a/test-components/http-client-2.wasm and b/test-components/http-client-2.wasm differ diff --git a/test-components/http-client-2/Cargo.lock b/test-components/http-client-2/Cargo.lock index 7ddf467fca..bcf8c2bd82 100644 --- a/test-components/http-client-2/Cargo.lock +++ b/test-components/http-client-2/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -19,15 +19,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -46,36 +46,27 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -101,9 +92,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -116,9 +107,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -126,9 +117,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fnv" @@ -201,9 +192,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "golem-it-http-client" @@ -212,14 +203,14 @@ dependencies = [ "reqwest", "serde", "serde_json", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -236,15 +227,15 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -264,9 +255,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -276,9 +267,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -323,9 +314,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -339,48 +330,42 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -390,18 +375,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", @@ -410,11 +395,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -428,9 +412,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -443,11 +427,11 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -475,9 +459,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -493,9 +477,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -505,41 +489,32 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "reqwest" version = "0.11.18" -source = "git+https://github.com/zivergetech/reqwest?branch=update-apr-2024#313324b1c9867e520f537a2205eaf4333f1a5300" +source = "git+https://github.com/zivergetech/reqwest?branch=update-jun-2024#bd7f40be61748668b054742e64e9d10d3ab29014" dependencies = [ "base64", "bytes", @@ -570,22 +545,22 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "winreg", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -594,9 +569,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" @@ -609,11 +584,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -622,9 +597,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -632,18 +607,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.196" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -652,9 +627,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -684,19 +659,19 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "syn" -version = "2.0.48" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -705,13 +680,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -733,9 +707,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -758,16 +732,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -815,18 +788,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -856,9 +829,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -866,9 +839,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -881,9 +854,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -893,9 +866,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -903,9 +876,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -916,15 +889,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -945,7 +918,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] @@ -965,17 +938,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -986,9 +960,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -998,9 +972,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -1010,9 +984,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -1022,9 +1002,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -1034,9 +1014,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -1046,9 +1026,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -1058,9 +1038,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winreg" @@ -1073,10 +1053,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ - "bitflags 2.4.2", + "bitflags", ] diff --git a/test-components/http-client-2/Cargo.toml b/test-components/http-client-2/Cargo.toml index cfce486136..8aee2a968a 100644 --- a/test-components/http-client-2/Cargo.toml +++ b/test-components/http-client-2/Cargo.toml @@ -13,14 +13,12 @@ opt-level = 's' strip = true [dependencies] -reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-apr-2024", features = [ +reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-jun-2024", features = [ "json", ] } -serde = { workspace = true } -serde_json = { workspace = true } -wit-bindgen = { version = "0.17.0", default-features = false, features = [ - "realloc", -] } +serde = { version = "1.0.203", features = ["derive"] } +serde_json = "1.0.117" +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component] package = "golem:it" diff --git a/test-components/http-client-2/src/bindings.rs b/test-components/http-client-2/src/bindings.rs index 58b888882d..70fe77f2c6 100644 --- a/test-components/http-client-2/src/bindings.rs +++ b/test-components/http-client-2/src/bindings.rs @@ -1,167 +1,203 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_start_polling_cabi(arg0: *mut u8, arg1: usize) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::start_polling(_rt::string_lift(bytes0)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_increment_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::increment(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_count_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_count(); + _rt::as_i64(result0) + } + pub trait Guest { + fn run() -> _rt::String; + fn start_polling(until: _rt::String); + fn increment(); + fn get_count() -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + #[export_name = "golem:it/api#start-polling"] + unsafe extern "C" fn export_start_polling(arg0: *mut u8,arg1: usize,) { + $($path_to_types)*::_export_start_polling_cabi::<$ty>(arg0, arg1) + } + #[export_name = "golem:it/api#increment"] + unsafe extern "C" fn export_increment() { + $($path_to_types)*::_export_increment_cabi::<$ty>() + } + #[export_name = "golem:it/api#get-count"] + unsafe extern "C" fn export_get_count() -> i64 { + $($path_to_types)*::_export_get_count_cabi::<$ty>() + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#start-polling"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_start_polling(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::start_polling(wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#increment"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_increment() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::increment(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-count"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_count() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_count(); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn run() -> wit_bindgen::rt::string::String; - fn start_polling(until: wit_bindgen::rt::string::String,); - fn increment(); - fn get_count() -> u64; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub use alloc_crate::alloc; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_http_client_test_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_http_client_test_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:http-client-test"] +#[link_section = "component-type:wit-bindgen:0.25.0:http-client-test:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 398] = [3, 0, 16, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 45, 116, 101, 115, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 104, 1, 65, 2, 1, 66, 8, 1, 64, 0, 0, 115, 4, 0, 3, 114, 117, 110, 1, 0, 1, 64, 1, 5, 117, 110, 116, 105, 108, 115, 1, 0, 4, 0, 13, 115, 116, 97, 114, 116, 45, 112, 111, 108, 108, 105, 110, 103, 1, 1, 1, 64, 0, 1, 0, 4, 0, 9, 105, 110, 99, 114, 101, 109, 101, 110, 116, 1, 2, 1, 64, 0, 0, 119, 4, 0, 9, 103, 101, 116, 45, 99, 111, 117, 110, 116, 1, 3, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 137, 1, 1, 65, 2, 1, 65, 2, 1, 66, 8, 1, 64, 0, 0, 115, 4, 0, 3, 114, 117, 110, 1, 0, 1, 64, 1, 5, 117, 110, 116, 105, 108, 115, 1, 0, 4, 0, 13, 115, 116, 97, 114, 116, 45, 112, 111, 108, 108, 105, 110, 103, 1, 1, 1, 64, 0, 1, 0, 4, 0, 9, 105, 110, 99, 114, 101, 109, 101, 110, 116, 1, 2, 1, 64, 0, 0, 119, 4, 0, 9, 103, 101, 116, 45, 99, 111, 117, 110, 116, 1, 3, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 25, 103, 111, 108, 101, 109, 58, 105, 116, 47, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 45, 116, 101, 115, 116, 4, 0, 11, 22, 1, 0, 16, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 45, 116, 101, 115, 116, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 272] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x89\x01\x01A\x02\x01\ +A\x02\x01B\x08\x01@\0\0s\x04\0\x03run\x01\0\x01@\x01\x05untils\x01\0\x04\0\x0dst\ +art-polling\x01\x01\x01@\0\x01\0\x04\0\x09increment\x01\x02\x01@\0\0w\x04\0\x09g\ +et-count\x01\x03\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x19golem:it/http-client-t\ +est\x04\0\x0b\x16\x01\0\x10http-client-test\x03\0\0\0G\x09producers\x01\x0cproce\ +ssed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/http-client-2/src/lib.rs b/test-components/http-client-2/src/lib.rs index f48278b813..6fd964142d 100644 --- a/test-components/http-client-2/src/lib.rs +++ b/test-components/http-client-2/src/lib.rs @@ -103,3 +103,5 @@ impl Guest for Component { with_state(|s| s.global) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/http-client.wasm b/test-components/http-client.wasm index 1699b97b57..ce5f18b9da 100755 Binary files a/test-components/http-client.wasm and b/test-components/http-client.wasm differ diff --git a/test-components/http-client/Cargo.lock b/test-components/http-client/Cargo.lock index 183059fae6..f2898b1957 100644 --- a/test-components/http-client/Cargo.lock +++ b/test-components/http-client/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-http-client" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/http-client/Cargo.toml b/test-components/http-client/Cargo.toml index abcdb63db6..bde4ced970 100644 --- a/test-components/http-client/Cargo.toml +++ b/test-components/http-client/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component] package = "golem:it" diff --git a/test-components/http-client/src/bindings.rs b/test-components/http-client/src/bindings.rs index 57206fe679..c4dc5c808f 100644 --- a/test-components/http-client/src/bindings.rs +++ b/test-components/http-client/src/bindings.rs @@ -1,3801 +1,4065 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the specified instant - /// occured. - pub fn subscribe_instant(when: Instant,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import(_: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. - pub fn subscribe_duration(when: Duration,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import(_: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "now"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "resolution"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the specified instant + /// occured. + pub fn subscribe_instant(when: Instant) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "subscribe-instant"] + fn wit_import(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + pub fn subscribe_duration(when: Duration) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "subscribe-duration"] + fn wit_import(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } } - } - } - - } - pub mod http { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type IoError = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// This type corresponds to HTTP standard Methods. - #[derive(Clone)] - pub enum Method{ - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(wit_bindgen::rt::string::String), - } - 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() - } - } - } - } - /// This type corresponds to HTTP standard Related Schemes. - #[derive(Clone)] - pub enum Scheme{ - Http, - Https, - Other(wit_bindgen::rt::string::String), - } - 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() - } - } - } - } - /// Defines the case payload type for `DNS-error` above: - #[derive(Clone)] - pub struct DnsErrorPayload { - pub rcode: Option, - pub info_code: Option, - } - impl ::core::fmt::Debug for DnsErrorPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DnsErrorPayload").field("rcode", &self.rcode).field("info-code", &self.info_code).finish() - } - } - /// Defines the case payload type for `TLS-alert-received` above: - #[derive(Clone)] - pub struct TlsAlertReceivedPayload { - pub alert_id: Option, - pub alert_message: Option, - } - impl ::core::fmt::Debug for TlsAlertReceivedPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("TlsAlertReceivedPayload").field("alert-id", &self.alert_id).field("alert-message", &self.alert_message).finish() - } - } - /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: - #[derive(Clone)] - pub struct FieldSizePayload { - pub field_name: Option, - pub field_size: Option, - } - impl ::core::fmt::Debug for FieldSizePayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FieldSizePayload").field("field-name", &self.field_name).field("field-size", &self.field_size).finish() - } - } - /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types - #[derive(Clone)] - pub enum ErrorCode{ - DnsTimeout, - DnsError(DnsErrorPayload), - DestinationNotFound, - DestinationUnavailable, - DestinationIpProhibited, - DestinationIpUnroutable, - ConnectionRefused, - ConnectionTerminated, - ConnectionTimeout, - ConnectionReadTimeout, - ConnectionWriteTimeout, - ConnectionLimitReached, - TlsProtocolError, - TlsCertificateError, - TlsAlertReceived(TlsAlertReceivedPayload), - HttpRequestDenied, - HttpRequestLengthRequired, - HttpRequestBodySize(Option), - HttpRequestMethodInvalid, - HttpRequestUriInvalid, - HttpRequestUriTooLong, - HttpRequestHeaderSectionSize(Option), - HttpRequestHeaderSize(Option), - HttpRequestTrailerSectionSize(Option), - HttpRequestTrailerSize(FieldSizePayload), - HttpResponseIncomplete, - HttpResponseHeaderSectionSize(Option), - HttpResponseHeaderSize(FieldSizePayload), - HttpResponseBodySize(Option), - HttpResponseTrailerSectionSize(Option), - HttpResponseTrailerSize(FieldSizePayload), - HttpResponseTransferCoding(Option), - HttpResponseContentCoding(Option), - HttpResponseTimeout, - HttpUpgradeFailed, - HttpProtocolError, - LoopDetected, - ConfigurationError, - /// This is a catch-all error for anything that doesn't fit cleanly into a - /// more specific case. It also includes an optional string for an - /// unstructured description of the error. Users should not depend on the - /// string for diagnosing errors, as it's not required to be consistent - /// between implementations. - InternalError(Option), - } - impl ::core::fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - ErrorCode::DnsTimeout => { - f.debug_tuple("ErrorCode::DnsTimeout").finish() - } - ErrorCode::DnsError(e) => { - f.debug_tuple("ErrorCode::DnsError").field(e).finish() - } - ErrorCode::DestinationNotFound => { - f.debug_tuple("ErrorCode::DestinationNotFound").finish() - } - ErrorCode::DestinationUnavailable => { - f.debug_tuple("ErrorCode::DestinationUnavailable").finish() - } - ErrorCode::DestinationIpProhibited => { - f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() - } - ErrorCode::DestinationIpUnroutable => { - f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() - } - ErrorCode::ConnectionRefused => { - f.debug_tuple("ErrorCode::ConnectionRefused").finish() - } - ErrorCode::ConnectionTerminated => { - f.debug_tuple("ErrorCode::ConnectionTerminated").finish() - } - ErrorCode::ConnectionTimeout => { - f.debug_tuple("ErrorCode::ConnectionTimeout").finish() - } - ErrorCode::ConnectionReadTimeout => { - f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() - } - ErrorCode::ConnectionWriteTimeout => { - f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() - } - ErrorCode::ConnectionLimitReached => { - f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() - } - ErrorCode::TlsProtocolError => { - f.debug_tuple("ErrorCode::TlsProtocolError").finish() - } - ErrorCode::TlsCertificateError => { - f.debug_tuple("ErrorCode::TlsCertificateError").finish() - } - ErrorCode::TlsAlertReceived(e) => { - f.debug_tuple("ErrorCode::TlsAlertReceived").field(e).finish() - } - ErrorCode::HttpRequestDenied => { - f.debug_tuple("ErrorCode::HttpRequestDenied").finish() - } - ErrorCode::HttpRequestLengthRequired => { - f.debug_tuple("ErrorCode::HttpRequestLengthRequired").finish() - } - ErrorCode::HttpRequestBodySize(e) => { - f.debug_tuple("ErrorCode::HttpRequestBodySize").field(e).finish() - } - ErrorCode::HttpRequestMethodInvalid => { - f.debug_tuple("ErrorCode::HttpRequestMethodInvalid").finish() - } - ErrorCode::HttpRequestUriInvalid => { - f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() + #[allow(dead_code)] + pub mod http { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type IoError = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// This type corresponds to HTTP standard Methods. + #[derive(Clone)] + pub enum Method { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(_rt::String), + } + 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(), + } + } } - ErrorCode::HttpRequestUriTooLong => { - f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() + /// This type corresponds to HTTP standard Related Schemes. + #[derive(Clone)] + pub enum Scheme { + Http, + Https, + Other(_rt::String), + } + 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(), + } + } } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize").field(e).finish() + /// Defines the case payload type for `DNS-error` above: + #[derive(Clone)] + pub struct DnsErrorPayload { + pub rcode: Option<_rt::String>, + pub info_code: Option, + } + impl ::core::fmt::Debug for DnsErrorPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DnsErrorPayload") + .field("rcode", &self.rcode) + .field("info-code", &self.info_code) + .finish() + } } - ErrorCode::HttpRequestHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSize").field(e).finish() + /// Defines the case payload type for `TLS-alert-received` above: + #[derive(Clone)] + pub struct TlsAlertReceivedPayload { + pub alert_id: Option, + pub alert_message: Option<_rt::String>, + } + impl ::core::fmt::Debug for TlsAlertReceivedPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TlsAlertReceivedPayload") + .field("alert-id", &self.alert_id) + .field("alert-message", &self.alert_message) + .finish() + } } - ErrorCode::HttpRequestTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSectionSize").field(e).finish() + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + #[derive(Clone)] + pub struct FieldSizePayload { + pub field_name: Option<_rt::String>, + pub field_size: Option, + } + impl ::core::fmt::Debug for FieldSizePayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FieldSizePayload") + .field("field-name", &self.field_name) + .field("field-size", &self.field_size) + .finish() + } } - ErrorCode::HttpRequestTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSize").field(e).finish() + /// These cases are inspired by the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + #[derive(Clone)] + pub enum ErrorCode { + DnsTimeout, + DnsError(DnsErrorPayload), + DestinationNotFound, + DestinationUnavailable, + DestinationIpProhibited, + DestinationIpUnroutable, + ConnectionRefused, + ConnectionTerminated, + ConnectionTimeout, + ConnectionReadTimeout, + ConnectionWriteTimeout, + ConnectionLimitReached, + TlsProtocolError, + TlsCertificateError, + TlsAlertReceived(TlsAlertReceivedPayload), + HttpRequestDenied, + HttpRequestLengthRequired, + HttpRequestBodySize(Option), + HttpRequestMethodInvalid, + HttpRequestUriInvalid, + HttpRequestUriTooLong, + HttpRequestHeaderSectionSize(Option), + HttpRequestHeaderSize(Option), + HttpRequestTrailerSectionSize(Option), + HttpRequestTrailerSize(FieldSizePayload), + HttpResponseIncomplete, + HttpResponseHeaderSectionSize(Option), + HttpResponseHeaderSize(FieldSizePayload), + HttpResponseBodySize(Option), + HttpResponseTrailerSectionSize(Option), + HttpResponseTrailerSize(FieldSizePayload), + HttpResponseTransferCoding(Option<_rt::String>), + HttpResponseContentCoding(Option<_rt::String>), + HttpResponseTimeout, + HttpUpgradeFailed, + HttpProtocolError, + LoopDetected, + ConfigurationError, + /// This is a catch-all error for anything that doesn't fit cleanly into a + /// more specific case. It also includes an optional string for an + /// unstructured description of the error. Users should not depend on the + /// string for diagnosing errors, as it's not required to be consistent + /// between implementations. + InternalError(Option<_rt::String>), + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + ErrorCode::DnsTimeout => f.debug_tuple("ErrorCode::DnsTimeout").finish(), + ErrorCode::DnsError(e) => { + f.debug_tuple("ErrorCode::DnsError").field(e).finish() + } + ErrorCode::DestinationNotFound => { + f.debug_tuple("ErrorCode::DestinationNotFound").finish() + } + ErrorCode::DestinationUnavailable => { + f.debug_tuple("ErrorCode::DestinationUnavailable").finish() + } + ErrorCode::DestinationIpProhibited => { + f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() + } + ErrorCode::DestinationIpUnroutable => { + f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() + } + ErrorCode::ConnectionRefused => { + f.debug_tuple("ErrorCode::ConnectionRefused").finish() + } + ErrorCode::ConnectionTerminated => { + f.debug_tuple("ErrorCode::ConnectionTerminated").finish() + } + ErrorCode::ConnectionTimeout => { + f.debug_tuple("ErrorCode::ConnectionTimeout").finish() + } + ErrorCode::ConnectionReadTimeout => { + f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() + } + ErrorCode::ConnectionWriteTimeout => { + f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() + } + ErrorCode::ConnectionLimitReached => { + f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() + } + ErrorCode::TlsProtocolError => { + f.debug_tuple("ErrorCode::TlsProtocolError").finish() + } + ErrorCode::TlsCertificateError => { + f.debug_tuple("ErrorCode::TlsCertificateError").finish() + } + ErrorCode::TlsAlertReceived(e) => f + .debug_tuple("ErrorCode::TlsAlertReceived") + .field(e) + .finish(), + ErrorCode::HttpRequestDenied => { + f.debug_tuple("ErrorCode::HttpRequestDenied").finish() + } + ErrorCode::HttpRequestLengthRequired => f + .debug_tuple("ErrorCode::HttpRequestLengthRequired") + .finish(), + ErrorCode::HttpRequestBodySize(e) => f + .debug_tuple("ErrorCode::HttpRequestBodySize") + .field(e) + .finish(), + ErrorCode::HttpRequestMethodInvalid => f + .debug_tuple("ErrorCode::HttpRequestMethodInvalid") + .finish(), + ErrorCode::HttpRequestUriInvalid => { + f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() + } + ErrorCode::HttpRequestUriTooLong => { + f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() + } + ErrorCode::HttpRequestHeaderSectionSize(e) => f + .debug_tuple("ErrorCode::HttpRequestHeaderSectionSize") + .field(e) + .finish(), + ErrorCode::HttpRequestHeaderSize(e) => f + .debug_tuple("ErrorCode::HttpRequestHeaderSize") + .field(e) + .finish(), + ErrorCode::HttpRequestTrailerSectionSize(e) => f + .debug_tuple("ErrorCode::HttpRequestTrailerSectionSize") + .field(e) + .finish(), + ErrorCode::HttpRequestTrailerSize(e) => f + .debug_tuple("ErrorCode::HttpRequestTrailerSize") + .field(e) + .finish(), + ErrorCode::HttpResponseIncomplete => { + f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() + } + ErrorCode::HttpResponseHeaderSectionSize(e) => f + .debug_tuple("ErrorCode::HttpResponseHeaderSectionSize") + .field(e) + .finish(), + ErrorCode::HttpResponseHeaderSize(e) => f + .debug_tuple("ErrorCode::HttpResponseHeaderSize") + .field(e) + .finish(), + ErrorCode::HttpResponseBodySize(e) => f + .debug_tuple("ErrorCode::HttpResponseBodySize") + .field(e) + .finish(), + ErrorCode::HttpResponseTrailerSectionSize(e) => f + .debug_tuple("ErrorCode::HttpResponseTrailerSectionSize") + .field(e) + .finish(), + ErrorCode::HttpResponseTrailerSize(e) => f + .debug_tuple("ErrorCode::HttpResponseTrailerSize") + .field(e) + .finish(), + ErrorCode::HttpResponseTransferCoding(e) => f + .debug_tuple("ErrorCode::HttpResponseTransferCoding") + .field(e) + .finish(), + ErrorCode::HttpResponseContentCoding(e) => f + .debug_tuple("ErrorCode::HttpResponseContentCoding") + .field(e) + .finish(), + ErrorCode::HttpResponseTimeout => { + f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() + } + ErrorCode::HttpUpgradeFailed => { + f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() + } + ErrorCode::HttpProtocolError => { + f.debug_tuple("ErrorCode::HttpProtocolError").finish() + } + ErrorCode::LoopDetected => { + f.debug_tuple("ErrorCode::LoopDetected").finish() + } + ErrorCode::ConfigurationError => { + f.debug_tuple("ErrorCode::ConfigurationError").finish() + } + ErrorCode::InternalError(e) => { + f.debug_tuple("ErrorCode::InternalError").field(e).finish() + } + } + } } - ErrorCode::HttpResponseIncomplete => { - f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSectionSize").field(e).finish() + + impl std::error::Error for ErrorCode {} + /// This type enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + #[derive(Clone, Copy)] + pub enum HeaderError { + /// This error indicates that a `field-key` or `field-value` was + /// syntactically invalid when used with an operation that sets headers in a + /// `fields`. + InvalidSyntax, + /// This error indicates that a forbidden `field-key` was used when trying + /// to set a header in a `fields`. + Forbidden, + /// This error indicates that the operation on the `fields` was not + /// permitted because the fields are immutable. + Immutable, + } + impl ::core::fmt::Debug for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + HeaderError::InvalidSyntax => { + f.debug_tuple("HeaderError::InvalidSyntax").finish() + } + HeaderError::Forbidden => f.debug_tuple("HeaderError::Forbidden").finish(), + HeaderError::Immutable => f.debug_tuple("HeaderError::Immutable").finish(), + } + } } - ErrorCode::HttpResponseHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSize").field(e).finish() + impl ::core::fmt::Display for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - ErrorCode::HttpResponseBodySize(e) => { - f.debug_tuple("ErrorCode::HttpResponseBodySize").field(e).finish() + + impl std::error::Error for HeaderError {} + /// Field keys are always strings. + pub type FieldKey = _rt::String; + /// Field values should always be ASCII strings. However, in + /// reality, HTTP implementations often have to interpret malformed values, + /// so they are provided as a list of bytes. + pub type FieldValue = _rt::Vec; + /// This following block defines the `fields` resource which corresponds to + /// HTTP standard Fields. Fields are a common representation used for both + /// Headers and Trailers. + /// + /// A `fields` may be mutable or immutable. A `fields` created using the + /// constructor, `from-list`, or `clone` will be mutable, but a `fields` + /// resource given by other means (including, but not limited to, + /// `incoming-request.headers`, `outgoing-request.headers`) might be be + /// immutable. In an immutable fields, the `set`, `append`, and `delete` + /// operations will fail with `header-error.immutable`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Fields { + handle: _rt::Resource, + } + + impl Fields { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - ErrorCode::HttpResponseTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSectionSize").field(e).finish() + + unsafe impl _rt::WasmResource for Fields { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]fields"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - ErrorCode::HttpResponseTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSize").field(e).finish() + + /// Headers is an alias for Fields. + pub type Headers = Fields; + /// Trailers is an alias for Fields. + pub type Trailers = Fields; + /// Represents an incoming HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingRequest { + handle: _rt::Resource, + } + + impl IncomingRequest { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - ErrorCode::HttpResponseTransferCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseTransferCoding").field(e).finish() + + unsafe impl _rt::WasmResource for IncomingRequest { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - ErrorCode::HttpResponseContentCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseContentCoding").field(e).finish() + + /// Represents an outgoing HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingRequest { + handle: _rt::Resource, } - ErrorCode::HttpResponseTimeout => { - f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() + + impl OutgoingRequest { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - ErrorCode::HttpUpgradeFailed => { - f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() + + unsafe impl _rt::WasmResource for OutgoingRequest { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - ErrorCode::HttpProtocolError => { - f.debug_tuple("ErrorCode::HttpProtocolError").finish() + + /// Parameters for making an HTTP Request. Each of these parameters is + /// currently an optional timeout applicable to the transport layer of the + /// HTTP protocol. + /// + /// These timeouts are separate from any the user may use to bound a + /// blocking call to `wasi:io/poll.poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct RequestOptions { + handle: _rt::Resource, + } + + impl RequestOptions { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - ErrorCode::LoopDetected => { - f.debug_tuple("ErrorCode::LoopDetected").finish() + + unsafe impl _rt::WasmResource for RequestOptions { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]request-options"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - ErrorCode::ConfigurationError => { - f.debug_tuple("ErrorCode::ConfigurationError").finish() + + /// Represents the ability to send an HTTP Response. + /// + /// This resource is used by the `wasi:http/incoming-handler` interface to + /// allow a Response to be sent corresponding to the Request provided as the + /// other argument to `incoming-handler.handle`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct ResponseOutparam { + handle: _rt::Resource, + } + + impl ResponseOutparam { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - ErrorCode::InternalError(e) => { - f.debug_tuple("ErrorCode::InternalError").field(e).finish() + + unsafe impl _rt::WasmResource for ResponseOutparam { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]response-outparam"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - } - } - } - impl ::core::fmt::Display for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for ErrorCode {} - /// This type enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. - #[derive(Clone, Copy)] - pub enum HeaderError{ - /// This error indicates that a `field-key` or `field-value` was - /// syntactically invalid when used with an operation that sets headers in a - /// `fields`. - InvalidSyntax, - /// This error indicates that a forbidden `field-key` was used when trying - /// to set a header in a `fields`. - Forbidden, - /// This error indicates that the operation on the `fields` was not - /// permitted because the fields are immutable. - Immutable, - } - impl ::core::fmt::Debug for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - HeaderError::InvalidSyntax => { - f.debug_tuple("HeaderError::InvalidSyntax").finish() - } - HeaderError::Forbidden => { - f.debug_tuple("HeaderError::Forbidden").finish() - } - HeaderError::Immutable => { - f.debug_tuple("HeaderError::Immutable").finish() - } - } - } - } - impl ::core::fmt::Display for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for HeaderError {} - /// Field keys are always strings. - pub type FieldKey = wit_bindgen::rt::string::String; - /// Field values should always be ASCII strings. However, in - /// reality, HTTP implementations often have to interpret malformed values, - /// so they are provided as a list of bytes. - pub type FieldValue = wit_bindgen::rt::vec::Vec::; - /// This following block defines the `fields` resource which corresponds to - /// HTTP standard Fields. Fields are a common representation used for both - /// Headers and Trailers. - /// - /// A `fields` may be mutable or immutable. A `fields` created using the - /// constructor, `from-list`, or `clone` will be mutable, but a `fields` - /// resource given by other means (including, but not limited to, - /// `incoming-request.headers`, `outgoing-request.headers`) might be be - /// immutable. In an immutable fields, the `set`, `append`, and `delete` - /// operations will fail with `header-error.immutable`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Fields{ - handle: wit_bindgen::rt::Resource, - } - - impl Fields{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Fields{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]fields"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Headers is an alias for Fields. - pub type Headers = Fields; - /// Trailers is an alias for Fields. - pub type Trailers = Fields; - /// Represents an incoming HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingRequest{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingRequest{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingRequest{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingRequest{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Parameters for making an HTTP Request. Each of these parameters is - /// currently an optional timeout applicable to the transport layer of the - /// HTTP protocol. - /// - /// These timeouts are separate from any the user may use to bound a - /// blocking call to `wasi:io/poll.poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct RequestOptions{ - handle: wit_bindgen::rt::Resource, - } - - impl RequestOptions{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for RequestOptions{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]request-options"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents the ability to send an HTTP Response. - /// - /// This resource is used by the `wasi:http/incoming-handler` interface to - /// allow a Response to be sent corresponding to the Request provided as the - /// other argument to `incoming-handler.handle`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct ResponseOutparam{ - handle: wit_bindgen::rt::Resource, - } - - impl ResponseOutparam{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for ResponseOutparam{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]response-outparam"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// This type corresponds to the HTTP standard Status Code. - pub type StatusCode = u16; - /// Represents an incoming HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an incoming HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, indicating that the full contents of the - /// body have been received. This resource represents the contents as - /// an `input-stream` and the delivery of trailers as a `future-trailers`, - /// and ensures that the user of this interface may only be consuming either - /// the body contents or waiting on trailers at any given time. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingBody{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingBody{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return trailers, or an error. - /// - /// In the case that the incoming HTTP Request or Response did not have any - /// trailers, this future will resolve to the empty set of trailers once the - /// complete Request or Response body has been received. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureTrailers{ - handle: wit_bindgen::rt::Resource, - } - - impl FutureTrailers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for FutureTrailers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-trailers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, inducating the full contents of the body - /// have been sent. This resource represents the contents as an - /// `output-stream` child resource, and the completion of the body (with - /// optional trailers) with a static function that consumes the - /// `outgoing-body` resource, and ensures that the user of this interface - /// may not write to the body contents after the body has been finished. - /// - /// If the user code drops this resource, as opposed to calling the static - /// method `finish`, the implementation should treat the body as incomplete, - /// and that an error has occured. The implementation should propogate this - /// error to the HTTP protocol by whatever means it has available, - /// including: corrupting the body on the wire, aborting the associated - /// Request, or sending a late status code for the Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingBody{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingBody{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return an incoming HTTP - /// Response, or an error. - /// - /// This resource is returned by the `wasi:http/outgoing-handler` interface to - /// provide the HTTP Response corresponding to the sent Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureIncomingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl FutureIncomingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for FutureIncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-incoming-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// Attempts to extract a http-related `error` from the wasi:io `error` - /// provided. - /// - /// Stream operations which return - /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of - /// type `wasi:io/error/error` with more information about the operation - /// that failed. This payload can be passed through to this function to see - /// if there's http-related information about the error to return. - /// - /// Note that this function is fallible because not all io-errors are - /// http-related errors. - pub fn http_error_code(err: &IoError,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "http-error-code"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((err).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - let v64 = match l2 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e64 = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - let l7 = i32::from(*((ptr0 + 28) as *const u8)); - - DnsErrorPayload{ - rcode: match l3 { - 0 => None, - 1 => { - let e = { - let l4 = *((ptr0 + 20) as *const i32); - let l5 = *((ptr0 + 24) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - info_code: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = i32::from(*((ptr0 + 30) as *const u16)); - - l8 as u16 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e64) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout - } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError - } - 14 => { - let e64 = { - let l9 = i32::from(*((ptr0 + 16) as *const u8)); - let l11 = i32::from(*((ptr0 + 20) as *const u8)); - - TlsAlertReceivedPayload{ - alert_id: match l9 { - 0 => None, - 1 => { - let e = { - let l10 = i32::from(*((ptr0 + 17) as *const u8)); - - l10 as u8 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - alert_message: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *((ptr0 + 24) as *const i32); - let l13 = *((ptr0 + 28) as *const i32); - let len14 = l13 as usize; - let bytes14 = Vec::from_raw_parts(l12 as *mut _, len14, len14); - - wit_bindgen::rt::string_lift(bytes14) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e64) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e64 = { - let l15 = i32::from(*((ptr0 + 16) as *const u8)); - - match l15 { - 0 => None, - 1 => { - let e = { - let l16 = *((ptr0 + 24) as *const i64); - - l16 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e64) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e64 = { - let l17 = i32::from(*((ptr0 + 16) as *const u8)); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *((ptr0 + 20) as *const i32); - - l18 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e64) - } - 22 => { - let e64 = { - let l19 = i32::from(*((ptr0 + 16) as *const u8)); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = i32::from(*((ptr0 + 20) as *const u8)); - let l24 = i32::from(*((ptr0 + 32) as *const u8)); - - FieldSizePayload{ - field_name: match l20 { - 0 => None, - 1 => { - let e = { - let l21 = *((ptr0 + 24) as *const i32); - let l22 = *((ptr0 + 28) as *const i32); - let len23 = l22 as usize; - let bytes23 = Vec::from_raw_parts(l21 as *mut _, len23, len23); - - wit_bindgen::rt::string_lift(bytes23) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l24 { - 0 => None, - 1 => { - let e = { - let l25 = *((ptr0 + 36) as *const i32); - - l25 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - Some(e) + + /// This type corresponds to the HTTP standard Status Code. + pub type StatusCode = u16; + /// Represents an incoming HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingResponse { + handle: _rt::Resource, + } + + impl IncomingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-response"] + fn drop(_: u32); } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e64) - } - 23 => { - let e64 = { - let l26 = i32::from(*((ptr0 + 16) as *const u8)); - - match l26 { - 0 => None, - 1 => { - let e = { - let l27 = *((ptr0 + 20) as *const i32); - - l27 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e64) - } - 24 => { - let e64 = { - let l28 = i32::from(*((ptr0 + 16) as *const u8)); - let l32 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *((ptr0 + 20) as *const i32); - let l30 = *((ptr0 + 24) as *const i32); - let len31 = l30 as usize; - let bytes31 = Vec::from_raw_parts(l29 as *mut _, len31, len31); - - wit_bindgen::rt::string_lift(bytes31) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *((ptr0 + 32) as *const i32); - - l33 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e64) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e64 = { - let l34 = i32::from(*((ptr0 + 16) as *const u8)); - - match l34 { + + drop(_handle); + } + } + } + + /// Represents an incoming HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, indicating that the full contents of the + /// body have been received. This resource represents the contents as + /// an `input-stream` and the delivery of trailers as a `future-trailers`, + /// and ensures that the user of this interface may only be consuming either + /// the body contents or waiting on trailers at any given time. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingBody { + handle: _rt::Resource, + } + + impl IncomingBody { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingBody { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return trailers, or an error. + /// + /// In the case that the incoming HTTP Request or Response did not have any + /// trailers, this future will resolve to the empty set of trailers once the + /// complete Request or Response body has been received. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureTrailers { + handle: _rt::Resource, + } + + impl FutureTrailers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for FutureTrailers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-trailers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingResponse { + handle: _rt::Resource, + } + + impl OutgoingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, inducating the full contents of the body + /// have been sent. This resource represents the contents as an + /// `output-stream` child resource, and the completion of the body (with + /// optional trailers) with a static function that consumes the + /// `outgoing-body` resource, and ensures that the user of this interface + /// may not write to the body contents after the body has been finished. + /// + /// If the user code drops this resource, as opposed to calling the static + /// method `finish`, the implementation should treat the body as incomplete, + /// and that an error has occured. The implementation should propogate this + /// error to the HTTP protocol by whatever means it has available, + /// including: corrupting the body on the wire, aborting the associated + /// Request, or sending a late status code for the Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingBody { + handle: _rt::Resource, + } + + impl OutgoingBody { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingBody { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return an incoming HTTP + /// Response, or an error. + /// + /// This resource is returned by the `wasi:http/outgoing-handler` interface to + /// provide the HTTP Response corresponding to the sent Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureIncomingResponse { + handle: _rt::Resource, + } + + impl FutureIncomingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for FutureIncomingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-incoming-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Attempts to extract a http-related `error` from the wasi:io `error` + /// provided. + /// + /// Stream operations which return + /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of + /// type `wasi:io/error/error` with more information about the operation + /// that failed. This payload can be passed through to this function to see + /// if there's http-related information about the error to return. + /// + /// Note that this function is fallible because not all io-errors are + /// http-related errors. + pub fn http_error_code(err: &IoError) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "http-error-code"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((err).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => None, 1 => { - let e = { - let l35 = *((ptr0 + 20) as *const i32); - - l35 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e64) - } - 27 => { - let e64 = { - let l36 = i32::from(*((ptr0 + 16) as *const u8)); - let l40 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *((ptr0 + 20) as *const i32); - let l38 = *((ptr0 + 24) as *const i32); - let len39 = l38 as usize; - let bytes39 = Vec::from_raw_parts(l37 as *mut _, len39, len39); - - wit_bindgen::rt::string_lift(bytes39) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l40 { - 0 => None, - 1 => { let e = { - let l41 = *((ptr0 + 32) as *const i32); - - l41 as u32 + let l2 = i32::from(*ptr0.add(8).cast::()); + let v64 = match l2 { + 0 => ErrorCode::DnsTimeout, + 1 => { + let e64 = { + let l3 = i32::from(*ptr0.add(16).cast::()); + let l7 = i32::from(*ptr0.add(28).cast::()); + + DnsErrorPayload { + rcode: match l3 { + 0 => None, + 1 => { + let e = { + let l4 = + *ptr0.add(20).cast::<*mut u8>(); + let l5 = *ptr0.add(24).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, + ); + + _rt::string_lift(bytes6) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = i32::from( + *ptr0.add(30).cast::(), + ); + + l8 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e64) + } + 2 => ErrorCode::DestinationNotFound, + 3 => ErrorCode::DestinationUnavailable, + 4 => ErrorCode::DestinationIpProhibited, + 5 => ErrorCode::DestinationIpUnroutable, + 6 => ErrorCode::ConnectionRefused, + 7 => ErrorCode::ConnectionTerminated, + 8 => ErrorCode::ConnectionTimeout, + 9 => ErrorCode::ConnectionReadTimeout, + 10 => ErrorCode::ConnectionWriteTimeout, + 11 => ErrorCode::ConnectionLimitReached, + 12 => ErrorCode::TlsProtocolError, + 13 => ErrorCode::TlsCertificateError, + 14 => { + let e64 = { + let l9 = i32::from(*ptr0.add(16).cast::()); + let l11 = i32::from(*ptr0.add(20).cast::()); + + TlsAlertReceivedPayload { + alert_id: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = i32::from( + *ptr0.add(17).cast::(), + ); + + l10 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = + *ptr0.add(24).cast::<*mut u8>(); + let l13 = *ptr0.add(28).cast::(); + let len14 = l13; + let bytes14 = _rt::Vec::from_raw_parts( + l12.cast(), + len14, + len14, + ); + + _rt::string_lift(bytes14) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e64) + } + 15 => ErrorCode::HttpRequestDenied, + 16 => ErrorCode::HttpRequestLengthRequired, + 17 => { + let e64 = { + let l15 = i32::from(*ptr0.add(16).cast::()); + + match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *ptr0.add(24).cast::(); + + l16 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e64) + } + 18 => ErrorCode::HttpRequestMethodInvalid, + 19 => ErrorCode::HttpRequestUriInvalid, + 20 => ErrorCode::HttpRequestUriTooLong, + 21 => { + let e64 = { + let l17 = i32::from(*ptr0.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr0.add(20).cast::(); + + l18 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e64) + } + 22 => { + let e64 = { + let l19 = i32::from(*ptr0.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = + i32::from(*ptr0.add(20).cast::()); + let l24 = + i32::from(*ptr0.add(32).cast::()); + + FieldSizePayload { + field_name: match l20 { + 0 => None, + 1 => { + let e = { + let l21 = *ptr0 + .add(24) + .cast::<*mut u8>( + ); + let l22 = *ptr0 + .add(28) + .cast::(); + let len23 = l22; + let bytes23 = _rt::Vec::from_raw_parts(l21.cast(), len23, len23); + + _rt::string_lift(bytes23) + }; + Some(e) + } + _ => { + _rt::invalid_enum_discriminant() + } + }, + field_size: match l24 { + 0 => None, + 1 => { + let e = { + let l25 = *ptr0 + .add(36) + .cast::(); + + l25 as u32 + }; + Some(e) + } + _ => { + _rt::invalid_enum_discriminant() + } + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e64) + } + 23 => { + let e64 = { + let l26 = i32::from(*ptr0.add(16).cast::()); + + match l26 { + 0 => None, + 1 => { + let e = { + let l27 = *ptr0.add(20).cast::(); + + l27 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e64) + } + 24 => { + let e64 = { + let l28 = i32::from(*ptr0.add(16).cast::()); + let l32 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l28 { + 0 => None, + 1 => { + let e = { + let l29 = + *ptr0.add(20).cast::<*mut u8>(); + let l30 = *ptr0.add(24).cast::(); + let len31 = l30; + let bytes31 = _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ); + + _rt::string_lift(bytes31) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l32 { + 0 => None, + 1 => { + let e = { + let l33 = *ptr0.add(32).cast::(); + + l33 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e64) + } + 25 => ErrorCode::HttpResponseIncomplete, + 26 => { + let e64 = { + let l34 = i32::from(*ptr0.add(16).cast::()); + + match l34 { + 0 => None, + 1 => { + let e = { + let l35 = *ptr0.add(20).cast::(); + + l35 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e64) + } + 27 => { + let e64 = { + let l36 = i32::from(*ptr0.add(16).cast::()); + let l40 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l36 { + 0 => None, + 1 => { + let e = { + let l37 = + *ptr0.add(20).cast::<*mut u8>(); + let l38 = *ptr0.add(24).cast::(); + let len39 = l38; + let bytes39 = _rt::Vec::from_raw_parts( + l37.cast(), + len39, + len39, + ); + + _rt::string_lift(bytes39) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l40 { + 0 => None, + 1 => { + let e = { + let l41 = *ptr0.add(32).cast::(); + + l41 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e64) + } + 28 => { + let e64 = { + let l42 = i32::from(*ptr0.add(16).cast::()); + + match l42 { + 0 => None, + 1 => { + let e = { + let l43 = *ptr0.add(24).cast::(); + + l43 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e64) + } + 29 => { + let e64 = { + let l44 = i32::from(*ptr0.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr0.add(20).cast::(); + + l45 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e64) + } + 30 => { + let e64 = { + let l46 = i32::from(*ptr0.add(16).cast::()); + let l50 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l46 { + 0 => None, + 1 => { + let e = { + let l47 = + *ptr0.add(20).cast::<*mut u8>(); + let l48 = *ptr0.add(24).cast::(); + let len49 = l48; + let bytes49 = _rt::Vec::from_raw_parts( + l47.cast(), + len49, + len49, + ); + + _rt::string_lift(bytes49) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l50 { + 0 => None, + 1 => { + let e = { + let l51 = *ptr0.add(32).cast::(); + + l51 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e64) + } + 31 => { + let e64 = { + let l52 = i32::from(*ptr0.add(16).cast::()); + + match l52 { + 0 => None, + 1 => { + let e = { + let l53 = *ptr0.add(20).cast::<*mut u8>(); + let l54 = *ptr0.add(24).cast::(); + let len55 = l54; + let bytes55 = _rt::Vec::from_raw_parts( + l53.cast(), + len55, + len55, + ); + + _rt::string_lift(bytes55) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e64) + } + 32 => { + let e64 = { + let l56 = i32::from(*ptr0.add(16).cast::()); + + match l56 { + 0 => None, + 1 => { + let e = { + let l57 = *ptr0.add(20).cast::<*mut u8>(); + let l58 = *ptr0.add(24).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e64) + } + 33 => ErrorCode::HttpResponseTimeout, + 34 => ErrorCode::HttpUpgradeFailed, + 35 => ErrorCode::HttpProtocolError, + 36 => ErrorCode::LoopDetected, + 37 => ErrorCode::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e64 = { + let l60 = i32::from(*ptr0.add(16).cast::()); + + match l60 { + 0 => None, + 1 => { + let e = { + let l61 = *ptr0.add(20).cast::<*mut u8>(); + let l62 = *ptr0.add(24).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts( + l61.cast(), + len63, + len63, + ); + + _rt::string_lift(bytes63) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e64) + } + }; + + v64 }; Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e64) - } - 28 => { - let e64 = { - let l42 = i32::from(*((ptr0 + 16) as *const u8)); - - match l42 { - 0 => None, - 1 => { - let e = { - let l43 = *((ptr0 + 24) as *const i64); - - l43 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e64) - } - 29 => { - let e64 = { - let l44 = i32::from(*((ptr0 + 16) as *const u8)); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *((ptr0 + 20) as *const i32); - - l45 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e64) - } - 30 => { - let e64 = { - let l46 = i32::from(*((ptr0 + 16) as *const u8)); - let l50 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *((ptr0 + 20) as *const i32); - let l48 = *((ptr0 + 24) as *const i32); - let len49 = l48 as usize; - let bytes49 = Vec::from_raw_parts(l47 as *mut _, len49, len49); - - wit_bindgen::rt::string_lift(bytes49) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an empty HTTP Fields. + /// + /// The resulting `fields` is mutable. + pub fn new() -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]fields"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + Fields::from_handle(ret as u32) + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an HTTP Fields. + /// + /// The resulting `fields` is mutable. + /// + /// The list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + /// + /// The tuple is a pair of the field key, represented as a string, and + /// Value, represented as a list of bytes. In a valid Fields, all keys + /// and values are valid UTF-8 strings. However, values are not always + /// well-formed, so they are represented as a raw list of bytes. + /// + /// An error result will be returned if any header or value was + /// syntactically invalid, or if a header was forbidden. + pub fn from_list( + entries: &[(FieldKey, FieldValue)], + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec3 = entries; + let len3 = vec3.len(); + let layout3 = + _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 16); + { + let (t0_0, t0_1) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + let vec2 = t0_1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]fields.from-list"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result3, len3, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + if layout3.size() != 0 { + _rt::alloc::dealloc(result3.cast(), layout3); + } + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::(); + + Fields::from_handle(l6 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr4.add(4).cast::()); + let v8 = match l7 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v8 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Get all of the values corresponding to a key. If the key is not present + /// in this `fields`, an empty list is returned. However, if the key is + /// present but empty, this is represented by a list with one or more + /// empty field-values present. + pub fn get(&self, name: &FieldKey) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.get"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l50 { - 0 => None, - 1 => { - let e = { - let l51 = *((ptr0 + 32) as *const i32); - - l51 as u32 + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + result7 + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Returns `true` when the key is present in this `fields`. If the key is + /// syntactically invalid, `false` is returned. + pub fn has(&self, name: &FieldKey) -> bool { + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.has"] + fn wit_import(_: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); + _rt::bool_lift(ret as u8) + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Set all of the values for a key. Clears any existing values for that + /// key, if they have been set. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn set( + &self, + name: &FieldKey, + value: &[FieldValue], + ) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec2 = value; + let len2 = vec2.len(); + let layout2 = + _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + } + } + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.set"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result2, + len2, + ptr3, + ); + let l4 = i32::from(*ptr3.add(0).cast::()); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(1).cast::()); + let v6 = match l5 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v6 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Delete all values for a key. Does nothing if no values for the key + /// exist. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn delete(&self, name: &FieldKey) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.delete"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + let v4 = match l3 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Append a value for a key. Does not change or delete any existing + /// values for that key. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn append( + &self, + name: &FieldKey, + value: &FieldValue, + ) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = value; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.append"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + let v5 = match l4 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Retrieve the full set of keys and values in the Fields. Like the + /// constructor, the list represents each key-value pair. + /// + /// The outer list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + pub fn entries(&self) -> _rt::Vec<(FieldKey, FieldValue)> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.entries"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base9 = l1; + let len9 = l2; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 16); + let e9 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let len8 = l7; + + ( + _rt::string_lift(bytes5), + _rt::Vec::from_raw_parts(l6.cast(), len8, len8), + ) }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e64) - } - 31 => { - let e64 = { - let l52 = i32::from(*((ptr0 + 16) as *const u8)); - - match l52 { - 0 => None, - 1 => { - let e = { - let l53 = *((ptr0 + 20) as *const i32); - let l54 = *((ptr0 + 24) as *const i32); - let len55 = l54 as usize; - let bytes55 = Vec::from_raw_parts(l53 as *mut _, len55, len55); - - wit_bindgen::rt::string_lift(bytes55) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e64) - } - 32 => { - let e64 = { - let l56 = i32::from(*((ptr0 + 16) as *const u8)); - - match l56 { - 0 => None, - 1 => { - let e = { - let l57 = *((ptr0 + 20) as *const i32); - let l58 = *((ptr0 + 24) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e64) - } - 33 => { - ErrorCode::HttpResponseTimeout - } - 34 => { - ErrorCode::HttpUpgradeFailed - } - 35 => { - ErrorCode::HttpProtocolError - } - 36 => { - ErrorCode::LoopDetected - } - 37 => { - ErrorCode::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e64 = { - let l60 = i32::from(*((ptr0 + 16) as *const u8)); - - match l60 { - 0 => None, - 1 => { - let e = { - let l61 = *((ptr0 + 20) as *const i32); - let l62 = *((ptr0 + 24) as *const i32); - let len63 = l62 as usize; - let bytes63 = Vec::from_raw_parts(l61 as *mut _, len63, len63); - - wit_bindgen::rt::string_lift(bytes63) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e64) - } - }; - - v64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an empty HTTP Fields. - /// - /// The resulting `fields` is mutable. - pub fn new() -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]fields"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - Fields::from_handle(ret as u32) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an HTTP Fields. - /// - /// The resulting `fields` is mutable. - /// - /// The list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - /// - /// The tuple is a pair of the field key, represented as a string, and - /// Value, represented as a list of bytes. In a valid Fields, all keys - /// and values are valid UTF-8 strings. However, values are not always - /// well-formed, so they are represented as a raw list of bytes. - /// - /// An error result will be returned if any header or value was - /// syntactically invalid, or if a header was forbidden. - pub fn from_list(entries: &[(FieldKey,FieldValue,)],) -> 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 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; - } - } - let ptr4 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]fields.from-list"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result3 as i32, len3, ptr4); - let l5 = i32::from(*((ptr4 + 0) as *const u8)); - if layout3.size() != 0 { - alloc::dealloc(result3, layout3); - } - match l5 { - 0 => { - let e = { - let l6 = *((ptr4 + 4) as *const i32); - - Fields::from_handle(l6 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*((ptr4 + 4) as *const u8)); - let v8 = match l7 { - 0 => { - HeaderError::InvalidSyntax + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 16, 4); + result9 + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Make a deep copy of the Fields. Equivelant in behavior to calling the + /// `fields` constructor on the return value of `entries`. The resulting + /// `fields` is mutable. + pub fn clone(&self) -> Fields { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.clone"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the method of the incoming request. + pub fn method(&self) -> Method { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.method"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + let v5 = match l1 { + 0 => Method::Get, + 1 => Method::Head, + 2 => Method::Post, + 3 => Method::Put, + 4 => Method::Delete, + 5 => Method::Connect, + 6 => Method::Options, + 7 => Method::Trace, + 8 => Method::Patch, + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) + } + }; + v5 + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the path with query parameters from the request, as a string. + pub fn path_with_query(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.path-with-query"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the protocol scheme from the request. + pub fn scheme(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.scheme"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v6 = match l2 { + 0 => Scheme::Http, + 1 => Scheme::Https, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = + _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Scheme::Other(e6) + } + }; + + v6 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the authority from the request, if it was present. + pub fn authority(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.authority"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - 1 => { - HeaderError::Forbidden + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the `headers` associated with the request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// The `headers` returned are a child resource: it must be dropped before + /// the parent `incoming-request` is dropped. Dropping this + /// `incoming-request` before all children are dropped will trap. + pub fn headers(&self) -> Headers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.headers"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Gives the `incoming-body` associated with this request. Will only + /// return success at most once, and subsequent calls will return error. + pub fn consume(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.consume"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Construct a new `outgoing-request` with a default `method` of `GET`, and + /// `none` values for `path-with-query`, `scheme`, and `authority`. + /// + /// * `headers` is the HTTP Headers for the Request. + /// + /// It is possible to construct, or manipulate with the accessor functions + /// below, an `outgoing-request` with an invalid combination of `scheme` + /// and `authority`, or `headers` which are not permitted to be sent. + /// It is the obligation of the `outgoing-handler.handle` implementation + /// to reject invalid constructions of `outgoing-request`. + pub fn new(headers: Headers) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-request"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingRequest::from_handle(ret as u32) + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this + /// Request. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-request` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.body"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the Method for the Request. + pub fn method(&self) -> Method { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.method"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + let v5 = match l1 { + 0 => Method::Get, + 1 => Method::Head, + 2 => Method::Post, + 3 => Method::Put, + 4 => Method::Delete, + 5 => Method::Connect, + 6 => Method::Options, + 7 => Method::Trace, + 8 => Method::Patch, + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) + } + }; + v5 + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the Method for the Request. Fails if the string present in a + /// `method.other` argument is not a syntactically valid method. + pub fn set_method(&self, method: &Method) -> Result<(), ()> { + unsafe { + let (result1_0, result1_1, result1_2) = match method { + Method::Get => (0i32, ::core::ptr::null_mut(), 0usize), + Method::Head => (1i32, ::core::ptr::null_mut(), 0usize), + Method::Post => (2i32, ::core::ptr::null_mut(), 0usize), + Method::Put => (3i32, ::core::ptr::null_mut(), 0usize), + Method::Delete => (4i32, ::core::ptr::null_mut(), 0usize), + Method::Connect => (5i32, ::core::ptr::null_mut(), 0usize), + Method::Options => (6i32, ::core::ptr::null_mut(), 0usize), + Method::Trace => (7i32, ::core::ptr::null_mut(), 0usize), + Method::Patch => (8i32, ::core::ptr::null_mut(), 0usize), + Method::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (9i32, ptr0.cast_mut(), len0) + } + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-method"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. + pub fn path_with_query(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.path-with-query"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. Fails is the + /// string given is not a syntactically valid path and query uri component. + pub fn set_path_with_query(&self, path_with_query: Option<&str>) -> Result<(), ()> { + unsafe { + let (result1_0, result1_1, result1_2) = match path_with_query { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-path-with-query"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. + pub fn scheme(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.scheme"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v6 = match l2 { + 0 => Scheme::Http, + 1 => Scheme::Https, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = + _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Scheme::Other(e6) + } + }; + + v6 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. Fails if the + /// string given is not a syntactically valid uri scheme. + pub fn set_scheme(&self, scheme: Option<&Scheme>) -> Result<(), ()> { + unsafe { + let (result2_0, result2_1, result2_2, result2_3) = match scheme { + Some(e) => { + let (result1_0, result1_1, result1_2) = match e { + Scheme::Http => (0i32, ::core::ptr::null_mut(), 0usize), + Scheme::Https => (1i32, ::core::ptr::null_mut(), 0usize), + Scheme::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (2i32, ptr0.cast_mut(), len0) + } + }; + + (1i32, result1_0, result1_1, result1_2) + } + None => (0i32, 0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-scheme"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + result2_0, + result2_1, + result2_2, + result2_3, + ); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. + pub fn authority(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.authority"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. Fails if the string given is + /// not a syntactically valid uri authority. + pub fn set_authority(&self, authority: Option<&str>) -> Result<(), ()> { + unsafe { + let (result1_0, result1_1, result1_2) = match authority { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-authority"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v8 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Get all of the values corresponding to a key. If the key is not present - /// in this `fields`, an empty list is returned. However, if the key is - /// present but empty, this is represented by a list with one or more - /// empty field-values present. - pub fn get(&self,name: &FieldKey,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.get"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let base7 = l2; - let len7 = l3; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 8; - let e7 = { - let l4 = *((base + 0) as *const i32); - let l5 = *((base + 4) as *const i32); - let len6 = l5 as usize; - - Vec::from_raw_parts(l4 as *mut _, len6, len6) - }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 8, 4); - result7 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Returns `true` when the key is present in this `fields`. If the key is - /// syntactically invalid, `false` is returned. - pub fn has(&self,name: &FieldKey,) -> bool{ - - #[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; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.has"] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0, len0); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Set all of the values for a key. Clears any existing values for that - /// key, if they have been set. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn set(&self,name: &FieldKey,value: &[FieldValue],) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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 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; - } - } - let ptr3 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result2 as i32, len2, ptr3); - let l4 = i32::from(*((ptr3 + 0) as *const u8)); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr3 + 1) as *const u8)); - let v6 = match l5 { - 0 => { - HeaderError::InvalidSyntax + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self) -> Headers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.headers"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) } - 1 => { - HeaderError::Forbidden + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Construct a default `request-options` value. + pub fn new() -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]request-options"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + RequestOptions::from_handle(ret as u32) } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for the initial connect to the HTTP Server. + pub fn connect_timeout(&self) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.connect-timeout"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v6 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Delete all values for a key. Does nothing if no values for the key - /// exist. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn delete(&self,name: &FieldKey,) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.delete"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 1) as *const u8)); - let v4 = match l3 { - 0 => { - HeaderError::InvalidSyntax + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for the initial connect to the HTTP Server. An error + /// return value indicates that this timeout is not supported. + pub fn set_connect_timeout(&self, duration: Option) -> Result<(), ()> { + unsafe { + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-connect-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - 1 => { - HeaderError::Forbidden + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving the first byte of the Response body. + pub fn first_byte_timeout(&self) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.first-byte-timeout"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving the first byte of the Response body. An + /// error return value indicates that this timeout is not supported. + pub fn set_first_byte_timeout(&self, duration: Option) -> Result<(), ()> { + unsafe { + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-first-byte-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Append a value for a key. Does not change or delete any existing - /// values for that key. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn append(&self,name: &FieldKey,value: &FieldValue,) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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 vec1 = value; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.append"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr2 + 1) as *const u8)); - let v5 = match l4 { - 0 => { - HeaderError::InvalidSyntax + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving subsequent chunks of bytes in the Response + /// body stream. + pub fn between_bytes_timeout(&self) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.between-bytes-timeout"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - 1 => { - HeaderError::Forbidden + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving subsequent chunks of bytes in the Response + /// body stream. An error return value indicates that this timeout is not + /// supported. + pub fn set_between_bytes_timeout( + &self, + duration: Option, + ) -> Result<(), ()> { + unsafe { + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-between-bytes-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable + } + } + impl ResponseOutparam { + #[allow(unused_unsafe, clippy::all)] + /// Set the value of the `response-outparam` to either send a response, + /// or indicate an error. + /// + /// This method consumes the `response-outparam` to ensure that it is + /// called at most once. If it is never called, the implementation + /// will respond with an error. + /// + /// The user may provide an `error` to `response` to allow the + /// implementation determine how to respond with an HTTP error response. + pub fn set(param: ResponseOutparam, response: Result) { + unsafe { + let ( + result38_0, + result38_1, + result38_2, + result38_3, + result38_4, + result38_5, + result38_6, + result38_7, + ) = match &response { + Ok(e) => ( + 0i32, + (e).take_handle() as i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + Err(e) => { + let ( + result37_0, + result37_1, + result37_2, + result37_3, + result37_4, + result37_5, + result37_6, + ) = match e { + ErrorCode::DnsTimeout => ( + 0i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DnsError(e) => { + let DnsErrorPayload { + rcode: rcode0, + info_code: info_code0, + } = e; + let (result2_0, result2_1, result2_2) = match rcode0 { + Some(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (1i32, ptr1.cast_mut(), len1) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result3_0, result3_1) = match info_code0 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 1i32, + result2_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result2_1); + t + }, + result2_2 as *mut u8, + result3_0 as *mut u8, + result3_1 as usize, + 0i32, + ) + } + ErrorCode::DestinationNotFound => ( + 2i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationUnavailable => ( + 3i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationIpProhibited => ( + 4i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationIpUnroutable => ( + 5i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionRefused => ( + 6i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionTerminated => ( + 7i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionTimeout => ( + 8i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionReadTimeout => ( + 9i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionWriteTimeout => ( + 10i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionLimitReached => ( + 11i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsProtocolError => ( + 12i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsCertificateError => ( + 13i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsAlertReceived(e) => { + let TlsAlertReceivedPayload { + alert_id: alert_id4, + alert_message: alert_message4, + } = e; + let (result5_0, result5_1) = match alert_id4 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + let (result7_0, result7_1, result7_2) = match alert_message4 + { + Some(e) => { + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + + (1i32, ptr6.cast_mut(), len6) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 14i32, + result5_0, + ::core::mem::MaybeUninit::new( + i64::from(result5_1) as u64 + ), + result7_0 as *mut u8, + result7_1, + result7_2, + 0i32, + ) + } + ErrorCode::HttpRequestDenied => ( + 15i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestLengthRequired => ( + 16i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestBodySize(e) => { + let (result8_0, result8_1) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + ( + 17i32, + result8_0, + ::core::mem::MaybeUninit::new(result8_1 as u64), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestMethodInvalid => ( + 18i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestUriInvalid => ( + 19i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestUriTooLong => ( + 20i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestHeaderSectionSize(e) => { + let (result9_0, result9_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 21i32, + result9_0, + ::core::mem::MaybeUninit::new( + i64::from(result9_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestHeaderSize(e) => { + let ( + result14_0, + result14_1, + result14_2, + result14_3, + result14_4, + result14_5, + ) = match e { + Some(e) => { + let FieldSizePayload { + field_name: field_name10, + field_size: field_size10, + } = e; + let (result12_0, result12_1, result12_2) = + match field_name10 { + Some(e) => { + let vec11 = e; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + + (1i32, ptr11.cast_mut(), len11) + } + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + } + }; + let (result13_0, result13_1) = match field_size10 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 1i32, result12_0, result12_1, result12_2, + result13_0, result13_1, + ) + } + None => ( + 0i32, + 0i32, + ::core::ptr::null_mut(), + 0usize, + 0i32, + 0i32, + ), + }; + ( + 22i32, + result14_0, + ::core::mem::MaybeUninit::new( + i64::from(result14_1) as u64 + ), + result14_2, + result14_3 as *mut u8, + result14_4 as usize, + result14_5, + ) + } + ErrorCode::HttpRequestTrailerSectionSize(e) => { + let (result15_0, result15_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 23i32, + result15_0, + ::core::mem::MaybeUninit::new( + i64::from(result15_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestTrailerSize(e) => { + let FieldSizePayload { + field_name: field_name16, + field_size: field_size16, + } = e; + let (result18_0, result18_1, result18_2) = + match field_name16 { + Some(e) => { + let vec17 = e; + let ptr17 = vec17.as_ptr().cast::(); + let len17 = vec17.len(); + + (1i32, ptr17.cast_mut(), len17) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result19_0, result19_1) = match field_size16 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 24i32, + result18_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result18_1); + t + }, + result18_2 as *mut u8, + result19_0 as *mut u8, + result19_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseIncomplete => ( + 25i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpResponseHeaderSectionSize(e) => { + let (result20_0, result20_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 26i32, + result20_0, + ::core::mem::MaybeUninit::new( + i64::from(result20_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseHeaderSize(e) => { + let FieldSizePayload { + field_name: field_name21, + field_size: field_size21, + } = e; + let (result23_0, result23_1, result23_2) = + match field_name21 { + Some(e) => { + let vec22 = e; + let ptr22 = vec22.as_ptr().cast::(); + let len22 = vec22.len(); + + (1i32, ptr22.cast_mut(), len22) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result24_0, result24_1) = match field_size21 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 27i32, + result23_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result23_1); + t + }, + result23_2 as *mut u8, + result24_0 as *mut u8, + result24_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseBodySize(e) => { + let (result25_0, result25_1) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + ( + 28i32, + result25_0, + ::core::mem::MaybeUninit::new(result25_1 as u64), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTrailerSectionSize(e) => { + let (result26_0, result26_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 29i32, + result26_0, + ::core::mem::MaybeUninit::new( + i64::from(result26_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTrailerSize(e) => { + let FieldSizePayload { + field_name: field_name27, + field_size: field_size27, + } = e; + let (result29_0, result29_1, result29_2) = + match field_name27 { + Some(e) => { + let vec28 = e; + let ptr28 = vec28.as_ptr().cast::(); + let len28 = vec28.len(); + + (1i32, ptr28.cast_mut(), len28) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result30_0, result30_1) = match field_size27 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 30i32, + result29_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result29_1); + t + }, + result29_2 as *mut u8, + result30_0 as *mut u8, + result30_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseTransferCoding(e) => { + let (result32_0, result32_1, result32_2) = match e { + Some(e) => { + let vec31 = e; + let ptr31 = vec31.as_ptr().cast::(); + let len31 = vec31.len(); + + (1i32, ptr31.cast_mut(), len31) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 31i32, + result32_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result32_1); + t + }, + result32_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseContentCoding(e) => { + let (result34_0, result34_1, result34_2) = match e { + Some(e) => { + let vec33 = e; + let ptr33 = vec33.as_ptr().cast::(); + let len33 = vec33.len(); + + (1i32, ptr33.cast_mut(), len33) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 32i32, + result34_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result34_1); + t + }, + result34_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTimeout => ( + 33i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpUpgradeFailed => ( + 34i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpProtocolError => ( + 35i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::LoopDetected => ( + 36i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConfigurationError => ( + 37i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::InternalError(e) => { + let (result36_0, result36_1, result36_2) = match e { + Some(e) => { + let vec35 = e; + let ptr35 = vec35.as_ptr().cast::(); + let len35 = vec35.len(); + + (1i32, ptr35.cast_mut(), len35) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 38i32, + result36_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result36_1); + t + }, + result36_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + }; + + ( + 1i32, result37_0, result37_1, result37_2, result37_3, + result37_4, result37_5, result37_6, + ) + } + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]response-outparam.set"] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: ::core::mem::MaybeUninit, + _: *mut u8, + _: *mut u8, + _: usize, + _: i32, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: ::core::mem::MaybeUninit, + _: *mut u8, + _: *mut u8, + _: usize, + _: i32, + ) { + unreachable!() + } + wit_import( + (¶m).take_handle() as i32, + result38_0, + result38_1, + result38_2, + result38_3, + result38_4, + result38_5, + result38_6, + result38_7, + ); } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Retrieve the full set of keys and values in the Fields. Like the - /// constructor, the list represents each key-value pair. - /// - /// The outer list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - pub fn entries(&self,) -> wit_bindgen::rt::vec::Vec::<(FieldKey,FieldValue,)>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.entries"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base9 = l1; - let len9 = l2; - let mut result9 = Vec::with_capacity(len9 as usize); - for i in 0..len9 { - let base = base9 + i * 16; - let e9 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((base + 8) as *const i32); - let l7 = *((base + 12) as *const i32); - let len8 = l7 as usize; - - (wit_bindgen::rt::string_lift(bytes5), Vec::from_raw_parts(l6 as *mut _, len8, len8)) - }; - result9.push(e9); - } - wit_bindgen::rt::dealloc(base9, (len9 as usize) * 16, 4); - result9 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Make a deep copy of the Fields. Equivelant in behavior to calling the - /// `fields` constructor on the return value of `entries`. The resulting - /// `fields` is mutable. - pub fn clone(&self,) -> Fields{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.clone"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the method of the incoming request. - pub fn method(&self,) -> Method{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.method"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - let v5 = match l1 { - 0 => { - Method::Get - } - 1 => { - Method::Head - } - 2 => { - Method::Post - } - 3 => { - Method::Put - } - 4 => { - Method::Delete - } - 5 => { - Method::Connect - } - 6 => { - Method::Options - } - 7 => { - Method::Trace - } - 8 => { - Method::Patch - } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the path with query parameters from the request, as a string. - pub fn path_with_query(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.path-with-query"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the protocol scheme from the request. - pub fn scheme(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.scheme"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v6 = match l2 { - 0 => { - Scheme::Http + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the status code from the incoming response. + pub fn status(&self) -> StatusCode { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.status"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 } - 1 => { - Scheme::Https + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the headers from the incoming response. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `incoming-response` is dropped. + pub fn headers(&self) -> Headers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.headers"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *((ptr0 + 8) as *const i32); - let l4 = *((ptr0 + 12) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Scheme::Other(e6) + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the incoming body. May be called at most once. Returns error + /// if called additional times. + pub fn consume(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.consume"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - }; - - v6 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the authority from the request, if it was present. - pub fn authority(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.authority"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the `headers` associated with the request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// The `headers` returned are a child resource: it must be dropped before - /// the parent `incoming-request` is dropped. Dropping this - /// `incoming-request` before all children are dropped will trap. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Gives the `incoming-body` associated with this request. Will only - /// return success at most once, and subsequent calls will return error. - pub fn consume(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.consume"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Construct a new `outgoing-request` with a default `method` of `GET`, and - /// `none` values for `path-with-query`, `scheme`, and `authority`. - /// - /// * `headers` is the HTTP Headers for the Request. - /// - /// It is possible to construct, or manipulate with the accessor functions - /// below, an `outgoing-request` with an invalid combination of `scheme` - /// and `authority`, or `headers` which are not permitted to be sent. - /// It is the obligation of the `outgoing-handler.handle` implementation - /// to reject invalid constructions of `outgoing-request`. - pub fn new(headers: Headers,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-request"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((headers).into_handle() as i32); - OutgoingRequest::from_handle(ret as u32) - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this - /// Request. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-request` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.body"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the Method for the Request. - pub fn method(&self,) -> Method{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.method"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - let v5 = match l1 { - 0 => { - Method::Get - } - 1 => { - Method::Head - } - 2 => { - Method::Post - } - 3 => { - Method::Put - } - 4 => { - Method::Delete - } - 5 => { - Method::Connect - } - 6 => { - Method::Options - } - 7 => { - Method::Trace - } - 8 => { - Method::Patch - } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the Method for the Request. Fails if the string present in a - /// `method.other` argument is not a syntactically valid method. - pub fn set_method(&self,method: &Method,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result1_0,result1_1,result1_2,) = match method { - Method::Get=> { - (0i32, 0i32, 0i32) - } - Method::Head=> { - (1i32, 0i32, 0i32) - } - Method::Post=> { - (2i32, 0i32, 0i32) - } - Method::Put=> { - (3i32, 0i32, 0i32) - } - Method::Delete=> { - (4i32, 0i32, 0i32) - } - Method::Connect=> { - (5i32, 0i32, 0i32) - } - Method::Options=> { - (6i32, 0i32, 0i32) - } - Method::Trace=> { - (7i32, 0i32, 0i32) - } - Method::Patch=> { - (8i32, 0i32, 0i32) - } - Method::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (9i32, ptr0, len0) - }, - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-method"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. - pub fn path_with_query(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.path-with-query"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. Fails is the - /// string given is not a syntactically valid path and query uri component. - pub fn set_path_with_query(&self,path_with_query: Option<&str>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result1_0,result1_1,result1_2,) = match path_with_query { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (1i32, ptr0, len0) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-path-with-query"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. - pub fn scheme(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.scheme"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v6 = match l2 { - 0 => { - Scheme::Http + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns the contents of the body, as a stream of bytes. + /// + /// Returns success on first call: the stream representing the contents + /// can be retrieved at most once. Subsequent calls will return error. + /// + /// The returned `input-stream` resource is a child: it must be dropped + /// before the parent `incoming-body` is dropped, or consumed by + /// `incoming-body.finish`. + /// + /// This invariant ensures that the implementation can determine whether + /// the user is consuming the contents of the body, waiting on the + /// `future-trailers` to be ready, or neither. This allows for network + /// backpressure is to be applied when the user is consuming the body, + /// and for that backpressure to not inhibit delivery of the trailers if + /// the user does not read the entire body. + pub fn stream(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-body.stream"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle( + l2 as u32, + ) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - 1 => { - Scheme::Https + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Takes ownership of `incoming-body`, and returns a `future-trailers`. + /// This function will trap if the `input-stream` child is still alive. + pub fn finish(this: IncomingBody) -> FutureTrailers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]incoming-body.finish"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((&this).take_handle() as i32); + FutureTrailers::from_handle(ret as u32) } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *((ptr0 + 8) as *const i32); - let l4 = *((ptr0 + 12) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - Scheme::Other(e6) + } + } + impl FutureTrailers { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the trailers have + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-trailers.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) } - }; - - v6 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. Fails if the - /// string given is not a syntactically valid uri scheme. - pub fn set_scheme(&self,scheme: Option<&Scheme>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result2_0,result2_1,result2_2,result2_3,) = match scheme { - Some(e) => { - let (result1_0,result1_1,result1_2,) = match e { - Scheme::Http=> { - (0i32, 0i32, 0i32) - } - Scheme::Https=> { - (1i32, 0i32, 0i32) - } - Scheme::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (2i32, ptr0, len0) - }, - }; - - (1i32, result1_0, result1_1, result1_2) - }, - None => { - (0i32, 0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-scheme"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result2_0, result2_1, result2_2, result2_3); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. - pub fn authority(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.authority"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. Fails if the string given is - /// not a syntactically valid uri authority. - pub fn set_authority(&self,authority: Option<&str>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result1_0,result1_1,result1_2,) = match authority { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (1i32, ptr0, len0) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-authority"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Construct a default `request-options` value. - pub fn new() -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]request-options"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - RequestOptions::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for the initial connect to the HTTP Server. - pub fn connect_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.connect-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for the initial connect to the HTTP Server. An error - /// return value indicates that this timeout is not supported. - pub fn set_connect_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-connect-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving the first byte of the Response body. - pub fn first_byte_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.first-byte-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving the first byte of the Response body. An - /// error return value indicates that this timeout is not supported. - pub fn set_first_byte_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-first-byte-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving subsequent chunks of bytes in the Response - /// body stream. - pub fn between_bytes_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.between-bytes-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving subsequent chunks of bytes in the Response - /// body stream. An error return value indicates that this timeout is not - /// supported. - pub fn set_between_bytes_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-between-bytes-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl ResponseOutparam { - #[allow(unused_unsafe, clippy::all)] - /// Set the value of the `response-outparam` to either send a response, - /// or indicate an error. - /// - /// This method consumes the `response-outparam` to ensure that it is - /// called at most once. If it is never called, the implementation - /// will respond with an error. - /// - /// The user may provide an `error` to `response` to allow the - /// implementation determine how to respond with an HTTP error response. - pub fn set(param: ResponseOutparam,response: Result,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result38_0,result38_1,result38_2,result38_3,result38_4,result38_5,result38_6,result38_7,) = match response { - Ok(e) => { (0i32, (e).into_handle() as i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) }, - Err(e) => { { - let (result37_0,result37_1,result37_2,result37_3,result37_4,result37_5,result37_6,) = match e { - ErrorCode::DnsTimeout=> { - (0i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DnsError(e) => { - let DnsErrorPayload{ rcode:rcode0, info_code:info_code0, } = e; - let (result2_0,result2_1,result2_2,) = match rcode0 { - Some(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - (1i32, ptr1, len1) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result3_0,result3_1,) = match info_code0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result2_0, i64::from(result2_1), result2_2, result3_0, result3_1, 0i32) - }, - ErrorCode::DestinationNotFound=> { - (2i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationUnavailable=> { - (3i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationIpProhibited=> { - (4i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationIpUnroutable=> { - (5i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionRefused=> { - (6i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionTerminated=> { - (7i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionTimeout=> { - (8i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionReadTimeout=> { - (9i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionWriteTimeout=> { - (10i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionLimitReached=> { - (11i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsProtocolError=> { - (12i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsCertificateError=> { - (13i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsAlertReceived(e) => { - let TlsAlertReceivedPayload{ alert_id:alert_id4, alert_message:alert_message4, } = e; - let (result5_0,result5_1,) = match alert_id4 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result7_0,result7_1,result7_2,) = match alert_message4 { - Some(e) => { - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - - (1i32, ptr6, len6) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (14i32, result5_0, i64::from(result5_1), result7_0, result7_1, result7_2, 0i32) - }, - ErrorCode::HttpRequestDenied=> { - (15i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestLengthRequired=> { - (16i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestBodySize(e) => { - let (result8_0,result8_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (17i32, result8_0, result8_1, 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestMethodInvalid=> { - (18i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestUriInvalid=> { - (19i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestUriTooLong=> { - (20i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - let (result9_0,result9_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (21i32, result9_0, i64::from(result9_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestHeaderSize(e) => { - let (result14_0,result14_1,result14_2,result14_3,result14_4,result14_5,) = match e { - Some(e) => { - let FieldSizePayload{ field_name:field_name10, field_size:field_size10, } = e; - let (result12_0,result12_1,result12_2,) = match field_name10 { - Some(e) => { - let vec11 = e; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - - (1i32, ptr11, len11) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result13_0,result13_1,) = match field_size10 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result12_0, result12_1, result12_2, result13_0, result13_1) - }, - None => { - (0i32, 0i32, 0i32, 0i32, 0i32, 0i32) - }, - }; - (22i32, result14_0, i64::from(result14_1), result14_2, result14_3, result14_4, result14_5) - }, - ErrorCode::HttpRequestTrailerSectionSize(e) => { - let (result15_0,result15_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (23i32, result15_0, i64::from(result15_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name16, field_size:field_size16, } = e; - let (result18_0,result18_1,result18_2,) = match field_name16 { - Some(e) => { - let vec17 = e; - let ptr17 = vec17.as_ptr() as i32; - let len17 = vec17.len() as i32; - - (1i32, ptr17, len17) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result19_0,result19_1,) = match field_size16 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (24i32, result18_0, i64::from(result18_1), result18_2, result19_0, result19_1, 0i32) - }, - ErrorCode::HttpResponseIncomplete=> { - (25i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - let (result20_0,result20_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (26i32, result20_0, i64::from(result20_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseHeaderSize(e) => { - let FieldSizePayload{ field_name:field_name21, field_size:field_size21, } = e; - let (result23_0,result23_1,result23_2,) = match field_name21 { - Some(e) => { - let vec22 = e; - let ptr22 = vec22.as_ptr() as i32; - let len22 = vec22.len() as i32; - - (1i32, ptr22, len22) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result24_0,result24_1,) = match field_size21 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (27i32, result23_0, i64::from(result23_1), result23_2, result24_0, result24_1, 0i32) - }, - ErrorCode::HttpResponseBodySize(e) => { - let (result25_0,result25_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (28i32, result25_0, result25_1, 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTrailerSectionSize(e) => { - let (result26_0,result26_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (29i32, result26_0, i64::from(result26_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name27, field_size:field_size27, } = e; - let (result29_0,result29_1,result29_2,) = match field_name27 { - Some(e) => { - let vec28 = e; - let ptr28 = vec28.as_ptr() as i32; - let len28 = vec28.len() as i32; - - (1i32, ptr28, len28) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result30_0,result30_1,) = match field_size27 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (30i32, result29_0, i64::from(result29_1), result29_2, result30_0, result30_1, 0i32) - }, - ErrorCode::HttpResponseTransferCoding(e) => { - let (result32_0,result32_1,result32_2,) = match e { - Some(e) => { - let vec31 = e; - let ptr31 = vec31.as_ptr() as i32; - let len31 = vec31.len() as i32; - - (1i32, ptr31, len31) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (31i32, result32_0, i64::from(result32_1), result32_2, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseContentCoding(e) => { - let (result34_0,result34_1,result34_2,) = match e { - Some(e) => { - let vec33 = e; - let ptr33 = vec33.as_ptr() as i32; - let len33 = vec33.len() as i32; - - (1i32, ptr33, len33) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (32i32, result34_0, i64::from(result34_1), result34_2, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTimeout=> { - (33i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpUpgradeFailed=> { - (34i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpProtocolError=> { - (35i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::LoopDetected=> { - (36i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConfigurationError=> { - (37i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::InternalError(e) => { - let (result36_0,result36_1,result36_2,) = match e { - Some(e) => { - let vec35 = e; - let ptr35 = vec35.as_ptr() as i32; - let len35 = vec35.len() as i32; - - (1i32, ptr35, len35) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (38i32, result36_0, i64::from(result36_1), result36_2, 0i32, 0i32, 0i32) - }, - }; - - (1i32, result37_0, result37_1, result37_2, result37_3, result37_4, result37_5, result37_6) - } }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]response-outparam.set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((param).into_handle() as i32, result38_0, result38_1, result38_2, result38_3, result38_4, result38_5, result38_6, result38_7); - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the status code from the incoming response. - pub fn status(&self,) -> StatusCode{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.status"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the headers from the incoming response. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `incoming-response` is dropped. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the incoming body. May be called at most once. Returns error - /// if called additional times. - pub fn consume(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.consume"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns the contents of the body, as a stream of bytes. - /// - /// Returns success on first call: the stream representing the contents - /// can be retrieved at most once. Subsequent calls will return error. - /// - /// The returned `input-stream` resource is a child: it must be dropped - /// before the parent `incoming-body` is dropped, or consumed by - /// `incoming-body.finish`. - /// - /// This invariant ensures that the implementation can determine whether - /// the user is consuming the contents of the body, waiting on the - /// `future-trailers` to be ready, or neither. This allows for network - /// backpressure is to be applied when the user is consuming the body, - /// and for that backpressure to not inhibit delivery of the trailers if - /// the user does not read the entire body. - pub fn stream(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-body.stream"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Takes ownership of `incoming-body`, and returns a `future-trailers`. - /// This function will trap if the `input-stream` child is still alive. - pub fn finish(this: IncomingBody,) -> FutureTrailers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]incoming-body.finish"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((this).into_handle() as i32); - FutureTrailers::from_handle(ret as u32) - } - } - } - impl FutureTrailers { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the trailers have - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-trailers.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl FutureTrailers { - #[allow(unused_unsafe, clippy::all)] - /// Returns the contents of the trailers, or an error which occured, - /// once the future is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the trailers or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the HTTP Request or Response - /// body, as well as any trailers, were received successfully, or that an - /// error occured receiving them. The optional `trailers` indicates whether - /// or not trailers were present in the body. - /// - /// When some `trailers` are returned by this method, the `trailers` - /// resource is immutable, and a child. Use of the `set`, `append`, or - /// `delete` methods will return an error, and the resource must be - /// dropped before the parent `future-trailers` is dropped. - pub fn get(&self,) -> Option,ErrorCode>,()>>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 56]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-trailers.get"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - - match l3 { - 0 => { - let e = { - let l4 = i32::from(*((ptr0 + 24) as *const u8)); - - match l4 { + } + } + impl FutureTrailers { + #[allow(unused_unsafe, clippy::all)] + /// Returns the contents of the trailers, or an error which occured, + /// once the future is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the trailers or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the HTTP Request or Response + /// body, as well as any trailers, were received successfully, or that an + /// error occured receiving them. The optional `trailers` indicates whether + /// or not trailers were present in the body. + /// + /// When some `trailers` are returned by this method, the `trailers` + /// resource is immutable, and a child. Use of the `set`, `append`, or + /// `delete` methods will return an error, and the resource must be + /// dropped before the parent `future-trailers` is dropped. + pub fn get(&self) -> Option, ErrorCode>, ()>> { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-trailers.get"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); + + match l3 { + 0 => { + let e = + { + let l4 = i32::from( + *ptr0.add(24).cast::(), + ); + + match l4 { 0 => None, 1 => { let e = { - let l5 = *((ptr0 + 28) as *const i32); - + let l5 = *ptr0.add(28).cast::(); + Fields::from_handle(l5 as u32) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr0 + 24) as *const u8)); - let v68 = match l6 { + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from( + *ptr0.add(24).cast::(), + ); + let v68 = match l6 { 0 => { ErrorCode::DnsTimeout } 1 => { let e68 = { - let l7 = i32::from(*((ptr0 + 32) as *const u8)); - let l11 = i32::from(*((ptr0 + 44) as *const u8)); - + let l7 = i32::from(*ptr0.add(32).cast::()); + let l11 = i32::from(*ptr0.add(44).cast::()); + DnsErrorPayload{ rcode: match l7 { 0 => None, 1 => { let e = { - let l8 = *((ptr0 + 36) as *const i32); - let l9 = *((ptr0 + 40) as *const i32); - let len10 = l9 as usize; - let bytes10 = Vec::from_raw_parts(l8 as *mut _, len10, len10); - - wit_bindgen::rt::string_lift(bytes10) + let l8 = *ptr0.add(36).cast::<*mut u8>(); + let l9 = *ptr0.add(40).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l11 { 0 => None, 1 => { let e = { - let l12 = i32::from(*((ptr0 + 46) as *const u16)); - + let l12 = i32::from(*ptr0.add(46).cast::()); + l12 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -3839,36 +4103,36 @@ pub mod wasi { } 14 => { let e68 = { - let l13 = i32::from(*((ptr0 + 32) as *const u8)); - let l15 = i32::from(*((ptr0 + 36) as *const u8)); - + let l13 = i32::from(*ptr0.add(32).cast::()); + let l15 = i32::from(*ptr0.add(36).cast::()); + TlsAlertReceivedPayload{ alert_id: match l13 { 0 => None, 1 => { let e = { - let l14 = i32::from(*((ptr0 + 33) as *const u8)); - + let l14 = i32::from(*ptr0.add(33).cast::()); + l14 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l15 { 0 => None, 1 => { let e = { - let l16 = *((ptr0 + 40) as *const i32); - let l17 = *((ptr0 + 44) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) + let l16 = *ptr0.add(40).cast::<*mut u8>(); + let l17 = *ptr0.add(44).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -3882,19 +4146,19 @@ pub mod wasi { } 17 => { let e68 = { - let l19 = i32::from(*((ptr0 + 32) as *const u8)); - + let l19 = i32::from(*ptr0.add(32).cast::()); + match l19 { 0 => None, 1 => { let e = { - let l20 = *((ptr0 + 40) as *const i64); - + let l20 = *ptr0.add(40).cast::(); + l20 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestBodySize(e68) @@ -3910,122 +4174,122 @@ pub mod wasi { } 21 => { let e68 = { - let l21 = i32::from(*((ptr0 + 32) as *const u8)); - + let l21 = i32::from(*ptr0.add(32).cast::()); + match l21 { 0 => None, 1 => { let e = { - let l22 = *((ptr0 + 36) as *const i32); - + let l22 = *ptr0.add(36).cast::(); + l22 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSectionSize(e68) } 22 => { let e68 = { - let l23 = i32::from(*((ptr0 + 32) as *const u8)); - + let l23 = i32::from(*ptr0.add(32).cast::()); + match l23 { 0 => None, 1 => { let e = { - let l24 = i32::from(*((ptr0 + 36) as *const u8)); - let l28 = i32::from(*((ptr0 + 48) as *const u8)); - + let l24 = i32::from(*ptr0.add(36).cast::()); + let l28 = i32::from(*ptr0.add(48).cast::()); + FieldSizePayload{ field_name: match l24 { 0 => None, 1 => { let e = { - let l25 = *((ptr0 + 40) as *const i32); - let l26 = *((ptr0 + 44) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) + let l25 = *ptr0.add(40).cast::<*mut u8>(); + let l26 = *ptr0.add(44).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts(l25.cast(), len27, len27); + + _rt::string_lift(bytes27) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l28 { 0 => None, 1 => { let e = { - let l29 = *((ptr0 + 52) as *const i32); - + let l29 = *ptr0.add(52).cast::(); + l29 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSize(e68) } 23 => { let e68 = { - let l30 = i32::from(*((ptr0 + 32) as *const u8)); - + let l30 = i32::from(*ptr0.add(32).cast::()); + match l30 { 0 => None, 1 => { let e = { - let l31 = *((ptr0 + 36) as *const i32); - + let l31 = *ptr0.add(36).cast::(); + l31 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestTrailerSectionSize(e68) } 24 => { let e68 = { - let l32 = i32::from(*((ptr0 + 32) as *const u8)); - let l36 = i32::from(*((ptr0 + 44) as *const u8)); - + let l32 = i32::from(*ptr0.add(32).cast::()); + let l36 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l32 { 0 => None, 1 => { let e = { - let l33 = *((ptr0 + 36) as *const i32); - let l34 = *((ptr0 + 40) as *const i32); - let len35 = l34 as usize; - let bytes35 = Vec::from_raw_parts(l33 as *mut _, len35, len35); - - wit_bindgen::rt::string_lift(bytes35) + let l33 = *ptr0.add(36).cast::<*mut u8>(); + let l34 = *ptr0.add(40).cast::(); + let len35 = l34; + let bytes35 = _rt::Vec::from_raw_parts(l33.cast(), len35, len35); + + _rt::string_lift(bytes35) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l36 { 0 => None, 1 => { let e = { - let l37 = *((ptr0 + 48) as *const i32); - + let l37 = *ptr0.add(48).cast::(); + l37 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -4036,55 +4300,55 @@ pub mod wasi { } 26 => { let e68 = { - let l38 = i32::from(*((ptr0 + 32) as *const u8)); - + let l38 = i32::from(*ptr0.add(32).cast::()); + match l38 { 0 => None, 1 => { let e = { - let l39 = *((ptr0 + 36) as *const i32); - + let l39 = *ptr0.add(36).cast::(); + l39 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseHeaderSectionSize(e68) } 27 => { let e68 = { - let l40 = i32::from(*((ptr0 + 32) as *const u8)); - let l44 = i32::from(*((ptr0 + 44) as *const u8)); - + let l40 = i32::from(*ptr0.add(32).cast::()); + let l44 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l40 { 0 => None, 1 => { let e = { - let l41 = *((ptr0 + 36) as *const i32); - let l42 = *((ptr0 + 40) as *const i32); - let len43 = l42 as usize; - let bytes43 = Vec::from_raw_parts(l41 as *mut _, len43, len43); - - wit_bindgen::rt::string_lift(bytes43) + let l41 = *ptr0.add(36).cast::<*mut u8>(); + let l42 = *ptr0.add(40).cast::(); + let len43 = l42; + let bytes43 = _rt::Vec::from_raw_parts(l41.cast(), len43, len43); + + _rt::string_lift(bytes43) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l44 { 0 => None, 1 => { let e = { - let l45 = *((ptr0 + 48) as *const i32); - + let l45 = *ptr0.add(48).cast::(); + l45 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -4092,74 +4356,74 @@ pub mod wasi { } 28 => { let e68 = { - let l46 = i32::from(*((ptr0 + 32) as *const u8)); - + let l46 = i32::from(*ptr0.add(32).cast::()); + match l46 { 0 => None, 1 => { let e = { - let l47 = *((ptr0 + 40) as *const i64); - + let l47 = *ptr0.add(40).cast::(); + l47 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseBodySize(e68) } 29 => { let e68 = { - let l48 = i32::from(*((ptr0 + 32) as *const u8)); - + let l48 = i32::from(*ptr0.add(32).cast::()); + match l48 { 0 => None, 1 => { let e = { - let l49 = *((ptr0 + 36) as *const i32); - + let l49 = *ptr0.add(36).cast::(); + l49 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTrailerSectionSize(e68) } 30 => { let e68 = { - let l50 = i32::from(*((ptr0 + 32) as *const u8)); - let l54 = i32::from(*((ptr0 + 44) as *const u8)); - + let l50 = i32::from(*ptr0.add(32).cast::()); + let l54 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l50 { 0 => None, 1 => { let e = { - let l51 = *((ptr0 + 36) as *const i32); - let l52 = *((ptr0 + 40) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) + let l51 = *ptr0.add(36).cast::<*mut u8>(); + let l52 = *ptr0.add(40).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts(l51.cast(), len53, len53); + + _rt::string_lift(bytes53) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l54 { 0 => None, 1 => { let e = { - let l55 = *((ptr0 + 48) as *const i32); - + let l55 = *ptr0.add(48).cast::(); + l55 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -4167,44 +4431,44 @@ pub mod wasi { } 31 => { let e68 = { - let l56 = i32::from(*((ptr0 + 32) as *const u8)); - + let l56 = i32::from(*ptr0.add(32).cast::()); + match l56 { 0 => None, 1 => { let e = { - let l57 = *((ptr0 + 36) as *const i32); - let l58 = *((ptr0 + 40) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) + let l57 = *ptr0.add(36).cast::<*mut u8>(); + let l58 = *ptr0.add(40).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts(l57.cast(), len59, len59); + + _rt::string_lift(bytes59) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTransferCoding(e68) } 32 => { let e68 = { - let l60 = i32::from(*((ptr0 + 32) as *const u8)); - + let l60 = i32::from(*ptr0.add(32).cast::()); + match l60 { 0 => None, 1 => { let e = { - let l61 = *((ptr0 + 36) as *const i32); - let l62 = *((ptr0 + 40) as *const i32); - let len63 = l62 as usize; - let bytes63 = Vec::from_raw_parts(l61 as *mut _, len63, len63); - - wit_bindgen::rt::string_lift(bytes63) + let l61 = *ptr0.add(36).cast::<*mut u8>(); + let l62 = *ptr0.add(40).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts(l61.cast(), len63, len63); + + _rt::string_lift(bytes63) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseContentCoding(e68) @@ -4227,925 +4491,924 @@ pub mod wasi { n => { debug_assert_eq!(n, 38, "invalid enum discriminant"); let e68 = { - let l64 = i32::from(*((ptr0 + 32) as *const u8)); - + let l64 = i32::from(*ptr0.add(32).cast::()); + match l64 { 0 => None, 1 => { let e = { - let l65 = *((ptr0 + 36) as *const i32); - let l66 = *((ptr0 + 40) as *const i32); - let len67 = l66 as usize; - let bytes67 = Vec::from_raw_parts(l65 as *mut _, len67, len67); - - wit_bindgen::rt::string_lift(bytes67) + let l65 = *ptr0.add(36).cast::<*mut u8>(); + let l66 = *ptr0.add(40).cast::(); + let len67 = l66; + let bytes67 = _rt::Vec::from_raw_parts(l65.cast(), len67, len67); + + _rt::string_lift(bytes67) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::InternalError(e68) } }; - - v68 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + v68 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) } - 1 => { - let e = (); - Err(e) + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Construct an `outgoing-response`, with a default `status-code` of `200`. + /// If a different `status-code` is needed, it must be set via the + /// `set-status-code` method. + /// + /// * `headers` is the HTTP Headers for the Response. + pub fn new(headers: Headers) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-response"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingResponse::from_handle(ret as u32) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Construct an `outgoing-response`, with a default `status-code` of `200`. - /// If a different `status-code` is needed, it must be set via the - /// `set-status-code` method. - /// - /// * `headers` is the HTTP Headers for the Response. - pub fn new(headers: Headers,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-response"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((headers).into_handle() as i32); - OutgoingResponse::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Status Code for the Response. - pub fn status_code(&self,) -> StatusCode{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.status-code"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Status Code for the Response. Fails if the status-code - /// given is not a valid http status code. - pub fn set_status_code(&self,status_code: StatusCode,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.set-status-code"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, wit_bindgen::rt::as_i32(status_code)); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this Response. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-response` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.body"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns a stream for writing the body contents. - /// - /// The returned `output-stream` is a child resource: it must be dropped - /// before the parent `outgoing-body` resource is dropped (or finished), - /// otherwise the `outgoing-body` drop or `finish` will trap. - /// - /// Returns success on the first call: the `output-stream` resource for - /// this `outgoing-body` may be retrieved at most once. Subsequent calls - /// will return error. - pub fn write(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-body.write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Finalize an outgoing body, optionally providing trailers. This must be - /// called to signal that the response is complete. If the `outgoing-body` - /// is dropped without calling `outgoing-body.finalize`, the implementation - /// should treat the body as corrupted. - /// - /// Fails if the body's `outgoing-request` or `outgoing-response` was - /// constructed with a Content-Length header, and the contents written - /// to the body (via `write`) does not match the value given in the - /// Content-Length. - pub fn finish(this: OutgoingBody,trailers: Option,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let (result0_0,result0_1,) = match trailers { - Some(e) => (1i32, (e).into_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]outgoing-body.finish"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((this).into_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 8) as *const u8)); - let v65 = match l3 { - 0 => { - ErrorCode::DnsTimeout + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Status Code for the Response. + pub fn status_code(&self) -> StatusCode { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.status-code"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 } - 1 => { - let e65 = { - let l4 = i32::from(*((ptr1 + 16) as *const u8)); - let l8 = i32::from(*((ptr1 + 28) as *const u8)); - - DnsErrorPayload{ - rcode: match l4 { - 0 => None, - 1 => { - let e = { - let l5 = *((ptr1 + 20) as *const i32); - let l6 = *((ptr1 + 24) as *const i32); - let len7 = l6 as usize; - let bytes7 = Vec::from_raw_parts(l5 as *mut _, len7, len7); - - wit_bindgen::rt::string_lift(bytes7) - }; - Some(e) + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Status Code for the Response. Fails if the status-code + /// given is not a valid http status code. + pub fn set_status_code(&self, status_code: StatusCode) -> Result<(), ()> { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.set-status-code"] + fn wit_import(_: i32, _: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, _rt::as_i32(status_code)); + match ret { + 0 => { + let e = (); + Ok(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - info_code: match l8 { - 0 => None, 1 => { - let e = { - let l9 = i32::from(*((ptr1 + 30) as *const u16)); - - l9 as u16 - }; - Some(e) + let e = (); + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, + _ => _rt::invalid_enum_discriminant(), } - }; - ErrorCode::DnsError(e65) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self) -> Headers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.headers"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) } - 14 => { - let e65 = { - let l10 = i32::from(*((ptr1 + 16) as *const u8)); - let l12 = i32::from(*((ptr1 + 20) as *const u8)); - - TlsAlertReceivedPayload{ - alert_id: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = i32::from(*((ptr1 + 17) as *const u8)); - - l11 as u8 - }; - Some(e) + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this Response. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-response` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.body"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) + }; + Ok(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - alert_message: match l12 { - 0 => None, 1 => { - let e = { - let l13 = *((ptr1 + 24) as *const i32); - let l14 = *((ptr1 + 28) as *const i32); - let len15 = l14 as usize; - let bytes15 = Vec::from_raw_parts(l13 as *mut _, len15, len15); - - wit_bindgen::rt::string_lift(bytes15) - }; - Some(e) + let e = (); + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, + _ => _rt::invalid_enum_discriminant(), } - }; - ErrorCode::TlsAlertReceived(e65) - } - 15 => { - ErrorCode::HttpRequestDenied } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e65 = { - let l16 = i32::from(*((ptr1 + 16) as *const u8)); - - match l16 { - 0 => None, - 1 => { - let e = { - let l17 = *((ptr1 + 24) as *const i64); - - l17 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns a stream for writing the body contents. + /// + /// The returned `output-stream` is a child resource: it must be dropped + /// before the parent `outgoing-body` resource is dropped (or finished), + /// otherwise the `outgoing-body` drop or `finish` will trap. + /// + /// Returns success on the first call: the `output-stream` resource for + /// this `outgoing-body` may be retrieved at most once. Subsequent calls + /// will return error. + pub fn write(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-body.write"] + fn wit_import(_: i32, _: *mut u8); } - }; - ErrorCode::HttpRequestBodySize(e65) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e65 = { - let l18 = i32::from(*((ptr1 + 16) as *const u8)); - - match l18 { - 0 => None, - 1 => { - let e = { - let l19 = *((ptr1 + 20) as *const i32); - - l19 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - }; - ErrorCode::HttpRequestHeaderSectionSize(e65) } - 22 => { - let e65 = { - let l20 = i32::from(*((ptr1 + 16) as *const u8)); - - match l20 { - 0 => None, - 1 => { - let e = { - let l21 = i32::from(*((ptr1 + 20) as *const u8)); - let l25 = i32::from(*((ptr1 + 32) as *const u8)); - - FieldSizePayload{ + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Finalize an outgoing body, optionally providing trailers. This must be + /// called to signal that the response is complete. If the `outgoing-body` + /// is dropped without calling `outgoing-body.finalize`, the implementation + /// should treat the body as corrupted. + /// + /// Fails if the body's `outgoing-request` or `outgoing-response` was + /// constructed with a Content-Length header, and the contents written + /// to the body (via `write`) does not match the value given in the + /// Content-Length. + pub fn finish( + this: OutgoingBody, + trailers: Option, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0, result0_1) = match &trailers { + Some(e) => (1i32, (e).take_handle() as i32), + None => (0i32, 0i32), + }; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]outgoing-body.finish"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import((&this).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v65 = match l3 { + 0 => ErrorCode::DnsTimeout, + 1 => { + let e65 = { + let l4 = i32::from(*ptr1.add(16).cast::()); + let l8 = i32::from(*ptr1.add(28).cast::()); + + DnsErrorPayload { + rcode: match l4 { + 0 => None, + 1 => { + let e = { + let l5 = + *ptr1.add(20).cast::<*mut u8>(); + let l6 = + *ptr1.add(24).cast::(); + let len7 = l6; + let bytes7 = + _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from( + *ptr1.add(30).cast::(), + ); + + l9 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e65) + } + 2 => ErrorCode::DestinationNotFound, + 3 => ErrorCode::DestinationUnavailable, + 4 => ErrorCode::DestinationIpProhibited, + 5 => ErrorCode::DestinationIpUnroutable, + 6 => ErrorCode::ConnectionRefused, + 7 => ErrorCode::ConnectionTerminated, + 8 => ErrorCode::ConnectionTimeout, + 9 => ErrorCode::ConnectionReadTimeout, + 10 => ErrorCode::ConnectionWriteTimeout, + 11 => ErrorCode::ConnectionLimitReached, + 12 => ErrorCode::TlsProtocolError, + 13 => ErrorCode::TlsCertificateError, + 14 => { + let e65 = { + let l10 = i32::from(*ptr1.add(16).cast::()); + let l12 = i32::from(*ptr1.add(20).cast::()); + + TlsAlertReceivedPayload { + alert_id: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = i32::from( + *ptr1.add(17).cast::(), + ); + + l11 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = + *ptr1.add(24).cast::<*mut u8>(); + let l14 = + *ptr1.add(28).cast::(); + let len15 = l14; + let bytes15 = + _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); + + _rt::string_lift(bytes15) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e65) + } + 15 => ErrorCode::HttpRequestDenied, + 16 => ErrorCode::HttpRequestLengthRequired, + 17 => { + let e65 = { + let l16 = i32::from(*ptr1.add(16).cast::()); + + match l16 { + 0 => None, + 1 => { + let e = { + let l17 = *ptr1.add(24).cast::(); + + l17 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e65) + } + 18 => ErrorCode::HttpRequestMethodInvalid, + 19 => ErrorCode::HttpRequestUriInvalid, + 20 => ErrorCode::HttpRequestUriTooLong, + 21 => { + let e65 = { + let l18 = i32::from(*ptr1.add(16).cast::()); + + match l18 { + 0 => None, + 1 => { + let e = { + let l19 = *ptr1.add(20).cast::(); + + l19 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e65) + } + 22 => { + let e65 = { + let l20 = i32::from(*ptr1.add(16).cast::()); + + match l20 { + 0 => None, + 1 => { + let e = { + let l21 = i32::from( + *ptr1.add(20).cast::(), + ); + let l25 = i32::from( + *ptr1.add(32).cast::(), + ); + + FieldSizePayload{ field_name: match l21 { 0 => None, 1 => { let e = { - let l22 = *((ptr1 + 24) as *const i32); - let l23 = *((ptr1 + 28) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) + let l22 = *ptr1.add(24).cast::<*mut u8>(); + let l23 = *ptr1.add(28).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l25 { 0 => None, 1 => { let e = { - let l26 = *((ptr1 + 36) as *const i32); - + let l26 = *ptr1.add(36).cast::(); + l26 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e65) - } - 23 => { - let e65 = { - let l27 = i32::from(*((ptr1 + 16) as *const u8)); - - match l27 { - 0 => None, - 1 => { - let e = { - let l28 = *((ptr1 + 20) as *const i32); - - l28 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e65) - } - 24 => { - let e65 = { - let l29 = i32::from(*((ptr1 + 16) as *const u8)); - let l33 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l29 { - 0 => None, - 1 => { - let e = { - let l30 = *((ptr1 + 20) as *const i32); - let l31 = *((ptr1 + 24) as *const i32); - let len32 = l31 as usize; - let bytes32 = Vec::from_raw_parts(l30 as *mut _, len32, len32); - - wit_bindgen::rt::string_lift(bytes32) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l33 { - 0 => None, - 1 => { - let e = { - let l34 = *((ptr1 + 32) as *const i32); - - l34 as u32 - }; - Some(e) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e65) + } + 23 => { + let e65 = { + let l27 = i32::from(*ptr1.add(16).cast::()); + + match l27 { + 0 => None, + 1 => { + let e = { + let l28 = *ptr1.add(20).cast::(); + + l28 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e65) + } + 24 => { + let e65 = { + let l29 = i32::from(*ptr1.add(16).cast::()); + let l33 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l29 { + 0 => None, + 1 => { + let e = { + let l30 = + *ptr1.add(20).cast::<*mut u8>(); + let l31 = + *ptr1.add(24).cast::(); + let len32 = l31; + let bytes32 = + _rt::Vec::from_raw_parts( + l30.cast(), + len32, + len32, + ); + + _rt::string_lift(bytes32) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l33 { + 0 => None, + 1 => { + let e = { + let l34 = + *ptr1.add(32).cast::(); + + l34 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e65) + } + 25 => ErrorCode::HttpResponseIncomplete, + 26 => { + let e65 = { + let l35 = i32::from(*ptr1.add(16).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = *ptr1.add(20).cast::(); + + l36 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e65) + } + 27 => { + let e65 = { + let l37 = i32::from(*ptr1.add(16).cast::()); + let l41 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l37 { + 0 => None, + 1 => { + let e = { + let l38 = + *ptr1.add(20).cast::<*mut u8>(); + let l39 = + *ptr1.add(24).cast::(); + let len40 = l39; + let bytes40 = + _rt::Vec::from_raw_parts( + l38.cast(), + len40, + len40, + ); + + _rt::string_lift(bytes40) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l41 { + 0 => None, + 1 => { + let e = { + let l42 = + *ptr1.add(32).cast::(); + + l42 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e65) + } + 28 => { + let e65 = { + let l43 = i32::from(*ptr1.add(16).cast::()); + + match l43 { + 0 => None, + 1 => { + let e = { + let l44 = *ptr1.add(24).cast::(); + + l44 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e65) + } + 29 => { + let e65 = { + let l45 = i32::from(*ptr1.add(16).cast::()); + + match l45 { + 0 => None, + 1 => { + let e = { + let l46 = *ptr1.add(20).cast::(); + + l46 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e65) + } + 30 => { + let e65 = { + let l47 = i32::from(*ptr1.add(16).cast::()); + let l51 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l47 { + 0 => None, + 1 => { + let e = { + let l48 = + *ptr1.add(20).cast::<*mut u8>(); + let l49 = + *ptr1.add(24).cast::(); + let len50 = l49; + let bytes50 = + _rt::Vec::from_raw_parts( + l48.cast(), + len50, + len50, + ); + + _rt::string_lift(bytes50) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l51 { + 0 => None, + 1 => { + let e = { + let l52 = + *ptr1.add(32).cast::(); + + l52 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e65) + } + 31 => { + let e65 = { + let l53 = i32::from(*ptr1.add(16).cast::()); + + match l53 { + 0 => None, + 1 => { + let e = { + let l54 = + *ptr1.add(20).cast::<*mut u8>(); + let l55 = *ptr1.add(24).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e65) + } + 32 => { + let e65 = { + let l57 = i32::from(*ptr1.add(16).cast::()); + + match l57 { + 0 => None, + 1 => { + let e = { + let l58 = + *ptr1.add(20).cast::<*mut u8>(); + let l59 = *ptr1.add(24).cast::(); + let len60 = l59; + let bytes60 = _rt::Vec::from_raw_parts( + l58.cast(), + len60, + len60, + ); + + _rt::string_lift(bytes60) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e65) + } + 33 => ErrorCode::HttpResponseTimeout, + 34 => ErrorCode::HttpUpgradeFailed, + 35 => ErrorCode::HttpProtocolError, + 36 => ErrorCode::LoopDetected, + 37 => ErrorCode::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e65 = { + let l61 = i32::from(*ptr1.add(16).cast::()); + + match l61 { + 0 => None, + 1 => { + let e = { + let l62 = + *ptr1.add(20).cast::<*mut u8>(); + let l63 = *ptr1.add(24).cast::(); + let len64 = l63; + let bytes64 = _rt::Vec::from_raw_parts( + l62.cast(), + len64, + len64, + ); + + _rt::string_lift(bytes64) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e65) + } + }; + + v65 + }; + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, + _ => _rt::invalid_enum_discriminant(), } - }; - ErrorCode::HttpRequestTrailerSize(e65) } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e65 = { - let l35 = i32::from(*((ptr1 + 16) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((ptr1 + 20) as *const i32); - - l36 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } + } + impl FutureIncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the Response has + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-incoming-response.subscribe"] + fn wit_import(_: i32) -> i32; } - }; - ErrorCode::HttpResponseHeaderSectionSize(e65) - } - 27 => { - let e65 = { - let l37 = i32::from(*((ptr1 + 16) as *const u8)); - let l41 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l37 { - 0 => None, - 1 => { - let e = { - let l38 = *((ptr1 + 20) as *const i32); - let l39 = *((ptr1 + 24) as *const i32); - let len40 = l39 as usize; - let bytes40 = Vec::from_raw_parts(l38 as *mut _, len40, len40); - - wit_bindgen::rt::string_lift(bytes40) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l41 { - 0 => None, - 1 => { - let e = { - let l42 = *((ptr1 + 32) as *const i32); - - l42 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - }; - ErrorCode::HttpResponseHeaderSize(e65) + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) } - 28 => { - let e65 = { - let l43 = i32::from(*((ptr1 + 16) as *const u8)); - - match l43 { - 0 => None, - 1 => { - let e = { - let l44 = *((ptr1 + 24) as *const i64); - - l44 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } + } + impl FutureIncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the incoming HTTP Response, or an error, once one is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the response or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the incoming HTTP Response + /// status and headers have recieved successfully, or that an error + /// occured. Errors may also occur while consuming the response body, + /// but those will be reported by the `incoming-body` and its + /// `output-stream` child. + pub fn get(&self) -> Option, ()>> { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-incoming-response.get"] + fn wit_import(_: i32, _: *mut u8); } - }; - ErrorCode::HttpResponseBodySize(e65) - } - 29 => { - let e65 = { - let l45 = i32::from(*((ptr1 + 16) as *const u8)); - - match l45 { - 0 => None, - 1 => { - let e = { - let l46 = *((ptr1 + 20) as *const i32); - - l46 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - }; - ErrorCode::HttpResponseTrailerSectionSize(e65) - } - 30 => { - let e65 = { - let l47 = i32::from(*((ptr1 + 16) as *const u8)); - let l51 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l47 { + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => None, 1 => { - let e = { - let l48 = *((ptr1 + 20) as *const i32); - let l49 = *((ptr1 + 24) as *const i32); - let len50 = l49 as usize; - let bytes50 = Vec::from_raw_parts(l48 as *mut _, len50, len50); - - wit_bindgen::rt::string_lift(bytes50) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l51 { - 0 => None, - 1 => { - let e = { - let l52 = *((ptr1 + 32) as *const i32); - - l52 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e65) - } - 31 => { - let e65 = { - let l53 = i32::from(*((ptr1 + 16) as *const u8)); - - match l53 { - 0 => None, - 1 => { - let e = { - let l54 = *((ptr1 + 20) as *const i32); - let l55 = *((ptr1 + 24) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e65) - } - 32 => { - let e65 = { - let l57 = i32::from(*((ptr1 + 16) as *const u8)); - - match l57 { - 0 => None, - 1 => { - let e = { - let l58 = *((ptr1 + 20) as *const i32); - let l59 = *((ptr1 + 24) as *const i32); - let len60 = l59 as usize; - let bytes60 = Vec::from_raw_parts(l58 as *mut _, len60, len60); - - wit_bindgen::rt::string_lift(bytes60) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e65) - } - 33 => { - ErrorCode::HttpResponseTimeout - } - 34 => { - ErrorCode::HttpUpgradeFailed - } - 35 => { - ErrorCode::HttpProtocolError - } - 36 => { - ErrorCode::LoopDetected - } - 37 => { - ErrorCode::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e65 = { - let l61 = i32::from(*((ptr1 + 16) as *const u8)); - - match l61 { - 0 => None, - 1 => { - let e = { - let l62 = *((ptr1 + 20) as *const i32); - let l63 = *((ptr1 + 24) as *const i32); - let len64 = l63 as usize; - let bytes64 = Vec::from_raw_parts(l62 as *mut _, len64, len64); - - wit_bindgen::rt::string_lift(bytes64) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e65) - } - }; - - v65 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl FutureIncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the Response has - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-incoming-response.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl FutureIncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the incoming HTTP Response, or an error, once one is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the response or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the incoming HTTP Response - /// status and headers have recieved successfully, or that an error - /// occured. Errors may also occur while consuming the response body, - /// but those will be reported by the `incoming-body` and its - /// `output-stream` child. - pub fn get(&self,) -> Option,()>>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 56]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-incoming-response.get"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - - match l3 { - 0 => { - let e = { - let l4 = *((ptr0 + 24) as *const i32); - - IncomingResponse::from_handle(l4 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 24) as *const u8)); - let v67 = match l5 { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); + + match l3 { + 0 => { + let e = { + let l4 = *ptr0.add(24).cast::(); + + IncomingResponse::from_handle(l4 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from( + *ptr0.add(24).cast::(), + ); + let v67 = match l5 { 0 => { ErrorCode::DnsTimeout } 1 => { let e67 = { - let l6 = i32::from(*((ptr0 + 32) as *const u8)); - let l10 = i32::from(*((ptr0 + 44) as *const u8)); - + let l6 = i32::from(*ptr0.add(32).cast::()); + let l10 = i32::from(*ptr0.add(44).cast::()); + DnsErrorPayload{ rcode: match l6 { 0 => None, 1 => { let e = { - let l7 = *((ptr0 + 36) as *const i32); - let l8 = *((ptr0 + 40) as *const i32); - let len9 = l8 as usize; - let bytes9 = Vec::from_raw_parts(l7 as *mut _, len9, len9); - - wit_bindgen::rt::string_lift(bytes9) + let l7 = *ptr0.add(36).cast::<*mut u8>(); + let l8 = *ptr0.add(40).cast::(); + let len9 = l8; + let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9); + + _rt::string_lift(bytes9) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l10 { 0 => None, 1 => { let e = { - let l11 = i32::from(*((ptr0 + 46) as *const u16)); - + let l11 = i32::from(*ptr0.add(46).cast::()); + l11 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5189,36 +5452,36 @@ pub mod wasi { } 14 => { let e67 = { - let l12 = i32::from(*((ptr0 + 32) as *const u8)); - let l14 = i32::from(*((ptr0 + 36) as *const u8)); - + let l12 = i32::from(*ptr0.add(32).cast::()); + let l14 = i32::from(*ptr0.add(36).cast::()); + TlsAlertReceivedPayload{ alert_id: match l12 { 0 => None, 1 => { let e = { - let l13 = i32::from(*((ptr0 + 33) as *const u8)); - + let l13 = i32::from(*ptr0.add(33).cast::()); + l13 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l14 { 0 => None, 1 => { let e = { - let l15 = *((ptr0 + 40) as *const i32); - let l16 = *((ptr0 + 44) as *const i32); - let len17 = l16 as usize; - let bytes17 = Vec::from_raw_parts(l15 as *mut _, len17, len17); - - wit_bindgen::rt::string_lift(bytes17) + let l15 = *ptr0.add(40).cast::<*mut u8>(); + let l16 = *ptr0.add(44).cast::(); + let len17 = l16; + let bytes17 = _rt::Vec::from_raw_parts(l15.cast(), len17, len17); + + _rt::string_lift(bytes17) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5232,19 +5495,19 @@ pub mod wasi { } 17 => { let e67 = { - let l18 = i32::from(*((ptr0 + 32) as *const u8)); - + let l18 = i32::from(*ptr0.add(32).cast::()); + match l18 { 0 => None, 1 => { let e = { - let l19 = *((ptr0 + 40) as *const i64); - + let l19 = *ptr0.add(40).cast::(); + l19 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestBodySize(e67) @@ -5260,122 +5523,122 @@ pub mod wasi { } 21 => { let e67 = { - let l20 = i32::from(*((ptr0 + 32) as *const u8)); - + let l20 = i32::from(*ptr0.add(32).cast::()); + match l20 { 0 => None, 1 => { let e = { - let l21 = *((ptr0 + 36) as *const i32); - + let l21 = *ptr0.add(36).cast::(); + l21 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSectionSize(e67) } 22 => { let e67 = { - let l22 = i32::from(*((ptr0 + 32) as *const u8)); - + let l22 = i32::from(*ptr0.add(32).cast::()); + match l22 { 0 => None, 1 => { let e = { - let l23 = i32::from(*((ptr0 + 36) as *const u8)); - let l27 = i32::from(*((ptr0 + 48) as *const u8)); - + let l23 = i32::from(*ptr0.add(36).cast::()); + let l27 = i32::from(*ptr0.add(48).cast::()); + FieldSizePayload{ field_name: match l23 { 0 => None, 1 => { let e = { - let l24 = *((ptr0 + 40) as *const i32); - let l25 = *((ptr0 + 44) as *const i32); - let len26 = l25 as usize; - let bytes26 = Vec::from_raw_parts(l24 as *mut _, len26, len26); - - wit_bindgen::rt::string_lift(bytes26) + let l24 = *ptr0.add(40).cast::<*mut u8>(); + let l25 = *ptr0.add(44).cast::(); + let len26 = l25; + let bytes26 = _rt::Vec::from_raw_parts(l24.cast(), len26, len26); + + _rt::string_lift(bytes26) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l27 { 0 => None, 1 => { let e = { - let l28 = *((ptr0 + 52) as *const i32); - + let l28 = *ptr0.add(52).cast::(); + l28 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSize(e67) } 23 => { let e67 = { - let l29 = i32::from(*((ptr0 + 32) as *const u8)); - + let l29 = i32::from(*ptr0.add(32).cast::()); + match l29 { 0 => None, 1 => { let e = { - let l30 = *((ptr0 + 36) as *const i32); - + let l30 = *ptr0.add(36).cast::(); + l30 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestTrailerSectionSize(e67) } 24 => { let e67 = { - let l31 = i32::from(*((ptr0 + 32) as *const u8)); - let l35 = i32::from(*((ptr0 + 44) as *const u8)); - + let l31 = i32::from(*ptr0.add(32).cast::()); + let l35 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l31 { 0 => None, 1 => { let e = { - let l32 = *((ptr0 + 36) as *const i32); - let l33 = *((ptr0 + 40) as *const i32); - let len34 = l33 as usize; - let bytes34 = Vec::from_raw_parts(l32 as *mut _, len34, len34); - - wit_bindgen::rt::string_lift(bytes34) + let l32 = *ptr0.add(36).cast::<*mut u8>(); + let l33 = *ptr0.add(40).cast::(); + let len34 = l33; + let bytes34 = _rt::Vec::from_raw_parts(l32.cast(), len34, len34); + + _rt::string_lift(bytes34) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l35 { 0 => None, 1 => { let e = { - let l36 = *((ptr0 + 48) as *const i32); - + let l36 = *ptr0.add(48).cast::(); + l36 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5386,55 +5649,55 @@ pub mod wasi { } 26 => { let e67 = { - let l37 = i32::from(*((ptr0 + 32) as *const u8)); - + let l37 = i32::from(*ptr0.add(32).cast::()); + match l37 { 0 => None, 1 => { let e = { - let l38 = *((ptr0 + 36) as *const i32); - + let l38 = *ptr0.add(36).cast::(); + l38 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseHeaderSectionSize(e67) } 27 => { let e67 = { - let l39 = i32::from(*((ptr0 + 32) as *const u8)); - let l43 = i32::from(*((ptr0 + 44) as *const u8)); - + let l39 = i32::from(*ptr0.add(32).cast::()); + let l43 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l39 { 0 => None, 1 => { let e = { - let l40 = *((ptr0 + 36) as *const i32); - let l41 = *((ptr0 + 40) as *const i32); - let len42 = l41 as usize; - let bytes42 = Vec::from_raw_parts(l40 as *mut _, len42, len42); - - wit_bindgen::rt::string_lift(bytes42) + let l40 = *ptr0.add(36).cast::<*mut u8>(); + let l41 = *ptr0.add(40).cast::(); + let len42 = l41; + let bytes42 = _rt::Vec::from_raw_parts(l40.cast(), len42, len42); + + _rt::string_lift(bytes42) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l43 { 0 => None, 1 => { let e = { - let l44 = *((ptr0 + 48) as *const i32); - + let l44 = *ptr0.add(48).cast::(); + l44 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5442,74 +5705,74 @@ pub mod wasi { } 28 => { let e67 = { - let l45 = i32::from(*((ptr0 + 32) as *const u8)); - + let l45 = i32::from(*ptr0.add(32).cast::()); + match l45 { 0 => None, 1 => { let e = { - let l46 = *((ptr0 + 40) as *const i64); - + let l46 = *ptr0.add(40).cast::(); + l46 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseBodySize(e67) } 29 => { let e67 = { - let l47 = i32::from(*((ptr0 + 32) as *const u8)); - + let l47 = i32::from(*ptr0.add(32).cast::()); + match l47 { 0 => None, 1 => { let e = { - let l48 = *((ptr0 + 36) as *const i32); - + let l48 = *ptr0.add(36).cast::(); + l48 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTrailerSectionSize(e67) } 30 => { let e67 = { - let l49 = i32::from(*((ptr0 + 32) as *const u8)); - let l53 = i32::from(*((ptr0 + 44) as *const u8)); - + let l49 = i32::from(*ptr0.add(32).cast::()); + let l53 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l49 { 0 => None, 1 => { let e = { - let l50 = *((ptr0 + 36) as *const i32); - let l51 = *((ptr0 + 40) as *const i32); - let len52 = l51 as usize; - let bytes52 = Vec::from_raw_parts(l50 as *mut _, len52, len52); - - wit_bindgen::rt::string_lift(bytes52) + let l50 = *ptr0.add(36).cast::<*mut u8>(); + let l51 = *ptr0.add(40).cast::(); + let len52 = l51; + let bytes52 = _rt::Vec::from_raw_parts(l50.cast(), len52, len52); + + _rt::string_lift(bytes52) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l53 { 0 => None, 1 => { let e = { - let l54 = *((ptr0 + 48) as *const i32); - + let l54 = *ptr0.add(48).cast::(); + l54 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5517,44 +5780,44 @@ pub mod wasi { } 31 => { let e67 = { - let l55 = i32::from(*((ptr0 + 32) as *const u8)); - + let l55 = i32::from(*ptr0.add(32).cast::()); + match l55 { 0 => None, 1 => { let e = { - let l56 = *((ptr0 + 36) as *const i32); - let l57 = *((ptr0 + 40) as *const i32); - let len58 = l57 as usize; - let bytes58 = Vec::from_raw_parts(l56 as *mut _, len58, len58); - - wit_bindgen::rt::string_lift(bytes58) + let l56 = *ptr0.add(36).cast::<*mut u8>(); + let l57 = *ptr0.add(40).cast::(); + let len58 = l57; + let bytes58 = _rt::Vec::from_raw_parts(l56.cast(), len58, len58); + + _rt::string_lift(bytes58) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTransferCoding(e67) } 32 => { let e67 = { - let l59 = i32::from(*((ptr0 + 32) as *const u8)); - + let l59 = i32::from(*ptr0.add(32).cast::()); + match l59 { 0 => None, 1 => { let e = { - let l60 = *((ptr0 + 36) as *const i32); - let l61 = *((ptr0 + 40) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) + let l60 = *ptr0.add(36).cast::<*mut u8>(); + let l61 = *ptr0.add(40).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts(l60.cast(), len62, len62); + + _rt::string_lift(bytes62) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseContentCoding(e67) @@ -5577,2198 +5840,2475 @@ pub mod wasi { n => { debug_assert_eq!(n, 38, "invalid enum discriminant"); let e67 = { - let l63 = i32::from(*((ptr0 + 32) as *const u8)); - + let l63 = i32::from(*ptr0.add(32).cast::()); + match l63 { 0 => None, 1 => { let e = { - let l64 = *((ptr0 + 36) as *const i32); - let l65 = *((ptr0 + 40) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) + let l64 = *ptr0.add(36).cast::<*mut u8>(); + let l65 = *ptr0.add(40).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts(l64.cast(), len66, len66); + + _rt::string_lift(bytes66) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::InternalError(e67) } }; - - v67 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + + v67 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + } + } } - } - - } - - - #[allow(clippy::all)] - pub mod outgoing_handler { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; - pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; - pub type FutureIncomingResponse = super::super::super::wasi::http::types::FutureIncomingResponse; - pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; - #[allow(unused_unsafe, clippy::all)] - /// This function is invoked with an outgoing HTTP Request, and it returns - /// a resource `future-incoming-response` which represents an HTTP Response - /// which may arrive in the future. - /// - /// The `options` argument accepts optional parameters for the HTTP - /// protocol's transport layer. - /// - /// This function may return an error if the `outgoing-request` is invalid - /// or not allowed to be made. Otherwise, protocol errors are reported - /// through the `future-incoming-response`. - pub fn handle(request: OutgoingRequest,options: Option,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let (result0_0,result0_1,) = match options { - Some(e) => (1i32, (e).into_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.0")] - extern "C" { - #[link_name = "handle"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((request).into_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr1 + 8) as *const u8)); - use super::super::super::wasi::http::types::ErrorCode as V66; - let v66 = match l4 { - 0 => { - V66::DnsTimeout - } - 1 => { - let e66 = { - let l5 = i32::from(*((ptr1 + 16) as *const u8)); - let l9 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::DnsErrorPayload{ + + #[allow(dead_code, clippy::all)] + pub mod outgoing_handler { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; + pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; + pub type FutureIncomingResponse = + super::super::super::wasi::http::types::FutureIncomingResponse; + pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; + #[allow(unused_unsafe, clippy::all)] + /// This function is invoked with an outgoing HTTP Request, and it returns + /// a resource `future-incoming-response` which represents an HTTP Response + /// which may arrive in the future. + /// + /// The `options` argument accepts optional parameters for the HTTP + /// protocol's transport layer. + /// + /// This function may return an error if the `outgoing-request` is invalid + /// or not allowed to be made. Otherwise, protocol errors are reported + /// through the `future-incoming-response`. + pub fn handle( + request: OutgoingRequest, + options: Option, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0, result0_1) = match &options { + Some(e) => (1i32, (e).take_handle() as i32), + None => (0i32, 0i32), + }; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.0")] + extern "C" { + #[link_name = "handle"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import((&request).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::(); + + super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(8).cast::()); + use super::super::super::wasi::http::types::ErrorCode as V66; + let v66 = match l4 { + 0 => V66::DnsTimeout, + 1 => { + let e66 = { + let l5 = i32::from(*ptr1.add(16).cast::()); + let l9 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::DnsErrorPayload{ rcode: match l5 { 0 => None, 1 => { let e = { - let l6 = *((ptr1 + 20) as *const i32); - let l7 = *((ptr1 + 24) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - - wit_bindgen::rt::string_lift(bytes8) + let l6 = *ptr1.add(20).cast::<*mut u8>(); + let l7 = *ptr1.add(24).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + _rt::string_lift(bytes8) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l9 { 0 => None, 1 => { let e = { - let l10 = i32::from(*((ptr1 + 30) as *const u16)); - + let l10 = i32::from(*ptr1.add(30).cast::()); + l10 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::DnsError(e66) - } - 2 => { - V66::DestinationNotFound - } - 3 => { - V66::DestinationUnavailable - } - 4 => { - V66::DestinationIpProhibited - } - 5 => { - V66::DestinationIpUnroutable - } - 6 => { - V66::ConnectionRefused - } - 7 => { - V66::ConnectionTerminated - } - 8 => { - V66::ConnectionTimeout - } - 9 => { - V66::ConnectionReadTimeout - } - 10 => { - V66::ConnectionWriteTimeout - } - 11 => { - V66::ConnectionLimitReached - } - 12 => { - V66::TlsProtocolError - } - 13 => { - V66::TlsCertificateError - } - 14 => { - let e66 = { - let l11 = i32::from(*((ptr1 + 16) as *const u8)); - let l13 = i32::from(*((ptr1 + 20) as *const u8)); - - super::super::super::wasi::http::types::TlsAlertReceivedPayload{ + }; + V66::DnsError(e66) + } + 2 => V66::DestinationNotFound, + 3 => V66::DestinationUnavailable, + 4 => V66::DestinationIpProhibited, + 5 => V66::DestinationIpUnroutable, + 6 => V66::ConnectionRefused, + 7 => V66::ConnectionTerminated, + 8 => V66::ConnectionTimeout, + 9 => V66::ConnectionReadTimeout, + 10 => V66::ConnectionWriteTimeout, + 11 => V66::ConnectionLimitReached, + 12 => V66::TlsProtocolError, + 13 => V66::TlsCertificateError, + 14 => { + let e66 = { + let l11 = i32::from(*ptr1.add(16).cast::()); + let l13 = i32::from(*ptr1.add(20).cast::()); + + super::super::super::wasi::http::types::TlsAlertReceivedPayload{ alert_id: match l11 { 0 => None, 1 => { let e = { - let l12 = i32::from(*((ptr1 + 17) as *const u8)); - + let l12 = i32::from(*ptr1.add(17).cast::()); + l12 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l13 { 0 => None, 1 => { let e = { - let l14 = *((ptr1 + 24) as *const i32); - let l15 = *((ptr1 + 28) as *const i32); - let len16 = l15 as usize; - let bytes16 = Vec::from_raw_parts(l14 as *mut _, len16, len16); - - wit_bindgen::rt::string_lift(bytes16) + let l14 = *ptr1.add(24).cast::<*mut u8>(); + let l15 = *ptr1.add(28).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + + _rt::string_lift(bytes16) }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - V66::TlsAlertReceived(e66) - } - 15 => { - V66::HttpRequestDenied - } - 16 => { - V66::HttpRequestLengthRequired - } - 17 => { - let e66 = { - let l17 = i32::from(*((ptr1 + 16) as *const u8)); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *((ptr1 + 24) as *const i64); - - l18 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestBodySize(e66) - } - 18 => { - V66::HttpRequestMethodInvalid - } - 19 => { - V66::HttpRequestUriInvalid - } - 20 => { - V66::HttpRequestUriTooLong - } - 21 => { - let e66 = { - let l19 = i32::from(*((ptr1 + 16) as *const u8)); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *((ptr1 + 20) as *const i32); - - l20 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, } - }; - V66::HttpRequestHeaderSectionSize(e66) - } - 22 => { - let e66 = { - let l21 = i32::from(*((ptr1 + 16) as *const u8)); - - match l21 { - 0 => None, - 1 => { - let e = { - let l22 = i32::from(*((ptr1 + 20) as *const u8)); - let l26 = i32::from(*((ptr1 + 32) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::TlsAlertReceived(e66) + } + 15 => V66::HttpRequestDenied, + 16 => V66::HttpRequestLengthRequired, + 17 => { + let e66 = { + let l17 = i32::from(*ptr1.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr1.add(24).cast::(); + + l18 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestBodySize(e66) + } + 18 => V66::HttpRequestMethodInvalid, + 19 => V66::HttpRequestUriInvalid, + 20 => V66::HttpRequestUriTooLong, + 21 => { + let e66 = { + let l19 = i32::from(*ptr1.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *ptr1.add(20).cast::(); + + l20 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSectionSize(e66) + } + 22 => { + let e66 = { + let l21 = i32::from(*ptr1.add(16).cast::()); + + match l21 { + 0 => None, + 1 => { + let e = { + let l22 = + i32::from(*ptr1.add(20).cast::()); + let l26 = + i32::from(*ptr1.add(32).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l22 { 0 => None, 1 => { let e = { - let l23 = *((ptr1 + 24) as *const i32); - let l24 = *((ptr1 + 28) as *const i32); - let len25 = l24 as usize; - let bytes25 = Vec::from_raw_parts(l23 as *mut _, len25, len25); - - wit_bindgen::rt::string_lift(bytes25) + let l23 = *ptr1.add(24).cast::<*mut u8>(); + let l24 = *ptr1.add(28).cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts(l23.cast(), len25, len25); + + _rt::string_lift(bytes25) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l26 { 0 => None, 1 => { let e = { - let l27 = *((ptr1 + 36) as *const i32); - + let l27 = *ptr1.add(36).cast::(); + l27 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestHeaderSize(e66) - } - 23 => { - let e66 = { - let l28 = i32::from(*((ptr1 + 16) as *const u8)); - - match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *((ptr1 + 20) as *const i32); - - l29 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestTrailerSectionSize(e66) - } - 24 => { - let e66 = { - let l30 = i32::from(*((ptr1 + 16) as *const u8)); - let l34 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSize(e66) + } + 23 => { + let e66 = { + let l28 = i32::from(*ptr1.add(16).cast::()); + + match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *ptr1.add(20).cast::(); + + l29 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestTrailerSectionSize(e66) + } + 24 => { + let e66 = { + let l30 = i32::from(*ptr1.add(16).cast::()); + let l34 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l30 { 0 => None, 1 => { let e = { - let l31 = *((ptr1 + 20) as *const i32); - let l32 = *((ptr1 + 24) as *const i32); - let len33 = l32 as usize; - let bytes33 = Vec::from_raw_parts(l31 as *mut _, len33, len33); - - wit_bindgen::rt::string_lift(bytes33) + let l31 = *ptr1.add(20).cast::<*mut u8>(); + let l32 = *ptr1.add(24).cast::(); + let len33 = l32; + let bytes33 = _rt::Vec::from_raw_parts(l31.cast(), len33, len33); + + _rt::string_lift(bytes33) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l34 { 0 => None, 1 => { let e = { - let l35 = *((ptr1 + 32) as *const i32); - + let l35 = *ptr1.add(32).cast::(); + l35 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::HttpRequestTrailerSize(e66) - } - 25 => { - V66::HttpResponseIncomplete - } - 26 => { - let e66 = { - let l36 = i32::from(*((ptr1 + 16) as *const u8)); - - match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *((ptr1 + 20) as *const i32); - - l37 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseHeaderSectionSize(e66) - } - 27 => { - let e66 = { - let l38 = i32::from(*((ptr1 + 16) as *const u8)); - let l42 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::HttpRequestTrailerSize(e66) + } + 25 => V66::HttpResponseIncomplete, + 26 => { + let e66 = { + let l36 = i32::from(*ptr1.add(16).cast::()); + + match l36 { + 0 => None, + 1 => { + let e = { + let l37 = *ptr1.add(20).cast::(); + + l37 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseHeaderSectionSize(e66) + } + 27 => { + let e66 = { + let l38 = i32::from(*ptr1.add(16).cast::()); + let l42 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l38 { 0 => None, 1 => { let e = { - let l39 = *((ptr1 + 20) as *const i32); - let l40 = *((ptr1 + 24) as *const i32); - let len41 = l40 as usize; - let bytes41 = Vec::from_raw_parts(l39 as *mut _, len41, len41); - - wit_bindgen::rt::string_lift(bytes41) + let l39 = *ptr1.add(20).cast::<*mut u8>(); + let l40 = *ptr1.add(24).cast::(); + let len41 = l40; + let bytes41 = _rt::Vec::from_raw_parts(l39.cast(), len41, len41); + + _rt::string_lift(bytes41) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l42 { 0 => None, 1 => { let e = { - let l43 = *((ptr1 + 32) as *const i32); - + let l43 = *ptr1.add(32).cast::(); + l43 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::HttpResponseHeaderSize(e66) - } - 28 => { - let e66 = { - let l44 = i32::from(*((ptr1 + 16) as *const u8)); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *((ptr1 + 24) as *const i64); - - l45 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseBodySize(e66) - } - 29 => { - let e66 = { - let l46 = i32::from(*((ptr1 + 16) as *const u8)); - - match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *((ptr1 + 20) as *const i32); - - l47 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTrailerSectionSize(e66) - } - 30 => { - let e66 = { - let l48 = i32::from(*((ptr1 + 16) as *const u8)); - let l52 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::HttpResponseHeaderSize(e66) + } + 28 => { + let e66 = { + let l44 = i32::from(*ptr1.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr1.add(24).cast::(); + + l45 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseBodySize(e66) + } + 29 => { + let e66 = { + let l46 = i32::from(*ptr1.add(16).cast::()); + + match l46 { + 0 => None, + 1 => { + let e = { + let l47 = *ptr1.add(20).cast::(); + + l47 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTrailerSectionSize(e66) + } + 30 => { + let e66 = { + let l48 = i32::from(*ptr1.add(16).cast::()); + let l52 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l48 { 0 => None, 1 => { let e = { - let l49 = *((ptr1 + 20) as *const i32); - let l50 = *((ptr1 + 24) as *const i32); - let len51 = l50 as usize; - let bytes51 = Vec::from_raw_parts(l49 as *mut _, len51, len51); - - wit_bindgen::rt::string_lift(bytes51) + let l49 = *ptr1.add(20).cast::<*mut u8>(); + let l50 = *ptr1.add(24).cast::(); + let len51 = l50; + let bytes51 = _rt::Vec::from_raw_parts(l49.cast(), len51, len51); + + _rt::string_lift(bytes51) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l52 { 0 => None, 1 => { let e = { - let l53 = *((ptr1 + 32) as *const i32); - + let l53 = *ptr1.add(32).cast::(); + l53 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } + }; + V66::HttpResponseTrailerSize(e66) + } + 31 => { + let e66 = { + let l54 = i32::from(*ptr1.add(16).cast::()); + + match l54 { + 0 => None, + 1 => { + let e = { + let l55 = *ptr1.add(20).cast::<*mut u8>(); + let l56 = *ptr1.add(24).cast::(); + let len57 = l56; + let bytes57 = _rt::Vec::from_raw_parts( + l55.cast(), + len57, + len57, + ); + + _rt::string_lift(bytes57) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTransferCoding(e66) + } + 32 => { + let e66 = { + let l58 = i32::from(*ptr1.add(16).cast::()); + + match l58 { + 0 => None, + 1 => { + let e = { + let l59 = *ptr1.add(20).cast::<*mut u8>(); + let l60 = *ptr1.add(24).cast::(); + let len61 = l60; + let bytes61 = _rt::Vec::from_raw_parts( + l59.cast(), + len61, + len61, + ); + + _rt::string_lift(bytes61) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseContentCoding(e66) + } + 33 => V66::HttpResponseTimeout, + 34 => V66::HttpUpgradeFailed, + 35 => V66::HttpProtocolError, + 36 => V66::LoopDetected, + 37 => V66::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e66 = { + let l62 = i32::from(*ptr1.add(16).cast::()); + + match l62 { + 0 => None, + 1 => { + let e = { + let l63 = *ptr1.add(20).cast::<*mut u8>(); + let l64 = *ptr1.add(24).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::InternalError(e66) + } + }; + + v66 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } + } + } + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = in_; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } }; - V66::HttpResponseTrailerSize(e66) - } - 31 => { - let e66 = { - let l54 = i32::from(*((ptr1 + 16) as *const u8)); - - match l54 { - 0 => None, - 1 => { - let e = { - let l55 = *((ptr1 + 20) as *const i32); - let l56 = *((ptr1 + 24) as *const i32); - let len57 = l56 as usize; - let bytes57 = Vec::from_raw_parts(l55 as *mut _, len57, len57); - - wit_bindgen::rt::string_lift(bytes57) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTransferCoding(e66) - } - 32 => { - let e66 = { - let l58 = i32::from(*((ptr1 + 16) as *const u8)); - - match l58 { - 0 => None, - 1 => { - let e = { - let l59 = *((ptr1 + 20) as *const i32); - let l60 = *((ptr1 + 24) as *const i32); - let len61 = l60 as usize; - let bytes61 = Vec::from_raw_parts(l59 as *mut _, len61, len61); - - wit_bindgen::rt::string_lift(bytes61) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseContentCoding(e66) - } - 33 => { - V66::HttpResponseTimeout - } - 34 => { - V66::HttpUpgradeFailed - } - 35 => { - V66::HttpProtocolError - } - 36 => { - V66::LoopDetected - } - 37 => { - V66::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e66 = { - let l62 = i32::from(*((ptr1 + 16) as *const u8)); - - match l62 { - 0 => None, - 1 => { - let e = { - let l63 = *((ptr1 + 20) as *const i32); - let l64 = *((ptr1 + 24) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::InternalError(e66) - } - }; - - v66 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + for (i, e) in vec0.into_iter().enumerate() { + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } + } + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + if layout0.size() != 0 { + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, + } + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, + } + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => f + .debug_tuple("StreamError::LastOperationFailed") + .field(e) + .finish(), + StreamError::Closed => f.debug_tuple("StreamError::Closed").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 input bytestream. + /// + /// `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` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream { + handle: _rt::Resource, + } + + impl InputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for InputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// An output bytestream. + /// + /// `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` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream { + handle: _rt::Resource, + } + + impl OutputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, 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. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self, src: &InputStream, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice( + &self, + src: &InputStream, + len: u64, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } } - } - } - - } - pub mod io { - - #[allow(clippy::all)] - pub mod poll { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(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 len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } - } - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - if layout0.size() != 0 { - alloc::dealloc(result0, layout0); - } - Vec::from_raw_parts(l2 as *mut _, len4, len4) +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_run_with_interrupt_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run_with_interrupt(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_run_with_interrupt(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_send_request_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::send_request(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_process_response_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::process_response(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_process_response(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + pub trait Guest { + fn run() -> _rt::String; + fn run_with_interrupt() -> _rt::String; + fn send_request(); + fn process_response() -> _rt::String; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + #[export_name = "golem:it/api#run-with-interrupt"] + unsafe extern "C" fn export_run_with_interrupt() -> *mut u8 { + $($path_to_types)*::_export_run_with_interrupt_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#run-with-interrupt"] + unsafe extern "C" fn _post_return_run_with_interrupt(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run_with_interrupt::<$ty>(arg0) + } + #[export_name = "golem:it/api#send-request"] + unsafe extern "C" fn export_send_request() { + $($path_to_types)*::_export_send_request_cabi::<$ty>() + } + #[export_name = "golem:it/api#process-response"] + unsafe extern "C" fn export_process_response() -> *mut u8 { + $($path_to_types)*::_export_process_response_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#process-response"] + unsafe extern "C" fn _post_return_process_response(arg0: *mut u8,) { + $($path_to_types)*::__post_return_process_response::<$ty>(arg0) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + } } - } - } - - - #[allow(clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) } - + #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } - } - } - } - - - #[allow(clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An error for input-stream and output-stream operations. - pub enum StreamError{ - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() - } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").finish() - } - } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() } - } - impl ::core::fmt::Display for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } } - } - - impl std::error::Error for StreamError {} - /// An input bytestream. - /// - /// `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` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl InputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() } - } - - - unsafe impl wit_bindgen::rt::WasmResource for InputStream{ + } + + impl AsI64 for i64 { #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `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` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl OutputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) + fn as_i64(self) -> i64 { + self as i64 } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutputStream{ + } + + impl AsI64 for u64 { #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + fn as_i64(self) -> i64 { + self as i64 } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() } - } - impl InputStream { - #[allow(unused_unsafe, 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. - /// The created `pollable` is a child resource of the `input-stream`. - /// Implementations may trap if the `input-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - - } } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#run-with-interrupt"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run_with_interrupt() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run_with_interrupt(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#run-with-interrupt"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run_with_interrupt(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#send-request"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_send_request() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::send_request(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#process-response"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_process_response() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::process_response(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#process-response"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_process_response(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn run() -> wit_bindgen::rt::string::String; - fn run_with_interrupt() -> wit_bindgen::rt::string::String; - fn send_request(); - fn process_response() -> wit_bindgen::rt::string::String; - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 } - } } - + #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:http-client"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6646] = [3, 0, 11, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 102, 1, 65, 2, 1, 66, 6, 1, 64, 0, 0, 115, 4, 0, 3, 114, 117, 110, 1, 0, 4, 0, 18, 114, 117, 110, 45, 119, 105, 116, 104, 45, 105, 110, 116, 101, 114, 114, 117, 112, 116, 1, 0, 1, 64, 0, 1, 0, 4, 0, 12, 115, 101, 110, 100, 45, 114, 101, 113, 117, 101, 115, 116, 1, 1, 4, 0, 16, 112, 114, 111, 99, 101, 115, 115, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 0, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 253, 49, 1, 65, 2, 1, 65, 23, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 111, 45, 100, 101, 98, 117, 103, 45, 115, 116, 114, 105, 110, 103, 1, 2, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 5, 101, 114, 114, 111, 114, 2, 3, 0, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 40, 2, 3, 2, 1, 2, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 7, 1, 112, 125, 1, 106, 1, 10, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 11, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 1, 12, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 114, 101, 97, 100, 1, 12, 1, 106, 1, 119, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 107, 105, 112, 1, 14, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 107, 105, 112, 1, 14, 1, 105, 3, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 15, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 16, 1, 104, 8, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 13, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 99, 104, 101, 99, 107, 45, 119, 114, 105, 116, 101, 1, 18, 1, 106, 0, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 17, 8, 99, 111, 110, 116, 101, 110, 116, 115, 10, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 1, 20, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 20, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 102, 108, 117, 115, 104, 1, 21, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 102, 108, 117, 115, 104, 1, 21, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 15, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 22, 1, 64, 2, 4, 115, 101, 108, 102, 17, 3, 108, 101, 110, 119, 0, 19, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 1, 23, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 23, 1, 64, 3, 4, 115, 101, 108, 102, 17, 3, 115, 114, 99, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 112, 108, 105, 99, 101, 1, 24, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 112, 108, 105, 99, 101, 1, 24, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 4, 1, 66, 15, 2, 3, 2, 1, 3, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 1, 64, 0, 0, 3, 4, 0, 3, 110, 111, 119, 1, 6, 1, 64, 0, 0, 5, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 7, 1, 105, 1, 1, 64, 1, 4, 119, 104, 101, 110, 3, 0, 8, 4, 0, 17, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 105, 110, 115, 116, 97, 110, 116, 1, 9, 1, 64, 1, 4, 119, 104, 101, 110, 5, 0, 8, 4, 0, 18, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 100, 117, 114, 97, 116, 105, 111, 110, 1, 10, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 5, 2, 3, 0, 3, 8, 100, 117, 114, 97, 116, 105, 111, 110, 2, 3, 0, 2, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 2, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 192, 1, 2, 3, 2, 1, 6, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 0, 2, 3, 2, 1, 7, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 8, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 4, 2, 3, 2, 1, 2, 4, 0, 8, 105, 111, 45, 101, 114, 114, 111, 114, 3, 0, 6, 2, 3, 2, 1, 3, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 8, 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, 0, 6, 109, 101, 116, 104, 111, 100, 3, 0, 10, 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, 0, 6, 115, 99, 104, 101, 109, 101, 3, 0, 12, 1, 107, 115, 1, 107, 123, 1, 114, 2, 5, 114, 99, 111, 100, 101, 14, 9, 105, 110, 102, 111, 45, 99, 111, 100, 101, 15, 4, 0, 17, 68, 78, 83, 45, 101, 114, 114, 111, 114, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 16, 1, 107, 125, 1, 114, 2, 8, 97, 108, 101, 114, 116, 45, 105, 100, 18, 13, 97, 108, 101, 114, 116, 45, 109, 101, 115, 115, 97, 103, 101, 14, 4, 0, 26, 84, 76, 83, 45, 97, 108, 101, 114, 116, 45, 114, 101, 99, 101, 105, 118, 101, 100, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 19, 1, 107, 121, 1, 114, 2, 10, 102, 105, 101, 108, 100, 45, 110, 97, 109, 101, 14, 10, 102, 105, 101, 108, 100, 45, 115, 105, 122, 101, 21, 4, 0, 18, 102, 105, 101, 108, 100, 45, 115, 105, 122, 101, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 22, 1, 107, 119, 1, 107, 23, 1, 113, 39, 11, 68, 78, 83, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 9, 68, 78, 83, 45, 101, 114, 114, 111, 114, 1, 17, 0, 21, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 110, 111, 116, 45, 102, 111, 117, 110, 100, 0, 0, 23, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 117, 110, 97, 118, 97, 105, 108, 97, 98, 108, 101, 0, 0, 25, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 73, 80, 45, 112, 114, 111, 104, 105, 98, 105, 116, 101, 100, 0, 0, 25, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 73, 80, 45, 117, 110, 114, 111, 117, 116, 97, 98, 108, 101, 0, 0, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 102, 117, 115, 101, 100, 0, 0, 21, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 116, 101, 114, 109, 105, 110, 97, 116, 101, 100, 0, 0, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 23, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 97, 100, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 24, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 119, 114, 105, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 24, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 108, 105, 109, 105, 116, 45, 114, 101, 97, 99, 104, 101, 100, 0, 0, 18, 84, 76, 83, 45, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 0, 0, 21, 84, 76, 83, 45, 99, 101, 114, 116, 105, 102, 105, 99, 97, 116, 101, 45, 101, 114, 114, 111, 114, 0, 0, 18, 84, 76, 83, 45, 97, 108, 101, 114, 116, 45, 114, 101, 99, 101, 105, 118, 101, 100, 1, 20, 0, 19, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 100, 101, 110, 105, 101, 100, 0, 0, 28, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 108, 101, 110, 103, 116, 104, 45, 114, 101, 113, 117, 105, 114, 101, 100, 0, 0, 22, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 98, 111, 100, 121, 45, 115, 105, 122, 101, 1, 24, 0, 27, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 45, 105, 110, 118, 97, 108, 105, 100, 0, 0, 24, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 85, 82, 73, 45, 105, 110, 118, 97, 108, 105, 100, 0, 0, 25, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 85, 82, 73, 45, 116, 111, 111, 45, 108, 111, 110, 103, 0, 0, 32, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 24, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 45, 115, 105, 122, 101, 1, 25, 0, 33, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 25, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 24, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 105, 110, 99, 111, 109, 112, 108, 101, 116, 101, 0, 0, 33, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 25, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 23, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 98, 111, 100, 121, 45, 115, 105, 122, 101, 1, 24, 0, 34, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 26, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 29, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 110, 115, 102, 101, 114, 45, 99, 111, 100, 105, 110, 103, 1, 14, 0, 28, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 116, 101, 110, 116, 45, 99, 111, 100, 105, 110, 103, 1, 14, 0, 21, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 19, 72, 84, 84, 80, 45, 117, 112, 103, 114, 97, 100, 101, 45, 102, 97, 105, 108, 101, 100, 0, 0, 19, 72, 84, 84, 80, 45, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 0, 0, 13, 108, 111, 111, 112, 45, 100, 101, 116, 101, 99, 116, 101, 100, 0, 0, 19, 99, 111, 110, 102, 105, 103, 117, 114, 97, 116, 105, 111, 110, 45, 101, 114, 114, 111, 114, 0, 0, 14, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 14, 0, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 26, 1, 113, 3, 14, 105, 110, 118, 97, 108, 105, 100, 45, 115, 121, 110, 116, 97, 120, 0, 0, 9, 102, 111, 114, 98, 105, 100, 100, 101, 110, 0, 0, 9, 105, 109, 109, 117, 116, 97, 98, 108, 101, 0, 0, 4, 0, 12, 104, 101, 97, 100, 101, 114, 45, 101, 114, 114, 111, 114, 3, 0, 28, 1, 115, 4, 0, 9, 102, 105, 101, 108, 100, 45, 107, 101, 121, 3, 0, 30, 1, 112, 125, 4, 0, 11, 102, 105, 101, 108, 100, 45, 118, 97, 108, 117, 101, 3, 0, 32, 4, 0, 6, 102, 105, 101, 108, 100, 115, 3, 1, 4, 0, 7, 104, 101, 97, 100, 101, 114, 115, 3, 0, 34, 4, 0, 8, 116, 114, 97, 105, 108, 101, 114, 115, 3, 0, 34, 4, 0, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 1, 4, 0, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 1, 4, 0, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 3, 1, 4, 0, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 3, 1, 1, 123, 4, 0, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 3, 0, 41, 4, 0, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 3, 1, 4, 0, 13, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 3, 1, 4, 0, 15, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 3, 1, 4, 0, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 3, 1, 4, 0, 13, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 3, 1, 4, 0, 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, 3, 1, 1, 105, 34, 1, 64, 0, 0, 49, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 102, 105, 101, 108, 100, 115, 1, 50, 1, 111, 2, 31, 33, 1, 112, 51, 1, 106, 1, 49, 1, 29, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 52, 0, 53, 4, 0, 24, 91, 115, 116, 97, 116, 105, 99, 93, 102, 105, 101, 108, 100, 115, 46, 102, 114, 111, 109, 45, 108, 105, 115, 116, 1, 54, 1, 104, 34, 1, 112, 33, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 56, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 103, 101, 116, 1, 57, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 127, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 104, 97, 115, 1, 58, 1, 106, 0, 1, 29, 1, 64, 3, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 5, 118, 97, 108, 117, 101, 56, 0, 59, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 115, 101, 116, 1, 60, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 59, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 100, 101, 108, 101, 116, 101, 1, 61, 1, 64, 3, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 5, 118, 97, 108, 117, 101, 33, 0, 59, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 97, 112, 112, 101, 110, 100, 1, 62, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 52, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 101, 110, 116, 114, 105, 101, 115, 1, 63, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 49, 4, 0, 20, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 99, 108, 111, 110, 101, 1, 64, 1, 104, 37, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 11, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 109, 101, 116, 104, 111, 100, 1, 66, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 14, 4, 0, 40, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 67, 1, 107, 13, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 196, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 99, 104, 101, 109, 101, 1, 69, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 67, 1, 105, 35, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 198, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 104, 101, 97, 100, 101, 114, 115, 1, 71, 1, 105, 44, 1, 106, 1, 200, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 201, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 99, 111, 110, 115, 117, 109, 101, 1, 74, 1, 105, 38, 1, 64, 1, 7, 104, 101, 97, 100, 101, 114, 115, 198, 0, 0, 203, 0, 4, 0, 29, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 1, 76, 1, 104, 38, 1, 105, 47, 1, 106, 1, 206, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 207, 0, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 98, 111, 100, 121, 1, 80, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 11, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 109, 101, 116, 104, 111, 100, 1, 81, 1, 106, 0, 0, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 6, 109, 101, 116, 104, 111, 100, 11, 0, 210, 0, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 109, 101, 116, 104, 111, 100, 1, 83, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 14, 4, 0, 40, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 84, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 15, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 14, 0, 210, 0, 4, 0, 44, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 85, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 196, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 99, 104, 101, 109, 101, 1, 86, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 6, 115, 99, 104, 101, 109, 101, 196, 0, 0, 210, 0, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 115, 99, 104, 101, 109, 101, 1, 87, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 84, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 14, 0, 210, 0, 4, 0, 38, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 88, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 198, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 104, 101, 97, 100, 101, 114, 115, 1, 89, 1, 105, 39, 1, 64, 0, 0, 218, 0, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 1, 91, 1, 104, 39, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 220, 0, 0, 221, 0, 4, 0, 39, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 1, 64, 2, 4, 115, 101, 108, 102, 220, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 221, 0, 0, 210, 0, 4, 0, 43, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 4, 0, 42, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 4, 0, 45, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 4, 0, 49, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 1, 105, 40, 1, 105, 46, 1, 106, 1, 225, 0, 1, 27, 1, 64, 2, 5, 112, 97, 114, 97, 109, 224, 0, 8, 114, 101, 115, 112, 111, 110, 115, 101, 226, 0, 1, 0, 4, 0, 29, 91, 115, 116, 97, 116, 105, 99, 93, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 46, 115, 101, 116, 1, 99, 1, 104, 43, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 42, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 116, 97, 116, 117, 115, 1, 101, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 198, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 104, 101, 97, 100, 101, 114, 115, 1, 102, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 201, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 99, 111, 110, 115, 117, 109, 101, 1, 103, 1, 104, 44, 1, 105, 3, 1, 106, 1, 233, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 232, 0, 0, 234, 0, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 46, 115, 116, 114, 101, 97, 109, 1, 107, 1, 105, 45, 1, 64, 1, 4, 116, 104, 105, 115, 200, 0, 0, 236, 0, 4, 0, 28, 91, 115, 116, 97, 116, 105, 99, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 46, 102, 105, 110, 105, 115, 104, 1, 109, 1, 104, 45, 1, 105, 9, 1, 64, 1, 4, 115, 101, 108, 102, 238, 0, 0, 239, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 112, 1, 105, 36, 1, 107, 241, 0, 1, 106, 1, 242, 0, 1, 27, 1, 106, 1, 243, 0, 0, 1, 107, 244, 0, 1, 64, 1, 4, 115, 101, 108, 102, 238, 0, 0, 245, 0, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 46, 103, 101, 116, 1, 118, 1, 64, 1, 7, 104, 101, 97, 100, 101, 114, 115, 198, 0, 0, 225, 0, 4, 0, 30, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 119, 1, 104, 46, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 42, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 1, 121, 1, 64, 2, 4, 115, 101, 108, 102, 248, 0, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 42, 0, 210, 0, 4, 0, 41, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 101, 116, 45, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 1, 122, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 198, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 104, 101, 97, 100, 101, 114, 115, 1, 123, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 207, 0, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 98, 111, 100, 121, 1, 124, 1, 104, 47, 1, 105, 5, 1, 106, 1, 254, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 253, 0, 0, 255, 0, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 46, 119, 114, 105, 116, 101, 1, 128, 1, 1, 106, 0, 1, 27, 1, 64, 2, 4, 116, 104, 105, 115, 206, 0, 8, 116, 114, 97, 105, 108, 101, 114, 115, 242, 0, 0, 129, 1, 4, 0, 28, 91, 115, 116, 97, 116, 105, 99, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 46, 102, 105, 110, 105, 115, 104, 1, 130, 1, 1, 104, 48, 1, 64, 1, 4, 115, 101, 108, 102, 131, 1, 0, 239, 0, 4, 0, 42, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 132, 1, 1, 105, 43, 1, 106, 1, 133, 1, 1, 27, 1, 106, 1, 134, 1, 0, 1, 107, 135, 1, 1, 64, 1, 4, 115, 101, 108, 102, 131, 1, 0, 136, 1, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 103, 101, 116, 1, 137, 1, 1, 104, 7, 1, 107, 27, 1, 64, 1, 3, 101, 114, 114, 138, 1, 0, 139, 1, 4, 0, 15, 104, 116, 116, 112, 45, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 1, 140, 1, 3, 1, 21, 119, 97, 115, 105, 58, 104, 116, 116, 112, 47, 116, 121, 112, 101, 115, 64, 48, 46, 50, 46, 48, 5, 9, 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, 2, 3, 0, 4, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 1, 66, 15, 2, 3, 2, 1, 10, 4, 0, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 0, 2, 3, 2, 1, 11, 4, 0, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 3, 0, 2, 2, 3, 2, 1, 12, 4, 0, 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, 3, 0, 4, 2, 3, 2, 1, 13, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 6, 1, 105, 1, 1, 105, 3, 1, 107, 9, 1, 105, 5, 1, 106, 1, 11, 1, 7, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 8, 7, 111, 112, 116, 105, 111, 110, 115, 10, 0, 12, 4, 0, 6, 104, 97, 110, 100, 108, 101, 1, 13, 3, 1, 32, 119, 97, 115, 105, 58, 104, 116, 116, 112, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 64, 48, 46, 50, 46, 48, 5, 14, 1, 66, 6, 1, 64, 0, 0, 115, 4, 0, 3, 114, 117, 110, 1, 0, 4, 0, 18, 114, 117, 110, 45, 119, 105, 116, 104, 45, 105, 110, 116, 101, 114, 114, 117, 112, 116, 1, 0, 1, 64, 0, 1, 0, 4, 0, 12, 115, 101, 110, 100, 45, 114, 101, 113, 117, 101, 115, 116, 1, 1, 4, 0, 16, 112, 114, 111, 99, 101, 115, 115, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 0, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 15, 4, 1, 20, 103, 111, 108, 101, 109, 58, 105, 116, 47, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 4, 0, 11, 17, 1, 0, 11, 104, 116, 116, 112, 45, 99, 108, 105, 101, 110, 116, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_http_client_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_http_client_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:http-client:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6527] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xfd1\x01A\x02\x01A\x17\ +\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[\ +method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollab\ +le.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\ +\x01\x12wasi:io/poll@0.2.0\x05\0\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\ +\x04self\x01\0s\x04\0\x1d[method]error.to-debug-string\x01\x02\x03\x01\x13wasi:i\ +o/error@0.2.0\x05\x01\x02\x03\0\x01\x05error\x02\x03\0\0\x08pollable\x01B(\x02\x03\ +\x02\x01\x02\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\x02\ +\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0cstr\ +eam-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\ +\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19\ +[method]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\ +\x01j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-str\ +eam.skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\x0e\x01i\x03\x01@\ +\x01\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\x01\x10\x01h\x08\x01\ +@\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-write\x01\x12\x01j\0\x01\ +\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b[method]output-stream.w\ +rite\x01\x14\x04\0.[method]output-stream.blocking-write-and-flush\x01\x14\x01@\x01\ +\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\x01\x15\x04\0$[method]ou\ +tput-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]o\ +utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method\ +]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ +eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ +method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ +\x18\x03\x01\x15wasi:io/streams@0.2.0\x05\x04\x01B\x0f\x02\x03\x02\x01\x03\x04\0\ +\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01w\x04\0\x08duration\x03\0\ +\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\0\x0aresolution\x01\x07\x01\ +i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-instant\x01\x09\x01@\x01\x04\ +when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\x01!wasi:clocks/monotonic\ +-clock@0.2.0\x05\x05\x02\x03\0\x03\x08duration\x02\x03\0\x02\x0cinput-stream\x02\ +\x03\0\x02\x0doutput-stream\x01B\xc0\x01\x02\x03\x02\x01\x06\x04\0\x08duration\x03\ +\0\0\x02\x03\x02\x01\x07\x04\0\x0cinput-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\ +\0\x0doutput-stream\x03\0\x04\x02\x03\x02\x01\x02\x04\0\x08io-error\x03\0\x06\x02\ +\x03\x02\x01\x03\x04\0\x08pollable\x03\0\x08\x01q\x0a\x03get\0\0\x04head\0\0\x04\ +post\0\0\x03put\0\0\x06delete\0\0\x07connect\0\0\x07options\0\0\x05trace\0\0\x05\ +patch\0\0\x05other\x01s\0\x04\0\x06method\x03\0\x0a\x01q\x03\x04HTTP\0\0\x05HTTP\ +S\0\0\x05other\x01s\0\x04\0\x06scheme\x03\0\x0c\x01ks\x01k{\x01r\x02\x05rcode\x0e\ +\x09info-code\x0f\x04\0\x11DNS-error-payload\x03\0\x10\x01k}\x01r\x02\x08alert-i\ +d\x12\x0dalert-message\x0e\x04\0\x1aTLS-alert-received-payload\x03\0\x13\x01ky\x01\ +r\x02\x0afield-name\x0e\x0afield-size\x15\x04\0\x12field-size-payload\x03\0\x16\x01\ +kw\x01k\x17\x01q'\x0bDNS-timeout\0\0\x09DNS-error\x01\x11\0\x15destination-not-f\ +ound\0\0\x17destination-unavailable\0\0\x19destination-IP-prohibited\0\0\x19dest\ +ination-IP-unroutable\0\0\x12connection-refused\0\0\x15connection-terminated\0\0\ +\x12connection-timeout\0\0\x17connection-read-timeout\0\0\x18connection-write-ti\ +meout\0\0\x18connection-limit-reached\0\0\x12TLS-protocol-error\0\0\x15TLS-certi\ +ficate-error\0\0\x12TLS-alert-received\x01\x14\0\x13HTTP-request-denied\0\0\x1cH\ +TTP-request-length-required\0\0\x16HTTP-request-body-size\x01\x18\0\x1bHTTP-requ\ +est-method-invalid\0\0\x18HTTP-request-URI-invalid\0\0\x19HTTP-request-URI-too-l\ +ong\0\0\x20HTTP-request-header-section-size\x01\x15\0\x18HTTP-request-header-siz\ +e\x01\x19\0!HTTP-request-trailer-section-size\x01\x15\0\x19HTTP-request-trailer-\ +size\x01\x17\0\x18HTTP-response-incomplete\0\0!HTTP-response-header-section-size\ +\x01\x15\0\x19HTTP-response-header-size\x01\x17\0\x17HTTP-response-body-size\x01\ +\x18\0\"HTTP-response-trailer-section-size\x01\x15\0\x1aHTTP-response-trailer-si\ +ze\x01\x17\0\x1dHTTP-response-transfer-coding\x01\x0e\0\x1cHTTP-response-content\ +-coding\x01\x0e\0\x15HTTP-response-timeout\0\0\x13HTTP-upgrade-failed\0\0\x13HTT\ +P-protocol-error\0\0\x0dloop-detected\0\0\x13configuration-error\0\0\x0einternal\ +-error\x01\x0e\0\x04\0\x0aerror-code\x03\0\x1a\x01q\x03\x0einvalid-syntax\0\0\x09\ +forbidden\0\0\x09immutable\0\0\x04\0\x0cheader-error\x03\0\x1c\x01s\x04\0\x09fie\ +ld-key\x03\0\x1e\x01p}\x04\0\x0bfield-value\x03\0\x20\x04\0\x06fields\x03\x01\x04\ +\0\x07headers\x03\0\"\x04\0\x08trailers\x03\0\"\x04\0\x10incoming-request\x03\x01\ +\x04\0\x10outgoing-request\x03\x01\x04\0\x0frequest-options\x03\x01\x04\0\x11res\ +ponse-outparam\x03\x01\x01{\x04\0\x0bstatus-code\x03\0)\x04\0\x11incoming-respon\ +se\x03\x01\x04\0\x0dincoming-body\x03\x01\x04\0\x0ffuture-trailers\x03\x01\x04\0\ +\x11outgoing-response\x03\x01\x04\0\x0doutgoing-body\x03\x01\x04\0\x18future-inc\ +oming-response\x03\x01\x01i\"\x01@\0\01\x04\0\x13[constructor]fields\x012\x01o\x02\ +\x1f!\x01p3\x01j\x011\x01\x1d\x01@\x01\x07entries4\05\x04\0\x18[static]fields.fr\ +om-list\x016\x01h\"\x01p!\x01@\x02\x04self7\x04name\x1f\08\x04\0\x12[method]fiel\ +ds.get\x019\x01@\x02\x04self7\x04name\x1f\0\x7f\x04\0\x12[method]fields.has\x01:\ +\x01j\0\x01\x1d\x01@\x03\x04self7\x04name\x1f\x05value8\0;\x04\0\x12[method]fiel\ +ds.set\x01<\x01@\x02\x04self7\x04name\x1f\0;\x04\0\x15[method]fields.delete\x01=\ +\x01@\x03\x04self7\x04name\x1f\x05value!\0;\x04\0\x15[method]fields.append\x01>\x01\ +@\x01\x04self7\04\x04\0\x16[method]fields.entries\x01?\x01@\x01\x04self7\01\x04\0\ +\x14[method]fields.clone\x01@\x01h%\x01@\x01\x04self\xc1\0\0\x0b\x04\0\x1f[metho\ +d]incoming-request.method\x01B\x01@\x01\x04self\xc1\0\0\x0e\x04\0([method]incomi\ +ng-request.path-with-query\x01C\x01k\x0d\x01@\x01\x04self\xc1\0\0\xc4\0\x04\0\x1f\ +[method]incoming-request.scheme\x01E\x04\0\"[method]incoming-request.authority\x01\ +C\x01i#\x01@\x01\x04self\xc1\0\0\xc6\0\x04\0\x20[method]incoming-request.headers\ +\x01G\x01i,\x01j\x01\xc8\0\0\x01@\x01\x04self\xc1\0\0\xc9\0\x04\0\x20[method]inc\ +oming-request.consume\x01J\x01i&\x01@\x01\x07headers\xc6\0\0\xcb\0\x04\0\x1d[con\ +structor]outgoing-request\x01L\x01h&\x01i/\x01j\x01\xce\0\0\x01@\x01\x04self\xcd\ +\0\0\xcf\0\x04\0\x1d[method]outgoing-request.body\x01P\x01@\x01\x04self\xcd\0\0\x0b\ +\x04\0\x1f[method]outgoing-request.method\x01Q\x01j\0\0\x01@\x02\x04self\xcd\0\x06\ +method\x0b\0\xd2\0\x04\0#[method]outgoing-request.set-method\x01S\x01@\x01\x04se\ +lf\xcd\0\0\x0e\x04\0([method]outgoing-request.path-with-query\x01T\x01@\x02\x04s\ +elf\xcd\0\x0fpath-with-query\x0e\0\xd2\0\x04\0,[method]outgoing-request.set-path\ +-with-query\x01U\x01@\x01\x04self\xcd\0\0\xc4\0\x04\0\x1f[method]outgoing-reques\ +t.scheme\x01V\x01@\x02\x04self\xcd\0\x06scheme\xc4\0\0\xd2\0\x04\0#[method]outgo\ +ing-request.set-scheme\x01W\x04\0\"[method]outgoing-request.authority\x01T\x01@\x02\ +\x04self\xcd\0\x09authority\x0e\0\xd2\0\x04\0&[method]outgoing-request.set-autho\ +rity\x01X\x01@\x01\x04self\xcd\0\0\xc6\0\x04\0\x20[method]outgoing-request.heade\ +rs\x01Y\x01i'\x01@\0\0\xda\0\x04\0\x1c[constructor]request-options\x01[\x01h'\x01\ +k\x01\x01@\x01\x04self\xdc\0\0\xdd\0\x04\0'[method]request-options.connect-timeo\ +ut\x01^\x01@\x02\x04self\xdc\0\x08duration\xdd\0\0\xd2\0\x04\0+[method]request-o\ +ptions.set-connect-timeout\x01_\x04\0*[method]request-options.first-byte-timeout\ +\x01^\x04\0.[method]request-options.set-first-byte-timeout\x01_\x04\0-[method]re\ +quest-options.between-bytes-timeout\x01^\x04\01[method]request-options.set-betwe\ +en-bytes-timeout\x01_\x01i(\x01i.\x01j\x01\xe1\0\x01\x1b\x01@\x02\x05param\xe0\0\ +\x08response\xe2\0\x01\0\x04\0\x1d[static]response-outparam.set\x01c\x01h+\x01@\x01\ +\x04self\xe4\0\0*\x04\0\x20[method]incoming-response.status\x01e\x01@\x01\x04sel\ +f\xe4\0\0\xc6\0\x04\0![method]incoming-response.headers\x01f\x01@\x01\x04self\xe4\ +\0\0\xc9\0\x04\0![method]incoming-response.consume\x01g\x01h,\x01i\x03\x01j\x01\xe9\ +\0\0\x01@\x01\x04self\xe8\0\0\xea\0\x04\0\x1c[method]incoming-body.stream\x01k\x01\ +i-\x01@\x01\x04this\xc8\0\0\xec\0\x04\0\x1c[static]incoming-body.finish\x01m\x01\ +h-\x01i\x09\x01@\x01\x04self\xee\0\0\xef\0\x04\0![method]future-trailers.subscri\ +be\x01p\x01i$\x01k\xf1\0\x01j\x01\xf2\0\x01\x1b\x01j\x01\xf3\0\0\x01k\xf4\0\x01@\ +\x01\x04self\xee\0\0\xf5\0\x04\0\x1b[method]future-trailers.get\x01v\x01@\x01\x07\ +headers\xc6\0\0\xe1\0\x04\0\x1e[constructor]outgoing-response\x01w\x01h.\x01@\x01\ +\x04self\xf8\0\0*\x04\0%[method]outgoing-response.status-code\x01y\x01@\x02\x04s\ +elf\xf8\0\x0bstatus-code*\0\xd2\0\x04\0)[method]outgoing-response.set-status-cod\ +e\x01z\x01@\x01\x04self\xf8\0\0\xc6\0\x04\0![method]outgoing-response.headers\x01\ +{\x01@\x01\x04self\xf8\0\0\xcf\0\x04\0\x1e[method]outgoing-response.body\x01|\x01\ +h/\x01i\x05\x01j\x01\xfe\0\0\x01@\x01\x04self\xfd\0\0\xff\0\x04\0\x1b[method]out\ +going-body.write\x01\x80\x01\x01j\0\x01\x1b\x01@\x02\x04this\xce\0\x08trailers\xf2\ +\0\0\x81\x01\x04\0\x1c[static]outgoing-body.finish\x01\x82\x01\x01h0\x01@\x01\x04\ +self\x83\x01\0\xef\0\x04\0*[method]future-incoming-response.subscribe\x01\x84\x01\ +\x01i+\x01j\x01\x85\x01\x01\x1b\x01j\x01\x86\x01\0\x01k\x87\x01\x01@\x01\x04self\ +\x83\x01\0\x88\x01\x04\0$[method]future-incoming-response.get\x01\x89\x01\x01h\x07\ +\x01k\x1b\x01@\x01\x03err\x8a\x01\0\x8b\x01\x04\0\x0fhttp-error-code\x01\x8c\x01\ +\x03\x01\x15wasi:http/types@0.2.0\x05\x09\x02\x03\0\x04\x10outgoing-request\x02\x03\ +\0\x04\x0frequest-options\x02\x03\0\x04\x18future-incoming-response\x02\x03\0\x04\ +\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x0a\x04\0\x10outgoing-request\x03\0\0\x02\ +\x03\x02\x01\x0b\x04\0\x0frequest-options\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x18\ +future-incoming-response\x03\0\x04\x02\x03\x02\x01\x0d\x04\0\x0aerror-code\x03\0\ +\x06\x01i\x01\x01i\x03\x01k\x09\x01i\x05\x01j\x01\x0b\x01\x07\x01@\x02\x07reques\ +t\x08\x07options\x0a\0\x0c\x04\0\x06handle\x01\x0d\x03\x01\x20wasi:http/outgoing\ +-handler@0.2.0\x05\x0e\x01B\x06\x01@\0\0s\x04\0\x03run\x01\0\x04\0\x12run-with-i\ +nterrupt\x01\0\x01@\0\x01\0\x04\0\x0csend-request\x01\x01\x04\0\x10process-respo\ +nse\x01\0\x04\x01\x0cgolem:it/api\x05\x0f\x04\x01\x14golem:it/http-client\x04\0\x0b\ +\x11\x01\0\x0bhttp-client\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit\ +-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/http-client/src/lib.rs b/test-components/http-client/src/lib.rs index 83cdc7e000..2bcbae8e80 100644 --- a/test-components/http-client/src/lib.rs +++ b/test-components/http-client/src/lib.rs @@ -169,3 +169,5 @@ fn get_incoming_response( }; incoming_response } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/interruption.wasm b/test-components/interruption.wasm index d943393281..9385f92811 100755 Binary files a/test-components/interruption.wasm and b/test-components/interruption.wasm differ diff --git a/test-components/interruption/Cargo.lock b/test-components/interruption/Cargo.lock index 041dc04983..dbde4b05cd 100644 --- a/test-components/interruption/Cargo.lock +++ b/test-components/interruption/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-interruption" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/interruption/Cargo.toml b/test-components/interruption/Cargo.toml index e6f98eeaa3..f7768bb3dc 100644 --- a/test-components/interruption/Cargo.toml +++ b/test-components/interruption/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/interruption/src/bindings.rs b/test-components/interruption/src/bindings.rs index c957e16a24..849e68edbc 100644 --- a/test-components/interruption/src/bindings.rs +++ b/test-components/interruption/src/bindings.rs @@ -1,67 +1,108 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec2 = (result0.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; -}; -use super::Component as _GuestImpl; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); +} pub trait Guest { - fn run() -> wit_bindgen::rt::string::String; + fn run() -> _rt::String; } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_interruption_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_interruption_cabi; #[repr(align(4))] -struct _RetArea([u8; 8]); -static mut _RET_AREA: _RetArea = _RetArea([0; 8]); +struct _RetArea([::core::mem::MaybeUninit; 8]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_interruption_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_interruption_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_interruption_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:interruption"] +#[link_section = "component-type:wit-bindgen:0.25.0:interruption:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 180] = [3, 0, 12, 105, 110, 116, 101, 114, 114, 117, 112, 116, 105, 111, 110, 0, 97, 115, 109, 13, 0, 1, 0, 7, 45, 1, 65, 2, 1, 65, 2, 1, 64, 0, 0, 115, 4, 0, 3, 114, 117, 110, 1, 0, 4, 1, 21, 103, 111, 108, 101, 109, 58, 105, 116, 47, 105, 110, 116, 101, 114, 114, 117, 112, 116, 105, 111, 110, 4, 0, 11, 18, 1, 0, 12, 105, 110, 116, 101, 114, 114, 117, 112, 116, 105, 111, 110, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 175] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07-\x01A\x02\x01A\x02\x01\ +@\0\0s\x04\0\x03run\x01\0\x04\x01\x15golem:it/interruption\x04\0\x0b\x12\x01\0\x0c\ +interruption\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x07\ +0.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/interruption/src/lib.rs b/test-components/interruption/src/lib.rs index 497e1ae79e..0e19535a5b 100644 --- a/test-components/interruption/src/lib.rs +++ b/test-components/interruption/src/lib.rs @@ -17,3 +17,5 @@ impl Guest for Component { "done".to_string() } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/js-1.wasm b/test-components/js-1.wasm index da16f6ffad..5a049dc78e 100644 Binary files a/test-components/js-1.wasm and b/test-components/js-1.wasm differ diff --git a/test-components/js-2.wasm b/test-components/js-2.wasm index 9c125d0009..e762c08b55 100644 Binary files a/test-components/js-2.wasm and b/test-components/js-2.wasm differ diff --git a/test-components/js-3.wasm b/test-components/js-3.wasm index af4f915f52..1ff6898189 100644 Binary files a/test-components/js-3.wasm and b/test-components/js-3.wasm differ diff --git a/test-components/js-4.wasm b/test-components/js-4.wasm index 7d11906932..2ca799342e 100644 Binary files a/test-components/js-4.wasm and b/test-components/js-4.wasm differ diff --git a/test-components/js-echo.wasm b/test-components/js-echo.wasm index 97ced9d862..4cb079e6a7 100644 Binary files a/test-components/js-echo.wasm and b/test-components/js-echo.wasm differ diff --git a/test-components/key-value-service.wasm b/test-components/key-value-service.wasm index 9ca7eb589a..b7afd5a944 100755 Binary files a/test-components/key-value-service.wasm and b/test-components/key-value-service.wasm differ diff --git a/test-components/key-value-service/Cargo.lock b/test-components/key-value-service/Cargo.lock index 5b33b2d4fa..242549946b 100644 --- a/test-components/key-value-service/Cargo.lock +++ b/test-components/key-value-service/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "key-value-service" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/key-value-service/cargo.toml b/test-components/key-value-service/cargo.toml index f9f1d7643b..23045a899f 100644 --- a/test-components/key-value-service/cargo.toml +++ b/test-components/key-value-service/cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/key-value-service/src/bindings.rs b/test-components/key-value-service/src/bindings.rs index db06cf5525..596d7fc080 100644 --- a/test-components/key-value-service/src/bindings.rs +++ b/test-components/key-value-service/src/bindings.rs @@ -1,3047 +1,3218 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod wasi { - pub mod io { - - #[allow(clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> 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; + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } - } - } - - } - - - #[allow(clippy::all)] - pub mod poll { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, + } + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } + } + } + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = in_; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec0.into_iter().enumerate() { + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } + } + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + if layout0.size() != 0 { + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(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 len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } - } - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - if layout0.size() != 0 { - alloc::dealloc(result0, layout0); - } - Vec::from_raw_parts(l2 as *mut _, len4, len4) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, + } + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => f + .debug_tuple("StreamError::LastOperationFailed") + .field(e) + .finish(), + StreamError::Closed => f.debug_tuple("StreamError::Closed").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 input bytestream. + /// + /// `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` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream { + handle: _rt::Resource, + } + + impl InputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for InputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// An output bytestream. + /// + /// `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` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream { + handle: _rt::Resource, + } + + impl OutputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, 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. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-flush"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self, src: &InputStream, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice( + &self, + src: &InputStream, + len: u64, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } } - } - } - - - #[allow(clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An error for input-stream and output-stream operations. - pub enum StreamError{ - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() - } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").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 input bytestream. - /// - /// `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` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl InputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for InputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `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` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl OutputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, 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. - /// The created `pollable` is a child resource of the `input-stream`. - /// Implementations may trap if the `input-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> 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; + #[allow(dead_code)] + pub mod keyvalue { + #[allow(dead_code, clippy::all)] + pub mod wasi_keyvalue_error { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// An error resource type for keyvalue operations. + /// + /// Common errors: + /// - Connectivity errors (e.g. network errors): when the client cannot establish + /// a connection to the keyvalue service. + /// - Authentication and Authorization errors: when the client fails to authenticate + /// or does not have the required permissions to perform the operation. + /// - Data errors: when the client sends incompatible or corrupted data. + /// - Resource errors: when the system runs out of resources (e.g. memory). + /// - Internal errors: unexpected errors on the server side. + /// + /// Currently, this provides only one function to return a string representation + /// of the error. In the future, this will be extended to provide more information + /// about the error. + /// Soon: switch to `resource error { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, + } + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:keyvalue/wasi-keyvalue-error@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + pub fn trace(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/wasi-keyvalue-error@0.1.0")] + extern "C" { + #[link_name = "[method]error.trace"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; + + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type Error = super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error; + /// A bucket is a collection of key-value pairs. Each key-value pair is stored + /// as a entry in the bucket, and the bucket itself acts as a collection of all + /// these entries. + /// + /// It is worth noting that the exact terminology for bucket in key-value stores + /// can very depending on the specific implementation. For example, + /// 1. Amazon DynamoDB calls a collection of key-value pairs a table + /// 2. Redis has hashes, sets, and sorted sets as different types of collections + /// 3. Cassandra calls a collection of key-value pairs a column family + /// 4. MongoDB calls a collection of key-value pairs a collection + /// 5. Riak calls a collection of key-value pairs a bucket + /// 6. Memcached calls a collection of key-value pairs a slab + /// 7. Azure Cosmos DB calls a collection of key-value pairs a container + /// + /// In this interface, we use the term `bucket` to refer to a collection of key-value + /// Soon: switch to `resource bucket { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct Bucket { + handle: _rt::Resource, + } + + impl Bucket { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) + + unsafe impl _rt::WasmResource for Bucket { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]bucket"] + fn drop(_: u32); + } + + drop(_handle); + } } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) + + /// A key is a unique identifier for a value in a bucket. The key is used to + /// retrieve the value from the bucket. + pub type Key = _rt::String; + /// A value is the data stored in a key-value pair. The value can be of any type + /// that can be represented in a byte array. It provides a way to write the value + /// to the output-stream defined in the `wasi-io` interface. + /// Soon: switch to `resource value { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingValue { + handle: _rt::Resource, + } + + impl OutgoingValue { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingValue { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-value"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub type OutgoingValueBodyAsync = OutputStream; + pub type OutgoingValueBodySync = _rt::Vec; + /// A incoming-value is a wrapper around a value. It provides a way to read the value + /// from the `input-stream` defined in the `wasi-io` interface. + /// + /// The incoming-value provides two ways to consume the value: + /// 1. `incoming-value-consume-sync` consumes the value synchronously and returns the + /// value as a `list`. + /// 2. `incoming-value-consume-async` consumes the value asynchronously and returns the + /// value as an `input-stream`. + /// In addition, it provides a `incoming-value-size` function to get the size of the value. + /// This is useful when the value is large and the caller wants to allocate a buffer of + /// the right size to consume the value. + /// Soon: switch to `resource incoming-value { ... }` + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingValue { + handle: _rt::Resource, + } + + impl IncomingValue { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingValue { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-value"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub type IncomingValueAsyncBody = InputStream; + pub type IncomingValueSyncBody = _rt::Vec; + impl Bucket { + #[allow(unused_unsafe, clippy::all)] + /// Opens a bucket with the given name. + /// + /// If any error occurs, including if the bucket does not exist, it returns an `Err(error)`. + pub fn open_bucket(name: &str) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[static]bucket.open-bucket"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + Bucket::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingValue { + #[allow(unused_unsafe, clippy::all)] + pub fn new_outgoing_value() -> OutgoingValue { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[static]outgoing-value.new-outgoing-value"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + OutgoingValue::from_handle(ret as u32) + } + } + } + impl OutgoingValue { + #[allow(unused_unsafe, clippy::all)] + /// Writes the value to the output-stream asynchronously. + /// If any other error occurs, it returns an `Err(error)`. + pub fn outgoing_value_write_body_async( + &self, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[method]outgoing-value.outgoing-value-write-body-async"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr0.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingValue { + #[allow(unused_unsafe, clippy::all)] + /// Writes the value to the output-stream synchronously. + /// If any other error occurs, it returns an `Err(error)`. + pub fn outgoing_value_write_body_sync( + &self, + value: &OutgoingValueBodySync, + ) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = value; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[method]outgoing-value.outgoing-value-write-body-sync"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + /// Consumes the value synchronously and returns the value as a list of bytes. + /// If any other error occurs, it returns an `Err(error)`. + pub fn incoming_value_consume_sync(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[method]incoming-value.incoming-value-consume-sync"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = *ptr0.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + /// Consumes the value asynchronously and returns the value as an `input-stream`. + /// If any other error occurs, it returns an `Err(error)`. + pub fn incoming_value_consume_async( + &self, + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[method]incoming-value.incoming-value-consume-async"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle( + l2 as u32, + ) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr0.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingValue { + #[allow(unused_unsafe, clippy::all)] + /// The size of the value in bytes. + /// If the size is unknown or unavailable, this function returns an `Err(error)`. + pub fn incoming_value_size(&self) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] + extern "C" { + #[link_name = "[method]incoming-value.incoming-value-size"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + + #[allow(dead_code, clippy::all)] + pub mod eventual_batch { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bucket = super::super::super::wasi::keyvalue::types::Bucket; + pub type Error = super::super::super::wasi::keyvalue::types::Error; + pub type Key = super::super::super::wasi::keyvalue::types::Key; + pub type IncomingValue = super::super::super::wasi::keyvalue::types::IncomingValue; + pub type OutgoingValue = super::super::super::wasi::keyvalue::types::OutgoingValue; + #[allow(unused_unsafe, clippy::all)] + /// Get the values associated with the keys in the bucket. It returns a list of + /// incoming-value that can be consumed to get the value associated with the key. + /// + /// If any of the keys do not exist in the bucket, it returns a `none` value for + /// that key in the list. + /// + /// Note that the key-value pairs are guaranteed to be returned in the same order + /// + /// MAY show an out-of-date value if there are concurrent writes to the bucket. + /// + /// If any other error occurs, it returns an `Err(error)`. + pub fn get_many( + bucket: &Bucket, + keys: &[Key], + ) -> Result<_rt::Vec>, Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec1 = keys; + let len1 = vec1.len(); + let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + } else { + { + ::core::ptr::null_mut() + } }; - - v4 - }; - Err(e) + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 8); + { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + *base.add(4).cast::() = len0; + *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + } + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] + extern "C" { + #[link_name = "get-many"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, result1, len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(4).cast::<*mut u8>(); + let l5 = *ptr2.add(8).cast::(); + let base8 = l4; + let len8 = l5; + let mut result8 = _rt::Vec::with_capacity(len8); + for i in 0..len8 { + let base = base8.add(i * 8); + let e8 = { + let l6 = i32::from(*base.add(0).cast::()); + + match l6 { + 0 => None, + 1 => { + let e = { + let l7 = *base.add(4).cast::(); + + super::super::super::wasi::keyvalue::types::IncomingValue::from_handle(l7 as u32) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + result8.push(e8); + } + _rt::cabi_dealloc(base8, len8 * 8, 4); + + result8 + }; + Ok(e) + } + 1 => { + let e = { + let l9 = *ptr2.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l9 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { + #[allow(unused_unsafe, clippy::all)] + /// Get all the keys in the bucket. It returns a list of keys. + /// + /// Note that the keys are not guaranteed to be returned in any particular order. + /// + /// If the bucket is empty, it returns an empty list. + /// + /// MAY show an out-of-date list of keys if there are concurrent writes to the bucket. + /// + /// If any error occurs, it returns an `Err(error)`. + pub fn keys(bucket: &Bucket) -> Result<_rt::Vec, Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] + extern "C" { + #[link_name = "keys"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + let bytes6 = + _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + + result7 + }; + Ok(e) + } + 1 => { + let e = { + let l8 = *ptr0.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l8 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - } - impl OutputStream { #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 + /// Set the values associated with the keys in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// Note that the key-value pairs are not guaranteed to be set in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already set. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// set while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + pub fn set_many( + bucket: &Bucket, + key_values: &[(Key, &OutgoingValue)], + ) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec2 = key_values; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 12, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 12); + { + let (t0_0, t0_1) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + *base.add(8).cast::() = (t0_1).handle() as i32; + } + } + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] + extern "C" { + #[link_name = "set-many"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, result2, len2, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + match l4 { 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = *ptr3.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - } - impl OutputStream { #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 + /// Delete the key-value pairs associated with the keys in the bucket. + /// + /// Note that the key-value pairs are not guaranteed to be deleted in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it skips the key. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already deleted. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// deleted while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + pub fn delete_many(bucket: &Bucket, keys: &[Key]) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec1 = keys; + let len1 = vec1.len(); + let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + } else { + { + ::core::ptr::null_mut() + } }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 8); + { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + *base.add(4).cast::() = len0; + *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + } + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] + extern "C" { + #[link_name = "delete-many"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, result1, len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + match l3 { 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr2.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } - } - } - - } - - } - pub mod keyvalue { - - #[allow(clippy::all)] - pub mod wasi_keyvalue_error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// An error resource type for keyvalue operations. - /// - /// Common errors: - /// - Connectivity errors (e.g. network errors): when the client cannot establish - /// a connection to the keyvalue service. - /// - Authentication and Authorization errors: when the client fails to authenticate - /// or does not have the required permissions to perform the operation. - /// - Data errors: when the client sends incompatible or corrupted data. - /// - Resource errors: when the system runs out of resources (e.g. memory). - /// - Internal errors: unexpected errors on the server side. - /// - /// Currently, this provides only one function to return a string representation - /// of the error. In the future, this will be extended to provide more information - /// about the error. - /// Soon: switch to `resource error { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:keyvalue/wasi-keyvalue-error@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - pub fn trace(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/wasi-keyvalue-error@0.1.0")] - extern "C" { - #[link_name = "[method]error.trace"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } - } - } - } - - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type Error = super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error; - /// A bucket is a collection of key-value pairs. Each key-value pair is stored - /// as a entry in the bucket, and the bucket itself acts as a collection of all - /// these entries. - /// - /// It is worth noting that the exact terminology for bucket in key-value stores - /// can very depending on the specific implementation. For example, - /// 1. Amazon DynamoDB calls a collection of key-value pairs a table - /// 2. Redis has hashes, sets, and sorted sets as different types of collections - /// 3. Cassandra calls a collection of key-value pairs a column family - /// 4. MongoDB calls a collection of key-value pairs a collection - /// 5. Riak calls a collection of key-value pairs a bucket - /// 6. Memcached calls a collection of key-value pairs a slab - /// 7. Azure Cosmos DB calls a collection of key-value pairs a container - /// - /// In this interface, we use the term `bucket` to refer to a collection of key-value - /// Soon: switch to `resource bucket { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct Bucket{ - handle: wit_bindgen::rt::Resource, - } - - impl Bucket{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Bucket{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]bucket"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// A key is a unique identifier for a value in a bucket. The key is used to - /// retrieve the value from the bucket. - pub type Key = wit_bindgen::rt::string::String; - /// A value is the data stored in a key-value pair. The value can be of any type - /// that can be represented in a byte array. It provides a way to write the value - /// to the output-stream defined in the `wasi-io` interface. - /// Soon: switch to `resource value { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingValue{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingValue{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingValue{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-value"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - pub type OutgoingValueBodyAsync = OutputStream; - pub type OutgoingValueBodySync = wit_bindgen::rt::vec::Vec::; - /// A incoming-value is a wrapper around a value. It provides a way to read the value - /// from the `input-stream` defined in the `wasi-io` interface. - /// - /// The incoming-value provides two ways to consume the value: - /// 1. `incoming-value-consume-sync` consumes the value synchronously and returns the - /// value as a `list`. - /// 2. `incoming-value-consume-async` consumes the value asynchronously and returns the - /// value as an `input-stream`. - /// In addition, it provides a `incoming-value-size` function to get the size of the value. - /// This is useful when the value is large and the caller wants to allocate a buffer of - /// the right size to consume the value. - /// Soon: switch to `resource incoming-value { ... }` - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingValue{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingValue{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - + + #[allow(dead_code, clippy::all)] + pub mod eventual { + #[used] #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingValue{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-value"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - pub type IncomingValueAsyncBody = InputStream; - pub type IncomingValueSyncBody = wit_bindgen::rt::vec::Vec::; - impl Bucket { - #[allow(unused_unsafe, clippy::all)] - /// Opens a bucket with the given name. - /// - /// If any error occurs, including if the bucket does not exist, it returns an `Err(error)`. - pub fn open_bucket(name: &str,) -> 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 vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[static]bucket.open-bucket"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - Bucket::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingValue { - #[allow(unused_unsafe, clippy::all)] - pub fn new_outgoing_value() -> OutgoingValue{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[static]outgoing-value.new-outgoing-value"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - OutgoingValue::from_handle(ret as u32) - } - } - } - impl OutgoingValue { + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bucket = super::super::super::wasi::keyvalue::types::Bucket; + pub type Error = super::super::super::wasi::keyvalue::types::Error; + pub type IncomingValue = super::super::super::wasi::keyvalue::types::IncomingValue; + pub type Key = super::super::super::wasi::keyvalue::types::Key; + pub type OutgoingValue = super::super::super::wasi::keyvalue::types::OutgoingValue; #[allow(unused_unsafe, clippy::all)] - /// Writes the value to the output-stream asynchronously. + /// Get the value associated with the key in the bucket. + /// + /// The value is returned as an option. If the key-value pair exists in the + /// bucket, it returns `Ok(value)`. If the key does not exist in the + /// bucket, it returns `Ok(none)`. + /// /// If any other error occurs, it returns an `Err(error)`. - pub fn outgoing_value_write_body_async(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[method]outgoing-value.outgoing-value-write-body-async"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + pub fn get(bucket: &Bucket, key: &Key) -> Result, Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] + extern "C" { + #[link_name = "get"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + + match l3 { + 0 => None, + 1 => { + let e = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::keyvalue::types::IncomingValue::from_handle(l4 as u32) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = { + let l5 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - } - impl OutgoingValue { #[allow(unused_unsafe, clippy::all)] - /// Writes the value to the output-stream synchronously. + /// Set the value associated with the key in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// If the key does not exist in the bucket, it creates a new key-value pair. + /// /// If any other error occurs, it returns an `Err(error)`. - pub fn outgoing_value_write_body_sync(&self,value: &OutgoingValueBodySync,) -> Result<(),Error>{ - - #[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 = value; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[method]outgoing-value.outgoing-value-write-body-sync"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + pub fn set( + bucket: &Bucket, + key: &Key, + outgoing_value: &OutgoingValue, + ) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] + extern "C" { + #[link_name = "set"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8) { + unreachable!() + } + wit_import( + (bucket).handle() as i32, + ptr0.cast_mut(), + len0, + (outgoing_value).handle() as i32, + ptr1, + ); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - } - impl IncomingValue { #[allow(unused_unsafe, clippy::all)] - /// Consumes the value synchronously and returns the value as a list of bytes. + /// Delete the key-value pair associated with the key in the bucket. + /// + /// If the key does not exist in the bucket, it does nothing. + /// /// If any other error occurs, it returns an `Err(error)`. - pub fn incoming_value_consume_sync(&self,) -> Result{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[method]incoming-value.incoming-value-consume-sync"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + pub fn delete(bucket: &Bucket, key: &Key) -> Result<(), Error> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] + extern "C" { + #[link_name = "delete"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - } - impl IncomingValue { #[allow(unused_unsafe, clippy::all)] - /// Consumes the value asynchronously and returns the value as an `input-stream`. + /// Check if the key exists in the bucket. + /// + /// If the key exists in the bucket, it returns `Ok(true)`. If the key does + /// not exist in the bucket, it returns `Ok(false)`. + /// /// If any other error occurs, it returns an `Err(error)`. - pub fn incoming_value_consume_async(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[method]incoming-value.incoming-value-consume-async"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingValue { - #[allow(unused_unsafe, clippy::all)] - /// The size of the value in bytes. - /// If the size is unknown or unavailable, this function returns an `Err(error)`. - pub fn incoming_value_size(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/types@0.1.0")] - extern "C" { - #[link_name = "[method]incoming-value.incoming-value-size"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - - } - - - #[allow(clippy::all)] - pub mod eventual_batch { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Bucket = super::super::super::wasi::keyvalue::types::Bucket; - pub type Error = super::super::super::wasi::keyvalue::types::Error; - pub type Key = super::super::super::wasi::keyvalue::types::Key; - pub type IncomingValue = super::super::super::wasi::keyvalue::types::IncomingValue; - pub type OutgoingValue = super::super::super::wasi::keyvalue::types::OutgoingValue; - #[allow(unused_unsafe, clippy::all)] - /// Get the values associated with the keys in the bucket. It returns a list of - /// incoming-value that can be consumed to get the value associated with the key. - /// - /// If any of the keys do not exist in the bucket, it returns a `none` value for - /// that key in the list. - /// - /// Note that the key-value pairs are guaranteed to be returned in the same order - /// - /// MAY show an out-of-date value if there are concurrent writes to the bucket. - /// - /// If any other error occurs, it returns an `Err(error)`. - pub fn get_many(bucket: &Bucket,keys: &[Key],) -> Result>,Error>{ - - #[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 vec1 = keys; - let len1 = vec1.len() as i32; - let layout1 = alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = if layout1.size() != 0 - { - let ptr = alloc::alloc(layout1); - if ptr.is_null() - { - alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1 as i32 + (i as i32) * 8; - { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - *((base + 4) as *mut i32) = len0; - *((base + 0) as *mut i32) = ptr0; - } - } - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] - extern "C" { - #[link_name = "get-many"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, result1 as i32, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - if layout1.size() != 0 { - alloc::dealloc(result1, layout1); - } - match l3 { - 0 => { - let e = { - let l4 = *((ptr2 + 4) as *const i32); - let l5 = *((ptr2 + 8) as *const i32); - let base8 = l4; - let len8 = l5; - let mut result8 = Vec::with_capacity(len8 as usize); - for i in 0..len8 { - let base = base8 + i * 8; - let e8 = { - let l6 = i32::from(*((base + 0) as *const u8)); - - match l6 { - 0 => None, - 1 => { + pub fn exists(bucket: &Bucket, key: &Key) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] + extern "C" { + #[link_name = "exists"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((bucket).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { let e = { - let l7 = *((base + 4) as *const i32); - - super::super::super::wasi::keyvalue::types::IncomingValue::from_handle(l7 as u32) + let l3 = i32::from(*ptr1.add(4).cast::()); + + _rt::bool_lift(l3 as u8) }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - result8.push(e8); - } - wit_bindgen::rt::dealloc(base8, (len8 as usize) * 8, 4); - - result8 - }; - Ok(e) - } - 1 => { - let e = { - let l9 = *((ptr2 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l9 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get all the keys in the bucket. It returns a list of keys. - /// - /// Note that the keys are not guaranteed to be returned in any particular order. - /// - /// If the bucket is empty, it returns an empty list. - /// - /// MAY show an out-of-date list of keys if there are concurrent writes to the bucket. - /// - /// If any error occurs, it returns an `Err(error)`. - pub fn keys(bucket: &Bucket,) -> Result,Error>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] - extern "C" { - #[link_name = "keys"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base7 = l2; - let len7 = l3; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 8; - let e7 = { - let l4 = *((base + 0) as *const i32); - let l5 = *((base + 4) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 8, 4); - - result7 - }; - Ok(e) - } - 1 => { - let e = { - let l8 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l8 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Set the values associated with the keys in the bucket. If the key already - /// exists in the bucket, it overwrites the value. - /// - /// Note that the key-value pairs are not guaranteed to be set in the order - /// they are provided. - /// - /// If any of the keys do not exist in the bucket, it creates a new key-value pair. - /// - /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it - /// does not rollback the key-value pairs that were already set. Thus, this batch operation - /// does not guarantee atomicity, implying that some key-value pairs could be - /// set while others might fail. - /// - /// Other concurrent operations may also be able to see the partial results. - pub fn set_many(bucket: &Bucket,key_values: &[(Key,&OutgoingValue,)],) -> Result<(),Error>{ - - #[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 vec2 = key_values; - let len2 = vec2.len() as i32; - let layout2 = alloc::Layout::from_size_align_unchecked(vec2.len() * 12, 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) * 12; - { - 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; - *((base + 8) as *mut i32) = (t0_1).handle() as i32; - } - } - let ptr3 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] - extern "C" { - #[link_name = "set-many"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, result2 as i32, len2, ptr3); - let l4 = i32::from(*((ptr3 + 0) as *const u8)); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = *((ptr3 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Delete the key-value pairs associated with the keys in the bucket. - /// - /// Note that the key-value pairs are not guaranteed to be deleted in the order - /// they are provided. - /// - /// If any of the keys do not exist in the bucket, it skips the key. - /// - /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it - /// does not rollback the key-value pairs that were already deleted. Thus, this batch operation - /// does not guarantee atomicity, implying that some key-value pairs could be - /// deleted while others might fail. - /// - /// Other concurrent operations may also be able to see the partial results. - pub fn delete_many(bucket: &Bucket,keys: &[Key],) -> Result<(),Error>{ - - #[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 vec1 = keys; - let len1 = vec1.len() as i32; - let layout1 = alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = if layout1.size() != 0 - { - let ptr = alloc::alloc(layout1); - if ptr.is_null() - { - alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1 as i32 + (i as i32) * 8; - { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - *((base + 4) as *mut i32) = len0; - *((base + 0) as *mut i32) = ptr0; - } - } - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual-batch@0.1.0")] - extern "C" { - #[link_name = "delete-many"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, result1 as i32, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - if layout1.size() != 0 { - alloc::dealloc(result1, layout1); - } - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr2 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - - } - - - #[allow(clippy::all)] - pub mod eventual { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Bucket = super::super::super::wasi::keyvalue::types::Bucket; - pub type Error = super::super::super::wasi::keyvalue::types::Error; - pub type IncomingValue = super::super::super::wasi::keyvalue::types::IncomingValue; - pub type Key = super::super::super::wasi::keyvalue::types::Key; - pub type OutgoingValue = super::super::super::wasi::keyvalue::types::OutgoingValue; - #[allow(unused_unsafe, clippy::all)] - /// Get the value associated with the key in the bucket. - /// - /// The value is returned as an option. If the key-value pair exists in the - /// bucket, it returns `Ok(value)`. If the key does not exist in the - /// bucket, it returns `Ok(none)`. - /// - /// If any other error occurs, it returns an `Err(error)`. - pub fn get(bucket: &Bucket,key: &Key,) -> Result,Error>{ - - #[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 vec0 = key; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] - extern "C" { - #[link_name = "get"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - - match l3 { - 0 => None, - 1 => { - let e = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::keyvalue::types::IncomingValue::from_handle(l4 as u32) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = { - let l5 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l5 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Set the value associated with the key in the bucket. If the key already - /// exists in the bucket, it overwrites the value. - /// - /// If the key does not exist in the bucket, it creates a new key-value pair. - /// - /// If any other error occurs, it returns an `Err(error)`. - pub fn set(bucket: &Bucket,key: &Key,outgoing_value: &OutgoingValue,) -> Result<(),Error>{ - - #[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 = key; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] - extern "C" { - #[link_name = "set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, ptr0, len0, (outgoing_value).handle() as i32, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Delete the key-value pair associated with the key in the bucket. - /// - /// If the key does not exist in the bucket, it does nothing. - /// - /// If any other error occurs, it returns an `Err(error)`. - pub fn delete(bucket: &Bucket,key: &Key,) -> Result<(),Error>{ - - #[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 = key; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] - extern "C" { - #[link_name = "delete"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l3 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Check if the key exists in the bucket. - /// - /// If the key exists in the bucket, it returns `Ok(true)`. If the key does - /// not exist in the bucket, it returns `Ok(false)`. - /// - /// If any other error occurs, it returns an `Err(error)`. - pub fn exists(bucket: &Bucket,key: &Key,) -> 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 vec0 = key; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:keyvalue/eventual@0.1.0")] - extern "C" { - #[link_name = "exists"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((bucket).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - - wit_bindgen::rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = *((ptr1 + 4) as *const i32); - - super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - + Ok(e) + } + 1 => { + let e = { + let l4 = *ptr1.add(4).cast::(); + + super::super::super::wasi::keyvalue::wasi_keyvalue_error::Error::from_handle(l4 as u32) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } - - } } - pub mod exports { - pub mod golem { +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#delete"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_delete(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - <_GuestImpl as Guest>::delete(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#delete-many"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_delete_many(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let base4 = arg2; - let len4 = arg3; - let mut result4 = Vec::with_capacity(len4 as usize); - for i in 0..len4 { - let base = base4 + i * 8; - let e4 = { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - - wit_bindgen::rt::string_lift(bytes3) - }; - result4.push(e4); - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - <_GuestImpl as Guest>::delete_many(wit_bindgen::rt::string_lift(bytes0), result4); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#exists"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_exists(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::exists(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - match result2 { true => 1, false => 0 } - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = <_GuestImpl as Guest>::get(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1)); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - match result2 { - Some(e) => { - *((ptr3 + 0) as *mut u8) = (1i32) as u8; - let vec4 = (e).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 8) as *mut i32) = len4; - *((ptr3 + 4) as *mut i32) = ptr4; - }, - None => { - { - *((ptr3 + 0) as *mut u8) = (0i32) as u8; + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_delete_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + T::delete(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_delete_many_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let base4 = arg2; + let len4 = arg3; + let mut result4 = _rt::Vec::with_capacity(len4); + for i in 0..len4 { + let base = base4.add(i * 8); + let e4 = { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + + _rt::string_lift(bytes3) + }; + result4.push(e4); } - }, - };ptr3 - } - - const _: () = { + _rt::cabi_dealloc(base4, len4 * 8, 4); + T::delete_many(_rt::string_lift(bytes0), result4); + } #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - let base3 = l1; - let len3 = l2; - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 1, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-keys"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_keys(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::get_keys(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - let vec4 = result1; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 8; - { - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - } - } - *((ptr2 + 4) as *mut i32) = len4; - *((ptr2 + 0) as *mut i32) = result4 as i32; - ptr2 - } - - const _: () = { + pub unsafe fn _export_exists_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::exists(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + match result2 { + true => 1, + false => 0, + } + } #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-keys"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_keys(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-many"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_many(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let base4 = arg2; - let len4 = arg3; - let mut result4 = Vec::with_capacity(len4 as usize); - for i in 0..len4 { - let base = base4 + i * 8; - let e4 = { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - - wit_bindgen::rt::string_lift(bytes3) - }; - result4.push(e4); - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - let result5 = <_GuestImpl as Guest>::get_many(wit_bindgen::rt::string_lift(bytes0), result4); - let ptr6 = _RET_AREA.0.as_mut_ptr() as i32; - match result5 { - Some(e) => { - *((ptr6 + 0) as *mut u8) = (1i32) as u8; - let vec8 = e; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 8, 4); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 8; - { - let vec7 = (e).into_boxed_slice(); - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - ::core::mem::forget(vec7); - *((base + 4) as *mut i32) = len7; - *((base + 0) as *mut i32) = ptr7; - } - } - *((ptr6 + 8) as *mut i32) = len8; - *((ptr6 + 4) as *mut i32) = result8 as i32; - }, - None => { - { - *((ptr6 + 0) as *mut u8) = (0i32) as u8; + pub unsafe fn _export_get_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::get(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + match result2 { + Some(e) => { + *ptr3.add(0).cast::() = (1i32) as u8; + let vec4 = (e).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(8).cast::() = len4; + *ptr3.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + None => { + *ptr3.add(0).cast::() = (0i32) as u8; + } + }; + ptr3 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base3 = l1; + let len3 = l2; + _rt::cabi_dealloc(base3, len3 * 1, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_keys_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::get_keys(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec4 = result1; + let len4 = vec4.len(); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); + let result4 = if layout4.size() != 0 { + let ptr = _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 8); + { + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + } } - }, - };ptr6 - } - - const _: () = { + *ptr2.add(4).cast::() = len4; + *ptr2.add(0).cast::<*mut u8>() = result4; + ptr2 + } #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-many"] #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_many(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l4 = *((arg0 + 4) as *const i32); - let l5 = *((arg0 + 8) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *8; + pub unsafe fn __post_return_get_keys(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - let base3 = l1; - let len3 = l2; - wit_bindgen::rt::dealloc(base3, (len3 as usize) * 1, 1); - } - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 8, 4); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#set"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_set(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let len2 = arg5 as usize; - <_GuestImpl as Guest>::set(wit_bindgen::rt::string_lift(bytes0), wit_bindgen::rt::string_lift(bytes1), Vec::from_raw_parts(arg4 as *mut _, len2, len2)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#set-many"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_set_many(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let base7 = arg2; - let len7 = arg3; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 16; - let e7 = { - let l1 = *((base + 0) as *const i32); - let l2 = *((base + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - let l4 = *((base + 8) as *const i32); - let l5 = *((base + 12) as *const i32); - let len6 = l5 as usize; - - (wit_bindgen::rt::string_lift(bytes3), Vec::from_raw_parts(l4 as *mut _, len6, len6)) - }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 16, 4); - <_GuestImpl as Guest>::set_many(wit_bindgen::rt::string_lift(bytes0), result7); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn delete(bucket: wit_bindgen::rt::string::String,key: wit_bindgen::rt::string::String,); - fn delete_many(bucket: wit_bindgen::rt::string::String,keys: wit_bindgen::rt::vec::Vec::,); - fn exists(bucket: wit_bindgen::rt::string::String,key: wit_bindgen::rt::string::String,) -> bool; - fn get(bucket: wit_bindgen::rt::string::String,key: wit_bindgen::rt::string::String,) -> Option>; - fn get_keys(bucket: wit_bindgen::rt::string::String,) -> wit_bindgen::rt::vec::Vec::; - fn get_many(bucket: wit_bindgen::rt::string::String,keys: wit_bindgen::rt::vec::Vec::,) -> Option>>; - fn set(bucket: wit_bindgen::rt::string::String,key: wit_bindgen::rt::string::String,value: wit_bindgen::rt::vec::Vec::,); - fn set_many(bucket: wit_bindgen::rt::string::String,key_values: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::vec::Vec::,)>,); - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_many_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let base4 = arg2; + let len4 = arg3; + let mut result4 = _rt::Vec::with_capacity(len4); + for i in 0..len4 { + let base = base4.add(i * 8); + let e4 = { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + + _rt::string_lift(bytes3) + }; + result4.push(e4); + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + let result5 = T::get_many(_rt::string_lift(bytes0), result4); + let ptr6 = _RET_AREA.0.as_mut_ptr().cast::(); + match result5 { + Some(e) => { + *ptr6.add(0).cast::() = (1i32) as u8; + let vec8 = e; + let len8 = vec8.len(); + let layout8 = + _rt::alloc::Layout::from_size_align_unchecked(vec8.len() * 8, 4); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec8.into_iter().enumerate() { + let base = result8.add(i * 8); + { + let vec7 = (e).into_boxed_slice(); + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + ::core::mem::forget(vec7); + *base.add(4).cast::() = len7; + *base.add(0).cast::<*mut u8>() = ptr7.cast_mut(); + } + } + *ptr6.add(8).cast::() = len8; + *ptr6.add(4).cast::<*mut u8>() = result8; + } + None => { + *ptr6.add(0).cast::() = (0i32) as u8; + } + }; + ptr6 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_many(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l4 = *arg0.add(4).cast::<*mut u8>(); + let l5 = *arg0.add(8).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 8); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + let base3 = l1; + let len3 = l2; + _rt::cabi_dealloc(base3, len3 * 1, 1); + } + } + _rt::cabi_dealloc(base6, len6 * 8, 4); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_set_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: *mut u8, + arg5: usize, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let len2 = arg5; + T::set( + _rt::string_lift(bytes0), + _rt::string_lift(bytes1), + _rt::Vec::from_raw_parts(arg4.cast(), len2, len2), + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_set_many_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let base7 = arg2; + let len7 = arg3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 16); + let e7 = { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + let l4 = *base.add(8).cast::<*mut u8>(); + let l5 = *base.add(12).cast::(); + let len6 = l5; + + ( + _rt::string_lift(bytes3), + _rt::Vec::from_raw_parts(l4.cast(), len6, len6), + ) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 16, 4); + T::set_many(_rt::string_lift(bytes0), result7); + } + pub trait Guest { + fn delete(bucket: _rt::String, key: _rt::String); + fn delete_many(bucket: _rt::String, keys: _rt::Vec<_rt::String>); + fn exists(bucket: _rt::String, key: _rt::String) -> bool; + fn get(bucket: _rt::String, key: _rt::String) -> Option<_rt::Vec>; + fn get_keys(bucket: _rt::String) -> _rt::Vec<_rt::String>; + fn get_many( + bucket: _rt::String, + keys: _rt::Vec<_rt::String>, + ) -> Option<_rt::Vec<_rt::Vec>>; + fn set(bucket: _rt::String, key: _rt::String, value: _rt::Vec); + fn set_many( + bucket: _rt::String, + key_values: _rt::Vec<(_rt::String, _rt::Vec)>, + ); + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#delete"] + unsafe extern "C" fn export_delete(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) { + $($path_to_types)*::_export_delete_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "golem:it/api#delete-many"] + unsafe extern "C" fn export_delete_many(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) { + $($path_to_types)*::_export_delete_many_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "golem:it/api#exists"] + unsafe extern "C" fn export_exists(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> i32 { + $($path_to_types)*::_export_exists_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "golem:it/api#get"] + unsafe extern "C" fn export_get(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#get"] + unsafe extern "C" fn _post_return_get(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-keys"] + unsafe extern "C" fn export_get_keys(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_keys_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#get-keys"] + unsafe extern "C" fn _post_return_get_keys(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_keys::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-many"] + unsafe extern "C" fn export_get_many(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_many_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + #[export_name = "cabi_post_golem:it/api#get-many"] + unsafe extern "C" fn _post_return_get_many(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_many::<$ty>(arg0) + } + #[export_name = "golem:it/api#set"] + unsafe extern "C" fn export_set(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,) { + $($path_to_types)*::_export_set_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + #[export_name = "golem:it/api#set-many"] + unsafe extern "C" fn export_set_many(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) { + $($path_to_types)*::_export_set_many_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); + } } - } } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:key-value-service"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3507] = [3, 0, 17, 107, 101, 121, 45, 118, 97, 108, 117, 101, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 166, 2, 1, 65, 2, 1, 66, 23, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 1, 0, 4, 0, 6, 100, 101, 108, 101, 116, 101, 1, 0, 1, 112, 115, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 4, 107, 101, 121, 115, 1, 1, 0, 4, 0, 11, 100, 101, 108, 101, 116, 101, 45, 109, 97, 110, 121, 1, 2, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 0, 127, 4, 0, 6, 101, 120, 105, 115, 116, 115, 1, 3, 1, 112, 125, 1, 107, 4, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 0, 5, 4, 0, 3, 103, 101, 116, 1, 6, 1, 64, 1, 6, 98, 117, 99, 107, 101, 116, 115, 0, 1, 4, 0, 8, 103, 101, 116, 45, 107, 101, 121, 115, 1, 7, 1, 112, 4, 1, 107, 8, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 4, 107, 101, 121, 115, 1, 0, 9, 4, 0, 8, 103, 101, 116, 45, 109, 97, 110, 121, 1, 10, 1, 64, 3, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 5, 118, 97, 108, 117, 101, 4, 1, 0, 4, 0, 3, 115, 101, 116, 1, 11, 1, 111, 2, 115, 4, 1, 112, 12, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 10, 107, 101, 121, 45, 118, 97, 108, 117, 101, 115, 13, 1, 0, 4, 0, 8, 115, 101, 116, 45, 109, 97, 110, 121, 1, 14, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 237, 23, 1, 65, 2, 1, 65, 26, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 111, 45, 100, 101, 98, 117, 103, 45, 115, 116, 114, 105, 110, 103, 1, 2, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 0, 5, 101, 114, 114, 111, 114, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 40, 2, 3, 2, 1, 2, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 7, 1, 112, 125, 1, 106, 1, 10, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 11, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 1, 12, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 114, 101, 97, 100, 1, 12, 1, 106, 1, 119, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 107, 105, 112, 1, 14, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 107, 105, 112, 1, 14, 1, 105, 3, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 15, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 16, 1, 104, 8, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 13, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 99, 104, 101, 99, 107, 45, 119, 114, 105, 116, 101, 1, 18, 1, 106, 0, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 17, 8, 99, 111, 110, 116, 101, 110, 116, 115, 10, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 1, 20, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 20, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 102, 108, 117, 115, 104, 1, 21, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 102, 108, 117, 115, 104, 1, 21, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 15, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 22, 1, 64, 2, 4, 115, 101, 108, 102, 17, 3, 108, 101, 110, 119, 0, 19, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 1, 23, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 23, 1, 64, 3, 4, 115, 101, 108, 102, 17, 3, 115, 114, 99, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 112, 108, 105, 99, 101, 1, 24, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 112, 108, 105, 99, 101, 1, 24, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 4, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 19, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 114, 97, 99, 101, 1, 2, 3, 1, 39, 119, 97, 115, 105, 58, 107, 101, 121, 118, 97, 108, 117, 101, 47, 119, 97, 115, 105, 45, 107, 101, 121, 118, 97, 108, 117, 101, 45, 101, 114, 114, 111, 114, 64, 48, 46, 49, 46, 48, 5, 5, 2, 3, 0, 2, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 2, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 3, 5, 101, 114, 114, 111, 114, 1, 66, 44, 2, 3, 2, 1, 6, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 0, 2, 3, 2, 1, 7, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 8, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 4, 4, 0, 6, 98, 117, 99, 107, 101, 116, 3, 1, 1, 115, 4, 0, 3, 107, 101, 121, 3, 0, 7, 4, 0, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 1, 4, 0, 25, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 98, 111, 100, 121, 45, 97, 115, 121, 110, 99, 3, 0, 3, 1, 112, 125, 4, 0, 24, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 98, 111, 100, 121, 45, 115, 121, 110, 99, 3, 0, 11, 4, 0, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 1, 4, 0, 25, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 97, 115, 121, 110, 99, 45, 98, 111, 100, 121, 3, 0, 1, 1, 112, 125, 4, 0, 24, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 115, 121, 110, 99, 45, 98, 111, 100, 121, 3, 0, 15, 1, 105, 6, 1, 105, 5, 1, 106, 1, 17, 1, 18, 1, 64, 1, 4, 110, 97, 109, 101, 115, 0, 19, 4, 0, 26, 91, 115, 116, 97, 116, 105, 99, 93, 98, 117, 99, 107, 101, 116, 46, 111, 112, 101, 110, 45, 98, 117, 99, 107, 101, 116, 1, 20, 1, 105, 9, 1, 64, 0, 0, 21, 4, 0, 41, 91, 115, 116, 97, 116, 105, 99, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 110, 101, 119, 45, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 1, 22, 1, 104, 9, 1, 105, 10, 1, 106, 1, 24, 1, 18, 1, 64, 1, 4, 115, 101, 108, 102, 23, 0, 25, 4, 0, 54, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 119, 114, 105, 116, 101, 45, 98, 111, 100, 121, 45, 97, 115, 121, 110, 99, 1, 26, 1, 106, 0, 1, 18, 1, 64, 2, 4, 115, 101, 108, 102, 23, 5, 118, 97, 108, 117, 101, 12, 0, 27, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 119, 114, 105, 116, 101, 45, 98, 111, 100, 121, 45, 115, 121, 110, 99, 1, 28, 1, 104, 13, 1, 106, 1, 16, 1, 18, 1, 64, 1, 4, 115, 101, 108, 102, 29, 0, 30, 4, 0, 50, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 99, 111, 110, 115, 117, 109, 101, 45, 115, 121, 110, 99, 1, 31, 1, 105, 14, 1, 106, 1, 32, 1, 18, 1, 64, 1, 4, 115, 101, 108, 102, 29, 0, 33, 4, 0, 51, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 99, 111, 110, 115, 117, 109, 101, 45, 97, 115, 121, 110, 99, 1, 34, 1, 106, 1, 119, 1, 18, 1, 64, 1, 4, 115, 101, 108, 102, 29, 0, 35, 4, 0, 42, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 46, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 45, 115, 105, 122, 101, 1, 36, 3, 1, 25, 119, 97, 115, 105, 58, 107, 101, 121, 118, 97, 108, 117, 101, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 9, 2, 3, 0, 4, 6, 98, 117, 99, 107, 101, 116, 2, 3, 0, 4, 5, 101, 114, 114, 111, 114, 2, 3, 0, 4, 3, 107, 101, 121, 2, 3, 0, 4, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 2, 3, 0, 4, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 1, 66, 30, 2, 3, 2, 1, 10, 4, 0, 6, 98, 117, 99, 107, 101, 116, 3, 0, 0, 2, 3, 2, 1, 11, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 2, 2, 3, 2, 1, 12, 4, 0, 3, 107, 101, 121, 3, 0, 4, 2, 3, 2, 1, 13, 4, 0, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 6, 2, 3, 2, 1, 14, 4, 0, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 8, 1, 104, 1, 1, 112, 5, 1, 105, 7, 1, 107, 12, 1, 112, 13, 1, 105, 3, 1, 106, 1, 14, 1, 15, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 4, 107, 101, 121, 115, 11, 0, 16, 4, 0, 8, 103, 101, 116, 45, 109, 97, 110, 121, 1, 17, 1, 106, 1, 11, 1, 15, 1, 64, 1, 6, 98, 117, 99, 107, 101, 116, 10, 0, 18, 4, 0, 4, 107, 101, 121, 115, 1, 19, 1, 104, 9, 1, 111, 2, 5, 20, 1, 112, 21, 1, 106, 0, 1, 15, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 10, 107, 101, 121, 45, 118, 97, 108, 117, 101, 115, 22, 0, 23, 4, 0, 8, 115, 101, 116, 45, 109, 97, 110, 121, 1, 24, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 4, 107, 101, 121, 115, 11, 0, 23, 4, 0, 11, 100, 101, 108, 101, 116, 101, 45, 109, 97, 110, 121, 1, 25, 3, 1, 34, 119, 97, 115, 105, 58, 107, 101, 121, 118, 97, 108, 117, 101, 47, 101, 118, 101, 110, 116, 117, 97, 108, 45, 98, 97, 116, 99, 104, 64, 48, 46, 49, 46, 48, 5, 15, 1, 66, 26, 2, 3, 2, 1, 10, 4, 0, 6, 98, 117, 99, 107, 101, 116, 3, 0, 0, 2, 3, 2, 1, 11, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 2, 2, 3, 2, 1, 13, 4, 0, 14, 105, 110, 99, 111, 109, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 4, 2, 3, 2, 1, 12, 4, 0, 3, 107, 101, 121, 3, 0, 6, 2, 3, 2, 1, 14, 4, 0, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 3, 0, 8, 1, 104, 1, 1, 105, 5, 1, 107, 11, 1, 105, 3, 1, 106, 1, 12, 1, 13, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 3, 107, 101, 121, 7, 0, 14, 4, 0, 3, 103, 101, 116, 1, 15, 1, 104, 9, 1, 106, 0, 1, 13, 1, 64, 3, 6, 98, 117, 99, 107, 101, 116, 10, 3, 107, 101, 121, 7, 14, 111, 117, 116, 103, 111, 105, 110, 103, 45, 118, 97, 108, 117, 101, 16, 0, 17, 4, 0, 3, 115, 101, 116, 1, 18, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 3, 107, 101, 121, 7, 0, 17, 4, 0, 6, 100, 101, 108, 101, 116, 101, 1, 19, 1, 106, 1, 127, 1, 13, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 10, 3, 107, 101, 121, 7, 0, 20, 4, 0, 6, 101, 120, 105, 115, 116, 115, 1, 21, 3, 1, 28, 119, 97, 115, 105, 58, 107, 101, 121, 118, 97, 108, 117, 101, 47, 101, 118, 101, 110, 116, 117, 97, 108, 64, 48, 46, 49, 46, 48, 5, 16, 1, 66, 23, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 1, 0, 4, 0, 6, 100, 101, 108, 101, 116, 101, 1, 0, 1, 112, 115, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 4, 107, 101, 121, 115, 1, 1, 0, 4, 0, 11, 100, 101, 108, 101, 116, 101, 45, 109, 97, 110, 121, 1, 2, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 0, 127, 4, 0, 6, 101, 120, 105, 115, 116, 115, 1, 3, 1, 112, 125, 1, 107, 4, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 0, 5, 4, 0, 3, 103, 101, 116, 1, 6, 1, 64, 1, 6, 98, 117, 99, 107, 101, 116, 115, 0, 1, 4, 0, 8, 103, 101, 116, 45, 107, 101, 121, 115, 1, 7, 1, 112, 4, 1, 107, 8, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 4, 107, 101, 121, 115, 1, 0, 9, 4, 0, 8, 103, 101, 116, 45, 109, 97, 110, 121, 1, 10, 1, 64, 3, 6, 98, 117, 99, 107, 101, 116, 115, 3, 107, 101, 121, 115, 5, 118, 97, 108, 117, 101, 4, 1, 0, 4, 0, 3, 115, 101, 116, 1, 11, 1, 111, 2, 115, 4, 1, 112, 12, 1, 64, 2, 6, 98, 117, 99, 107, 101, 116, 115, 10, 107, 101, 121, 45, 118, 97, 108, 117, 101, 115, 13, 1, 0, 4, 0, 8, 115, 101, 116, 45, 109, 97, 110, 121, 1, 14, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 17, 4, 1, 26, 103, 111, 108, 101, 109, 58, 105, 116, 47, 107, 101, 121, 45, 118, 97, 108, 117, 101, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 23, 1, 0, 17, 107, 101, 121, 45, 118, 97, 108, 117, 101, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_key_value_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_key_value_service_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:key-value-service:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3189] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xed\x17\x01A\x02\x01\ +A\x1a\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\0\x1d[m\ +ethod]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\0\x01B\x0a\ +\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[method]po\ +llable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollable.block\x01\ +\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\x01\x12wa\ +si:io/poll@0.2.0\x05\x01\x02\x03\0\0\x05error\x02\x03\0\x01\x08pollable\x01B(\x02\ +\x03\x02\x01\x02\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\ +\0\x02\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0c\ +stream-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\ +\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19\ +[method]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\ +\x01j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-str\ +eam.skip\x01\x0e\x04\0\"[method]input-stream.blocking-skip\x01\x0e\x01i\x03\x01@\ +\x01\x04self\x09\0\x0f\x04\0\x1e[method]input-stream.subscribe\x01\x10\x01h\x08\x01\ +@\x01\x04self\x11\0\x0d\x04\0![method]output-stream.check-write\x01\x12\x01j\0\x01\ +\x06\x01@\x02\x04self\x11\x08contents\x0a\0\x13\x04\0\x1b[method]output-stream.w\ +rite\x01\x14\x04\0.[method]output-stream.blocking-write-and-flush\x01\x14\x01@\x01\ +\x04self\x11\0\x13\x04\0\x1b[method]output-stream.flush\x01\x15\x04\0$[method]ou\ +tput-stream.blocking-flush\x01\x15\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]o\ +utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method\ +]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ +eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ +method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ +\x18\x03\x01\x15wasi:io/streams@0.2.0\x05\x04\x01B\x04\x04\0\x05error\x03\x01\x01\ +h\0\x01@\x01\x04self\x01\0s\x04\0\x13[method]error.trace\x01\x02\x03\x01'wasi:ke\ +yvalue/wasi-keyvalue-error@0.1.0\x05\x05\x02\x03\0\x02\x0cinput-stream\x02\x03\0\ +\x02\x0doutput-stream\x02\x03\0\x03\x05error\x01B,\x02\x03\x02\x01\x06\x04\0\x0c\ +input-stream\x03\0\0\x02\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\x02\x02\x03\ +\x02\x01\x08\x04\0\x05error\x03\0\x04\x04\0\x06bucket\x03\x01\x01s\x04\0\x03key\x03\ +\0\x07\x04\0\x0eoutgoing-value\x03\x01\x04\0\x19outgoing-value-body-async\x03\0\x03\ +\x01p}\x04\0\x18outgoing-value-body-sync\x03\0\x0b\x04\0\x0eincoming-value\x03\x01\ +\x04\0\x19incoming-value-async-body\x03\0\x01\x01p}\x04\0\x18incoming-value-sync\ +-body\x03\0\x0f\x01i\x06\x01i\x05\x01j\x01\x11\x01\x12\x01@\x01\x04names\0\x13\x04\ +\0\x1a[static]bucket.open-bucket\x01\x14\x01i\x09\x01@\0\0\x15\x04\0)[static]out\ +going-value.new-outgoing-value\x01\x16\x01h\x09\x01i\x0a\x01j\x01\x18\x01\x12\x01\ +@\x01\x04self\x17\0\x19\x04\06[method]outgoing-value.outgoing-value-write-body-a\ +sync\x01\x1a\x01j\0\x01\x12\x01@\x02\x04self\x17\x05value\x0c\0\x1b\x04\05[metho\ +d]outgoing-value.outgoing-value-write-body-sync\x01\x1c\x01h\x0d\x01j\x01\x10\x01\ +\x12\x01@\x01\x04self\x1d\0\x1e\x04\02[method]incoming-value.incoming-value-cons\ +ume-sync\x01\x1f\x01i\x0e\x01j\x01\x20\x01\x12\x01@\x01\x04self\x1d\0!\x04\03[me\ +thod]incoming-value.incoming-value-consume-async\x01\"\x01j\x01w\x01\x12\x01@\x01\ +\x04self\x1d\0#\x04\0*[method]incoming-value.incoming-value-size\x01$\x03\x01\x19\ +wasi:keyvalue/types@0.1.0\x05\x09\x02\x03\0\x04\x06bucket\x02\x03\0\x04\x05error\ +\x02\x03\0\x04\x03key\x02\x03\0\x04\x0eincoming-value\x02\x03\0\x04\x0eoutgoing-\ +value\x01B\x1e\x02\x03\x02\x01\x0a\x04\0\x06bucket\x03\0\0\x02\x03\x02\x01\x0b\x04\ +\0\x05error\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x03key\x03\0\x04\x02\x03\x02\x01\ +\x0d\x04\0\x0eincoming-value\x03\0\x06\x02\x03\x02\x01\x0e\x04\0\x0eoutgoing-val\ +ue\x03\0\x08\x01h\x01\x01p\x05\x01i\x07\x01k\x0c\x01p\x0d\x01i\x03\x01j\x01\x0e\x01\ +\x0f\x01@\x02\x06bucket\x0a\x04keys\x0b\0\x10\x04\0\x08get-many\x01\x11\x01j\x01\ +\x0b\x01\x0f\x01@\x01\x06bucket\x0a\0\x12\x04\0\x04keys\x01\x13\x01h\x09\x01o\x02\ +\x05\x14\x01p\x15\x01j\0\x01\x0f\x01@\x02\x06bucket\x0a\x0akey-values\x16\0\x17\x04\ +\0\x08set-many\x01\x18\x01@\x02\x06bucket\x0a\x04keys\x0b\0\x17\x04\0\x0bdelete-\ +many\x01\x19\x03\x01\"wasi:keyvalue/eventual-batch@0.1.0\x05\x0f\x01B\x1a\x02\x03\ +\x02\x01\x0a\x04\0\x06bucket\x03\0\0\x02\x03\x02\x01\x0b\x04\0\x05error\x03\0\x02\ +\x02\x03\x02\x01\x0d\x04\0\x0eincoming-value\x03\0\x04\x02\x03\x02\x01\x0c\x04\0\ +\x03key\x03\0\x06\x02\x03\x02\x01\x0e\x04\0\x0eoutgoing-value\x03\0\x08\x01h\x01\ +\x01i\x05\x01k\x0b\x01i\x03\x01j\x01\x0c\x01\x0d\x01@\x02\x06bucket\x0a\x03key\x07\ +\0\x0e\x04\0\x03get\x01\x0f\x01h\x09\x01j\0\x01\x0d\x01@\x03\x06bucket\x0a\x03ke\ +y\x07\x0eoutgoing-value\x10\0\x11\x04\0\x03set\x01\x12\x01@\x02\x06bucket\x0a\x03\ +key\x07\0\x11\x04\0\x06delete\x01\x13\x01j\x01\x7f\x01\x0d\x01@\x02\x06bucket\x0a\ +\x03key\x07\0\x14\x04\0\x06exists\x01\x15\x03\x01\x1cwasi:keyvalue/eventual@0.1.\ +0\x05\x10\x01B\x17\x01@\x02\x06buckets\x03keys\x01\0\x04\0\x06delete\x01\0\x01ps\ +\x01@\x02\x06buckets\x04keys\x01\x01\0\x04\0\x0bdelete-many\x01\x02\x01@\x02\x06\ +buckets\x03keys\0\x7f\x04\0\x06exists\x01\x03\x01p}\x01k\x04\x01@\x02\x06buckets\ +\x03keys\0\x05\x04\0\x03get\x01\x06\x01@\x01\x06buckets\0\x01\x04\0\x08get-keys\x01\ +\x07\x01p\x04\x01k\x08\x01@\x02\x06buckets\x04keys\x01\0\x09\x04\0\x08get-many\x01\ +\x0a\x01@\x03\x06buckets\x03keys\x05value\x04\x01\0\x04\0\x03set\x01\x0b\x01o\x02\ +s\x04\x01p\x0c\x01@\x02\x06buckets\x0akey-values\x0d\x01\0\x04\0\x08set-many\x01\ +\x0e\x04\x01\x0cgolem:it/api\x05\x11\x04\x01\x1agolem:it/key-value-service\x04\0\ +\x0b\x17\x01\0\x11key-value-service\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/key-value-service/src/lib.rs b/test-components/key-value-service/src/lib.rs index 9eebdd2900..6fabd4352d 100644 --- a/test-components/key-value-service/src/lib.rs +++ b/test-components/key-value-service/src/lib.rs @@ -92,3 +92,5 @@ impl Guest for Component { set_many(&bucket, outgoing_values_refs.as_slice()).unwrap() } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/networking.wasm b/test-components/networking.wasm index 4fef299f43..05fa0f34ab 100755 Binary files a/test-components/networking.wasm and b/test-components/networking.wasm differ diff --git a/test-components/networking/Cargo.lock b/test-components/networking/Cargo.lock index e09f7d6b9c..6840030e36 100644 --- a/test-components/networking/Cargo.lock +++ b/test-components/networking/Cargo.lock @@ -12,14 +12,14 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" name = "networking" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/networking/Cargo.toml b/test-components/networking/Cargo.toml index 7ac4935347..233e385369 100644 --- a/test-components/networking/Cargo.toml +++ b/test-components/networking/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/networking/src/bindings.rs b/test-components/networking/src/bindings.rs index eb9437dbc9..533c511080 100644 --- a/test-components/networking/src/bindings.rs +++ b/test-components/networking/src/bindings.rs @@ -1,2519 +1,2740 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod host { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - /// An index into the persistent log storing all performed operations of a worker - pub type OplogIndex = u64; - /// Represents a Golem component's version - pub type ComponentVersion = u64; - /// UUID - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Uuid { - pub high_bits: u64, - pub low_bits: u64, - } - impl ::core::fmt::Debug for Uuid { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uuid").field("high-bits", &self.high_bits).field("low-bits", &self.low_bits).finish() - } - } - /// Represents a Golem component - #[repr(C)] - #[derive(Clone, Copy)] - pub struct ComponentId { - pub uuid: Uuid, - } - impl ::core::fmt::Debug for ComponentId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ComponentId").field("uuid", &self.uuid).finish() - } - } - /// Represents a Golem worker - #[derive(Clone)] - pub struct WorkerId { - pub component_id: ComponentId, - pub worker_name: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerId").field("component-id", &self.component_id).field("worker-name", &self.worker_name).finish() - } - } - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - #[derive(Clone)] - pub struct PromiseId { - pub worker_id: WorkerId, - pub oplog_idx: OplogIndex, - } - impl ::core::fmt::Debug for PromiseId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("PromiseId").field("worker-id", &self.worker_id).field("oplog-idx", &self.oplog_idx).finish() - } - } - /// Configures how the executor retries failures - #[repr(C)] - #[derive(Clone, Copy)] - pub struct RetryPolicy { - /// The maximum number of retries before the worker becomes permanently failed - pub max_attempts: u32, - /// The minimum delay between retries (applied to the first retry) - pub min_delay: Duration, - /// The maximum delay between retries - pub max_delay: Duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - pub multiplier: u32, - } - impl ::core::fmt::Debug for RetryPolicy { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RetryPolicy").field("max-attempts", &self.max_attempts).field("min-delay", &self.min_delay).field("max-delay", &self.max_delay).field("multiplier", &self.multiplier).finish() - } - } - /// Configurable persistence level for workers - #[derive(Clone, Copy)] - pub enum PersistenceLevel{ - PersistNothing, - PersistRemoteSideEffects, - Smart, - } - impl ::core::fmt::Debug for PersistenceLevel { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - PersistenceLevel::PersistNothing => { - f.debug_tuple("PersistenceLevel::PersistNothing").finish() - } - PersistenceLevel::PersistRemoteSideEffects => { - f.debug_tuple("PersistenceLevel::PersistRemoteSideEffects").finish() - } - PersistenceLevel::Smart => { - f.debug_tuple("PersistenceLevel::Smart").finish() - } - } - } - } - /// Describes how to update a worker to a different component version - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum UpdateMode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - Automatic, - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - SnapshotBased, - } - impl ::core::fmt::Debug for UpdateMode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - UpdateMode::Automatic => { - f.debug_tuple("UpdateMode::Automatic").finish() - } - UpdateMode::SnapshotBased => { - f.debug_tuple("UpdateMode::SnapshotBased").finish() - } - } - } - } - - impl UpdateMode{ - pub(crate) unsafe fn _lift(val: u8) -> UpdateMode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => UpdateMode::Automatic, - 1 => UpdateMode::SnapshotBased, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum FilterComparator { - Equal, - NotEqual, - GreaterEqual, - Greater, - LessEqual, - Less, - } - impl ::core::fmt::Debug for FilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - FilterComparator::Equal => { - f.debug_tuple("FilterComparator::Equal").finish() - } - FilterComparator::NotEqual => { - f.debug_tuple("FilterComparator::NotEqual").finish() - } - FilterComparator::GreaterEqual => { - f.debug_tuple("FilterComparator::GreaterEqual").finish() - } - FilterComparator::Greater => { - f.debug_tuple("FilterComparator::Greater").finish() - } - FilterComparator::LessEqual => { - f.debug_tuple("FilterComparator::LessEqual").finish() - } - FilterComparator::Less => { - f.debug_tuple("FilterComparator::Less").finish() - } - } - } - } - - impl FilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> FilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => FilterComparator::Equal, - 1 => FilterComparator::NotEqual, - 2 => FilterComparator::GreaterEqual, - 3 => FilterComparator::Greater, - 4 => FilterComparator::LessEqual, - 5 => FilterComparator::Less, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum StringFilterComparator { - Equal, - NotEqual, - Like, - NotLike, - } - impl ::core::fmt::Debug for StringFilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StringFilterComparator::Equal => { - f.debug_tuple("StringFilterComparator::Equal").finish() - } - StringFilterComparator::NotEqual => { - f.debug_tuple("StringFilterComparator::NotEqual").finish() - } - StringFilterComparator::Like => { - f.debug_tuple("StringFilterComparator::Like").finish() - } - StringFilterComparator::NotLike => { - f.debug_tuple("StringFilterComparator::NotLike").finish() - } - } - } - } - - impl StringFilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> StringFilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => StringFilterComparator::Equal, - 1 => StringFilterComparator::NotEqual, - 2 => StringFilterComparator::Like, - 3 => StringFilterComparator::NotLike, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum WorkerStatus { - /// The worker is running an invoked function - Running, - /// The worker is ready to run an invoked function - Idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - Suspended, - /// The last invocation was interrupted but will be resumed - Interrupted, - /// The last invocation failed and a retry was scheduled - Retrying, - /// The last invocation failed and the worker can no longer be used - Failed, - /// The worker exited after a successful invocation and can no longer be invoked - Exited, - } - impl ::core::fmt::Debug for WorkerStatus { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerStatus::Running => { - f.debug_tuple("WorkerStatus::Running").finish() - } - WorkerStatus::Idle => { - f.debug_tuple("WorkerStatus::Idle").finish() - } - WorkerStatus::Suspended => { - f.debug_tuple("WorkerStatus::Suspended").finish() - } - WorkerStatus::Interrupted => { - f.debug_tuple("WorkerStatus::Interrupted").finish() - } - WorkerStatus::Retrying => { - f.debug_tuple("WorkerStatus::Retrying").finish() - } - WorkerStatus::Failed => { - f.debug_tuple("WorkerStatus::Failed").finish() - } - WorkerStatus::Exited => { - f.debug_tuple("WorkerStatus::Exited").finish() - } - } - } - } - - impl WorkerStatus{ - pub(crate) unsafe fn _lift(val: u8) -> WorkerStatus{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => WorkerStatus::Running, - 1 => WorkerStatus::Idle, - 2 => WorkerStatus::Suspended, - 3 => WorkerStatus::Interrupted, - 4 => WorkerStatus::Retrying, - 5 => WorkerStatus::Failed, - 6 => WorkerStatus::Exited, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[derive(Clone)] - pub struct WorkerNameFilter { - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerNameFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerNameFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerStatusFilter { - pub comparator: FilterComparator, - pub value: WorkerStatus, - } - impl ::core::fmt::Debug for WorkerStatusFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerStatusFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerVersionFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerVersionFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerVersionFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerCreatedAtFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerCreatedAtFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerCreatedAtFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub struct WorkerEnvFilter { - pub name: wit_bindgen::rt::string::String, - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerEnvFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerEnvFilter").field("name", &self.name).field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WorkerPropertyFilter{ - Name(WorkerNameFilter), - Status(WorkerStatusFilter), - Version(WorkerVersionFilter), - CreatedAt(WorkerCreatedAtFilter), - Env(WorkerEnvFilter), - } - impl ::core::fmt::Debug for WorkerPropertyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerPropertyFilter::Name(e) => { - f.debug_tuple("WorkerPropertyFilter::Name").field(e).finish() - } - WorkerPropertyFilter::Status(e) => { - f.debug_tuple("WorkerPropertyFilter::Status").field(e).finish() - } - WorkerPropertyFilter::Version(e) => { - f.debug_tuple("WorkerPropertyFilter::Version").field(e).finish() - } - WorkerPropertyFilter::CreatedAt(e) => { - f.debug_tuple("WorkerPropertyFilter::CreatedAt").field(e).finish() - } - WorkerPropertyFilter::Env(e) => { - f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WorkerAllFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAllFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAllFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerAnyFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAnyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAnyFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerMetadata { - pub worker_id: WorkerId, - pub args: wit_bindgen::rt::vec::Vec::, - pub env: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>, - pub status: WorkerStatus, - pub component_version: u64, - pub retry_count: u64, - } - impl ::core::fmt::Debug for WorkerMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerMetadata").field("worker-id", &self.worker_id).field("args", &self.args).field("env", &self.env).field("status", &self.status).field("component-version", &self.component_version).field("retry-count", &self.retry_count).finish() - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct GetWorkers{ - handle: wit_bindgen::rt::Resource, - } - - impl GetWorkers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for GetWorkers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]get-workers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn new(component_id: ComponentId,filter: Option<&WorkerAnyFilter>,precise: bool,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - let ComponentId{ uuid:uuid0, } = component_id; - let Uuid{ high_bits:high_bits1, low_bits:low_bits1, } = uuid0; - let (result14_0,result14_1,result14_2,) = match filter { - Some(e) => { - let WorkerAnyFilter{ filters:filters2, } = e; - let vec13 = filters2; - let len13 = vec13.len() as i32; - let layout13 = alloc::Layout::from_size_align_unchecked(vec13.len() * 8, 4); - let result13 = if layout13.size() != 0 - { - let ptr = alloc::alloc(layout13); - if ptr.is_null() - { - alloc::handle_alloc_error(layout13); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec13.into_iter().enumerate() { - let base = result13 as i32 + (i as i32) * 8; - { - let WorkerAllFilter{ filters:filters3, } = e; - let vec12 = filters3; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 32, 8); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 32; - { - match e { - WorkerPropertyFilter::Name(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let WorkerNameFilter{ comparator:comparator4, value:value4, } = e; - *((base + 8) as *mut u8) = (comparator4.clone() as i32) as u8; - let vec5 = value4; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 16) as *mut i32) = len5; - *((base + 12) as *mut i32) = ptr5; - }, - WorkerPropertyFilter::Status(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let WorkerStatusFilter{ comparator:comparator6, value:value6, } = e; - *((base + 8) as *mut u8) = (comparator6.clone() as i32) as u8; - *((base + 9) as *mut u8) = (value6.clone() as i32) as u8; - }, - WorkerPropertyFilter::Version(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - let WorkerVersionFilter{ comparator:comparator7, value:value7, } = e; - *((base + 8) as *mut u8) = (comparator7.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value7); - }, - WorkerPropertyFilter::CreatedAt(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let WorkerCreatedAtFilter{ comparator:comparator8, value:value8, } = e; - *((base + 8) as *mut u8) = (comparator8.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value8); - }, - WorkerPropertyFilter::Env(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let WorkerEnvFilter{ name:name9, comparator:comparator9, value:value9, } = e; - let vec10 = name9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut u8) = (comparator9.clone() as i32) as u8; - let vec11 = value9; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - *((base + 24) as *mut i32) = len11; - *((base + 20) as *mut i32) = ptr11; - }, - } - } - } - *((base + 4) as *mut i32) = len12; - *((base + 0) as *mut i32) = result12 as i32; - cleanup_list.extend_from_slice(&[(result12, layout12),]); - } - } - cleanup_list.extend_from_slice(&[(result13, layout13),]); - - (1i32, result13 as i32, len13) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[constructor]get-workers"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits1), wit_bindgen::rt::as_i64(low_bits1), result14_0, result14_1, result14_2, match precise { true => 1, false => 0 }); - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - GetWorkers::from_handle(ret as u32) - } - } - } - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn get_next(&self,) -> Option>{ - - #[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; + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod host { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[method]get-workers.get-next"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base27 = l2; - let len27 = l3; - let mut result27 = Vec::with_capacity(len27 as usize); - for i in 0..len27 { - let base = base27 + i * 64; - let e27 = { - let l4 = *((base + 0) as *const i64); - let l5 = *((base + 8) as *const i64); - let l6 = *((base + 16) as *const i32); - let l7 = *((base + 20) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - let l9 = *((base + 24) as *const i32); - let l10 = *((base + 28) as *const i32); - let base14 = l9; - let len14 = l10; - let mut result14 = Vec::with_capacity(len14 as usize); - for i in 0..len14 { - let base = base14 + i * 8; - let e14 = { - let l11 = *((base + 0) as *const i32); - let l12 = *((base + 4) as *const i32); - let len13 = l12 as usize; - let bytes13 = Vec::from_raw_parts(l11 as *mut _, len13, len13); - - wit_bindgen::rt::string_lift(bytes13) - }; - result14.push(e14); - } - wit_bindgen::rt::dealloc(base14, (len14 as usize) * 8, 4); - let l15 = *((base + 32) as *const i32); - let l16 = *((base + 36) as *const i32); - let base23 = l15; - let len23 = l16; - let mut result23 = Vec::with_capacity(len23 as usize); - for i in 0..len23 { - let base = base23 + i * 16; - let e23 = { - let l17 = *((base + 0) as *const i32); - let l18 = *((base + 4) as *const i32); - let len19 = l18 as usize; - let bytes19 = Vec::from_raw_parts(l17 as *mut _, len19, len19); - let l20 = *((base + 8) as *const i32); - let l21 = *((base + 12) as *const i32); - let len22 = l21 as usize; - let bytes22 = Vec::from_raw_parts(l20 as *mut _, len22, len22); - - (wit_bindgen::rt::string_lift(bytes19), wit_bindgen::rt::string_lift(bytes22)) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + /// An index into the persistent log storing all performed operations of a worker + pub type OplogIndex = u64; + /// Represents a Golem component's version + pub type ComponentVersion = u64; + /// UUID + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Uuid { + pub high_bits: u64, + pub low_bits: u64, + } + impl ::core::fmt::Debug for Uuid { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uuid") + .field("high-bits", &self.high_bits) + .field("low-bits", &self.low_bits) + .finish() + } + } + /// Represents a Golem component + #[repr(C)] + #[derive(Clone, Copy)] + pub struct ComponentId { + pub uuid: Uuid, + } + impl ::core::fmt::Debug for ComponentId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ComponentId") + .field("uuid", &self.uuid) + .finish() + } + } + /// Represents a Golem worker + #[derive(Clone)] + pub struct WorkerId { + pub component_id: ComponentId, + pub worker_name: _rt::String, + } + impl ::core::fmt::Debug for WorkerId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerId") + .field("component-id", &self.component_id) + .field("worker-name", &self.worker_name) + .finish() + } + } + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + #[derive(Clone)] + pub struct PromiseId { + pub worker_id: WorkerId, + pub oplog_idx: OplogIndex, + } + impl ::core::fmt::Debug for PromiseId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PromiseId") + .field("worker-id", &self.worker_id) + .field("oplog-idx", &self.oplog_idx) + .finish() + } + } + /// Configures how the executor retries failures + #[repr(C)] + #[derive(Clone, Copy)] + pub struct RetryPolicy { + /// The maximum number of retries before the worker becomes permanently failed + pub max_attempts: u32, + /// The minimum delay between retries (applied to the first retry) + pub min_delay: Duration, + /// The maximum delay between retries + pub max_delay: Duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + pub multiplier: u32, + } + impl ::core::fmt::Debug for RetryPolicy { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RetryPolicy") + .field("max-attempts", &self.max_attempts) + .field("min-delay", &self.min_delay) + .field("max-delay", &self.max_delay) + .field("multiplier", &self.multiplier) + .finish() + } + } + /// Configurable persistence level for workers + #[derive(Clone, Copy)] + pub enum PersistenceLevel { + PersistNothing, + PersistRemoteSideEffects, + Smart, + } + impl ::core::fmt::Debug for PersistenceLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + PersistenceLevel::PersistNothing => { + f.debug_tuple("PersistenceLevel::PersistNothing").finish() + } + PersistenceLevel::PersistRemoteSideEffects => f + .debug_tuple("PersistenceLevel::PersistRemoteSideEffects") + .finish(), + PersistenceLevel::Smart => { + f.debug_tuple("PersistenceLevel::Smart").finish() + } + } + } + } + /// Describes how to update a worker to a different component version + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum UpdateMode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + Automatic, + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + SnapshotBased, + } + impl ::core::fmt::Debug for UpdateMode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + UpdateMode::Automatic => f.debug_tuple("UpdateMode::Automatic").finish(), + UpdateMode::SnapshotBased => { + f.debug_tuple("UpdateMode::SnapshotBased").finish() + } + } + } + } + + impl UpdateMode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> UpdateMode { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => UpdateMode::Automatic, + 1 => UpdateMode::SnapshotBased, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum FilterComparator { + Equal, + NotEqual, + GreaterEqual, + Greater, + LessEqual, + Less, + } + impl ::core::fmt::Debug for FilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + FilterComparator::Equal => { + f.debug_tuple("FilterComparator::Equal").finish() + } + FilterComparator::NotEqual => { + f.debug_tuple("FilterComparator::NotEqual").finish() + } + FilterComparator::GreaterEqual => { + f.debug_tuple("FilterComparator::GreaterEqual").finish() + } + FilterComparator::Greater => { + f.debug_tuple("FilterComparator::Greater").finish() + } + FilterComparator::LessEqual => { + f.debug_tuple("FilterComparator::LessEqual").finish() + } + FilterComparator::Less => f.debug_tuple("FilterComparator::Less").finish(), + } + } + } + + impl FilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> FilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => FilterComparator::Equal, + 1 => FilterComparator::NotEqual, + 2 => FilterComparator::GreaterEqual, + 3 => FilterComparator::Greater, + 4 => FilterComparator::LessEqual, + 5 => FilterComparator::Less, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum StringFilterComparator { + Equal, + NotEqual, + Like, + NotLike, + } + impl ::core::fmt::Debug for StringFilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StringFilterComparator::Equal => { + f.debug_tuple("StringFilterComparator::Equal").finish() + } + StringFilterComparator::NotEqual => { + f.debug_tuple("StringFilterComparator::NotEqual").finish() + } + StringFilterComparator::Like => { + f.debug_tuple("StringFilterComparator::Like").finish() + } + StringFilterComparator::NotLike => { + f.debug_tuple("StringFilterComparator::NotLike").finish() + } + } + } + } + + impl StringFilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> StringFilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => StringFilterComparator::Equal, + 1 => StringFilterComparator::NotEqual, + 2 => StringFilterComparator::Like, + 3 => StringFilterComparator::NotLike, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum WorkerStatus { + /// The worker is running an invoked function + Running, + /// The worker is ready to run an invoked function + Idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + Suspended, + /// The last invocation was interrupted but will be resumed + Interrupted, + /// The last invocation failed and a retry was scheduled + Retrying, + /// The last invocation failed and the worker can no longer be used + Failed, + /// The worker exited after a successful invocation and can no longer be invoked + Exited, + } + impl ::core::fmt::Debug for WorkerStatus { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerStatus::Running => f.debug_tuple("WorkerStatus::Running").finish(), + WorkerStatus::Idle => f.debug_tuple("WorkerStatus::Idle").finish(), + WorkerStatus::Suspended => { + f.debug_tuple("WorkerStatus::Suspended").finish() + } + WorkerStatus::Interrupted => { + f.debug_tuple("WorkerStatus::Interrupted").finish() + } + WorkerStatus::Retrying => f.debug_tuple("WorkerStatus::Retrying").finish(), + WorkerStatus::Failed => f.debug_tuple("WorkerStatus::Failed").finish(), + WorkerStatus::Exited => f.debug_tuple("WorkerStatus::Exited").finish(), + } + } + } + + impl WorkerStatus { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> WorkerStatus { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => WorkerStatus::Running, + 1 => WorkerStatus::Idle, + 2 => WorkerStatus::Suspended, + 3 => WorkerStatus::Interrupted, + 4 => WorkerStatus::Retrying, + 5 => WorkerStatus::Failed, + 6 => WorkerStatus::Exited, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Clone)] + pub struct WorkerNameFilter { + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerNameFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerNameFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerStatusFilter { + pub comparator: FilterComparator, + pub value: WorkerStatus, + } + impl ::core::fmt::Debug for WorkerStatusFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerStatusFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerVersionFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerVersionFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerVersionFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerCreatedAtFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerCreatedAtFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerCreatedAtFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerEnvFilter { + pub name: _rt::String, + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerEnvFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerEnvFilter") + .field("name", &self.name) + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub enum WorkerPropertyFilter { + Name(WorkerNameFilter), + Status(WorkerStatusFilter), + Version(WorkerVersionFilter), + CreatedAt(WorkerCreatedAtFilter), + Env(WorkerEnvFilter), + } + impl ::core::fmt::Debug for WorkerPropertyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerPropertyFilter::Name(e) => f + .debug_tuple("WorkerPropertyFilter::Name") + .field(e) + .finish(), + WorkerPropertyFilter::Status(e) => f + .debug_tuple("WorkerPropertyFilter::Status") + .field(e) + .finish(), + WorkerPropertyFilter::Version(e) => f + .debug_tuple("WorkerPropertyFilter::Version") + .field(e) + .finish(), + WorkerPropertyFilter::CreatedAt(e) => f + .debug_tuple("WorkerPropertyFilter::CreatedAt") + .field(e) + .finish(), + WorkerPropertyFilter::Env(e) => { + f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WorkerAllFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAllFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAllFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerAnyFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAnyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAnyFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerMetadata { + pub worker_id: WorkerId, + pub args: _rt::Vec<_rt::String>, + pub env: _rt::Vec<(_rt::String, _rt::String)>, + pub status: WorkerStatus, + pub component_version: u64, + pub retry_count: u64, + } + impl ::core::fmt::Debug for WorkerMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerMetadata") + .field("worker-id", &self.worker_id) + .field("args", &self.args) + .field("env", &self.env) + .field("status", &self.status) + .field("component-version", &self.component_version) + .field("retry-count", &self.retry_count) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct GetWorkers { + handle: _rt::Resource, + } + + impl GetWorkers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for GetWorkers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]get-workers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn new( + component_id: ComponentId, + filter: Option<&WorkerAnyFilter>, + precise: bool, + ) -> Self { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let ComponentId { uuid: uuid0 } = component_id; + let Uuid { + high_bits: high_bits1, + low_bits: low_bits1, + } = uuid0; + let (result14_0, result14_1, result14_2) = match filter { + Some(e) => { + let WorkerAnyFilter { filters: filters2 } = e; + let vec13 = filters2; + let len13 = vec13.len(); + let layout13 = _rt::alloc::Layout::from_size_align_unchecked( + vec13.len() * 8, + 4, + ); + let result13 = if layout13.size() != 0 { + let ptr = _rt::alloc::alloc(layout13).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout13); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec13.into_iter().enumerate() { + let base = result13.add(i * 8); + { + let WorkerAllFilter { filters: filters3 } = e; + let vec12 = filters3; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked( + vec12.len() * 32, + 8, + ); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 32); + { + match e { + WorkerPropertyFilter::Name(e) => { + *base.add(0).cast::() = (0i32) as u8; + let WorkerNameFilter { + comparator: comparator4, + value: value4, + } = e; + *base.add(8).cast::() = + (comparator4.clone() as i32) as u8; + let vec5 = value4; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(16).cast::() = len5; + *base.add(12).cast::<*mut u8>() = + ptr5.cast_mut(); + } + WorkerPropertyFilter::Status(e) => { + *base.add(0).cast::() = (1i32) as u8; + let WorkerStatusFilter { + comparator: comparator6, + value: value6, + } = e; + *base.add(8).cast::() = + (comparator6.clone() as i32) as u8; + *base.add(9).cast::() = + (value6.clone() as i32) as u8; + } + WorkerPropertyFilter::Version(e) => { + *base.add(0).cast::() = (2i32) as u8; + let WorkerVersionFilter { + comparator: comparator7, + value: value7, + } = e; + *base.add(8).cast::() = + (comparator7.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value7); + } + WorkerPropertyFilter::CreatedAt(e) => { + *base.add(0).cast::() = (3i32) as u8; + let WorkerCreatedAtFilter { + comparator: comparator8, + value: value8, + } = e; + *base.add(8).cast::() = + (comparator8.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value8); + } + WorkerPropertyFilter::Env(e) => { + *base.add(0).cast::() = (4i32) as u8; + let WorkerEnvFilter { + name: name9, + comparator: comparator9, + value: value9, + } = e; + let vec10 = name9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = + ptr10.cast_mut(); + *base.add(16).cast::() = + (comparator9.clone() as i32) as u8; + let vec11 = value9; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + *base.add(24).cast::() = len11; + *base.add(20).cast::<*mut u8>() = + ptr11.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len12; + *base.add(0).cast::<*mut u8>() = result12; + cleanup_list.extend_from_slice(&[(result12, layout12)]); + } + } + cleanup_list.extend_from_slice(&[(result13, layout13)]); + + (1i32, result13, len13) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), }; - result23.push(e23); - } - wit_bindgen::rt::dealloc(base23, (len23 as usize) * 16, 4); - let l24 = i32::from(*((base + 40) as *const u8)); - let l25 = *((base + 48) as *const i64); - let l26 = *((base + 56) as *const i64); - - WorkerMetadata{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l4 as u64, - low_bits: l5 as u64, + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[constructor]get-workers"] + fn wit_import( + _: i64, + _: i64, + _: i32, + _: *mut u8, + _: usize, + _: i32, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: i32, _: *mut u8, _: usize, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits1), + _rt::as_i64(low_bits1), + result14_0, + result14_1, + result14_2, + match &precise { + true => 1, + false => 0, + }, + ); + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + GetWorkers::from_handle(ret as u32) + } + } + } + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn get_next(&self) -> Option<_rt::Vec> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[method]get-workers.get-next"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base27 = l2; + let len27 = l3; + let mut result27 = _rt::Vec::with_capacity(len27); + for i in 0..len27 { + let base = base27.add(i * 64); + let e27 = { + let l4 = *base.add(0).cast::(); + let l5 = *base.add(8).cast::(); + let l6 = *base.add(16).cast::<*mut u8>(); + let l7 = *base.add(20).cast::(); + let len8 = l7; + let bytes8 = + _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + let l9 = *base.add(24).cast::<*mut u8>(); + let l10 = *base.add(28).cast::(); + let base14 = l9; + let len14 = l10; + let mut result14 = _rt::Vec::with_capacity(len14); + for i in 0..len14 { + let base = base14.add(i * 8); + let e14 = { + let l11 = *base.add(0).cast::<*mut u8>(); + let l12 = *base.add(4).cast::(); + let len13 = l12; + let bytes13 = _rt::Vec::from_raw_parts( + l11.cast(), + len13, + len13, + ); + + _rt::string_lift(bytes13) + }; + result14.push(e14); + } + _rt::cabi_dealloc(base14, len14 * 8, 4); + let l15 = *base.add(32).cast::<*mut u8>(); + let l16 = *base.add(36).cast::(); + let base23 = l15; + let len23 = l16; + let mut result23 = _rt::Vec::with_capacity(len23); + for i in 0..len23 { + let base = base23.add(i * 16); + let e23 = { + let l17 = *base.add(0).cast::<*mut u8>(); + let l18 = *base.add(4).cast::(); + let len19 = l18; + let bytes19 = _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ); + let l20 = *base.add(8).cast::<*mut u8>(); + let l21 = *base.add(12).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ); + + ( + _rt::string_lift(bytes19), + _rt::string_lift(bytes22), + ) + }; + result23.push(e23); + } + _rt::cabi_dealloc(base23, len23 * 16, 4); + let l24 = i32::from(*base.add(40).cast::()); + let l25 = *base.add(48).cast::(); + let l26 = *base.add(56).cast::(); + + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l4 as u64, + low_bits: l5 as u64, + }, + }, + worker_name: _rt::string_lift(bytes8), + }, + args: result14, + env: result23, + status: WorkerStatus::_lift(l24 as u8), + component_version: l25 as u64, + retry_count: l26 as u64, + } + }; + result27.push(e27); + } + _rt::cabi_dealloc(base27, len27 * 64, 8); + + result27 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a new promise + pub fn golem_create_promise() -> PromiseId { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-create-promise"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::<*mut u8>(); + let l4 = *ptr0.add(20).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *ptr0.add(24).cast::(); + PromiseId { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + }, }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes8), + worker_name: _rt::string_lift(bytes5), }, - args: result14, - env: result23, - status: WorkerStatus::_lift(l24 as u8), - component_version: l25 as u64, - retry_count: l26 as u64, - } - }; - result27.push(e27); - } - wit_bindgen::rt::dealloc(base27, (len27 as usize) * 64, 8); - - result27 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a new promise - pub fn golem_create_promise() -> PromiseId{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-create-promise"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i32); - let l4 = *((ptr0 + 20) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((ptr0 + 24) as *const i64); - PromiseId{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes5), - }, - oplog_idx: l6 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - pub fn golem_await_promise(promise_id: &PromiseId,) -> 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 PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let ptr5 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-await-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5); - let l6 = *((ptr5 + 0) as *const i32); - let l7 = *((ptr5 + 4) as *const i32); - let len8 = l7 as usize; - Vec::from_raw_parts(l6 as *mut _, len8, len8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - pub fn golem_complete_promise(promise_id: &PromiseId,data: &[u8],) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = data; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-complete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5, len5); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Deletes the given promise - pub fn golem_delete_promise(promise_id: &PromiseId,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-delete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - pub fn get_self_uri(function_name: &str,) -> Uri{ - - #[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 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-self-uri"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes4), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the current position in the persistent op log - pub fn get_oplog_index() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-index"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - pub fn set_oplog_index(oplog_idx: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-index"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(oplog_idx)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - pub fn oplog_commit(replicas: u8,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "oplog-commit"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(replicas)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - pub fn mark_begin_operation() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-begin-operation"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - pub fn mark_end_operation(begin: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-end-operation"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(begin)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current retry policy associated with the worker - pub fn get_retry_policy() -> RetryPolicy{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-retry-policy"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i32); - RetryPolicy{ - max_attempts: l1 as u32, - min_delay: l2 as u64, - max_delay: l3 as u64, - multiplier: l4 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - pub fn set_retry_policy(new_retry_policy: RetryPolicy,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RetryPolicy{ max_attempts:max_attempts0, min_delay:min_delay0, max_delay:max_delay0, multiplier:multiplier0, } = new_retry_policy; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-retry-policy"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(max_attempts0), wit_bindgen::rt::as_i64(min_delay0), wit_bindgen::rt::as_i64(max_delay0), wit_bindgen::rt::as_i32(multiplier0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the worker's current persistence level. - pub fn get_oplog_persistence_level() -> PersistenceLevel{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-persistence-level"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - let v0 = match ret { - 0 => { - PersistenceLevel::PersistNothing - } - 1 => { - PersistenceLevel::PersistRemoteSideEffects - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - PersistenceLevel::Smart - } - }; - v0 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let result0 = match new_persistence_level { - PersistenceLevel::PersistNothing=> { - 0i32 - } - PersistenceLevel::PersistRemoteSideEffects=> { - 1i32 - } - PersistenceLevel::Smart=> { - 2i32 - } - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-persistence-level"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(result0); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - pub fn get_idempotence_mode() -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-idempotence-mode"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - pub fn set_idempotence_mode(idempotent: bool,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-idempotence-mode"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(match idempotent { true => 1, false => 0 }); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - pub fn generate_idempotency_key() -> Uuid{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "generate-idempotency-key"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - pub fn update_worker(worker_id: &WorkerId,target_version: ComponentVersion,mode: UpdateMode,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let WorkerId{ component_id:component_id0, worker_name:worker_name0, } = worker_id; - let ComponentId{ uuid:uuid1, } = component_id0; - let Uuid{ high_bits:high_bits2, low_bits:low_bits2, } = uuid1; - let vec3 = worker_name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "update-worker"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits2), wit_bindgen::rt::as_i64(low_bits2), ptr3, len3, wit_bindgen::rt::as_i64(target_version), mode.clone() as i32); + oplog_idx: l6 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + pub fn golem_await_promise(promise_id: &PromiseId) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let ptr5 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-await-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5, + ); + let l6 = *ptr5.add(0).cast::<*mut u8>(); + let l7 = *ptr5.add(4).cast::(); + let len8 = l7; + _rt::Vec::from_raw_parts(l6.cast(), len8, len8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + pub fn golem_complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = data; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-complete-promise"] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5.cast_mut(), + len5, + ); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Deletes the given promise + pub fn golem_delete_promise(promise_id: &PromiseId) { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-delete-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + pub fn get_self_uri(function_name: &str) -> Uri { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-self-uri"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes4), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns the current position in the persistent op log + pub fn get_oplog_index() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-index"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + pub fn set_oplog_index(oplog_idx: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-index"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(oplog_idx)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + pub fn oplog_commit(replicas: u8) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "oplog-commit"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(_rt::as_i32(&replicas)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + pub fn mark_begin_operation() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-begin-operation"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + pub fn mark_end_operation(begin: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-end-operation"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(begin)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current retry policy associated with the worker + pub fn get_retry_policy() -> RetryPolicy { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-retry-policy"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + RetryPolicy { + max_attempts: l1 as u32, + min_delay: l2 as u64, + max_delay: l3 as u64, + multiplier: l4 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + pub fn set_retry_policy(new_retry_policy: RetryPolicy) { + unsafe { + let RetryPolicy { + max_attempts: max_attempts0, + min_delay: min_delay0, + max_delay: max_delay0, + multiplier: multiplier0, + } = new_retry_policy; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-retry-policy"] + fn wit_import(_: i32, _: i64, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i32(max_attempts0), + _rt::as_i64(min_delay0), + _rt::as_i64(max_delay0), + _rt::as_i32(multiplier0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the worker's current persistence level. + pub fn get_oplog_persistence_level() -> PersistenceLevel { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-persistence-level"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + let v0 = match ret { + 0 => PersistenceLevel::PersistNothing, + 1 => PersistenceLevel::PersistRemoteSideEffects, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + PersistenceLevel::Smart + } + }; + v0 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel) { + unsafe { + let result0 = match new_persistence_level { + PersistenceLevel::PersistNothing => 0i32, + PersistenceLevel::PersistRemoteSideEffects => 1i32, + PersistenceLevel::Smart => 2i32, + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-persistence-level"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(result0); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + pub fn get_idempotence_mode() -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-idempotence-mode"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + pub fn set_idempotence_mode(idempotent: bool) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-idempotence-mode"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(match &idempotent { + true => 1, + false => 0, + }); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + pub fn generate_idempotency_key() -> Uuid { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "generate-idempotency-key"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + pub fn update_worker( + worker_id: &WorkerId, + target_version: ComponentVersion, + mode: UpdateMode, + ) { + unsafe { + let WorkerId { + component_id: component_id0, + worker_name: worker_name0, + } = worker_id; + let ComponentId { uuid: uuid1 } = component_id0; + let Uuid { + high_bits: high_bits2, + low_bits: low_bits2, + } = uuid1; + let vec3 = worker_name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "update-worker"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits2), + _rt::as_i64(low_bits2), + ptr3.cast_mut(), + len3, + _rt::as_i64(target_version), + mode.clone() as i32, + ); + } + } } - } - } - - } - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() - } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() - } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() - } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() - } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() - } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() - } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() - } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() - } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() - } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec9 = function_params; - let len9 = vec9.len() as i32; - let layout9 = alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); - let result9 = if layout9.size() != 0 - { - let ptr = alloc::alloc(layout9); - if ptr.is_null() - { - alloc::handle_alloc_error(layout9); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec8 = nodes1; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 24, 8); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + } + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, + } + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } + } + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, + } + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } + } + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), + } + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } + } + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, + } + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec9 = function_params; + let len9 = vec9.len(); + let layout9 = + _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); + let result9 = if layout9.size() != 0 { + let ptr = _rt::alloc::alloc(layout9).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout9); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec9.into_iter().enumerate() { + let base = result9.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec8 = nodes1; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked( + vec8.len() * 24, + 8, + ); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - } + }; + for (i, e) in vec8.into_iter().enumerate() { + let base = result8.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len8; + *base.add(0).cast::<*mut u8>() = result8; + cleanup_list.extend_from_slice(&[(result8, layout8)]); } - } - *((base + 4) as *mut i32) = len8; - *((base + 0) as *mut i32) = result8 as i32; - cleanup_list.extend_from_slice(&[(result8, layout8),]); - } - } - let ptr10 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result9 as i32, len9, ptr10); - let l11 = i32::from(*((ptr10 + 0) as *const u8)); - if layout9.size() != 0 { - alloc::dealloc(result9, layout9); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l11 { - 0 => { - let e = { - let l12 = *((ptr10 + 4) as *const i32); - let l13 = *((ptr10 + 8) as *const i32); - let base55 = l12; - let len55 = l13; - let mut result55 = Vec::with_capacity(len55 as usize); - for i in 0..len55 { - let base = base55 + i * 24; - let e55 = { - let l14 = i32::from(*((base + 0) as *const u8)); - let v54 = match l14 { - 0 => { - let e54 = { - let l15 = *((base + 8) as *const i32); - let l16 = *((base + 12) as *const i32); - let len17 = l16 as usize; - - Vec::from_raw_parts(l15 as *mut _, len17, len17) - }; - WitNode::RecordValue(e54) - } - 1 => { - let e54 = { - let l18 = *((base + 8) as *const i32); - let l19 = i32::from(*((base + 12) as *const u8)); - - (l18 as u32, match l19 { + } + let ptr10 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result9, + len9, + ptr10, + ); + let l11 = i32::from(*ptr10.add(0).cast::()); + if layout9.size() != 0 { + _rt::alloc::dealloc(result9.cast(), layout9); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l11 { + 0 => { + let e = { + let l12 = *ptr10.add(4).cast::<*mut u8>(); + let l13 = *ptr10.add(8).cast::(); + let base55 = l12; + let len55 = l13; + let mut result55 = _rt::Vec::with_capacity(len55); + for i in 0..len55 { + let base = base55.add(i * 24); + let e55 = { + let l14 = i32::from(*base.add(0).cast::()); + let v54 = match l14 { + 0 => { + let e54 = { + let l15 = *base.add(8).cast::<*mut u8>(); + let l16 = *base.add(12).cast::(); + let len17 = l16; + + _rt::Vec::from_raw_parts( + l15.cast(), + len17, + len17, + ) + }; + WitNode::RecordValue(e54) + } + 1 => { + let e54 = + { + let l18 = *base.add(8).cast::(); + let l19 = i32::from( + *base.add(12).cast::(), + ); + + (l18 as u32, match l19 { 0 => None, 1 => { let e = { - let l20 = *((base + 16) as *const i32); - + let l20 = *base.add(16).cast::(); + l20 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }) - }; - WitNode::VariantValue(e54) - } - 2 => { - let e54 = { - let l21 = *((base + 8) as *const i32); - - l21 as u32 - }; - WitNode::EnumValue(e54) - } - 3 => { - let e54 = { - let l22 = *((base + 8) as *const i32); - let l23 = *((base + 12) as *const i32); - let base25 = l22; - let len25 = l23; - let mut result25 = Vec::with_capacity(len25 as usize); - for i in 0..len25 { - let base = base25 + i * 1; - let e25 = { - let l24 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l24 as u8) - }; - result25.push(e25); - } - wit_bindgen::rt::dealloc(base25, (len25 as usize) * 1, 1); - - result25 - }; - WitNode::FlagsValue(e54) - } - 4 => { - let e54 = { - let l26 = *((base + 8) as *const i32); - let l27 = *((base + 12) as *const i32); - let len28 = l27 as usize; - - Vec::from_raw_parts(l26 as *mut _, len28, len28) - }; - WitNode::TupleValue(e54) - } - 5 => { - let e54 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::ListValue(e54) - } - 6 => { - let e54 = { - let l32 = i32::from(*((base + 8) as *const u8)); - - match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *((base + 12) as *const i32); - - l33 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e54) - } - 7 => { - let e54 = { - let l34 = i32::from(*((base + 8) as *const u8)); - - match l34 { - 0 => { - let e = { - let l35 = i32::from(*((base + 12) as *const u8)); - - match l35 { + }; + WitNode::VariantValue(e54) + } + 2 => { + let e54 = { + let l21 = *base.add(8).cast::(); + + l21 as u32 + }; + WitNode::EnumValue(e54) + } + 3 => { + let e54 = { + let l22 = *base.add(8).cast::<*mut u8>(); + let l23 = *base.add(12).cast::(); + let base25 = l22; + let len25 = l23; + let mut result25 = + _rt::Vec::with_capacity(len25); + for i in 0..len25 { + let base = base25.add(i * 1); + let e25 = { + let l24 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l24 as u8) + }; + result25.push(e25); + } + _rt::cabi_dealloc(base25, len25 * 1, 1); + + result25 + }; + WitNode::FlagsValue(e54) + } + 4 => { + let e54 = { + let l26 = *base.add(8).cast::<*mut u8>(); + let l27 = *base.add(12).cast::(); + let len28 = l27; + + _rt::Vec::from_raw_parts( + l26.cast(), + len28, + len28, + ) + }; + WitNode::TupleValue(e54) + } + 5 => { + let e54 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::ListValue(e54) + } + 6 => { + let e54 = { + let l32 = + i32::from(*base.add(8).cast::()); + + match l32 { + 0 => None, + 1 => { + let e = { + let l33 = + *base.add(12).cast::(); + + l33 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e54) + } + 7 => { + let e54 = { + let l34 = + i32::from(*base.add(8).cast::()); + + match l34 { + 0 => { + let e = { + let l35 = i32::from( + *base.add(12).cast::(), + ); + + match l35 { 0 => None, 1 => { let e = { - let l36 = *((base + 16) as *const i32); - + let l36 = *base.add(16).cast::(); + l36 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l37 = i32::from(*((base + 12) as *const u8)); - - match l37 { + }; + Ok(e) + } + 1 => { + let e = { + let l37 = i32::from( + *base.add(12).cast::(), + ); + + match l37 { 0 => None, 1 => { let e = { - let l38 = *((base + 16) as *const i32); - + let l38 = *base.add(16).cast::(); + l38 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e54) + } + 8 => { + let e54 = { + let l39 = + i32::from(*base.add(8).cast::()); + + l39 as u8 + }; + WitNode::PrimU8(e54) + } + 9 => { + let e54 = { + let l40 = + i32::from(*base.add(8).cast::()); + + l40 as u16 + }; + WitNode::PrimU16(e54) + } + 10 => { + let e54 = { + let l41 = *base.add(8).cast::(); + + l41 as u32 + }; + WitNode::PrimU32(e54) + } + 11 => { + let e54 = { + let l42 = *base.add(8).cast::(); + + l42 as u64 + }; + WitNode::PrimU64(e54) + } + 12 => { + let e54 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as i8 + }; + WitNode::PrimS8(e54) + } + 13 => { + let e54 = { + let l44 = + i32::from(*base.add(8).cast::()); + + l44 as i16 + }; + WitNode::PrimS16(e54) + } + 14 => { + let e54 = { + let l45 = *base.add(8).cast::(); + + l45 + }; + WitNode::PrimS32(e54) + } + 15 => { + let e54 = { + let l46 = *base.add(8).cast::(); + + l46 + }; + WitNode::PrimS64(e54) + } + 16 => { + let e54 = { + let l47 = *base.add(8).cast::(); + + l47 + }; + WitNode::PrimFloat32(e54) + } + 17 => { + let e54 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimFloat64(e54) + } + 18 => { + let e54 = { + let l49 = *base.add(8).cast::(); + + _rt::char_lift(l49 as u32) + }; + WitNode::PrimChar(e54) + } + 19 => { + let e54 = { + let l50 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l50 as u8) + }; + WitNode::PrimBool(e54) + } + n => { + debug_assert_eq!( + n, 20, + "invalid enum discriminant" + ); + let e54 = { + let l51 = *base.add(8).cast::<*mut u8>(); + let l52 = *base.add(12).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts( + l51.cast(), + len53, + len53, + ); + + _rt::string_lift(bytes53) + }; + WitNode::PrimString(e54) + } + }; + + v54 + }; + result55.push(e55); + } + _rt::cabi_dealloc(base55, len55 * 24, 8); + + WitValue { nodes: result55 } + }; + Ok(e) + } + 1 => { + let e = { + let l56 = i32::from(*ptr10.add(4).cast::()); + let v69 = match l56 { + 0 => { + let e69 = { + let l57 = *ptr10.add(8).cast::<*mut u8>(); + let l58 = *ptr10.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + RpcError::ProtocolError(e69) + } + 1 => { + let e69 = { + let l60 = *ptr10.add(8).cast::<*mut u8>(); + let l61 = *ptr10.add(12).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts( + l60.cast(), + len62, + len62, + ); + + _rt::string_lift(bytes62) + }; + RpcError::Denied(e69) + } + 2 => { + let e69 = { + let l63 = *ptr10.add(8).cast::<*mut u8>(); + let l64 = *ptr10.add(12).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + RpcError::NotFound(e69) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e69 = { + let l66 = *ptr10.add(8).cast::<*mut u8>(); + let l67 = *ptr10.add(12).cast::(); + let len68 = l67; + let bytes68 = _rt::Vec::from_raw_parts( + l66.cast(), + len68, + len68, + ); + + _rt::string_lift(bytes68) + }; + RpcError::RemoteInternalError(e69) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e54) - } - 8 => { - let e54 = { - let l39 = i32::from(*((base + 8) as *const u8)); - - l39 as u8 - }; - WitNode::PrimU8(e54) - } - 9 => { - let e54 = { - let l40 = i32::from(*((base + 8) as *const u16)); - - l40 as u16 - }; - WitNode::PrimU16(e54) - } - 10 => { - let e54 = { - let l41 = *((base + 8) as *const i32); - - l41 as u32 - }; - WitNode::PrimU32(e54) - } - 11 => { - let e54 = { - let l42 = *((base + 8) as *const i64); - - l42 as u64 - }; - WitNode::PrimU64(e54) - } - 12 => { - let e54 = { - let l43 = i32::from(*((base + 8) as *const i8)); - - l43 as i8 - }; - WitNode::PrimS8(e54) - } - 13 => { - let e54 = { - let l44 = i32::from(*((base + 8) as *const i16)); - - l44 as i16 - }; - WitNode::PrimS16(e54) - } - 14 => { - let e54 = { - let l45 = *((base + 8) as *const i32); - - l45 - }; - WitNode::PrimS32(e54) - } - 15 => { - let e54 = { - let l46 = *((base + 8) as *const i64); - - l46 - }; - WitNode::PrimS64(e54) - } - 16 => { - let e54 = { - let l47 = *((base + 8) as *const f32); - - l47 - }; - WitNode::PrimFloat32(e54) - } - 17 => { - let e54 = { - let l48 = *((base + 8) as *const f64); - - l48 - }; - WitNode::PrimFloat64(e54) - } - 18 => { - let e54 = { - let l49 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l49 as u32) - }; - WitNode::PrimChar(e54) - } - 19 => { - let e54 = { - let l50 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l50 as u8) - }; - WitNode::PrimBool(e54) - } - n => { - debug_assert_eq!(n, 20, "invalid enum discriminant"); - let e54 = { - let l51 = *((base + 8) as *const i32); - let l52 = *((base + 12) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) }; - WitNode::PrimString(e54) - } + + v69 }; - - v54 - }; - result55.push(e55); - } - wit_bindgen::rt::dealloc(base55, (len55 as usize) * 24, 8); - - WitValue{ - nodes: result55, + Err(e) } - }; - Ok(e) + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = { - let l56 = i32::from(*((ptr10 + 4) as *const u8)); - let v69 = match l56 { - 0 => { - let e69 = { - let l57 = *((ptr10 + 8) as *const i32); - let l58 = *((ptr10 + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - RpcError::ProtocolError(e69) - } - 1 => { - let e69 = { - let l60 = *((ptr10 + 8) as *const i32); - let l61 = *((ptr10 + 12) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) - }; - RpcError::Denied(e69) - } - 2 => { - let e69 = { - let l63 = *((ptr10 + 8) as *const i32); - let l64 = *((ptr10 + 12) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - RpcError::NotFound(e69) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e69 = { - let l66 = *((ptr10 + 8) as *const i32); - let l67 = *((ptr10 + 12) as *const i32); - let len68 = l67 as usize; - let bytes68 = Vec::from_raw_parts(l66 as *mut _, len68, len68); - - wit_bindgen::rt::string_lift(bytes68) - }; - RpcError::RemoteInternalError(e69) - } - }; - - v69 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - - } - - } - } - pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + } + } + } + } +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; + #[link_name = "now"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; + #[link_name = "resolution"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the specified instant - /// occured. - pub fn subscribe_instant(when: Instant,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the specified instant + /// occured. + pub fn subscribe_instant(when: Instant) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-instant"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. - pub fn subscribe_duration(when: Duration,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + pub fn subscribe_duration(when: Duration) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-duration"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - - } - } - pub mod io { - - #[allow(clippy::all)] - pub mod poll { - #[used] + } + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } } + } + impl Pollable { #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(in_: &[&Pollable],) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let vec0 = in_; - let len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } } - let ptr1 = ret_area.as_mut_ptr() as i32; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/poll@0.2.0")] extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; if layout0.size() != 0 { - alloc::dealloc(result0, layout0); + _rt::alloc::dealloc(result0.cast(), layout0); } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) } - - } - } - pub mod sockets { - - #[allow(clippy::all)] - pub mod network { - #[used] + } + } + #[allow(dead_code)] + pub mod sockets { + #[allow(dead_code, clippy::all)] + pub mod network { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// An opaque resource that represents access to (a subset of) the network. + /// This enables context-based security for networking. + /// There is no need for this to map 1:1 to a physical network interface. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Network { + handle: _rt::Resource, + } + + impl Network { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// An opaque resource that represents access to (a subset of) the network. - /// This enables context-based security for networking. - /// There is no need for this to map 1:1 to a physical network interface. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Network{ - handle: wit_bindgen::rt::Resource, - } - - impl Network{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Network{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Network { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:sockets/network@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]network"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Error codes. - /// - /// In theory, every API can return any error code. - /// In practice, API's typically only return the errors documented per API - /// combined with a couple of errors that are always possible: - /// - `unknown` - /// - `access-denied` - /// - `not-supported` - /// - `out-of-memory` - /// - `concurrency-conflict` - /// - /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum ErrorCode { - /// Unknown error - Unknown, - /// Access denied. - /// - /// POSIX equivalent: EACCES, EPERM - AccessDenied, - /// The operation is not supported. - /// - /// POSIX equivalent: EOPNOTSUPP - NotSupported, - /// One of the arguments is invalid. - /// - /// POSIX equivalent: EINVAL - InvalidArgument, - /// Not enough memory to complete the operation. - /// - /// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY - OutOfMemory, - /// The operation timed out before it could finish completely. - Timeout, - /// This operation is incompatible with another asynchronous operation that is already in progress. - /// - /// POSIX equivalent: EALREADY - ConcurrencyConflict, - /// Trying to finish an asynchronous operation that: - /// - has not been started yet, or: - /// - was already finished by a previous `finish-*` call. - /// - /// Note: this is scheduled to be removed when `future`s are natively supported. - NotInProgress, - /// The operation has been aborted because it could not be completed immediately. - /// - /// Note: this is scheduled to be removed when `future`s are natively supported. - WouldBlock, - /// The operation is not valid in the socket's current state. - InvalidState, - /// A new socket resource could not be created because of a system limit. - NewSocketLimit, - /// A bind operation failed because the provided address is not an address that the `network` can bind to. - AddressNotBindable, - /// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available. - AddressInUse, - /// The remote address is not reachable - RemoteUnreachable, - /// The TCP connection was forcefully rejected - ConnectionRefused, - /// The TCP connection was reset. - ConnectionReset, - /// A TCP connection was aborted. - ConnectionAborted, - /// The size of a datagram sent to a UDP socket exceeded the maximum - /// supported size. - DatagramTooLarge, - /// Name does not exist or has no suitable associated IP addresses. - NameUnresolvable, - /// A temporary failure in name resolution occurred. - TemporaryResolverFailure, - /// A permanent failure in name resolution occurred. - PermanentResolverFailure, - } - impl ErrorCode{ - pub fn name(&self) -> &'static str { + #[link(wasm_import_module = "wasi:sockets/network@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]network"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Error codes. + /// + /// In theory, every API can return any error code. + /// In practice, API's typically only return the errors documented per API + /// combined with a couple of errors that are always possible: + /// - `unknown` + /// - `access-denied` + /// - `not-supported` + /// - `out-of-memory` + /// - `concurrency-conflict` + /// + /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum ErrorCode { + /// Unknown error + Unknown, + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + AccessDenied, + /// The operation is not supported. + /// + /// POSIX equivalent: EOPNOTSUPP + NotSupported, + /// One of the arguments is invalid. + /// + /// POSIX equivalent: EINVAL + InvalidArgument, + /// Not enough memory to complete the operation. + /// + /// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY + OutOfMemory, + /// The operation timed out before it could finish completely. + Timeout, + /// This operation is incompatible with another asynchronous operation that is already in progress. + /// + /// POSIX equivalent: EALREADY + ConcurrencyConflict, + /// Trying to finish an asynchronous operation that: + /// - has not been started yet, or: + /// - was already finished by a previous `finish-*` call. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. + NotInProgress, + /// The operation has been aborted because it could not be completed immediately. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. + WouldBlock, + /// The operation is not valid in the socket's current state. + InvalidState, + /// A new socket resource could not be created because of a system limit. + NewSocketLimit, + /// A bind operation failed because the provided address is not an address that the `network` can bind to. + AddressNotBindable, + /// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available. + AddressInUse, + /// The remote address is not reachable + RemoteUnreachable, + /// The TCP connection was forcefully rejected + ConnectionRefused, + /// The TCP connection was reset. + ConnectionReset, + /// A TCP connection was aborted. + ConnectionAborted, + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. + DatagramTooLarge, + /// Name does not exist or has no suitable associated IP addresses. + NameUnresolvable, + /// A temporary failure in name resolution occurred. + TemporaryResolverFailure, + /// A permanent failure in name resolution occurred. + PermanentResolverFailure, + } + impl ErrorCode { + pub fn name(&self) -> &'static str { match self { - ErrorCode::Unknown => "unknown", - ErrorCode::AccessDenied => "access-denied", - ErrorCode::NotSupported => "not-supported", - ErrorCode::InvalidArgument => "invalid-argument", - ErrorCode::OutOfMemory => "out-of-memory", - ErrorCode::Timeout => "timeout", - ErrorCode::ConcurrencyConflict => "concurrency-conflict", - ErrorCode::NotInProgress => "not-in-progress", - ErrorCode::WouldBlock => "would-block", - ErrorCode::InvalidState => "invalid-state", - ErrorCode::NewSocketLimit => "new-socket-limit", - ErrorCode::AddressNotBindable => "address-not-bindable", - ErrorCode::AddressInUse => "address-in-use", - ErrorCode::RemoteUnreachable => "remote-unreachable", - ErrorCode::ConnectionRefused => "connection-refused", - ErrorCode::ConnectionReset => "connection-reset", - ErrorCode::ConnectionAborted => "connection-aborted", - ErrorCode::DatagramTooLarge => "datagram-too-large", - ErrorCode::NameUnresolvable => "name-unresolvable", - ErrorCode::TemporaryResolverFailure => "temporary-resolver-failure", - ErrorCode::PermanentResolverFailure => "permanent-resolver-failure", - } - } - pub fn message(&self) -> &'static str { + ErrorCode::Unknown => "unknown", + ErrorCode::AccessDenied => "access-denied", + ErrorCode::NotSupported => "not-supported", + ErrorCode::InvalidArgument => "invalid-argument", + ErrorCode::OutOfMemory => "out-of-memory", + ErrorCode::Timeout => "timeout", + ErrorCode::ConcurrencyConflict => "concurrency-conflict", + ErrorCode::NotInProgress => "not-in-progress", + ErrorCode::WouldBlock => "would-block", + ErrorCode::InvalidState => "invalid-state", + ErrorCode::NewSocketLimit => "new-socket-limit", + ErrorCode::AddressNotBindable => "address-not-bindable", + ErrorCode::AddressInUse => "address-in-use", + ErrorCode::RemoteUnreachable => "remote-unreachable", + ErrorCode::ConnectionRefused => "connection-refused", + ErrorCode::ConnectionReset => "connection-reset", + ErrorCode::ConnectionAborted => "connection-aborted", + ErrorCode::DatagramTooLarge => "datagram-too-large", + ErrorCode::NameUnresolvable => "name-unresolvable", + ErrorCode::TemporaryResolverFailure => "temporary-resolver-failure", + ErrorCode::PermanentResolverFailure => "permanent-resolver-failure", + } + } + pub fn message(&self) -> &'static str { match self { ErrorCode::Unknown => "Unknown error", ErrorCode::AccessDenied => "Access denied. - + POSIX equivalent: EACCES, EPERM", ErrorCode::NotSupported => "The operation is not supported. - + POSIX equivalent: EOPNOTSUPP", ErrorCode::InvalidArgument => "One of the arguments is invalid. - + POSIX equivalent: EINVAL", ErrorCode::OutOfMemory => "Not enough memory to complete the operation. - + POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY", ErrorCode::Timeout => "The operation timed out before it could finish completely.", ErrorCode::ConcurrencyConflict => "This operation is incompatible with another asynchronous operation that is already in progress. - + POSIX equivalent: EALREADY", ErrorCode::NotInProgress => "Trying to finish an asynchronous operation that: - has not been started yet, or: - was already finished by a previous `finish-*` call. - + Note: this is scheduled to be removed when `future`s are natively supported.", ErrorCode::WouldBlock => "The operation has been aborted because it could not be completed immediately. - + Note: this is scheduled to be removed when `future`s are natively supported.", ErrorCode::InvalidState => "The operation is not valid in the socket's current state.", ErrorCode::NewSocketLimit => "A new socket resource could not be created because of a system limit.", @@ -2529,560 +2750,984 @@ pub mod golem { ErrorCode::TemporaryResolverFailure => "A temporary failure in name resolution occurred.", ErrorCode::PermanentResolverFailure => "A permanent failure in name resolution occurred.", } - } } - impl ::core::fmt::Debug for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { write!(f, "{} (error {})", self.name(), *self as i32) - } } - - impl std::error::Error for ErrorCode{} - - impl ErrorCode{ - pub(crate) unsafe fn _lift(val: u8) -> ErrorCode{ + } + + impl std::error::Error for ErrorCode {} + + impl ErrorCode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> ErrorCode { if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); + return ::core::mem::transmute(val); } - + match val { - 0 => ErrorCode::Unknown, - 1 => ErrorCode::AccessDenied, - 2 => ErrorCode::NotSupported, - 3 => ErrorCode::InvalidArgument, - 4 => ErrorCode::OutOfMemory, - 5 => ErrorCode::Timeout, - 6 => ErrorCode::ConcurrencyConflict, - 7 => ErrorCode::NotInProgress, - 8 => ErrorCode::WouldBlock, - 9 => ErrorCode::InvalidState, - 10 => ErrorCode::NewSocketLimit, - 11 => ErrorCode::AddressNotBindable, - 12 => ErrorCode::AddressInUse, - 13 => ErrorCode::RemoteUnreachable, - 14 => ErrorCode::ConnectionRefused, - 15 => ErrorCode::ConnectionReset, - 16 => ErrorCode::ConnectionAborted, - 17 => ErrorCode::DatagramTooLarge, - 18 => ErrorCode::NameUnresolvable, - 19 => ErrorCode::TemporaryResolverFailure, - 20 => ErrorCode::PermanentResolverFailure, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum IpAddressFamily { - /// Similar to `AF_INET` in POSIX. - Ipv4, - /// Similar to `AF_INET6` in POSIX. - Ipv6, - } - impl ::core::fmt::Debug for IpAddressFamily { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 0 => ErrorCode::Unknown, + 1 => ErrorCode::AccessDenied, + 2 => ErrorCode::NotSupported, + 3 => ErrorCode::InvalidArgument, + 4 => ErrorCode::OutOfMemory, + 5 => ErrorCode::Timeout, + 6 => ErrorCode::ConcurrencyConflict, + 7 => ErrorCode::NotInProgress, + 8 => ErrorCode::WouldBlock, + 9 => ErrorCode::InvalidState, + 10 => ErrorCode::NewSocketLimit, + 11 => ErrorCode::AddressNotBindable, + 12 => ErrorCode::AddressInUse, + 13 => ErrorCode::RemoteUnreachable, + 14 => ErrorCode::ConnectionRefused, + 15 => ErrorCode::ConnectionReset, + 16 => ErrorCode::ConnectionAborted, + 17 => ErrorCode::DatagramTooLarge, + 18 => ErrorCode::NameUnresolvable, + 19 => ErrorCode::TemporaryResolverFailure, + 20 => ErrorCode::PermanentResolverFailure, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum IpAddressFamily { + /// Similar to `AF_INET` in POSIX. + Ipv4, + /// Similar to `AF_INET6` in POSIX. + Ipv6, + } + impl ::core::fmt::Debug for IpAddressFamily { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { - IpAddressFamily::Ipv4 => { - f.debug_tuple("IpAddressFamily::Ipv4").finish() - } - IpAddressFamily::Ipv6 => { - f.debug_tuple("IpAddressFamily::Ipv6").finish() - } - } - } - } - - impl IpAddressFamily{ - pub(crate) unsafe fn _lift(val: u8) -> IpAddressFamily{ + IpAddressFamily::Ipv4 => f.debug_tuple("IpAddressFamily::Ipv4").finish(), + IpAddressFamily::Ipv6 => f.debug_tuple("IpAddressFamily::Ipv6").finish(), + } + } + } + + impl IpAddressFamily { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> IpAddressFamily { if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); + return ::core::mem::transmute(val); } - + match val { - 0 => IpAddressFamily::Ipv4, - 1 => IpAddressFamily::Ipv6, - - _ => panic!("invalid enum discriminant"), - } - } - } - - pub type Ipv4Address = (u8,u8,u8,u8,); - pub type Ipv6Address = (u16,u16,u16,u16,u16,u16,u16,u16,); - #[derive(Clone, Copy)] - pub enum IpAddress{ - Ipv4(Ipv4Address), - Ipv6(Ipv6Address), - } - impl ::core::fmt::Debug for IpAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 0 => IpAddressFamily::Ipv4, + 1 => IpAddressFamily::Ipv6, + + _ => panic!("invalid enum discriminant"), + } + } + } + + pub type Ipv4Address = (u8, u8, u8, u8); + pub type Ipv6Address = (u16, u16, u16, u16, u16, u16, u16, u16); + #[derive(Clone, Copy)] + pub enum IpAddress { + Ipv4(Ipv4Address), + Ipv6(Ipv6Address), + } + impl ::core::fmt::Debug for IpAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { - IpAddress::Ipv4(e) => { - f.debug_tuple("IpAddress::Ipv4").field(e).finish() - } - IpAddress::Ipv6(e) => { - f.debug_tuple("IpAddress::Ipv6").field(e).finish() - } - } - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Ipv4SocketAddress { - /// sin_port - pub port: u16, - /// sin_addr - pub address: Ipv4Address, - } - impl ::core::fmt::Debug for Ipv4SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Ipv4SocketAddress").field("port", &self.port).field("address", &self.address).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Ipv6SocketAddress { - /// sin6_port - pub port: u16, - /// sin6_flowinfo - pub flow_info: u32, - /// sin6_addr - pub address: Ipv6Address, - /// sin6_scope_id - pub scope_id: u32, - } - impl ::core::fmt::Debug for Ipv6SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Ipv6SocketAddress").field("port", &self.port).field("flow-info", &self.flow_info).field("address", &self.address).field("scope-id", &self.scope_id).finish() - } - } - #[derive(Clone, Copy)] - pub enum IpSocketAddress{ - Ipv4(Ipv4SocketAddress), - Ipv6(Ipv6SocketAddress), - } - impl ::core::fmt::Debug for IpSocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + IpAddress::Ipv4(e) => f.debug_tuple("IpAddress::Ipv4").field(e).finish(), + IpAddress::Ipv6(e) => f.debug_tuple("IpAddress::Ipv6").field(e).finish(), + } + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Ipv4SocketAddress { + /// sin_port + pub port: u16, + /// sin_addr + pub address: Ipv4Address, + } + impl ::core::fmt::Debug for Ipv4SocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ipv4SocketAddress") + .field("port", &self.port) + .field("address", &self.address) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Ipv6SocketAddress { + /// sin6_port + pub port: u16, + /// sin6_flowinfo + pub flow_info: u32, + /// sin6_addr + pub address: Ipv6Address, + /// sin6_scope_id + pub scope_id: u32, + } + impl ::core::fmt::Debug for Ipv6SocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ipv6SocketAddress") + .field("port", &self.port) + .field("flow-info", &self.flow_info) + .field("address", &self.address) + .field("scope-id", &self.scope_id) + .finish() + } + } + #[derive(Clone, Copy)] + pub enum IpSocketAddress { + Ipv4(Ipv4SocketAddress), + Ipv6(Ipv6SocketAddress), + } + impl ::core::fmt::Debug for IpSocketAddress { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { - IpSocketAddress::Ipv4(e) => { - f.debug_tuple("IpSocketAddress::Ipv4").field(e).finish() - } - IpSocketAddress::Ipv6(e) => { - f.debug_tuple("IpSocketAddress::Ipv6").field(e).finish() - } - } - } - } - - } - - - #[allow(clippy::all)] - pub mod ip_name_lookup { - #[used] + IpSocketAddress::Ipv4(e) => { + f.debug_tuple("IpSocketAddress::Ipv4").field(e).finish() + } + IpSocketAddress::Ipv6(e) => { + f.debug_tuple("IpSocketAddress::Ipv6").field(e).finish() + } + } + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod ip_name_lookup { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + pub type Network = super::super::super::wasi::sockets::network::Network; + pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; + pub type IpAddress = super::super::super::wasi::sockets::network::IpAddress; + + #[derive(Debug)] + #[repr(transparent)] + pub struct ResolveAddressStream { + handle: _rt::Resource, + } + + impl ResolveAddressStream { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - pub type Network = super::super::super::wasi::sockets::network::Network; - pub type ErrorCode = super::super::super::wasi::sockets::network::ErrorCode; - pub type IpAddress = super::super::super::wasi::sockets::network::IpAddress; - - #[derive(Debug)] - #[repr(transparent)] - pub struct ResolveAddressStream{ - handle: wit_bindgen::rt::Resource, - } - - impl ResolveAddressStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for ResolveAddressStream{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for ResolveAddressStream { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]resolve-address-stream"] - fn drop(_: u32); - } - - drop(_handle); + #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]resolve-address-stream"] + fn drop(_: u32); + } + + drop(_handle); } - } } - - #[allow(unused_unsafe, clippy::all)] - /// Resolve an internet host name to a list of IP addresses. - /// - /// Unicode domain names are automatically converted to ASCII using IDNA encoding. - /// If the input is an IP address string, the address is parsed and returned - /// as-is without making any external requests. - /// - /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. - /// - /// This function never blocks. It either immediately fails or immediately - /// returns successfully with a `resolve-address-stream` that can be used - /// to (asynchronously) fetch the results. - /// - /// # Typical errors - /// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. - /// - /// # References: - /// - - /// - - /// - - /// - - pub fn resolve_addresses(network: &Network,name: &str,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + + #[allow(unused_unsafe, clippy::all)] + /// Resolve an internet host name to a list of IP addresses. + /// + /// Unicode domain names are automatically converted to ASCII using IDNA encoding. + /// If the input is an IP address string, the address is parsed and returned + /// as-is without making any external requests. + /// + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. + /// + /// This function never blocks. It either immediately fails or immediately + /// returns successfully with a `resolve-address-stream` that can be used + /// to (asynchronously) fetch the results. + /// + /// # Typical errors + /// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. + /// + /// # References: + /// - + /// - + /// - + /// - + pub fn resolve_addresses( + network: &Network, + name: &str, + ) -> Result { + unsafe { #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); 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; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] extern "C" { - #[link_name = "resolve-addresses"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + #[link_name = "resolve-addresses"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((network).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((network).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 4) as *const i32); - - ResolveAddressStream::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr1 + 4) as *const u8)); - - super::super::super::wasi::sockets::network::ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - impl ResolveAddressStream { - #[allow(unused_unsafe, clippy::all)] - /// Returns the next address from the resolver. - /// - /// This function should be called multiple times. On each call, it will - /// return the next address in connection order preference. If all - /// addresses have been exhausted, this function returns `none`. - /// - /// This function never returns IPv4-mapped IPv6 addresses. - /// - /// # Typical errors - /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) - /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) - /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) - /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) - pub fn resolve_next_address(&self,) -> Result,ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(2))] - struct RetArea([u8; 22]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - extern "C" { - #[link_name = "[method]resolve-address-stream.resolve-next-address"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { 0 => { - let e = { - let l2 = i32::from(*((ptr0 + 2) as *const u8)); - - match l2 { - 0 => None, - 1 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + ResolveAddressStream::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(4).cast::()); + + super::super::super::wasi::sockets::network::ErrorCode::_lift( + l4 as u8, + ) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + impl ResolveAddressStream { + #[allow(unused_unsafe, clippy::all)] + /// Returns the next address from the resolver. + /// + /// This function should be called multiple times. On each call, it will + /// return the next address in connection order preference. If all + /// addresses have been exhausted, this function returns `none`. + /// + /// This function never returns IPv4-mapped IPv6 addresses. + /// + /// # Typical errors + /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) + /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) + /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) + /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) + pub fn resolve_next_address(&self) -> Result, ErrorCode> { + unsafe { + #[repr(align(2))] + struct RetArea([::core::mem::MaybeUninit; 22]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 22]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] + extern "C" { + #[link_name = "[method]resolve-address-stream.resolve-next-address"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { let e = { - let l3 = i32::from(*((ptr0 + 4) as *const u8)); - use super::super::super::wasi::sockets::network::IpAddress as V16; - let v16 = match l3 { - 0 => { - let e16 = { - let l4 = i32::from(*((ptr0 + 6) as *const u8)); - let l5 = i32::from(*((ptr0 + 7) as *const u8)); - let l6 = i32::from(*((ptr0 + 8) as *const u8)); - let l7 = i32::from(*((ptr0 + 9) as *const u8)); - - (l4 as u8, l5 as u8, l6 as u8, l7 as u8) - }; - V16::Ipv4(e16) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e16 = { - let l8 = i32::from(*((ptr0 + 6) as *const u16)); - let l9 = i32::from(*((ptr0 + 8) as *const u16)); - let l10 = i32::from(*((ptr0 + 10) as *const u16)); - let l11 = i32::from(*((ptr0 + 12) as *const u16)); - let l12 = i32::from(*((ptr0 + 14) as *const u16)); - let l13 = i32::from(*((ptr0 + 16) as *const u16)); - let l14 = i32::from(*((ptr0 + 18) as *const u16)); - let l15 = i32::from(*((ptr0 + 20) as *const u16)); - - (l8 as u16, l9 as u16, l10 as u16, l11 as u16, l12 as u16, l13 as u16, l14 as u16, l15 as u16) - }; - V16::Ipv6(e16) + let l2 = i32::from(*ptr0.add(2).cast::()); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + use super::super::super::wasi::sockets::network::IpAddress as V16; + let v16 = match l3 { + 0 => { + let e16 = { + let l4 = i32::from( + *ptr0.add(6).cast::(), + ); + let l5 = i32::from( + *ptr0.add(7).cast::(), + ); + let l6 = i32::from( + *ptr0.add(8).cast::(), + ); + let l7 = i32::from( + *ptr0.add(9).cast::(), + ); + + (l4 as u8, l5 as u8, l6 as u8, l7 as u8) + }; + V16::Ipv4(e16) + } + n => { + debug_assert_eq!( + n, 1, + "invalid enum discriminant" + ); + let e16 = { + let l8 = i32::from( + *ptr0.add(6).cast::(), + ); + let l9 = i32::from( + *ptr0.add(8).cast::(), + ); + let l10 = i32::from( + *ptr0.add(10).cast::(), + ); + let l11 = i32::from( + *ptr0.add(12).cast::(), + ); + let l12 = i32::from( + *ptr0.add(14).cast::(), + ); + let l13 = i32::from( + *ptr0.add(16).cast::(), + ); + let l14 = i32::from( + *ptr0.add(18).cast::(), + ); + let l15 = i32::from( + *ptr0.add(20).cast::(), + ); + + ( + l8 as u16, l9 as u16, l10 as u16, + l11 as u16, l12 as u16, l13 as u16, + l14 as u16, l15 as u16, + ) + }; + V16::Ipv6(e16) + } + }; + + v16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), } - }; - - v16 }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + Ok(e) + } + 1 => { + let e = { + let l17 = i32::from(*ptr0.add(2).cast::()); + + super::super::super::wasi::sockets::network::ErrorCode::_lift( + l17 as u8, + ) + }; + Err(e) } - }; - Ok(e) + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = { - let l17 = i32::from(*((ptr0 + 2) as *const u8)); - - super::super::super::wasi::sockets::network::ErrorCode::_lift(l17 as u8) - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl ResolveAddressStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the stream is ready for I/O. - /// - /// Note: this function is here for WASI Preview2 only. - /// It's planned to be removed when `future` is natively supported in Preview3. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] - extern "C" { - #[link_name = "[method]resolve-address-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - - } - - - #[allow(clippy::all)] - pub mod instance_network { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Network = super::super::super::wasi::sockets::network::Network; + } + } + } + impl ResolveAddressStream { #[allow(unused_unsafe, clippy::all)] - /// Get a handle to the default network. - pub fn instance_network() -> Network{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + /// Create a `pollable` which will resolve once the stream is ready for I/O. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:sockets/ip-name-lookup@0.2.0")] + extern "C" { + #[link_name = "[method]resolve-address-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod instance_network { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + pub type Network = super::super::super::wasi::sockets::network::Network; + #[allow(unused_unsafe, clippy::all)] + /// Get a handle to the default network. + pub fn instance_network() -> Network { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:sockets/instance-network@0.2.0")] extern "C" { - #[link_name = "instance-network"] - fn wit_import() -> i32; + #[link_name = "instance-network"] + fn wit_import() -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } + fn wit_import() -> i32 { + unreachable!() + } let ret = wit_import(); super::super::super::wasi::sockets::network::Network::from_handle(ret as u32) - } - } - - } - - } - } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = result0; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); - let result3 = if layout3.size() != 0 - { - let ptr = alloc::alloc(layout3); - if ptr.is_null() - { - alloc::handle_alloc_error(layout3); + } + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::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) * 8; + } else { { - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((base + 4) as *mut i32) = len2; - *((base + 0) as *mut i32) = ptr2; - } - } - *((ptr1 + 4) as *mut i32) = len3; - *((ptr1 + 0) as *mut i32) = result3 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - } + ::core::ptr::null_mut() + } }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn get() -> wit_bindgen::rt::vec::Vec::; - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - - } - } - } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:networking"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4437] = [3, 0, 10, 110, 101, 116, 119, 111, 114, 107, 105, 110, 103, 0, 97, 115, 109, 13, 0, 1, 0, 7, 39, 1, 65, 2, 1, 66, 3, 1, 112, 115, 1, 64, 0, 0, 0, 4, 0, 3, 103, 101, 116, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 157, 33, 1, 65, 2, 1, 65, 22, 1, 66, 25, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 3, 1, 112, 127, 1, 106, 1, 3, 1, 3, 1, 113, 21, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 2, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 5, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 2, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 2, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 3, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 7, 1, 112, 8, 1, 114, 1, 5, 110, 111, 100, 101, 115, 9, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 10, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 12, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 14, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 16, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 13, 0, 17, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 18, 1, 104, 16, 1, 112, 11, 1, 106, 1, 11, 1, 15, 1, 64, 3, 4, 115, 101, 108, 102, 19, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 20, 0, 21, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 22, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 1, 64, 0, 0, 3, 4, 0, 3, 110, 111, 119, 1, 6, 1, 64, 0, 0, 5, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 7, 1, 105, 1, 1, 64, 1, 4, 119, 104, 101, 110, 3, 0, 8, 4, 0, 17, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 105, 110, 115, 116, 97, 110, 116, 1, 9, 1, 64, 1, 4, 119, 104, 101, 110, 5, 0, 8, 4, 0, 18, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 100, 117, 114, 97, 116, 105, 111, 110, 1, 10, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 3, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 2, 8, 100, 117, 114, 97, 116, 105, 111, 110, 1, 66, 97, 2, 3, 2, 1, 4, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 2, 1, 119, 4, 0, 11, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 3, 0, 4, 1, 119, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 6, 1, 114, 2, 9, 104, 105, 103, 104, 45, 98, 105, 116, 115, 119, 8, 108, 111, 119, 45, 98, 105, 116, 115, 119, 4, 0, 4, 117, 117, 105, 100, 3, 0, 8, 1, 114, 1, 4, 117, 117, 105, 100, 9, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 10, 1, 114, 2, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 11, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 115, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 12, 1, 114, 2, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 4, 0, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 3, 0, 14, 1, 114, 4, 12, 109, 97, 120, 45, 97, 116, 116, 101, 109, 112, 116, 115, 121, 9, 109, 105, 110, 45, 100, 101, 108, 97, 121, 3, 9, 109, 97, 120, 45, 100, 101, 108, 97, 121, 3, 10, 109, 117, 108, 116, 105, 112, 108, 105, 101, 114, 121, 4, 0, 12, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 3, 0, 16, 1, 113, 3, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 0, 0, 27, 112, 101, 114, 115, 105, 115, 116, 45, 114, 101, 109, 111, 116, 101, 45, 115, 105, 100, 101, 45, 101, 102, 102, 101, 99, 116, 115, 0, 0, 5, 115, 109, 97, 114, 116, 0, 0, 4, 0, 17, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 3, 0, 18, 1, 109, 2, 9, 97, 117, 116, 111, 109, 97, 116, 105, 99, 14, 115, 110, 97, 112, 115, 104, 111, 116, 45, 98, 97, 115, 101, 100, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 20, 1, 109, 6, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 13, 103, 114, 101, 97, 116, 101, 114, 45, 101, 113, 117, 97, 108, 7, 103, 114, 101, 97, 116, 101, 114, 10, 108, 101, 115, 115, 45, 101, 113, 117, 97, 108, 4, 108, 101, 115, 115, 4, 0, 17, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 22, 1, 109, 4, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 4, 108, 105, 107, 101, 8, 110, 111, 116, 45, 108, 105, 107, 101, 4, 0, 24, 115, 116, 114, 105, 110, 103, 45, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 24, 1, 109, 7, 7, 114, 117, 110, 110, 105, 110, 103, 4, 105, 100, 108, 101, 9, 115, 117, 115, 112, 101, 110, 100, 101, 100, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 8, 114, 101, 116, 114, 121, 105, 110, 103, 6, 102, 97, 105, 108, 101, 100, 6, 101, 120, 105, 116, 101, 100, 4, 0, 13, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 3, 0, 26, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 18, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 45, 102, 105, 108, 116, 101, 114, 3, 0, 28, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 27, 4, 0, 20, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 45, 102, 105, 108, 116, 101, 114, 3, 0, 30, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 21, 119, 111, 114, 107, 101, 114, 45, 118, 101, 114, 115, 105, 111, 110, 45, 102, 105, 108, 116, 101, 114, 3, 0, 32, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 24, 119, 111, 114, 107, 101, 114, 45, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 45, 102, 105, 108, 116, 101, 114, 3, 0, 34, 1, 114, 3, 4, 110, 97, 109, 101, 115, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 101, 110, 118, 45, 102, 105, 108, 116, 101, 114, 3, 0, 36, 1, 113, 5, 4, 110, 97, 109, 101, 1, 29, 0, 6, 115, 116, 97, 116, 117, 115, 1, 31, 0, 7, 118, 101, 114, 115, 105, 111, 110, 1, 33, 0, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 1, 35, 0, 3, 101, 110, 118, 1, 37, 0, 4, 0, 22, 119, 111, 114, 107, 101, 114, 45, 112, 114, 111, 112, 101, 114, 116, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 38, 1, 112, 39, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 40, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 108, 108, 45, 102, 105, 108, 116, 101, 114, 3, 0, 41, 1, 112, 42, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 43, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 44, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 47, 1, 114, 6, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 4, 97, 114, 103, 115, 46, 3, 101, 110, 118, 48, 6, 115, 116, 97, 116, 117, 115, 27, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 119, 11, 114, 101, 116, 114, 121, 45, 99, 111, 117, 110, 116, 119, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 49, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 3, 1, 1, 107, 45, 1, 105, 51, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 6, 102, 105, 108, 116, 101, 114, 52, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 53, 4, 0, 24, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 54, 1, 104, 51, 1, 112, 50, 1, 107, 56, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 57, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 46, 103, 101, 116, 45, 110, 101, 120, 116, 1, 58, 1, 64, 0, 0, 15, 4, 0, 20, 103, 111, 108, 101, 109, 45, 99, 114, 101, 97, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 59, 1, 112, 125, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 0, 60, 4, 0, 19, 103, 111, 108, 101, 109, 45, 97, 119, 97, 105, 116, 45, 112, 114, 111, 109, 105, 115, 101, 1, 61, 1, 64, 2, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 4, 100, 97, 116, 97, 60, 0, 127, 4, 0, 22, 103, 111, 108, 101, 109, 45, 99, 111, 109, 112, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 62, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 1, 0, 4, 0, 20, 103, 111, 108, 101, 109, 45, 100, 101, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 63, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 1, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 64, 1, 64, 0, 0, 5, 4, 0, 15, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 65, 1, 64, 1, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 1, 0, 4, 0, 15, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 66, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 12, 111, 112, 108, 111, 103, 45, 99, 111, 109, 109, 105, 116, 1, 67, 4, 0, 20, 109, 97, 114, 107, 45, 98, 101, 103, 105, 110, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 65, 1, 64, 1, 5, 98, 101, 103, 105, 110, 5, 1, 0, 4, 0, 18, 109, 97, 114, 107, 45, 101, 110, 100, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 68, 1, 64, 0, 0, 17, 4, 0, 16, 103, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 69, 1, 64, 1, 16, 110, 101, 119, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 17, 1, 0, 4, 0, 16, 115, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 70, 1, 64, 0, 0, 19, 4, 0, 27, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 71, 1, 64, 1, 21, 110, 101, 119, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 19, 1, 0, 4, 0, 27, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 72, 1, 64, 0, 0, 127, 4, 0, 20, 103, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 73, 1, 64, 1, 10, 105, 100, 101, 109, 112, 111, 116, 101, 110, 116, 127, 1, 0, 4, 0, 20, 115, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 74, 1, 64, 0, 0, 9, 4, 0, 24, 103, 101, 110, 101, 114, 97, 116, 101, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 121, 45, 107, 101, 121, 1, 75, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 14, 116, 97, 114, 103, 101, 116, 45, 118, 101, 114, 115, 105, 111, 110, 7, 4, 109, 111, 100, 101, 21, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 76, 3, 1, 20, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 104, 111, 115, 116, 64, 48, 46, 50, 46, 48, 5, 6, 1, 66, 17, 4, 0, 7, 110, 101, 116, 119, 111, 114, 107, 3, 1, 1, 109, 21, 7, 117, 110, 107, 110, 111, 119, 110, 13, 97, 99, 99, 101, 115, 115, 45, 100, 101, 110, 105, 101, 100, 13, 110, 111, 116, 45, 115, 117, 112, 112, 111, 114, 116, 101, 100, 16, 105, 110, 118, 97, 108, 105, 100, 45, 97, 114, 103, 117, 109, 101, 110, 116, 13, 111, 117, 116, 45, 111, 102, 45, 109, 101, 109, 111, 114, 121, 7, 116, 105, 109, 101, 111, 117, 116, 20, 99, 111, 110, 99, 117, 114, 114, 101, 110, 99, 121, 45, 99, 111, 110, 102, 108, 105, 99, 116, 15, 110, 111, 116, 45, 105, 110, 45, 112, 114, 111, 103, 114, 101, 115, 115, 11, 119, 111, 117, 108, 100, 45, 98, 108, 111, 99, 107, 13, 105, 110, 118, 97, 108, 105, 100, 45, 115, 116, 97, 116, 101, 16, 110, 101, 119, 45, 115, 111, 99, 107, 101, 116, 45, 108, 105, 109, 105, 116, 20, 97, 100, 100, 114, 101, 115, 115, 45, 110, 111, 116, 45, 98, 105, 110, 100, 97, 98, 108, 101, 14, 97, 100, 100, 114, 101, 115, 115, 45, 105, 110, 45, 117, 115, 101, 18, 114, 101, 109, 111, 116, 101, 45, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 102, 117, 115, 101, 100, 16, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 115, 101, 116, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 97, 98, 111, 114, 116, 101, 100, 18, 100, 97, 116, 97, 103, 114, 97, 109, 45, 116, 111, 111, 45, 108, 97, 114, 103, 101, 17, 110, 97, 109, 101, 45, 117, 110, 114, 101, 115, 111, 108, 118, 97, 98, 108, 101, 26, 116, 101, 109, 112, 111, 114, 97, 114, 121, 45, 114, 101, 115, 111, 108, 118, 101, 114, 45, 102, 97, 105, 108, 117, 114, 101, 26, 112, 101, 114, 109, 97, 110, 101, 110, 116, 45, 114, 101, 115, 111, 108, 118, 101, 114, 45, 102, 97, 105, 108, 117, 114, 101, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 1, 1, 109, 2, 4, 105, 112, 118, 52, 4, 105, 112, 118, 54, 4, 0, 17, 105, 112, 45, 97, 100, 100, 114, 101, 115, 115, 45, 102, 97, 109, 105, 108, 121, 3, 0, 3, 1, 111, 4, 125, 125, 125, 125, 4, 0, 12, 105, 112, 118, 52, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 5, 1, 111, 8, 123, 123, 123, 123, 123, 123, 123, 123, 4, 0, 12, 105, 112, 118, 54, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 7, 1, 113, 2, 4, 105, 112, 118, 52, 1, 6, 0, 4, 105, 112, 118, 54, 1, 8, 0, 4, 0, 10, 105, 112, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 9, 1, 114, 2, 4, 112, 111, 114, 116, 123, 7, 97, 100, 100, 114, 101, 115, 115, 6, 4, 0, 19, 105, 112, 118, 52, 45, 115, 111, 99, 107, 101, 116, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 11, 1, 114, 4, 4, 112, 111, 114, 116, 123, 9, 102, 108, 111, 119, 45, 105, 110, 102, 111, 121, 7, 97, 100, 100, 114, 101, 115, 115, 8, 8, 115, 99, 111, 112, 101, 45, 105, 100, 121, 4, 0, 19, 105, 112, 118, 54, 45, 115, 111, 99, 107, 101, 116, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 13, 1, 113, 2, 4, 105, 112, 118, 52, 1, 12, 0, 4, 105, 112, 118, 54, 1, 14, 0, 4, 0, 17, 105, 112, 45, 115, 111, 99, 107, 101, 116, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 15, 3, 1, 26, 119, 97, 115, 105, 58, 115, 111, 99, 107, 101, 116, 115, 47, 110, 101, 116, 119, 111, 114, 107, 64, 48, 46, 50, 46, 48, 5, 7, 2, 3, 0, 4, 7, 110, 101, 116, 119, 111, 114, 107, 2, 3, 0, 4, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 2, 3, 0, 4, 10, 105, 112, 45, 97, 100, 100, 114, 101, 115, 115, 1, 66, 22, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 2, 3, 2, 1, 8, 4, 0, 7, 110, 101, 116, 119, 111, 114, 107, 3, 0, 2, 2, 3, 2, 1, 9, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 4, 2, 3, 2, 1, 10, 4, 0, 10, 105, 112, 45, 97, 100, 100, 114, 101, 115, 115, 3, 0, 6, 4, 0, 22, 114, 101, 115, 111, 108, 118, 101, 45, 97, 100, 100, 114, 101, 115, 115, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 8, 1, 107, 7, 1, 106, 1, 10, 1, 5, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 11, 4, 0, 51, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 115, 111, 108, 118, 101, 45, 97, 100, 100, 114, 101, 115, 115, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 115, 111, 108, 118, 101, 45, 110, 101, 120, 116, 45, 97, 100, 100, 114, 101, 115, 115, 1, 12, 1, 105, 1, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 13, 4, 0, 40, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 115, 111, 108, 118, 101, 45, 97, 100, 100, 114, 101, 115, 115, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 14, 1, 104, 3, 1, 105, 8, 1, 106, 1, 16, 1, 5, 1, 64, 2, 7, 110, 101, 116, 119, 111, 114, 107, 15, 4, 110, 97, 109, 101, 115, 0, 17, 4, 0, 17, 114, 101, 115, 111, 108, 118, 101, 45, 97, 100, 100, 114, 101, 115, 115, 101, 115, 1, 18, 3, 1, 33, 119, 97, 115, 105, 58, 115, 111, 99, 107, 101, 116, 115, 47, 105, 112, 45, 110, 97, 109, 101, 45, 108, 111, 111, 107, 117, 112, 64, 48, 46, 50, 46, 48, 5, 11, 1, 66, 5, 2, 3, 2, 1, 8, 4, 0, 7, 110, 101, 116, 119, 111, 114, 107, 3, 0, 0, 1, 105, 1, 1, 64, 0, 0, 2, 4, 0, 16, 105, 110, 115, 116, 97, 110, 99, 101, 45, 110, 101, 116, 119, 111, 114, 107, 1, 3, 3, 1, 35, 119, 97, 115, 105, 58, 115, 111, 99, 107, 101, 116, 115, 47, 105, 110, 115, 116, 97, 110, 99, 101, 45, 110, 101, 116, 119, 111, 114, 107, 64, 48, 46, 50, 46, 48, 5, 12, 1, 66, 3, 1, 112, 115, 1, 64, 0, 0, 0, 4, 0, 3, 103, 101, 116, 1, 1, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 13, 4, 1, 19, 103, 111, 108, 101, 109, 58, 105, 116, 47, 110, 101, 116, 119, 111, 114, 107, 105, 110, 103, 4, 0, 11, 16, 1, 0, 10, 110, 101, 116, 119, 111, 114, 107, 105, 110, 103, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + pub trait Guest { + fn get() -> _rt::Vec<_rt::String>; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#get"] + unsafe extern "C" fn export_get() -> *mut u8 { + $($path_to_types)*::_export_get_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#get"] + unsafe extern "C" fn _post_return_get(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_networking_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) + } +#[doc(inline)] +pub(crate) use __export_networking_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:networking:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4382] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9d!\x01A\x02\x01A\x16\ +\x01B\x19\x01z\x04\0\x0anode-index\x03\0\0\x01p\x01\x01k\x01\x01o\x02y\x03\x01p\x7f\ +\x01j\x01\x03\x01\x03\x01q\x15\x0crecord-value\x01\x02\0\x0dvariant-value\x01\x04\ +\0\x0aenum-value\x01y\0\x0bflags-value\x01\x05\0\x0btuple-value\x01\x02\0\x0alis\ +t-value\x01\x02\0\x0coption-value\x01\x03\0\x0cresult-value\x01\x06\0\x07prim-u8\ +\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\ +\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\ +\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-str\ +ing\x01s\0\x04\0\x08wit-node\x03\0\x07\x01p\x08\x01r\x01\x05nodes\x09\x04\0\x09w\ +it-value\x03\0\x0a\x01r\x01\x05values\x04\0\x03uri\x03\0\x0c\x01q\x04\x0eprotoco\ +l-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\x15remote-internal-error\x01\ +s\0\x04\0\x09rpc-error\x03\0\x0e\x04\0\x08wasm-rpc\x03\x01\x01i\x10\x01@\x01\x08\ +location\x0d\0\x11\x04\0\x15[constructor]wasm-rpc\x01\x12\x01h\x10\x01p\x0b\x01j\ +\x01\x0b\x01\x0f\x01@\x03\x04self\x13\x0dfunction-names\x0ffunction-params\x14\0\ +\x15\x04\0![method]wasm-rpc.invoke-and-await\x01\x16\x03\x01\x15golem:rpc/types@\ +0.1.0\x05\0\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\ +\x04\0\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[me\ +thod]pollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04pol\ +l\x01\x06\x03\x01\x12wasi:io/poll@0.2.0\x05\x01\x02\x03\0\x01\x08pollable\x01B\x0f\ +\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01\ +w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\ +\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-\ +instant\x01\x09\x01@\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\ +\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x03\x02\x03\0\0\x03uri\x02\x03\0\x02\x08\ +duration\x01Ba\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\ +\x08duration\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11compone\ +nt-version\x03\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\ +\x01r\x01\x04uuid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\ +\x0bworker-names\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog\ +-idx\x05\x04\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\ +\x09max-delay\x03\x0amultipliery\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fper\ +sist-nothing\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persis\ +tence-level\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mo\ +de\x03\0\x14\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-\ +equal\x04less\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equa\ +l\x04like\x08not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07ru\ +nning\x04idle\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0d\ +worker-status\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-nam\ +e-filter\x03\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-statu\ +s-filter\x03\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-\ +filter\x03\0\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at\ +-filter\x03\0\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-en\ +v-filter\x03\0$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\ +\x0acreated-at\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\ +\x01r\x01\x07filters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filter\ +s+\x04\0\x11worker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-i\ +d\x0d\x04args.\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\ +\x0fworker-metadata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0c\ +component-id\x0b\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x01\ +6\x01h3\x01p2\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01\ +:\x01@\0\0\x0f\x04\0\x14golem-create-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\ +\0<\x04\0\x13golem-await-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\ +\0\x16golem-complete-promise\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x14gole\ +m-delete-promise\x01?\x01@\x01\x0dfunction-names\0\x01\x04\0\x0cget-self-uri\x01\ +@\x01@\0\0\x05\x04\0\x0fget-oplog-index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\ +\0\x0fset-oplog-index\x01B\x01@\x01\x08replicas}\x01\0\x04\0\x0coplog-commit\x01\ +C\x04\0\x14mark-begin-operation\x01A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-e\ +nd-operation\x01D\x01@\0\0\x11\x04\0\x10get-retry-policy\x01E\x01@\x01\x10new-re\ +try-policy\x11\x01\0\x04\0\x10set-retry-policy\x01F\x01@\0\0\x13\x04\0\x1bget-op\ +log-persistence-level\x01G\x01@\x01\x15new-persistence-level\x13\x01\0\x04\0\x1b\ +set-oplog-persistence-level\x01H\x01@\0\0\x7f\x04\0\x14get-idempotence-mode\x01I\ +\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\x14set-idempotence-mode\x01J\x01@\0\0\x09\ +\x04\0\x18generate-idempotency-key\x01K\x01@\x03\x09worker-id\x0d\x0etarget-vers\ +ion\x07\x04mode\x15\x01\0\x04\0\x0dupdate-worker\x01L\x03\x01\x14golem:api/host@\ +0.2.0\x05\x06\x01B\x11\x04\0\x07network\x03\x01\x01m\x15\x07unknown\x0daccess-de\ +nied\x0dnot-supported\x10invalid-argument\x0dout-of-memory\x07timeout\x14concurr\ +ency-conflict\x0fnot-in-progress\x0bwould-block\x0dinvalid-state\x10new-socket-l\ +imit\x14address-not-bindable\x0eaddress-in-use\x12remote-unreachable\x12connecti\ +on-refused\x10connection-reset\x12connection-aborted\x12datagram-too-large\x11na\ +me-unresolvable\x1atemporary-resolver-failure\x1apermanent-resolver-failure\x04\0\ +\x0aerror-code\x03\0\x01\x01m\x02\x04ipv4\x04ipv6\x04\0\x11ip-address-family\x03\ +\0\x03\x01o\x04}}}}\x04\0\x0cipv4-address\x03\0\x05\x01o\x08{{{{{{{{\x04\0\x0cip\ +v6-address\x03\0\x07\x01q\x02\x04ipv4\x01\x06\0\x04ipv6\x01\x08\0\x04\0\x0aip-ad\ +dress\x03\0\x09\x01r\x02\x04port{\x07address\x06\x04\0\x13ipv4-socket-address\x03\ +\0\x0b\x01r\x04\x04port{\x09flow-infoy\x07address\x08\x08scope-idy\x04\0\x13ipv6\ +-socket-address\x03\0\x0d\x01q\x02\x04ipv4\x01\x0c\0\x04ipv6\x01\x0e\0\x04\0\x11\ +ip-socket-address\x03\0\x0f\x03\x01\x1awasi:sockets/network@0.2.0\x05\x07\x02\x03\ +\0\x04\x07network\x02\x03\0\x04\x0aerror-code\x02\x03\0\x04\x0aip-address\x01B\x16\ +\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\x08\x04\0\x07netw\ +ork\x03\0\x02\x02\x03\x02\x01\x09\x04\0\x0aerror-code\x03\0\x04\x02\x03\x02\x01\x0a\ +\x04\0\x0aip-address\x03\0\x06\x04\0\x16resolve-address-stream\x03\x01\x01h\x08\x01\ +k\x07\x01j\x01\x0a\x01\x05\x01@\x01\x04self\x09\0\x0b\x04\03[method]resolve-addr\ +ess-stream.resolve-next-address\x01\x0c\x01i\x01\x01@\x01\x04self\x09\0\x0d\x04\0\ +([method]resolve-address-stream.subscribe\x01\x0e\x01h\x03\x01i\x08\x01j\x01\x10\ +\x01\x05\x01@\x02\x07network\x0f\x04names\0\x11\x04\0\x11resolve-addresses\x01\x12\ +\x03\x01!wasi:sockets/ip-name-lookup@0.2.0\x05\x0b\x01B\x05\x02\x03\x02\x01\x08\x04\ +\0\x07network\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x10instance-network\x01\x03\x03\ +\x01#wasi:sockets/instance-network@0.2.0\x05\x0c\x01B\x03\x01ps\x01@\0\0\0\x04\0\ +\x03get\x01\x01\x04\x01\x0cgolem:it/api\x05\x0d\x04\x01\x13golem:it/networking\x04\ +\0\x0b\x10\x01\0\x0anetworking\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/networking/src/lib.rs b/test-components/networking/src/lib.rs index b5d82780a9..657fdde5f8 100644 --- a/test-components/networking/src/lib.rs +++ b/test-components/networking/src/lib.rs @@ -26,3 +26,5 @@ impl Guest for Component { result } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/option-service.wasm b/test-components/option-service.wasm index b754bdc20a..378761c2b4 100755 Binary files a/test-components/option-service.wasm and b/test-components/option-service.wasm differ diff --git a/test-components/option-service/Cargo.lock b/test-components/option-service/Cargo.lock index 75a41b9836..7589a00f09 100644 --- a/test-components/option-service/Cargo.lock +++ b/test-components/option-service/Cargo.lock @@ -43,7 +43,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/option-service/cargo.toml b/test-components/option-service/cargo.toml index 8e4c28d7ec..dfcbee8b7b 100644 --- a/test-components/option-service/cargo.toml +++ b/test-components/option-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/option-service/src/bindings.rs b/test-components/option-service/src/bindings.rs index 576046c875..c0520559fc 100644 --- a/test-components/option-service/src/bindings.rs +++ b/test-components/option-service/src/bindings.rs @@ -1,183 +1,240 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - #[derive(Clone)] - pub struct Task { - pub name: wit_bindgen::rt::string::String, - pub description: Option, - } - impl ::core::fmt::Debug for Task { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Task").field("name", &self.name).field("description", &self.description).finish() - } - } - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#echo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_echo(arg0: i32,arg1: i32,arg2: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result1 = <_GuestImpl as Guest>::echo(match arg0 { - 0 => None, - 1 => { - let e = { - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - - wit_bindgen::rt::string_lift(bytes0) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Some(e) => { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - }, - None => { - { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[derive(Clone)] + pub struct Task { + pub name: _rt::String, + pub description: Option<_rt::String>, } - }, - };ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#echo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_echo(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#todo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_todo(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result2 = <_GuestImpl as Guest>::todo(Task{ - name: wit_bindgen::rt::string_lift(bytes0), - description: match arg2 { - 0 => None, - 1 => { - let e = { - let len1 = arg4 as usize; - let bytes1 = Vec::from_raw_parts(arg3 as *mut _, len1, len1); - - wit_bindgen::rt::string_lift(bytes1) - }; - Some(e) + impl ::core::fmt::Debug for Task { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Task") + .field("name", &self.name) + .field("description", &self.description) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_echo_cabi( + arg0: i32, + arg1: *mut u8, + arg2: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result1 = T::echo(match arg0 { + 0 => None, + 1 => { + let e = { + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + + _rt::string_lift(bytes0) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Some(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + None => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_echo(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_todo_cabi( + arg0: *mut u8, + arg1: usize, + arg2: i32, + arg3: *mut u8, + arg4: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result2 = T::todo(Task { + name: _rt::string_lift(bytes0), + description: match arg2 { + 0 => None, + 1 => { + let e = { + let len1 = arg4; + let bytes1 = _rt::Vec::from_raw_parts(arg3.cast(), len1, len1); + + _rt::string_lift(bytes1) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + }); + let ptr3 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec4 = (result2.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr3.add(4).cast::() = len4; + *ptr3.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + ptr3 } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - }); - let ptr3 = _RET_AREA.0.as_mut_ptr() as i32; - let vec4 = (result2.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr3 + 4) as *mut i32) = len4; - *((ptr3 + 0) as *mut i32) = ptr4; - ptr3 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#todo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_todo(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_todo(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + pub trait Guest { + fn echo(input: Option<_rt::String>) -> Option<_rt::String>; + fn todo(input: Task) -> _rt::String; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#echo"] + unsafe extern "C" fn export_echo(arg0: i32,arg1: *mut u8,arg2: usize,) -> *mut u8 { + $($path_to_types)*::_export_echo_cabi::<$ty>(arg0, arg1, arg2) + } + #[export_name = "cabi_post_golem:it/api#echo"] + unsafe extern "C" fn _post_return_echo(arg0: *mut u8,) { + $($path_to_types)*::__post_return_echo::<$ty>(arg0) + } + #[export_name = "golem:it/api#todo"] + unsafe extern "C" fn export_todo(arg0: *mut u8,arg1: usize,arg2: i32,arg3: *mut u8,arg4: usize,) -> *mut u8 { + $($path_to_types)*::_export_todo_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) + } + #[export_name = "cabi_post_golem:it/api#todo"] + unsafe extern "C" fn _post_return_todo(arg0: *mut u8,) { + $($path_to_types)*::__post_return_todo::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn echo(input: Option,) -> Option; - fn todo(input: Task,) -> wit_bindgen::rt::string::String; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + pub use alloc_crate::string::String; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + extern crate alloc as alloc_crate; + pub use alloc_crate::alloc; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_option_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_option_service_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:option-service"] +#[link_section = "component-type:wit-bindgen:0.25.0:option-service:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 384] = [3, 0, 14, 111, 112, 116, 105, 111, 110, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 100, 1, 65, 2, 1, 66, 7, 1, 107, 115, 1, 114, 2, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 4, 0, 4, 116, 97, 115, 107, 3, 0, 1, 1, 64, 1, 5, 105, 110, 112, 117, 116, 0, 0, 0, 4, 0, 4, 101, 99, 104, 111, 1, 3, 1, 64, 1, 5, 105, 110, 112, 117, 116, 2, 0, 115, 4, 0, 4, 116, 111, 100, 111, 1, 4, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 131, 1, 1, 65, 2, 1, 65, 2, 1, 66, 7, 1, 107, 115, 1, 114, 2, 4, 110, 97, 109, 101, 115, 11, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 4, 0, 4, 116, 97, 115, 107, 3, 0, 1, 1, 64, 1, 5, 105, 110, 112, 117, 116, 0, 0, 0, 4, 0, 4, 101, 99, 104, 111, 1, 3, 1, 64, 1, 5, 105, 110, 112, 117, 116, 2, 0, 115, 4, 0, 4, 116, 111, 100, 111, 1, 4, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 23, 103, 111, 108, 101, 109, 58, 105, 116, 47, 111, 112, 116, 105, 111, 110, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 20, 1, 0, 14, 111, 112, 116, 105, 111, 110, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 264] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x83\x01\x01A\x02\x01\ +A\x02\x01B\x07\x01ks\x01r\x02\x04names\x0bdescription\0\x04\0\x04task\x03\0\x01\x01\ +@\x01\x05input\0\0\0\x04\0\x04echo\x01\x03\x01@\x01\x05input\x02\0s\x04\0\x04tod\ +o\x01\x04\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x17golem:it/option-service\x04\0\ +\x0b\x14\x01\0\x0eoption-service\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/option-service/src/lib.rs b/test-components/option-service/src/lib.rs index f6834c7f18..aca7c69469 100644 --- a/test-components/option-service/src/lib.rs +++ b/test-components/option-service/src/lib.rs @@ -13,3 +13,5 @@ impl Guest for Component { input.name } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/promise.wasm b/test-components/promise.wasm index f69c896c25..8177b03dd5 100755 Binary files a/test-components/promise.wasm and b/test-components/promise.wasm differ diff --git a/test-components/promise/Cargo.lock b/test-components/promise/Cargo.lock index 7825ecf8ae..83012a5d12 100644 --- a/test-components/promise/Cargo.lock +++ b/test-components/promise/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/promise/cargo.toml b/test-components/promise/cargo.toml index c871ed59ec..a2f050de44 100644 --- a/test-components/promise/cargo.toml +++ b/test-components/promise/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/promise/src/bindings.rs b/test-components/promise/src/bindings.rs index b702eef4e3..dc85abcb25 100644 --- a/test-components/promise/src/bindings.rs +++ b/test-components/promise/src/bindings.rs @@ -1,2402 +1,2992 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec2 = (result0).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - let base2 = l0; - let len2 = l1; - wit_bindgen::rt::dealloc(base2, (len2 as usize) * 1, 1); - } - }; -}; -use super::Component as _GuestImpl; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 1, 1); +} pub trait Guest { - fn run() -> wit_bindgen::rt::vec::Vec::; + fn run() -> _rt::Vec; } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_promise_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_promise_cabi; #[repr(align(4))] -struct _RetArea([u8; 8]); -static mut _RET_AREA: _RetArea = _RetArea([0; 8]); +struct _RetArea([::core::mem::MaybeUninit; 8]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); +#[allow(dead_code)] pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod host { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - /// An index into the persistent log storing all performed operations of a worker - pub type OplogIndex = u64; - /// Represents a Golem component's version - pub type ComponentVersion = u64; - /// UUID - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Uuid { - pub high_bits: u64, - pub low_bits: u64, - } - impl ::core::fmt::Debug for Uuid { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uuid").field("high-bits", &self.high_bits).field("low-bits", &self.low_bits).finish() - } - } - /// Represents a Golem component - #[repr(C)] - #[derive(Clone, Copy)] - pub struct ComponentId { - pub uuid: Uuid, - } - impl ::core::fmt::Debug for ComponentId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ComponentId").field("uuid", &self.uuid).finish() - } - } - /// Represents a Golem worker - #[derive(Clone)] - pub struct WorkerId { - pub component_id: ComponentId, - pub worker_name: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerId").field("component-id", &self.component_id).field("worker-name", &self.worker_name).finish() - } - } - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - #[derive(Clone)] - pub struct PromiseId { - pub worker_id: WorkerId, - pub oplog_idx: OplogIndex, - } - impl ::core::fmt::Debug for PromiseId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("PromiseId").field("worker-id", &self.worker_id).field("oplog-idx", &self.oplog_idx).finish() - } - } - /// Configures how the executor retries failures - #[repr(C)] - #[derive(Clone, Copy)] - pub struct RetryPolicy { - /// The maximum number of retries before the worker becomes permanently failed - pub max_attempts: u32, - /// The minimum delay between retries (applied to the first retry) - pub min_delay: Duration, - /// The maximum delay between retries - pub max_delay: Duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - pub multiplier: u32, - } - impl ::core::fmt::Debug for RetryPolicy { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RetryPolicy").field("max-attempts", &self.max_attempts).field("min-delay", &self.min_delay).field("max-delay", &self.max_delay).field("multiplier", &self.multiplier).finish() + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod host { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + /// An index into the persistent log storing all performed operations of a worker + pub type OplogIndex = u64; + /// Represents a Golem component's version + pub type ComponentVersion = u64; + /// UUID + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Uuid { + pub high_bits: u64, + pub low_bits: u64, + } + impl ::core::fmt::Debug for Uuid { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uuid") + .field("high-bits", &self.high_bits) + .field("low-bits", &self.low_bits) + .finish() + } + } + /// Represents a Golem component + #[repr(C)] + #[derive(Clone, Copy)] + pub struct ComponentId { + pub uuid: Uuid, + } + impl ::core::fmt::Debug for ComponentId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ComponentId") + .field("uuid", &self.uuid) + .finish() + } + } + /// Represents a Golem worker + #[derive(Clone)] + pub struct WorkerId { + pub component_id: ComponentId, + pub worker_name: _rt::String, + } + impl ::core::fmt::Debug for WorkerId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerId") + .field("component-id", &self.component_id) + .field("worker-name", &self.worker_name) + .finish() + } + } + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + #[derive(Clone)] + pub struct PromiseId { + pub worker_id: WorkerId, + pub oplog_idx: OplogIndex, + } + impl ::core::fmt::Debug for PromiseId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PromiseId") + .field("worker-id", &self.worker_id) + .field("oplog-idx", &self.oplog_idx) + .finish() + } + } + /// Configures how the executor retries failures + #[repr(C)] + #[derive(Clone, Copy)] + pub struct RetryPolicy { + /// The maximum number of retries before the worker becomes permanently failed + pub max_attempts: u32, + /// The minimum delay between retries (applied to the first retry) + pub min_delay: Duration, + /// The maximum delay between retries + pub max_delay: Duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + pub multiplier: u32, + } + impl ::core::fmt::Debug for RetryPolicy { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RetryPolicy") + .field("max-attempts", &self.max_attempts) + .field("min-delay", &self.min_delay) + .field("max-delay", &self.max_delay) + .field("multiplier", &self.multiplier) + .finish() + } + } + /// Configurable persistence level for workers + #[derive(Clone, Copy)] + pub enum PersistenceLevel { + PersistNothing, + PersistRemoteSideEffects, + Smart, + } + impl ::core::fmt::Debug for PersistenceLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + PersistenceLevel::PersistNothing => { + f.debug_tuple("PersistenceLevel::PersistNothing").finish() + } + PersistenceLevel::PersistRemoteSideEffects => f + .debug_tuple("PersistenceLevel::PersistRemoteSideEffects") + .finish(), + PersistenceLevel::Smart => { + f.debug_tuple("PersistenceLevel::Smart").finish() + } + } + } + } + /// Describes how to update a worker to a different component version + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum UpdateMode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + Automatic, + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + SnapshotBased, + } + impl ::core::fmt::Debug for UpdateMode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + UpdateMode::Automatic => f.debug_tuple("UpdateMode::Automatic").finish(), + UpdateMode::SnapshotBased => { + f.debug_tuple("UpdateMode::SnapshotBased").finish() + } + } + } + } + + impl UpdateMode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> UpdateMode { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => UpdateMode::Automatic, + 1 => UpdateMode::SnapshotBased, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum FilterComparator { + Equal, + NotEqual, + GreaterEqual, + Greater, + LessEqual, + Less, + } + impl ::core::fmt::Debug for FilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + FilterComparator::Equal => { + f.debug_tuple("FilterComparator::Equal").finish() + } + FilterComparator::NotEqual => { + f.debug_tuple("FilterComparator::NotEqual").finish() + } + FilterComparator::GreaterEqual => { + f.debug_tuple("FilterComparator::GreaterEqual").finish() + } + FilterComparator::Greater => { + f.debug_tuple("FilterComparator::Greater").finish() + } + FilterComparator::LessEqual => { + f.debug_tuple("FilterComparator::LessEqual").finish() + } + FilterComparator::Less => f.debug_tuple("FilterComparator::Less").finish(), + } + } + } + + impl FilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> FilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => FilterComparator::Equal, + 1 => FilterComparator::NotEqual, + 2 => FilterComparator::GreaterEqual, + 3 => FilterComparator::Greater, + 4 => FilterComparator::LessEqual, + 5 => FilterComparator::Less, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum StringFilterComparator { + Equal, + NotEqual, + Like, + NotLike, + } + impl ::core::fmt::Debug for StringFilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StringFilterComparator::Equal => { + f.debug_tuple("StringFilterComparator::Equal").finish() + } + StringFilterComparator::NotEqual => { + f.debug_tuple("StringFilterComparator::NotEqual").finish() + } + StringFilterComparator::Like => { + f.debug_tuple("StringFilterComparator::Like").finish() + } + StringFilterComparator::NotLike => { + f.debug_tuple("StringFilterComparator::NotLike").finish() + } + } + } + } + + impl StringFilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> StringFilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => StringFilterComparator::Equal, + 1 => StringFilterComparator::NotEqual, + 2 => StringFilterComparator::Like, + 3 => StringFilterComparator::NotLike, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum WorkerStatus { + /// The worker is running an invoked function + Running, + /// The worker is ready to run an invoked function + Idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + Suspended, + /// The last invocation was interrupted but will be resumed + Interrupted, + /// The last invocation failed and a retry was scheduled + Retrying, + /// The last invocation failed and the worker can no longer be used + Failed, + /// The worker exited after a successful invocation and can no longer be invoked + Exited, + } + impl ::core::fmt::Debug for WorkerStatus { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerStatus::Running => f.debug_tuple("WorkerStatus::Running").finish(), + WorkerStatus::Idle => f.debug_tuple("WorkerStatus::Idle").finish(), + WorkerStatus::Suspended => { + f.debug_tuple("WorkerStatus::Suspended").finish() + } + WorkerStatus::Interrupted => { + f.debug_tuple("WorkerStatus::Interrupted").finish() + } + WorkerStatus::Retrying => f.debug_tuple("WorkerStatus::Retrying").finish(), + WorkerStatus::Failed => f.debug_tuple("WorkerStatus::Failed").finish(), + WorkerStatus::Exited => f.debug_tuple("WorkerStatus::Exited").finish(), + } + } + } + + impl WorkerStatus { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> WorkerStatus { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => WorkerStatus::Running, + 1 => WorkerStatus::Idle, + 2 => WorkerStatus::Suspended, + 3 => WorkerStatus::Interrupted, + 4 => WorkerStatus::Retrying, + 5 => WorkerStatus::Failed, + 6 => WorkerStatus::Exited, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Clone)] + pub struct WorkerNameFilter { + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerNameFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerNameFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerStatusFilter { + pub comparator: FilterComparator, + pub value: WorkerStatus, + } + impl ::core::fmt::Debug for WorkerStatusFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerStatusFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerVersionFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerVersionFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerVersionFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerCreatedAtFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerCreatedAtFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerCreatedAtFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerEnvFilter { + pub name: _rt::String, + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerEnvFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerEnvFilter") + .field("name", &self.name) + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub enum WorkerPropertyFilter { + Name(WorkerNameFilter), + Status(WorkerStatusFilter), + Version(WorkerVersionFilter), + CreatedAt(WorkerCreatedAtFilter), + Env(WorkerEnvFilter), + } + impl ::core::fmt::Debug for WorkerPropertyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerPropertyFilter::Name(e) => f + .debug_tuple("WorkerPropertyFilter::Name") + .field(e) + .finish(), + WorkerPropertyFilter::Status(e) => f + .debug_tuple("WorkerPropertyFilter::Status") + .field(e) + .finish(), + WorkerPropertyFilter::Version(e) => f + .debug_tuple("WorkerPropertyFilter::Version") + .field(e) + .finish(), + WorkerPropertyFilter::CreatedAt(e) => f + .debug_tuple("WorkerPropertyFilter::CreatedAt") + .field(e) + .finish(), + WorkerPropertyFilter::Env(e) => { + f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WorkerAllFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAllFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAllFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerAnyFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAnyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAnyFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerMetadata { + pub worker_id: WorkerId, + pub args: _rt::Vec<_rt::String>, + pub env: _rt::Vec<(_rt::String, _rt::String)>, + pub status: WorkerStatus, + pub component_version: u64, + pub retry_count: u64, + } + impl ::core::fmt::Debug for WorkerMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerMetadata") + .field("worker-id", &self.worker_id) + .field("args", &self.args) + .field("env", &self.env) + .field("status", &self.status) + .field("component-version", &self.component_version) + .field("retry-count", &self.retry_count) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct GetWorkers { + handle: _rt::Resource, + } + + impl GetWorkers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for GetWorkers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]get-workers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn new( + component_id: ComponentId, + filter: Option<&WorkerAnyFilter>, + precise: bool, + ) -> Self { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let ComponentId { uuid: uuid0 } = component_id; + let Uuid { + high_bits: high_bits1, + low_bits: low_bits1, + } = uuid0; + let (result14_0, result14_1, result14_2) = match filter { + Some(e) => { + let WorkerAnyFilter { filters: filters2 } = e; + let vec13 = filters2; + let len13 = vec13.len(); + let layout13 = _rt::alloc::Layout::from_size_align_unchecked( + vec13.len() * 8, + 4, + ); + let result13 = if layout13.size() != 0 { + let ptr = _rt::alloc::alloc(layout13).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout13); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec13.into_iter().enumerate() { + let base = result13.add(i * 8); + { + let WorkerAllFilter { filters: filters3 } = e; + let vec12 = filters3; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked( + vec12.len() * 32, + 8, + ); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 32); + { + match e { + WorkerPropertyFilter::Name(e) => { + *base.add(0).cast::() = (0i32) as u8; + let WorkerNameFilter { + comparator: comparator4, + value: value4, + } = e; + *base.add(8).cast::() = + (comparator4.clone() as i32) as u8; + let vec5 = value4; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(16).cast::() = len5; + *base.add(12).cast::<*mut u8>() = + ptr5.cast_mut(); + } + WorkerPropertyFilter::Status(e) => { + *base.add(0).cast::() = (1i32) as u8; + let WorkerStatusFilter { + comparator: comparator6, + value: value6, + } = e; + *base.add(8).cast::() = + (comparator6.clone() as i32) as u8; + *base.add(9).cast::() = + (value6.clone() as i32) as u8; + } + WorkerPropertyFilter::Version(e) => { + *base.add(0).cast::() = (2i32) as u8; + let WorkerVersionFilter { + comparator: comparator7, + value: value7, + } = e; + *base.add(8).cast::() = + (comparator7.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value7); + } + WorkerPropertyFilter::CreatedAt(e) => { + *base.add(0).cast::() = (3i32) as u8; + let WorkerCreatedAtFilter { + comparator: comparator8, + value: value8, + } = e; + *base.add(8).cast::() = + (comparator8.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value8); + } + WorkerPropertyFilter::Env(e) => { + *base.add(0).cast::() = (4i32) as u8; + let WorkerEnvFilter { + name: name9, + comparator: comparator9, + value: value9, + } = e; + let vec10 = name9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = + ptr10.cast_mut(); + *base.add(16).cast::() = + (comparator9.clone() as i32) as u8; + let vec11 = value9; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + *base.add(24).cast::() = len11; + *base.add(20).cast::<*mut u8>() = + ptr11.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len12; + *base.add(0).cast::<*mut u8>() = result12; + cleanup_list.extend_from_slice(&[(result12, layout12)]); + } + } + cleanup_list.extend_from_slice(&[(result13, layout13)]); + + (1i32, result13, len13) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[constructor]get-workers"] + fn wit_import( + _: i64, + _: i64, + _: i32, + _: *mut u8, + _: usize, + _: i32, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: i32, _: *mut u8, _: usize, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits1), + _rt::as_i64(low_bits1), + result14_0, + result14_1, + result14_2, + match &precise { + true => 1, + false => 0, + }, + ); + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + GetWorkers::from_handle(ret as u32) + } + } + } + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn get_next(&self) -> Option<_rt::Vec> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[method]get-workers.get-next"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base27 = l2; + let len27 = l3; + let mut result27 = _rt::Vec::with_capacity(len27); + for i in 0..len27 { + let base = base27.add(i * 64); + let e27 = { + let l4 = *base.add(0).cast::(); + let l5 = *base.add(8).cast::(); + let l6 = *base.add(16).cast::<*mut u8>(); + let l7 = *base.add(20).cast::(); + let len8 = l7; + let bytes8 = + _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + let l9 = *base.add(24).cast::<*mut u8>(); + let l10 = *base.add(28).cast::(); + let base14 = l9; + let len14 = l10; + let mut result14 = _rt::Vec::with_capacity(len14); + for i in 0..len14 { + let base = base14.add(i * 8); + let e14 = { + let l11 = *base.add(0).cast::<*mut u8>(); + let l12 = *base.add(4).cast::(); + let len13 = l12; + let bytes13 = _rt::Vec::from_raw_parts( + l11.cast(), + len13, + len13, + ); + + _rt::string_lift(bytes13) + }; + result14.push(e14); + } + _rt::cabi_dealloc(base14, len14 * 8, 4); + let l15 = *base.add(32).cast::<*mut u8>(); + let l16 = *base.add(36).cast::(); + let base23 = l15; + let len23 = l16; + let mut result23 = _rt::Vec::with_capacity(len23); + for i in 0..len23 { + let base = base23.add(i * 16); + let e23 = { + let l17 = *base.add(0).cast::<*mut u8>(); + let l18 = *base.add(4).cast::(); + let len19 = l18; + let bytes19 = _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ); + let l20 = *base.add(8).cast::<*mut u8>(); + let l21 = *base.add(12).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ); + + ( + _rt::string_lift(bytes19), + _rt::string_lift(bytes22), + ) + }; + result23.push(e23); + } + _rt::cabi_dealloc(base23, len23 * 16, 4); + let l24 = i32::from(*base.add(40).cast::()); + let l25 = *base.add(48).cast::(); + let l26 = *base.add(56).cast::(); + + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l4 as u64, + low_bits: l5 as u64, + }, + }, + worker_name: _rt::string_lift(bytes8), + }, + args: result14, + env: result23, + status: WorkerStatus::_lift(l24 as u8), + component_version: l25 as u64, + retry_count: l26 as u64, + } + }; + result27.push(e27); + } + _rt::cabi_dealloc(base27, len27 * 64, 8); + + result27 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a new promise + pub fn golem_create_promise() -> PromiseId { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-create-promise"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::<*mut u8>(); + let l4 = *ptr0.add(20).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *ptr0.add(24).cast::(); + PromiseId { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + }, + }, + worker_name: _rt::string_lift(bytes5), + }, + oplog_idx: l6 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + pub fn golem_await_promise(promise_id: &PromiseId) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let ptr5 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-await-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5, + ); + let l6 = *ptr5.add(0).cast::<*mut u8>(); + let l7 = *ptr5.add(4).cast::(); + let len8 = l7; + _rt::Vec::from_raw_parts(l6.cast(), len8, len8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + pub fn golem_complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = data; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-complete-promise"] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5.cast_mut(), + len5, + ); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Deletes the given promise + pub fn golem_delete_promise(promise_id: &PromiseId) { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-delete-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + pub fn get_self_uri(function_name: &str) -> Uri { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-self-uri"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes4), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns the current position in the persistent op log + pub fn get_oplog_index() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-index"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + pub fn set_oplog_index(oplog_idx: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-index"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(oplog_idx)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + pub fn oplog_commit(replicas: u8) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "oplog-commit"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(_rt::as_i32(&replicas)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + pub fn mark_begin_operation() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-begin-operation"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + pub fn mark_end_operation(begin: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-end-operation"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(begin)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current retry policy associated with the worker + pub fn get_retry_policy() -> RetryPolicy { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-retry-policy"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + RetryPolicy { + max_attempts: l1 as u32, + min_delay: l2 as u64, + max_delay: l3 as u64, + multiplier: l4 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + pub fn set_retry_policy(new_retry_policy: RetryPolicy) { + unsafe { + let RetryPolicy { + max_attempts: max_attempts0, + min_delay: min_delay0, + max_delay: max_delay0, + multiplier: multiplier0, + } = new_retry_policy; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-retry-policy"] + fn wit_import(_: i32, _: i64, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i32(max_attempts0), + _rt::as_i64(min_delay0), + _rt::as_i64(max_delay0), + _rt::as_i32(multiplier0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the worker's current persistence level. + pub fn get_oplog_persistence_level() -> PersistenceLevel { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-persistence-level"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + let v0 = match ret { + 0 => PersistenceLevel::PersistNothing, + 1 => PersistenceLevel::PersistRemoteSideEffects, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + PersistenceLevel::Smart + } + }; + v0 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel) { + unsafe { + let result0 = match new_persistence_level { + PersistenceLevel::PersistNothing => 0i32, + PersistenceLevel::PersistRemoteSideEffects => 1i32, + PersistenceLevel::Smart => 2i32, + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-persistence-level"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(result0); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + pub fn get_idempotence_mode() -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-idempotence-mode"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + pub fn set_idempotence_mode(idempotent: bool) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-idempotence-mode"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(match &idempotent { + true => 1, + false => 0, + }); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + pub fn generate_idempotency_key() -> Uuid { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "generate-idempotency-key"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + pub fn update_worker( + worker_id: &WorkerId, + target_version: ComponentVersion, + mode: UpdateMode, + ) { + unsafe { + let WorkerId { + component_id: component_id0, + worker_name: worker_name0, + } = worker_id; + let ComponentId { uuid: uuid1 } = component_id0; + let Uuid { + high_bits: high_bits2, + low_bits: low_bits2, + } = uuid1; + let vec3 = worker_name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "update-worker"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits2), + _rt::as_i64(low_bits2), + ptr3.cast_mut(), + len3, + _rt::as_i64(target_version), + mode.clone() as i32, + ); + } + } } - } - /// Configurable persistence level for workers - #[derive(Clone, Copy)] - pub enum PersistenceLevel{ - PersistNothing, - PersistRemoteSideEffects, - Smart, - } - impl ::core::fmt::Debug for PersistenceLevel { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - PersistenceLevel::PersistNothing => { - f.debug_tuple("PersistenceLevel::PersistNothing").finish() - } - PersistenceLevel::PersistRemoteSideEffects => { - f.debug_tuple("PersistenceLevel::PersistRemoteSideEffects").finish() - } - PersistenceLevel::Smart => { - f.debug_tuple("PersistenceLevel::Smart").finish() + } + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + } + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + } + } } - } - } - } - /// Describes how to update a worker to a different component version - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum UpdateMode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - Automatic, - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - SnapshotBased, - } - impl ::core::fmt::Debug for UpdateMode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - UpdateMode::Automatic => { - f.debug_tuple("UpdateMode::Automatic").finish() - } - UpdateMode::SnapshotBased => { - f.debug_tuple("UpdateMode::SnapshotBased").finish() + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, } - } - } - } - - impl UpdateMode{ - pub(crate) unsafe fn _lift(val: u8) -> UpdateMode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => UpdateMode::Automatic, - 1 => UpdateMode::SnapshotBased, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum FilterComparator { - Equal, - NotEqual, - GreaterEqual, - Greater, - LessEqual, - Less, - } - impl ::core::fmt::Debug for FilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - FilterComparator::Equal => { - f.debug_tuple("FilterComparator::Equal").finish() - } - FilterComparator::NotEqual => { - f.debug_tuple("FilterComparator::NotEqual").finish() - } - FilterComparator::GreaterEqual => { - f.debug_tuple("FilterComparator::GreaterEqual").finish() - } - FilterComparator::Greater => { - f.debug_tuple("FilterComparator::Greater").finish() - } - FilterComparator::LessEqual => { - f.debug_tuple("FilterComparator::LessEqual").finish() - } - FilterComparator::Less => { - f.debug_tuple("FilterComparator::Less").finish() + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } } - } - } - } - - impl FilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> FilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => FilterComparator::Equal, - 1 => FilterComparator::NotEqual, - 2 => FilterComparator::GreaterEqual, - 3 => FilterComparator::Greater, - 4 => FilterComparator::LessEqual, - 5 => FilterComparator::Less, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum StringFilterComparator { - Equal, - NotEqual, - Like, - NotLike, - } - impl ::core::fmt::Debug for StringFilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StringFilterComparator::Equal => { - f.debug_tuple("StringFilterComparator::Equal").finish() - } - StringFilterComparator::NotEqual => { - f.debug_tuple("StringFilterComparator::NotEqual").finish() - } - StringFilterComparator::Like => { - f.debug_tuple("StringFilterComparator::Like").finish() - } - StringFilterComparator::NotLike => { - f.debug_tuple("StringFilterComparator::NotLike").finish() + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, } - } - } - } - - impl StringFilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> StringFilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => StringFilterComparator::Equal, - 1 => StringFilterComparator::NotEqual, - 2 => StringFilterComparator::Like, - 3 => StringFilterComparator::NotLike, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum WorkerStatus { - /// The worker is running an invoked function - Running, - /// The worker is ready to run an invoked function - Idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - Suspended, - /// The last invocation was interrupted but will be resumed - Interrupted, - /// The last invocation failed and a retry was scheduled - Retrying, - /// The last invocation failed and the worker can no longer be used - Failed, - /// The worker exited after a successful invocation and can no longer be invoked - Exited, - } - impl ::core::fmt::Debug for WorkerStatus { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerStatus::Running => { - f.debug_tuple("WorkerStatus::Running").finish() - } - WorkerStatus::Idle => { - f.debug_tuple("WorkerStatus::Idle").finish() - } - WorkerStatus::Suspended => { - f.debug_tuple("WorkerStatus::Suspended").finish() - } - WorkerStatus::Interrupted => { - f.debug_tuple("WorkerStatus::Interrupted").finish() - } - WorkerStatus::Retrying => { - f.debug_tuple("WorkerStatus::Retrying").finish() - } - WorkerStatus::Failed => { - f.debug_tuple("WorkerStatus::Failed").finish() - } - WorkerStatus::Exited => { - f.debug_tuple("WorkerStatus::Exited").finish() + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } } - } - } - } - - impl WorkerStatus{ - pub(crate) unsafe fn _lift(val: u8) -> WorkerStatus{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => WorkerStatus::Running, - 1 => WorkerStatus::Idle, - 2 => WorkerStatus::Suspended, - 3 => WorkerStatus::Interrupted, - 4 => WorkerStatus::Retrying, - 5 => WorkerStatus::Failed, - 6 => WorkerStatus::Exited, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[derive(Clone)] - pub struct WorkerNameFilter { - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerNameFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerNameFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerStatusFilter { - pub comparator: FilterComparator, - pub value: WorkerStatus, - } - impl ::core::fmt::Debug for WorkerStatusFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerStatusFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerVersionFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerVersionFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerVersionFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerCreatedAtFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerCreatedAtFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerCreatedAtFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub struct WorkerEnvFilter { - pub name: wit_bindgen::rt::string::String, - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerEnvFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerEnvFilter").field("name", &self.name).field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WorkerPropertyFilter{ - Name(WorkerNameFilter), - Status(WorkerStatusFilter), - Version(WorkerVersionFilter), - CreatedAt(WorkerCreatedAtFilter), - Env(WorkerEnvFilter), - } - impl ::core::fmt::Debug for WorkerPropertyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerPropertyFilter::Name(e) => { - f.debug_tuple("WorkerPropertyFilter::Name").field(e).finish() - } - WorkerPropertyFilter::Status(e) => { - f.debug_tuple("WorkerPropertyFilter::Status").field(e).finish() - } - WorkerPropertyFilter::Version(e) => { - f.debug_tuple("WorkerPropertyFilter::Version").field(e).finish() - } - WorkerPropertyFilter::CreatedAt(e) => { - f.debug_tuple("WorkerPropertyFilter::CreatedAt").field(e).finish() - } - WorkerPropertyFilter::Env(e) => { - f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), + } + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } } - } - } - } - #[derive(Clone)] - pub struct WorkerAllFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAllFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAllFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerAnyFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAnyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAnyFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerMetadata { - pub worker_id: WorkerId, - pub args: wit_bindgen::rt::vec::Vec::, - pub env: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>, - pub status: WorkerStatus, - pub component_version: u64, - pub retry_count: u64, - } - impl ::core::fmt::Debug for WorkerMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerMetadata").field("worker-id", &self.worker_id).field("args", &self.args).field("env", &self.env).field("status", &self.status).field("component-version", &self.component_version).field("retry-count", &self.retry_count).finish() - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct GetWorkers{ - handle: wit_bindgen::rt::Resource, - } - - impl GetWorkers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for GetWorkers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]get-workers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn new(component_id: ComponentId,filter: Option<&WorkerAnyFilter>,precise: bool,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - let ComponentId{ uuid:uuid0, } = component_id; - let Uuid{ high_bits:high_bits1, low_bits:low_bits1, } = uuid0; - let (result14_0,result14_1,result14_2,) = match filter { - Some(e) => { - let WorkerAnyFilter{ filters:filters2, } = e; - let vec13 = filters2; - let len13 = vec13.len() as i32; - let layout13 = alloc::Layout::from_size_align_unchecked(vec13.len() * 8, 4); - let result13 = if layout13.size() != 0 - { - let ptr = alloc::alloc(layout13); - if ptr.is_null() - { - alloc::handle_alloc_error(layout13); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec13.into_iter().enumerate() { - let base = result13 as i32 + (i as i32) * 8; - { - let WorkerAllFilter{ filters:filters3, } = e; - let vec12 = filters3; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 32, 8); - let result12 = if layout12.size() != 0 + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, + } + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 32; - { - match e { - WorkerPropertyFilter::Name(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let WorkerNameFilter{ comparator:comparator4, value:value4, } = e; - *((base + 8) as *mut u8) = (comparator4.clone() as i32) as u8; - let vec5 = value4; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 16) as *mut i32) = len5; - *((base + 12) as *mut i32) = ptr5; - }, - WorkerPropertyFilter::Status(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let WorkerStatusFilter{ comparator:comparator6, value:value6, } = e; - *((base + 8) as *mut u8) = (comparator6.clone() as i32) as u8; - *((base + 9) as *mut u8) = (value6.clone() as i32) as u8; - }, - WorkerPropertyFilter::Version(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - let WorkerVersionFilter{ comparator:comparator7, value:value7, } = e; - *((base + 8) as *mut u8) = (comparator7.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value7); - }, - WorkerPropertyFilter::CreatedAt(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let WorkerCreatedAtFilter{ comparator:comparator8, value:value8, } = e; - *((base + 8) as *mut u8) = (comparator8.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value8); - }, - WorkerPropertyFilter::Env(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let WorkerEnvFilter{ name:name9, comparator:comparator9, value:value9, } = e; - let vec10 = name9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut u8) = (comparator9.clone() as i32) as u8; - let vec11 = value9; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - *((base + 24) as *mut i32) = len11; - *((base + 20) as *mut i32) = ptr11; - }, + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); } - } - } - *((base + 4) as *mut i32) = len12; - *((base + 0) as *mut i32) = result12 as i32; - cleanup_list.extend_from_slice(&[(result12, layout12),]); - } - } - cleanup_list.extend_from_slice(&[(result13, layout13),]); - - (1i32, result13 as i32, len13) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[constructor]get-workers"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits1), wit_bindgen::rt::as_i64(low_bits1), result14_0, result14_1, result14_2, match precise { true => 1, false => 0 }); - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - GetWorkers::from_handle(ret as u32) - } - } - } - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn get_next(&self,) -> Option>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[method]get-workers.get-next"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base27 = l2; - let len27 = l3; - let mut result27 = Vec::with_capacity(len27 as usize); - for i in 0..len27 { - let base = base27 + i * 64; - let e27 = { - let l4 = *((base + 0) as *const i64); - let l5 = *((base + 8) as *const i64); - let l6 = *((base + 16) as *const i32); - let l7 = *((base + 20) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - let l9 = *((base + 24) as *const i32); - let l10 = *((base + 28) as *const i32); - let base14 = l9; - let len14 = l10; - let mut result14 = Vec::with_capacity(len14 as usize); - for i in 0..len14 { - let base = base14 + i * 8; - let e14 = { - let l11 = *((base + 0) as *const i32); - let l12 = *((base + 4) as *const i32); - let len13 = l12 as usize; - let bytes13 = Vec::from_raw_parts(l11 as *mut _, len13, len13); - - wit_bindgen::rt::string_lift(bytes13) - }; - result14.push(e14); - } - wit_bindgen::rt::dealloc(base14, (len14 as usize) * 8, 4); - let l15 = *((base + 32) as *const i32); - let l16 = *((base + 36) as *const i32); - let base23 = l15; - let len23 = l16; - let mut result23 = Vec::with_capacity(len23 as usize); - for i in 0..len23 { - let base = base23 + i * 16; - let e23 = { - let l17 = *((base + 0) as *const i32); - let l18 = *((base + 4) as *const i32); - let len19 = l18 as usize; - let bytes19 = Vec::from_raw_parts(l17 as *mut _, len19, len19); - let l20 = *((base + 8) as *const i32); - let l21 = *((base + 12) as *const i32); - let len22 = l21 as usize; - let bytes22 = Vec::from_raw_parts(l20 as *mut _, len22, len22); - - (wit_bindgen::rt::string_lift(bytes19), wit_bindgen::rt::string_lift(bytes22)) - }; - result23.push(e23); - } - wit_bindgen::rt::dealloc(base23, (len23 as usize) * 16, 4); - let l24 = i32::from(*((base + 40) as *const u8)); - let l25 = *((base + 48) as *const i64); - let l26 = *((base + 56) as *const i64); - - WorkerMetadata{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l4 as u64, - low_bits: l5 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes8), - }, - args: result14, - env: result23, - status: WorkerStatus::_lift(l24 as u8), - component_version: l25 as u64, - retry_count: l26 as u64, - } - }; - result27.push(e27); - } - wit_bindgen::rt::dealloc(base27, (len27 as usize) * 64, 8); - - result27 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a new promise - pub fn golem_create_promise() -> PromiseId{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-create-promise"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i32); - let l4 = *((ptr0 + 20) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((ptr0 + 24) as *const i64); - PromiseId{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes5), - }, - oplog_idx: l6 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - pub fn golem_await_promise(promise_id: &PromiseId,) -> 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 PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let ptr5 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-await-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5); - let l6 = *((ptr5 + 0) as *const i32); - let l7 = *((ptr5 + 4) as *const i32); - let len8 = l7 as usize; - Vec::from_raw_parts(l6 as *mut _, len8, len8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - pub fn golem_complete_promise(promise_id: &PromiseId,data: &[u8],) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = data; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-complete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5, len5); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Deletes the given promise - pub fn golem_delete_promise(promise_id: &PromiseId,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-delete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - pub fn get_self_uri(function_name: &str,) -> Uri{ - - #[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 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-self-uri"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes4), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the current position in the persistent op log - pub fn get_oplog_index() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-index"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - pub fn set_oplog_index(oplog_idx: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-index"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(oplog_idx)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - pub fn oplog_commit(replicas: u8,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "oplog-commit"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(replicas)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - pub fn mark_begin_operation() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-begin-operation"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - pub fn mark_end_operation(begin: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-end-operation"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(begin)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current retry policy associated with the worker - pub fn get_retry_policy() -> RetryPolicy{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-retry-policy"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i32); - RetryPolicy{ - max_attempts: l1 as u32, - min_delay: l2 as u64, - max_delay: l3 as u64, - multiplier: l4 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - pub fn set_retry_policy(new_retry_policy: RetryPolicy,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RetryPolicy{ max_attempts:max_attempts0, min_delay:min_delay0, max_delay:max_delay0, multiplier:multiplier0, } = new_retry_policy; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-retry-policy"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(max_attempts0), wit_bindgen::rt::as_i64(min_delay0), wit_bindgen::rt::as_i64(max_delay0), wit_bindgen::rt::as_i32(multiplier0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the worker's current persistence level. - pub fn get_oplog_persistence_level() -> PersistenceLevel{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-persistence-level"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - let v0 = match ret { - 0 => { - PersistenceLevel::PersistNothing - } - 1 => { - PersistenceLevel::PersistRemoteSideEffects - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - PersistenceLevel::Smart - } - }; - v0 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let result0 = match new_persistence_level { - PersistenceLevel::PersistNothing=> { - 0i32 - } - PersistenceLevel::PersistRemoteSideEffects=> { - 1i32 - } - PersistenceLevel::Smart=> { - 2i32 - } - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-persistence-level"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(result0); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - pub fn get_idempotence_mode() -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-idempotence-mode"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - pub fn set_idempotence_mode(idempotent: bool,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-idempotence-mode"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(match idempotent { true => 1, false => 0 }); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - pub fn generate_idempotency_key() -> Uuid{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "generate-idempotency-key"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - pub fn update_worker(worker_id: &WorkerId,target_version: ComponentVersion,mode: UpdateMode,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let WorkerId{ component_id:component_id0, worker_name:worker_name0, } = worker_id; - let ComponentId{ uuid:uuid1, } = component_id0; - let Uuid{ high_bits:high_bits2, low_bits:low_bits2, } = uuid1; - let vec3 = worker_name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "update-worker"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits2), wit_bindgen::rt::as_i64(low_bits2), ptr3, len3, wit_bindgen::rt::as_i64(target_version), mode.clone() as i32); - } - } - - } - - } - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() - } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() - } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() - } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() - } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() - } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() + + drop(_handle); + } + } } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() - } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() - } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() - } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec9 = function_params; - let len9 = vec9.len() as i32; - let layout9 = alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); - let result9 = if layout9.size() != 0 - { - let ptr = alloc::alloc(layout9); - if ptr.is_null() - { - alloc::handle_alloc_error(layout9); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec8 = nodes1; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 24, 8); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec9 = function_params; + let len9 = vec9.len(); + let layout9 = + _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); + let result9 = if layout9.size() != 0 { + let ptr = _rt::alloc::alloc(layout9).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout9); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec9.into_iter().enumerate() { + let base = result9.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec8 = nodes1; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked( + vec8.len() * 24, + 8, + ); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - } + }; + for (i, e) in vec8.into_iter().enumerate() { + let base = result8.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len8; + *base.add(0).cast::<*mut u8>() = result8; + cleanup_list.extend_from_slice(&[(result8, layout8)]); } - } - *((base + 4) as *mut i32) = len8; - *((base + 0) as *mut i32) = result8 as i32; - cleanup_list.extend_from_slice(&[(result8, layout8),]); } - } - let ptr10 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result9 as i32, len9, ptr10); - let l11 = i32::from(*((ptr10 + 0) as *const u8)); - if layout9.size() != 0 { - alloc::dealloc(result9, layout9); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - + let ptr10 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); } - - } - match l11 { - 0 => { - let e = { - let l12 = *((ptr10 + 4) as *const i32); - let l13 = *((ptr10 + 8) as *const i32); - let base55 = l12; - let len55 = l13; - let mut result55 = Vec::with_capacity(len55 as usize); - for i in 0..len55 { - let base = base55 + i * 24; - let e55 = { - let l14 = i32::from(*((base + 0) as *const u8)); - let v54 = match l14 { - 0 => { - let e54 = { - let l15 = *((base + 8) as *const i32); - let l16 = *((base + 12) as *const i32); - let len17 = l16 as usize; - - Vec::from_raw_parts(l15 as *mut _, len17, len17) - }; - WitNode::RecordValue(e54) - } - 1 => { - let e54 = { - let l18 = *((base + 8) as *const i32); - let l19 = i32::from(*((base + 12) as *const u8)); - - (l18 as u32, match l19 { + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result9, + len9, + ptr10, + ); + let l11 = i32::from(*ptr10.add(0).cast::()); + if layout9.size() != 0 { + _rt::alloc::dealloc(result9.cast(), layout9); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l11 { + 0 => { + let e = { + let l12 = *ptr10.add(4).cast::<*mut u8>(); + let l13 = *ptr10.add(8).cast::(); + let base55 = l12; + let len55 = l13; + let mut result55 = _rt::Vec::with_capacity(len55); + for i in 0..len55 { + let base = base55.add(i * 24); + let e55 = { + let l14 = i32::from(*base.add(0).cast::()); + let v54 = match l14 { + 0 => { + let e54 = { + let l15 = *base.add(8).cast::<*mut u8>(); + let l16 = *base.add(12).cast::(); + let len17 = l16; + + _rt::Vec::from_raw_parts( + l15.cast(), + len17, + len17, + ) + }; + WitNode::RecordValue(e54) + } + 1 => { + let e54 = + { + let l18 = *base.add(8).cast::(); + let l19 = i32::from( + *base.add(12).cast::(), + ); + + (l18 as u32, match l19 { 0 => None, 1 => { let e = { - let l20 = *((base + 16) as *const i32); - + let l20 = *base.add(16).cast::(); + l20 }; Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }) - }; - WitNode::VariantValue(e54) - } - 2 => { - let e54 = { - let l21 = *((base + 8) as *const i32); - - l21 as u32 - }; - WitNode::EnumValue(e54) - } - 3 => { - let e54 = { - let l22 = *((base + 8) as *const i32); - let l23 = *((base + 12) as *const i32); - let base25 = l22; - let len25 = l23; - let mut result25 = Vec::with_capacity(len25 as usize); - for i in 0..len25 { - let base = base25 + i * 1; - let e25 = { - let l24 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l24 as u8) - }; - result25.push(e25); - } - wit_bindgen::rt::dealloc(base25, (len25 as usize) * 1, 1); - - result25 - }; - WitNode::FlagsValue(e54) - } - 4 => { - let e54 = { - let l26 = *((base + 8) as *const i32); - let l27 = *((base + 12) as *const i32); - let len28 = l27 as usize; - - Vec::from_raw_parts(l26 as *mut _, len28, len28) - }; - WitNode::TupleValue(e54) - } - 5 => { - let e54 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::ListValue(e54) - } - 6 => { - let e54 = { - let l32 = i32::from(*((base + 8) as *const u8)); - - match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *((base + 12) as *const i32); - - l33 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e54) - } - 7 => { - let e54 = { - let l34 = i32::from(*((base + 8) as *const u8)); - - match l34 { - 0 => { - let e = { - let l35 = i32::from(*((base + 12) as *const u8)); - - match l35 { + } + _ => _rt::invalid_enum_discriminant(), + }) + }; + WitNode::VariantValue(e54) + } + 2 => { + let e54 = { + let l21 = *base.add(8).cast::(); + + l21 as u32 + }; + WitNode::EnumValue(e54) + } + 3 => { + let e54 = { + let l22 = *base.add(8).cast::<*mut u8>(); + let l23 = *base.add(12).cast::(); + let base25 = l22; + let len25 = l23; + let mut result25 = + _rt::Vec::with_capacity(len25); + for i in 0..len25 { + let base = base25.add(i * 1); + let e25 = { + let l24 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l24 as u8) + }; + result25.push(e25); + } + _rt::cabi_dealloc(base25, len25 * 1, 1); + + result25 + }; + WitNode::FlagsValue(e54) + } + 4 => { + let e54 = { + let l26 = *base.add(8).cast::<*mut u8>(); + let l27 = *base.add(12).cast::(); + let len28 = l27; + + _rt::Vec::from_raw_parts( + l26.cast(), + len28, + len28, + ) + }; + WitNode::TupleValue(e54) + } + 5 => { + let e54 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::ListValue(e54) + } + 6 => { + let e54 = { + let l32 = + i32::from(*base.add(8).cast::()); + + match l32 { + 0 => None, + 1 => { + let e = { + let l33 = + *base.add(12).cast::(); + + l33 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e54) + } + 7 => { + let e54 = { + let l34 = + i32::from(*base.add(8).cast::()); + + match l34 { + 0 => { + let e = { + let l35 = i32::from( + *base.add(12).cast::(), + ); + + match l35 { 0 => None, 1 => { let e = { - let l36 = *((base + 16) as *const i32); - + let l36 = *base.add(16).cast::(); + l36 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l37 = i32::from(*((base + 12) as *const u8)); - - match l37 { + }; + Ok(e) + } + 1 => { + let e = { + let l37 = i32::from( + *base.add(12).cast::(), + ); + + match l37 { 0 => None, 1 => { let e = { - let l38 = *((base + 16) as *const i32); - + let l38 = *base.add(16).cast::(); + l38 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e54) + } + 8 => { + let e54 = { + let l39 = + i32::from(*base.add(8).cast::()); + + l39 as u8 + }; + WitNode::PrimU8(e54) + } + 9 => { + let e54 = { + let l40 = + i32::from(*base.add(8).cast::()); + + l40 as u16 + }; + WitNode::PrimU16(e54) + } + 10 => { + let e54 = { + let l41 = *base.add(8).cast::(); + + l41 as u32 + }; + WitNode::PrimU32(e54) + } + 11 => { + let e54 = { + let l42 = *base.add(8).cast::(); + + l42 as u64 + }; + WitNode::PrimU64(e54) + } + 12 => { + let e54 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as i8 + }; + WitNode::PrimS8(e54) + } + 13 => { + let e54 = { + let l44 = + i32::from(*base.add(8).cast::()); + + l44 as i16 + }; + WitNode::PrimS16(e54) + } + 14 => { + let e54 = { + let l45 = *base.add(8).cast::(); + + l45 + }; + WitNode::PrimS32(e54) + } + 15 => { + let e54 = { + let l46 = *base.add(8).cast::(); + + l46 + }; + WitNode::PrimS64(e54) + } + 16 => { + let e54 = { + let l47 = *base.add(8).cast::(); + + l47 + }; + WitNode::PrimFloat32(e54) + } + 17 => { + let e54 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimFloat64(e54) + } + 18 => { + let e54 = { + let l49 = *base.add(8).cast::(); + + _rt::char_lift(l49 as u32) + }; + WitNode::PrimChar(e54) + } + 19 => { + let e54 = { + let l50 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l50 as u8) + }; + WitNode::PrimBool(e54) + } + n => { + debug_assert_eq!( + n, 20, + "invalid enum discriminant" + ); + let e54 = { + let l51 = *base.add(8).cast::<*mut u8>(); + let l52 = *base.add(12).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts( + l51.cast(), + len53, + len53, + ); + + _rt::string_lift(bytes53) + }; + WitNode::PrimString(e54) + } + }; + + v54 + }; + result55.push(e55); + } + _rt::cabi_dealloc(base55, len55 * 24, 8); + + WitValue { nodes: result55 } + }; + Ok(e) + } + 1 => { + let e = { + let l56 = i32::from(*ptr10.add(4).cast::()); + let v69 = match l56 { + 0 => { + let e69 = { + let l57 = *ptr10.add(8).cast::<*mut u8>(); + let l58 = *ptr10.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + RpcError::ProtocolError(e69) + } + 1 => { + let e69 = { + let l60 = *ptr10.add(8).cast::<*mut u8>(); + let l61 = *ptr10.add(12).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts( + l60.cast(), + len62, + len62, + ); + + _rt::string_lift(bytes62) + }; + RpcError::Denied(e69) + } + 2 => { + let e69 = { + let l63 = *ptr10.add(8).cast::<*mut u8>(); + let l64 = *ptr10.add(12).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + RpcError::NotFound(e69) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e69 = { + let l66 = *ptr10.add(8).cast::<*mut u8>(); + let l67 = *ptr10.add(12).cast::(); + let len68 = l67; + let bytes68 = _rt::Vec::from_raw_parts( + l66.cast(), + len68, + len68, + ); + + _rt::string_lift(bytes68) + }; + RpcError::RemoteInternalError(e69) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e54) - } - 8 => { - let e54 = { - let l39 = i32::from(*((base + 8) as *const u8)); - - l39 as u8 - }; - WitNode::PrimU8(e54) - } - 9 => { - let e54 = { - let l40 = i32::from(*((base + 8) as *const u16)); - - l40 as u16 - }; - WitNode::PrimU16(e54) - } - 10 => { - let e54 = { - let l41 = *((base + 8) as *const i32); - - l41 as u32 - }; - WitNode::PrimU32(e54) - } - 11 => { - let e54 = { - let l42 = *((base + 8) as *const i64); - - l42 as u64 - }; - WitNode::PrimU64(e54) - } - 12 => { - let e54 = { - let l43 = i32::from(*((base + 8) as *const i8)); - - l43 as i8 - }; - WitNode::PrimS8(e54) - } - 13 => { - let e54 = { - let l44 = i32::from(*((base + 8) as *const i16)); - - l44 as i16 - }; - WitNode::PrimS16(e54) - } - 14 => { - let e54 = { - let l45 = *((base + 8) as *const i32); - - l45 - }; - WitNode::PrimS32(e54) - } - 15 => { - let e54 = { - let l46 = *((base + 8) as *const i64); - - l46 - }; - WitNode::PrimS64(e54) - } - 16 => { - let e54 = { - let l47 = *((base + 8) as *const f32); - - l47 - }; - WitNode::PrimFloat32(e54) - } - 17 => { - let e54 = { - let l48 = *((base + 8) as *const f64); - - l48 - }; - WitNode::PrimFloat64(e54) - } - 18 => { - let e54 = { - let l49 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l49 as u32) - }; - WitNode::PrimChar(e54) - } - 19 => { - let e54 = { - let l50 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l50 as u8) - }; - WitNode::PrimBool(e54) - } - n => { - debug_assert_eq!(n, 20, "invalid enum discriminant"); - let e54 = { - let l51 = *((base + 8) as *const i32); - let l52 = *((base + 12) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) }; - WitNode::PrimString(e54) - } + + v69 }; - - v54 - }; - result55.push(e55); - } - wit_bindgen::rt::dealloc(base55, (len55 as usize) * 24, 8); - - WitValue{ - nodes: result55, + Err(e) } - }; - Ok(e) - } - 1 => { - let e = { - let l56 = i32::from(*((ptr10 + 4) as *const u8)); - let v69 = match l56 { - 0 => { - let e69 = { - let l57 = *((ptr10 + 8) as *const i32); - let l58 = *((ptr10 + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - RpcError::ProtocolError(e69) - } - 1 => { - let e69 = { - let l60 = *((ptr10 + 8) as *const i32); - let l61 = *((ptr10 + 12) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) - }; - RpcError::Denied(e69) - } - 2 => { - let e69 = { - let l63 = *((ptr10 + 8) as *const i32); - let l64 = *((ptr10 + 12) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - RpcError::NotFound(e69) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e69 = { - let l66 = *((ptr10 + 8) as *const i32); - let l67 = *((ptr10 + 12) as *const i32); - let len68 = l67 as usize; - let bytes68 = Vec::from_raw_parts(l66 as *mut _, len68, len68); - - wit_bindgen::rt::string_lift(bytes68) - }; - RpcError::RemoteInternalError(e69) - } - }; - - v69 - }; - Err(e) + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - - } - } - } - pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + } +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; + #[link_name = "now"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; + #[link_name = "resolution"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the specified instant - /// occured. - pub fn subscribe_instant(when: Instant,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the specified instant + /// occured. + pub fn subscribe_instant(when: Instant) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-instant"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. - pub fn subscribe_duration(when: Duration,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + pub fn subscribe_duration(when: Duration) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-duration"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - - } - } - pub mod io { - - #[allow(clippy::all)] - pub mod poll { - #[used] + } + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } } + } + impl Pollable { #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(in_: &[&Pollable],) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let vec0 = in_; - let len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } } - let ptr1 = ret_area.as_mut_ptr() as i32; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/poll@0.2.0")] extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; if layout0.size() != 0 { - alloc::dealloc(result0, layout0); + _rt::alloc::dealloc(result0.cast(), layout0); } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), } - - } - } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_promise_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_promise_cabi!($ty with_types_in $($path_to_types_root)*); + ) } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:promise"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3190] = [3, 0, 7, 112, 114, 111, 109, 105, 115, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 248, 23, 1, 65, 2, 1, 65, 14, 1, 66, 25, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 3, 1, 112, 127, 1, 106, 1, 3, 1, 3, 1, 113, 21, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 2, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 5, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 2, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 2, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 3, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 7, 1, 112, 8, 1, 114, 1, 5, 110, 111, 100, 101, 115, 9, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 10, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 12, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 14, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 16, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 13, 0, 17, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 18, 1, 104, 16, 1, 112, 11, 1, 106, 1, 11, 1, 15, 1, 64, 3, 4, 115, 101, 108, 102, 19, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 20, 0, 21, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 22, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 1, 64, 0, 0, 3, 4, 0, 3, 110, 111, 119, 1, 6, 1, 64, 0, 0, 5, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 7, 1, 105, 1, 1, 64, 1, 4, 119, 104, 101, 110, 3, 0, 8, 4, 0, 17, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 105, 110, 115, 116, 97, 110, 116, 1, 9, 1, 64, 1, 4, 119, 104, 101, 110, 5, 0, 8, 4, 0, 18, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 100, 117, 114, 97, 116, 105, 111, 110, 1, 10, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 3, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 2, 8, 100, 117, 114, 97, 116, 105, 111, 110, 1, 66, 97, 2, 3, 2, 1, 4, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 2, 1, 119, 4, 0, 11, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 3, 0, 4, 1, 119, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 6, 1, 114, 2, 9, 104, 105, 103, 104, 45, 98, 105, 116, 115, 119, 8, 108, 111, 119, 45, 98, 105, 116, 115, 119, 4, 0, 4, 117, 117, 105, 100, 3, 0, 8, 1, 114, 1, 4, 117, 117, 105, 100, 9, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 10, 1, 114, 2, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 11, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 115, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 12, 1, 114, 2, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 4, 0, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 3, 0, 14, 1, 114, 4, 12, 109, 97, 120, 45, 97, 116, 116, 101, 109, 112, 116, 115, 121, 9, 109, 105, 110, 45, 100, 101, 108, 97, 121, 3, 9, 109, 97, 120, 45, 100, 101, 108, 97, 121, 3, 10, 109, 117, 108, 116, 105, 112, 108, 105, 101, 114, 121, 4, 0, 12, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 3, 0, 16, 1, 113, 3, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 0, 0, 27, 112, 101, 114, 115, 105, 115, 116, 45, 114, 101, 109, 111, 116, 101, 45, 115, 105, 100, 101, 45, 101, 102, 102, 101, 99, 116, 115, 0, 0, 5, 115, 109, 97, 114, 116, 0, 0, 4, 0, 17, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 3, 0, 18, 1, 109, 2, 9, 97, 117, 116, 111, 109, 97, 116, 105, 99, 14, 115, 110, 97, 112, 115, 104, 111, 116, 45, 98, 97, 115, 101, 100, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 20, 1, 109, 6, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 13, 103, 114, 101, 97, 116, 101, 114, 45, 101, 113, 117, 97, 108, 7, 103, 114, 101, 97, 116, 101, 114, 10, 108, 101, 115, 115, 45, 101, 113, 117, 97, 108, 4, 108, 101, 115, 115, 4, 0, 17, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 22, 1, 109, 4, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 4, 108, 105, 107, 101, 8, 110, 111, 116, 45, 108, 105, 107, 101, 4, 0, 24, 115, 116, 114, 105, 110, 103, 45, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 24, 1, 109, 7, 7, 114, 117, 110, 110, 105, 110, 103, 4, 105, 100, 108, 101, 9, 115, 117, 115, 112, 101, 110, 100, 101, 100, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 8, 114, 101, 116, 114, 121, 105, 110, 103, 6, 102, 97, 105, 108, 101, 100, 6, 101, 120, 105, 116, 101, 100, 4, 0, 13, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 3, 0, 26, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 18, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 45, 102, 105, 108, 116, 101, 114, 3, 0, 28, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 27, 4, 0, 20, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 45, 102, 105, 108, 116, 101, 114, 3, 0, 30, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 21, 119, 111, 114, 107, 101, 114, 45, 118, 101, 114, 115, 105, 111, 110, 45, 102, 105, 108, 116, 101, 114, 3, 0, 32, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 24, 119, 111, 114, 107, 101, 114, 45, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 45, 102, 105, 108, 116, 101, 114, 3, 0, 34, 1, 114, 3, 4, 110, 97, 109, 101, 115, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 101, 110, 118, 45, 102, 105, 108, 116, 101, 114, 3, 0, 36, 1, 113, 5, 4, 110, 97, 109, 101, 1, 29, 0, 6, 115, 116, 97, 116, 117, 115, 1, 31, 0, 7, 118, 101, 114, 115, 105, 111, 110, 1, 33, 0, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 1, 35, 0, 3, 101, 110, 118, 1, 37, 0, 4, 0, 22, 119, 111, 114, 107, 101, 114, 45, 112, 114, 111, 112, 101, 114, 116, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 38, 1, 112, 39, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 40, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 108, 108, 45, 102, 105, 108, 116, 101, 114, 3, 0, 41, 1, 112, 42, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 43, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 44, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 47, 1, 114, 6, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 4, 97, 114, 103, 115, 46, 3, 101, 110, 118, 48, 6, 115, 116, 97, 116, 117, 115, 27, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 119, 11, 114, 101, 116, 114, 121, 45, 99, 111, 117, 110, 116, 119, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 49, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 3, 1, 1, 107, 45, 1, 105, 51, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 6, 102, 105, 108, 116, 101, 114, 52, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 53, 4, 0, 24, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 54, 1, 104, 51, 1, 112, 50, 1, 107, 56, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 57, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 46, 103, 101, 116, 45, 110, 101, 120, 116, 1, 58, 1, 64, 0, 0, 15, 4, 0, 20, 103, 111, 108, 101, 109, 45, 99, 114, 101, 97, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 59, 1, 112, 125, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 0, 60, 4, 0, 19, 103, 111, 108, 101, 109, 45, 97, 119, 97, 105, 116, 45, 112, 114, 111, 109, 105, 115, 101, 1, 61, 1, 64, 2, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 4, 100, 97, 116, 97, 60, 0, 127, 4, 0, 22, 103, 111, 108, 101, 109, 45, 99, 111, 109, 112, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 62, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 1, 0, 4, 0, 20, 103, 111, 108, 101, 109, 45, 100, 101, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 63, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 1, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 64, 1, 64, 0, 0, 5, 4, 0, 15, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 65, 1, 64, 1, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 1, 0, 4, 0, 15, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 66, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 12, 111, 112, 108, 111, 103, 45, 99, 111, 109, 109, 105, 116, 1, 67, 4, 0, 20, 109, 97, 114, 107, 45, 98, 101, 103, 105, 110, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 65, 1, 64, 1, 5, 98, 101, 103, 105, 110, 5, 1, 0, 4, 0, 18, 109, 97, 114, 107, 45, 101, 110, 100, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 68, 1, 64, 0, 0, 17, 4, 0, 16, 103, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 69, 1, 64, 1, 16, 110, 101, 119, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 17, 1, 0, 4, 0, 16, 115, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 70, 1, 64, 0, 0, 19, 4, 0, 27, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 71, 1, 64, 1, 21, 110, 101, 119, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 19, 1, 0, 4, 0, 27, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 72, 1, 64, 0, 0, 127, 4, 0, 20, 103, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 73, 1, 64, 1, 10, 105, 100, 101, 109, 112, 111, 116, 101, 110, 116, 127, 1, 0, 4, 0, 20, 115, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 74, 1, 64, 0, 0, 9, 4, 0, 24, 103, 101, 110, 101, 114, 97, 116, 101, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 121, 45, 107, 101, 121, 1, 75, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 14, 116, 97, 114, 103, 101, 116, 45, 118, 101, 114, 115, 105, 111, 110, 7, 4, 109, 111, 100, 101, 21, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 76, 3, 1, 20, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 104, 111, 115, 116, 64, 48, 46, 50, 46, 48, 5, 6, 1, 112, 125, 1, 64, 0, 0, 7, 4, 0, 3, 114, 117, 110, 1, 8, 4, 1, 16, 103, 111, 108, 101, 109, 58, 105, 116, 47, 112, 114, 111, 109, 105, 115, 101, 4, 0, 11, 13, 1, 0, 7, 112, 114, 111, 109, 105, 115, 101, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file +#[doc(inline)] +pub(crate) use __export_promise_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:promise:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3190] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf8\x17\x01A\x02\x01\ +A\x0e\x01B\x19\x01z\x04\0\x0anode-index\x03\0\0\x01p\x01\x01k\x01\x01o\x02y\x03\x01\ +p\x7f\x01j\x01\x03\x01\x03\x01q\x15\x0crecord-value\x01\x02\0\x0dvariant-value\x01\ +\x04\0\x0aenum-value\x01y\0\x0bflags-value\x01\x05\0\x0btuple-value\x01\x02\0\x0a\ +list-value\x01\x02\0\x0coption-value\x01\x03\0\x0cresult-value\x01\x06\0\x07prim\ +-u8\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01\ +~\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01\ +v\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-st\ +ring\x01s\0\x04\0\x08wit-node\x03\0\x07\x01p\x08\x01r\x01\x05nodes\x09\x04\0\x09\ +wit-value\x03\0\x0a\x01r\x01\x05values\x04\0\x03uri\x03\0\x0c\x01q\x04\x0eprotoc\ +ol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\x15remote-internal-error\x01\ +s\0\x04\0\x09rpc-error\x03\0\x0e\x04\0\x08wasm-rpc\x03\x01\x01i\x10\x01@\x01\x08\ +location\x0d\0\x11\x04\0\x15[constructor]wasm-rpc\x01\x12\x01h\x10\x01p\x0b\x01j\ +\x01\x0b\x01\x0f\x01@\x03\x04self\x13\x0dfunction-names\x0ffunction-params\x14\0\ +\x15\x04\0![method]wasm-rpc.invoke-and-await\x01\x16\x03\x01\x15golem:rpc/types@\ +0.1.0\x05\0\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\ +\x04\0\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[me\ +thod]pollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04pol\ +l\x01\x06\x03\x01\x12wasi:io/poll@0.2.0\x05\x01\x02\x03\0\x01\x08pollable\x01B\x0f\ +\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01\ +w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\ +\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-\ +instant\x01\x09\x01@\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\ +\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x03\x02\x03\0\0\x03uri\x02\x03\0\x02\x08\ +duration\x01Ba\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\ +\x08duration\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11compone\ +nt-version\x03\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\ +\x01r\x01\x04uuid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\ +\x0bworker-names\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog\ +-idx\x05\x04\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\ +\x09max-delay\x03\x0amultipliery\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fper\ +sist-nothing\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persis\ +tence-level\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mo\ +de\x03\0\x14\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-\ +equal\x04less\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equa\ +l\x04like\x08not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07ru\ +nning\x04idle\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0d\ +worker-status\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-nam\ +e-filter\x03\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-statu\ +s-filter\x03\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-\ +filter\x03\0\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at\ +-filter\x03\0\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-en\ +v-filter\x03\0$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\ +\x0acreated-at\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\ +\x01r\x01\x07filters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filter\ +s+\x04\0\x11worker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-i\ +d\x0d\x04args.\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\ +\x0fworker-metadata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0c\ +component-id\x0b\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x01\ +6\x01h3\x01p2\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01\ +:\x01@\0\0\x0f\x04\0\x14golem-create-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\ +\0<\x04\0\x13golem-await-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\ +\0\x16golem-complete-promise\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x14gole\ +m-delete-promise\x01?\x01@\x01\x0dfunction-names\0\x01\x04\0\x0cget-self-uri\x01\ +@\x01@\0\0\x05\x04\0\x0fget-oplog-index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\ +\0\x0fset-oplog-index\x01B\x01@\x01\x08replicas}\x01\0\x04\0\x0coplog-commit\x01\ +C\x04\0\x14mark-begin-operation\x01A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-e\ +nd-operation\x01D\x01@\0\0\x11\x04\0\x10get-retry-policy\x01E\x01@\x01\x10new-re\ +try-policy\x11\x01\0\x04\0\x10set-retry-policy\x01F\x01@\0\0\x13\x04\0\x1bget-op\ +log-persistence-level\x01G\x01@\x01\x15new-persistence-level\x13\x01\0\x04\0\x1b\ +set-oplog-persistence-level\x01H\x01@\0\0\x7f\x04\0\x14get-idempotence-mode\x01I\ +\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\x14set-idempotence-mode\x01J\x01@\0\0\x09\ +\x04\0\x18generate-idempotency-key\x01K\x01@\x03\x09worker-id\x0d\x0etarget-vers\ +ion\x07\x04mode\x15\x01\0\x04\0\x0dupdate-worker\x01L\x03\x01\x14golem:api/host@\ +0.2.0\x05\x06\x01p}\x01@\0\0\x07\x04\0\x03run\x01\x08\x04\x01\x10golem:it/promis\ +e\x04\0\x0b\x0d\x01\0\x07promise\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/promise/src/lib.rs b/test-components/promise/src/lib.rs index 3ae4b56d4c..9d79439f60 100644 --- a/test-components/promise/src/lib.rs +++ b/test-components/promise/src/lib.rs @@ -11,3 +11,5 @@ impl Guest for Component { golem_await_promise(&promise_id) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/py-echo.wasm b/test-components/py-echo.wasm index 1fb8e3b126..09b9142c2f 100644 Binary files a/test-components/py-echo.wasm and b/test-components/py-echo.wasm differ diff --git a/test-components/python-1.wasm b/test-components/python-1.wasm index 64b2ac10bd..79328db1fb 100644 Binary files a/test-components/python-1.wasm and b/test-components/python-1.wasm differ diff --git a/test-components/read-stdin.wasm b/test-components/read-stdin.wasm index f73924c1a6..6eb3fef434 100755 Binary files a/test-components/read-stdin.wasm and b/test-components/read-stdin.wasm differ diff --git a/test-components/read-stdin/Cargo.lock b/test-components/read-stdin/Cargo.lock index 303a5e6724..5290890c59 100644 --- a/test-components/read-stdin/Cargo.lock +++ b/test-components/read-stdin/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-read-stdin" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/read-stdin/Cargo.toml b/test-components/read-stdin/Cargo.toml index 667bcdb0dd..e7c5bfb4c1 100644 --- a/test-components/read-stdin/Cargo.toml +++ b/test-components/read-stdin/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/read-stdin/src/bindings.rs b/test-components/read-stdin/src/bindings.rs index 6862363069..575e580605 100644 --- a/test-components/read-stdin/src/bindings.rs +++ b/test-components/read-stdin/src/bindings.rs @@ -1,90 +1,132 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::run(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::run(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { - Ok(e) => { { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 8) as *mut i32) = len2; - *((ptr1 + 4) as *mut i32) = ptr2; - } }, - Err(e) => { { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr1 + 8) as *mut i32) = len3; - *((ptr1 + 4) as *mut i32) = ptr3; - } }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_run(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { + Ok(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(8).cast::() = len2; + *ptr1.add(4).cast::<*mut u8>() = ptr2.cast_mut(); + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr1 +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_run(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { 0 => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } _ => { - let l3 = *((arg0 + 4) as *const i32); - let l4 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l3, (l4) as usize, 1); - }, - } + let l3 = *arg0.add(4).cast::<*mut u8>(); + let l4 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + } } - }; -}; -use super::Component as _GuestImpl; +} pub trait Guest { - fn run() -> Result; + fn run() -> Result<_rt::String, _rt::String>; } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_read_stdin_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "run"] + unsafe extern "C" fn export_run() -> *mut u8 { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + #[export_name = "cabi_post_run"] + unsafe extern "C" fn _post_return_run(arg0: *mut u8,) { + $($path_to_types)*::__post_return_run::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_read_stdin_cabi; #[repr(align(4))] -struct _RetArea([u8; 12]); -static mut _RET_AREA: _RetArea = _RetArea([0; 12]); +struct _RetArea([::core::mem::MaybeUninit; 12]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_read_stdin_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_read_stdin_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_read_stdin_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:read-stdin"] +#[link_section = "component-type:wit-bindgen:0.25.0:read-stdin:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 180] = [3, 0, 10, 114, 101, 97, 100, 45, 115, 116, 100, 105, 110, 0, 97, 115, 109, 13, 0, 1, 0, 7, 49, 1, 65, 2, 1, 65, 3, 1, 106, 1, 115, 1, 115, 1, 64, 0, 0, 0, 4, 0, 3, 114, 117, 110, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 105, 116, 47, 114, 101, 97, 100, 45, 115, 116, 100, 105, 110, 4, 0, 11, 16, 1, 0, 10, 114, 101, 97, 100, 45, 115, 116, 100, 105, 110, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 177] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x071\x01A\x02\x01A\x03\x01\ +j\x01s\x01s\x01@\0\0\0\x04\0\x03run\x01\x01\x04\x01\x13golem:it/read-stdin\x04\0\ +\x0b\x10\x01\0\x0aread-stdin\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/read-stdin/src/lib.rs b/test-components/read-stdin/src/lib.rs index 7cc64d64b0..f88e2e73b1 100644 --- a/test-components/read-stdin/src/lib.rs +++ b/test-components/read-stdin/src/lib.rs @@ -15,3 +15,5 @@ impl Guest for Component { .map(|_| line) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rpc/Cargo.lock b/test-components/rpc/Cargo.lock index 3c1d8e3a60..26d6ca5223 100644 --- a/test-components/rpc/Cargo.lock +++ b/test-components/rpc/Cargo.lock @@ -42,7 +42,7 @@ dependencies = [ "once_cell", "rand", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -58,7 +58,7 @@ dependencies = [ "once_cell", "rand", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -66,7 +66,7 @@ name = "counters-stub" version = "0.0.1" dependencies = [ "golem-wasm-rpc", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -116,12 +116,12 @@ dependencies = [ [[package]] name = "golem-wasm-rpc" -version = "0.0.25" +version = "0.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b188cc053d5bf31ea81ffa3f52d6a195d29ed839951e25fdbc12a4a43f6b03" +checksum = "5ae26028226e258a3cfa04cd35b6e1fdcde4d86037ee7df4f1ec9dfc537447b7" dependencies = [ "prost-build", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -136,15 +136,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys", -] - [[package]] name = "indexmap" version = "2.2.2" @@ -237,9 +228,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -247,9 +238,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck", @@ -264,14 +255,13 @@ dependencies = [ "regex", "syn", "tempfile", - "which", ] [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools", @@ -282,9 +272,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -445,18 +435,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -524,10 +502,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags 2.4.2", ] diff --git a/test-components/rpc/caller/Cargo.toml b/test-components/rpc/caller/Cargo.toml index f1dade9f4e..da007c5388 100644 --- a/test-components/rpc/caller/Cargo.toml +++ b/test-components/rpc/caller/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] once_cell = "1.19.0" rand = "0.8.5" uuid = { version = "1.7.0", features = ["v4", "serde"] } -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/rpc/caller/src/bindings.rs b/test-components/rpc/caller/src/bindings.rs index 7970ddb75d..727cb198cd 100644 --- a/test-components/rpc/caller/src/bindings.rs +++ b/test-components/rpc/caller/src/bindings.rs @@ -1,1891 +1,2308 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "test1"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_test1() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::test1(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_test1_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::test1(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec4 = result0; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len4 = vec4.len(); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); + let result4 = if layout4.size() != 0 { + let ptr = _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(t2_1); - } + let base = result4.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + *base.add(8).cast::() = _rt::as_i64(t2_1); + } } - *((ptr1 + 4) as *mut i32) = len4; - *((ptr1 + 0) as *mut i32) = result4 as i32; + *ptr1.add(4).cast::() = len4; + *ptr1.add(0).cast::<*mut u8>() = result4; ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_test1"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_test1(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *16; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_test1(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 16); { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 16, 8); } - }; -}; -const _: () = { - - #[doc(hidden)] - #[export_name = "test2"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_test2() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::test2(); - wit_bindgen::rt::as_i64(result0) - } -}; -const _: () = { - - #[doc(hidden)] - #[export_name = "test3"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_test3() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::test3(); - wit_bindgen::rt::as_i64(result0) - } -}; -const _: () = { - - #[doc(hidden)] - #[export_name = "test4"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_test4() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::test4(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let (t2_0, t2_1, ) = result0; + _rt::cabi_dealloc(base4, len4 * 16, 8); +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_test2_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::test2(); + _rt::as_i64(result0) +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_test3_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::test3(); + _rt::as_i64(result0) +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_test4_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::test4(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let (t2_0, t2_1) = result0; let vec4 = t2_0; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len4 = vec4.len(); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); + let result4 = if layout4.size() != 0 { + let ptr = _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 8; - { - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - } + let base = result4.add(i * 8); + { + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + } } - *((ptr1 + 4) as *mut i32) = len4; - *((ptr1 + 0) as *mut i32) = result4 as i32; + *ptr1.add(4).cast::() = len4; + *ptr1.add(0).cast::<*mut u8>() = result4; let vec8 = t2_1; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 16, 4); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked(vec8.len() * 16, 4); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 16; - { - let (t5_0, t5_1, ) = e; - let vec6 = (t5_0.into_bytes()).into_boxed_slice(); - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - ::core::mem::forget(vec6); - *((base + 4) as *mut i32) = len6; - *((base + 0) as *mut i32) = ptr6; - let vec7 = (t5_1.into_bytes()).into_boxed_slice(); - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - ::core::mem::forget(vec7); - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - } + let base = result8.add(i * 16); + { + let (t5_0, t5_1) = e; + let vec6 = (t5_0.into_bytes()).into_boxed_slice(); + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + ::core::mem::forget(vec6); + *base.add(4).cast::() = len6; + *base.add(0).cast::<*mut u8>() = ptr6.cast_mut(); + let vec7 = (t5_1.into_bytes()).into_boxed_slice(); + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + ::core::mem::forget(vec7); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } } - *((ptr1 + 12) as *mut i32) = len8; - *((ptr1 + 8) as *mut i32) = result8 as i32; + *ptr1.add(12).cast::() = len8; + *ptr1.add(8).cast::<*mut u8>() = result8; ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_test4"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_test4(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_test4(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - let l9 = *((arg0 + 8) as *const i32); - let l10 = *((arg0 + 12) as *const i32); - let base11 = l9; - let len11 = l10; - for i in 0..len11 { - let base = base11 + i *16; + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + let l9 = *arg0.add(8).cast::<*mut u8>(); + let l10 = *arg0.add(12).cast::(); + let base11 = l9; + let len11 = l10; + for i in 0..len11 { + let base = base11.add(i * 16); { - let l5 = *((base + 0) as *const i32); - let l6 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l5, (l6) as usize, 1); - let l7 = *((base + 8) as *const i32); - let l8 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l7, (l8) as usize, 1); + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base.add(4).cast::(); + _rt::cabi_dealloc(l5, l6, 1); + let l7 = *base.add(8).cast::<*mut u8>(); + let l8 = *base.add(12).cast::(); + _rt::cabi_dealloc(l7, l8, 1); } - } - wit_bindgen::rt::dealloc(base11, (len11 as usize) * 16, 4); } - }; -}; -use super::Component as _GuestImpl; + _rt::cabi_dealloc(base11, len11 * 16, 4); +} pub trait Guest { - fn test1() -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,u64,)>; - fn test2() -> u64; - fn test3() -> u64; - fn test4() -> (wit_bindgen::rt::vec::Vec::,wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>,); + fn test1() -> _rt::Vec<(_rt::String, u64)>; + fn test2() -> u64; + fn test3() -> u64; + fn test4() -> (_rt::Vec<_rt::String>, _rt::Vec<(_rt::String, _rt::String)>); } +#[doc(hidden)] -#[allow(unused_imports)] -use wit_bindgen::rt::{alloc, vec::Vec, string::String}; +macro_rules! __export_world_caller_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "test1"] + unsafe extern "C" fn export_test1() -> *mut u8 { + $($path_to_types)*::_export_test1_cabi::<$ty>() + } + #[export_name = "cabi_post_test1"] + unsafe extern "C" fn _post_return_test1(arg0: *mut u8,) { + $($path_to_types)*::__post_return_test1::<$ty>(arg0) + } + #[export_name = "test2"] + unsafe extern "C" fn export_test2() -> i64 { + $($path_to_types)*::_export_test2_cabi::<$ty>() + } + #[export_name = "test3"] + unsafe extern "C" fn export_test3() -> i64 { + $($path_to_types)*::_export_test3_cabi::<$ty>() + } + #[export_name = "test4"] + unsafe extern "C" fn export_test4() -> *mut u8 { + $($path_to_types)*::_export_test4_cabi::<$ty>() + } + #[export_name = "cabi_post_test4"] + unsafe extern "C" fn _post_return_test4(arg0: *mut u8,) { + $($path_to_types)*::__post_return_test4::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_caller_cabi; #[repr(align(4))] -struct _RetArea([u8; 16]); -static mut _RET_AREA: _RetArea = _RetArea([0; 16]); +struct _RetArea([::core::mem::MaybeUninit; 16]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); +#[allow(dead_code)] pub mod golem { - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - Handle((Uri,u64,)), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + Handle((Uri, u64)), } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + WitNode::Handle(e) => f.debug_tuple("WitNode::Handle").field(e).finish(), + } + } } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } } - WitNode::Handle(e) => { - f.debug_tuple("WitNode::Handle").field(e).finish() + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); { - *((base + 12) as *mut u8) = (0i32) as u8; + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, - } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); } - } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); } - - } - match l14 { - 0 => { - let e = { - let l15 = *((ptr13 + 4) as *const i32); - let l16 = *((ptr13 + 8) as *const i32); - let base62 = l15; - let len62 = l16; - let mut result62 = Vec::with_capacity(len62 as usize); - for i in 0..len62 { - let base = base62 + i * 24; - let e62 = { - let l17 = i32::from(*((base + 0) as *const u8)); - let v61 = match l17 { - 0 => { - let e61 = { - let l18 = *((base + 8) as *const i32); - let l19 = *((base + 12) as *const i32); - let len20 = l19 as usize; - - Vec::from_raw_parts(l18 as *mut _, len20, len20) - }; - WitNode::RecordValue(e61) - } - 1 => { - let e61 = { - let l21 = *((base + 8) as *const i32); - let l22 = i32::from(*((base + 12) as *const u8)); - - (l21 as u32, match l22 { + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = { + let l15 = *ptr13.add(4).cast::<*mut u8>(); + let l16 = *ptr13.add(8).cast::(); + let base62 = l15; + let len62 = l16; + let mut result62 = _rt::Vec::with_capacity(len62); + for i in 0..len62 { + let base = base62.add(i * 24); + let e62 = { + let l17 = i32::from(*base.add(0).cast::()); + let v61 = match l17 { + 0 => { + let e61 = { + let l18 = *base.add(8).cast::<*mut u8>(); + let l19 = *base.add(12).cast::(); + let len20 = l19; + + _rt::Vec::from_raw_parts( + l18.cast(), + len20, + len20, + ) + }; + WitNode::RecordValue(e61) + } + 1 => { + let e61 = + { + let l21 = *base.add(8).cast::(); + let l22 = i32::from( + *base.add(12).cast::(), + ); + + (l21 as u32, match l22 { 0 => None, 1 => { let e = { - let l23 = *((base + 16) as *const i32); - + let l23 = *base.add(16).cast::(); + l23 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }) - }; - WitNode::VariantValue(e61) - } - 2 => { - let e61 = { - let l24 = *((base + 8) as *const i32); - - l24 as u32 - }; - WitNode::EnumValue(e61) - } - 3 => { - let e61 = { - let l25 = *((base + 8) as *const i32); - let l26 = *((base + 12) as *const i32); - let base28 = l25; - let len28 = l26; - let mut result28 = Vec::with_capacity(len28 as usize); - for i in 0..len28 { - let base = base28 + i * 1; - let e28 = { - let l27 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l27 as u8) - }; - result28.push(e28); - } - wit_bindgen::rt::dealloc(base28, (len28 as usize) * 1, 1); - - result28 - }; - WitNode::FlagsValue(e61) - } - 4 => { - let e61 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::TupleValue(e61) - } - 5 => { - let e61 = { - let l32 = *((base + 8) as *const i32); - let l33 = *((base + 12) as *const i32); - let len34 = l33 as usize; - - Vec::from_raw_parts(l32 as *mut _, len34, len34) - }; - WitNode::ListValue(e61) - } - 6 => { - let e61 = { - let l35 = i32::from(*((base + 8) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((base + 12) as *const i32); - - l36 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e61) - } - 7 => { - let e61 = { - let l37 = i32::from(*((base + 8) as *const u8)); - - match l37 { - 0 => { - let e = { - let l38 = i32::from(*((base + 12) as *const u8)); - - match l38 { + }; + WitNode::VariantValue(e61) + } + 2 => { + let e61 = { + let l24 = *base.add(8).cast::(); + + l24 as u32 + }; + WitNode::EnumValue(e61) + } + 3 => { + let e61 = { + let l25 = *base.add(8).cast::<*mut u8>(); + let l26 = *base.add(12).cast::(); + let base28 = l25; + let len28 = l26; + let mut result28 = + _rt::Vec::with_capacity(len28); + for i in 0..len28 { + let base = base28.add(i * 1); + let e28 = { + let l27 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l27 as u8) + }; + result28.push(e28); + } + _rt::cabi_dealloc(base28, len28 * 1, 1); + + result28 + }; + WitNode::FlagsValue(e61) + } + 4 => { + let e61 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::TupleValue(e61) + } + 5 => { + let e61 = { + let l32 = *base.add(8).cast::<*mut u8>(); + let l33 = *base.add(12).cast::(); + let len34 = l33; + + _rt::Vec::from_raw_parts( + l32.cast(), + len34, + len34, + ) + }; + WitNode::ListValue(e61) + } + 6 => { + let e61 = { + let l35 = + i32::from(*base.add(8).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = + *base.add(12).cast::(); + + l36 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e61) + } + 7 => { + let e61 = { + let l37 = + i32::from(*base.add(8).cast::()); + + match l37 { + 0 => { + let e = { + let l38 = i32::from( + *base.add(12).cast::(), + ); + + match l38 { 0 => None, 1 => { let e = { - let l39 = *((base + 16) as *const i32); - + let l39 = *base.add(16).cast::(); + l39 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l40 = i32::from(*((base + 12) as *const u8)); - - match l40 { + }; + Ok(e) + } + 1 => { + let e = { + let l40 = i32::from( + *base.add(12).cast::(), + ); + + match l40 { 0 => None, 1 => { let e = { - let l41 = *((base + 16) as *const i32); - + let l41 = *base.add(16).cast::(); + l41 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e61) - } - 8 => { - let e61 = { - let l42 = i32::from(*((base + 8) as *const u8)); - - l42 as u8 - }; - WitNode::PrimU8(e61) - } - 9 => { - let e61 = { - let l43 = i32::from(*((base + 8) as *const u16)); - - l43 as u16 - }; - WitNode::PrimU16(e61) - } - 10 => { - let e61 = { - let l44 = *((base + 8) as *const i32); - - l44 as u32 - }; - WitNode::PrimU32(e61) - } - 11 => { - let e61 = { - let l45 = *((base + 8) as *const i64); - - l45 as u64 - }; - WitNode::PrimU64(e61) - } - 12 => { - let e61 = { - let l46 = i32::from(*((base + 8) as *const i8)); - - l46 as i8 - }; - WitNode::PrimS8(e61) - } - 13 => { - let e61 = { - let l47 = i32::from(*((base + 8) as *const i16)); - - l47 as i16 - }; - WitNode::PrimS16(e61) - } - 14 => { - let e61 = { - let l48 = *((base + 8) as *const i32); - - l48 - }; - WitNode::PrimS32(e61) - } - 15 => { - let e61 = { - let l49 = *((base + 8) as *const i64); - - l49 - }; - WitNode::PrimS64(e61) - } - 16 => { - let e61 = { - let l50 = *((base + 8) as *const f32); - - l50 - }; - WitNode::PrimFloat32(e61) - } - 17 => { - let e61 = { - let l51 = *((base + 8) as *const f64); - - l51 - }; - WitNode::PrimFloat64(e61) - } - 18 => { - let e61 = { - let l52 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l52 as u32) - }; - WitNode::PrimChar(e61) - } - 19 => { - let e61 = { - let l53 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l53 as u8) - }; - WitNode::PrimBool(e61) - } - 20 => { - let e61 = { - let l54 = *((base + 8) as *const i32); - let l55 = *((base + 12) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - WitNode::PrimString(e61) - } - n => { - debug_assert_eq!(n, 21, "invalid enum discriminant"); - let e61 = { - let l57 = *((base + 8) as *const i32); - let l58 = *((base + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - let l60 = *((base + 16) as *const i64); - - (Uri{ - value: wit_bindgen::rt::string_lift(bytes59), - }, l60 as u64) - }; - WitNode::Handle(e61) - } + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e61) + } + 8 => { + let e61 = { + let l42 = + i32::from(*base.add(8).cast::()); + + l42 as u8 + }; + WitNode::PrimU8(e61) + } + 9 => { + let e61 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as u16 + }; + WitNode::PrimU16(e61) + } + 10 => { + let e61 = { + let l44 = *base.add(8).cast::(); + + l44 as u32 + }; + WitNode::PrimU32(e61) + } + 11 => { + let e61 = { + let l45 = *base.add(8).cast::(); + + l45 as u64 + }; + WitNode::PrimU64(e61) + } + 12 => { + let e61 = { + let l46 = + i32::from(*base.add(8).cast::()); + + l46 as i8 + }; + WitNode::PrimS8(e61) + } + 13 => { + let e61 = { + let l47 = + i32::from(*base.add(8).cast::()); + + l47 as i16 + }; + WitNode::PrimS16(e61) + } + 14 => { + let e61 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimS32(e61) + } + 15 => { + let e61 = { + let l49 = *base.add(8).cast::(); + + l49 + }; + WitNode::PrimS64(e61) + } + 16 => { + let e61 = { + let l50 = *base.add(8).cast::(); + + l50 + }; + WitNode::PrimFloat32(e61) + } + 17 => { + let e61 = { + let l51 = *base.add(8).cast::(); + + l51 + }; + WitNode::PrimFloat64(e61) + } + 18 => { + let e61 = { + let l52 = *base.add(8).cast::(); + + _rt::char_lift(l52 as u32) + }; + WitNode::PrimChar(e61) + } + 19 => { + let e61 = { + let l53 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l53 as u8) + }; + WitNode::PrimBool(e61) + } + 20 => { + let e61 = { + let l54 = *base.add(8).cast::<*mut u8>(); + let l55 = *base.add(12).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + WitNode::PrimString(e61) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e61 = { + let l57 = *base.add(8).cast::<*mut u8>(); + let l58 = *base.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + let l60 = *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift(bytes59), + }, + l60 as u64, + ) + }; + WitNode::Handle(e61) + } + }; + + v61 + }; + result62.push(e62); + } + _rt::cabi_dealloc(base62, len62 * 24, 8); + + WitValue { nodes: result62 } }; - - v61 - }; - result62.push(e62); + Ok(e) } - wit_bindgen::rt::dealloc(base62, (len62 as usize) * 24, 8); - - WitValue{ - nodes: result62, - } - }; - Ok(e) - } - 1 => { - let e = { - let l63 = i32::from(*((ptr13 + 4) as *const u8)); - let v76 = match l63 { - 0 => { - let e76 = { - let l64 = *((ptr13 + 8) as *const i32); - let l65 = *((ptr13 + 12) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) - }; - RpcError::ProtocolError(e76) - } - 1 => { - let e76 = { - let l67 = *((ptr13 + 8) as *const i32); - let l68 = *((ptr13 + 12) as *const i32); - let len69 = l68 as usize; - let bytes69 = Vec::from_raw_parts(l67 as *mut _, len69, len69); - - wit_bindgen::rt::string_lift(bytes69) - }; - RpcError::Denied(e76) - } - 2 => { - let e76 = { - let l70 = *((ptr13 + 8) as *const i32); - let l71 = *((ptr13 + 12) as *const i32); - let len72 = l71 as usize; - let bytes72 = Vec::from_raw_parts(l70 as *mut _, len72, len72); - - wit_bindgen::rt::string_lift(bytes72) - }; - RpcError::NotFound(e76) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e76 = { - let l73 = *((ptr13 + 8) as *const i32); - let l74 = *((ptr13 + 12) as *const i32); - let len75 = l74 as usize; - let bytes75 = Vec::from_raw_parts(l73 as *mut _, len75, len75); - - wit_bindgen::rt::string_lift(bytes75) + 1 => { + let e = { + let l63 = i32::from(*ptr13.add(4).cast::()); + let v76 = match l63 { + 0 => { + let e76 = { + let l64 = *ptr13.add(8).cast::<*mut u8>(); + let l65 = *ptr13.add(12).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts( + l64.cast(), + len66, + len66, + ); + + _rt::string_lift(bytes66) + }; + RpcError::ProtocolError(e76) + } + 1 => { + let e76 = { + let l67 = *ptr13.add(8).cast::<*mut u8>(); + let l68 = *ptr13.add(12).cast::(); + let len69 = l68; + let bytes69 = _rt::Vec::from_raw_parts( + l67.cast(), + len69, + len69, + ); + + _rt::string_lift(bytes69) + }; + RpcError::Denied(e76) + } + 2 => { + let e76 = { + let l70 = *ptr13.add(8).cast::<*mut u8>(); + let l71 = *ptr13.add(12).cast::(); + let len72 = l71; + let bytes72 = _rt::Vec::from_raw_parts( + l70.cast(), + len72, + len72, + ); + + _rt::string_lift(bytes72) + }; + RpcError::NotFound(e76) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e76 = { + let l73 = *ptr13.add(8).cast::<*mut u8>(); + let l74 = *ptr13.add(12).cast::(); + let len75 = l74; + let bytes75 = _rt::Vec::from_raw_parts( + l73.cast(), + len75, + len75, + ); + + _rt::string_lift(bytes75) + }; + RpcError::RemoteInternalError(e76) + } + }; + + v76 }; - RpcError::RemoteInternalError(e76) - } - }; - - v76 - }; - Err(e) + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke(&self,function_name: &str,function_params: &[WitValue],) -> Result<(),RpcError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result<(), RpcError> { unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; + } else { { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; - { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - } + ::core::ptr::null_mut() } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } } - } } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); - } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l14 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l15 = i32::from(*((ptr13 + 4) as *const u8)); - let v28 = match l15 { + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(4).cast::()); + let v28 = match l15 { 0 => { - let e28 = { - let l16 = *((ptr13 + 8) as *const i32); - let l17 = *((ptr13 + 12) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) - }; - RpcError::ProtocolError(e28) + let e28 = { + let l16 = *ptr13.add(8).cast::<*mut u8>(); + let l17 = *ptr13.add(12).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, + ); + + _rt::string_lift(bytes18) + }; + RpcError::ProtocolError(e28) } 1 => { - let e28 = { - let l19 = *((ptr13 + 8) as *const i32); - let l20 = *((ptr13 + 12) as *const i32); - let len21 = l20 as usize; - let bytes21 = Vec::from_raw_parts(l19 as *mut _, len21, len21); - - wit_bindgen::rt::string_lift(bytes21) - }; - RpcError::Denied(e28) + let e28 = { + let l19 = *ptr13.add(8).cast::<*mut u8>(); + let l20 = *ptr13.add(12).cast::(); + let len21 = l20; + let bytes21 = _rt::Vec::from_raw_parts( + l19.cast(), + len21, + len21, + ); + + _rt::string_lift(bytes21) + }; + RpcError::Denied(e28) } 2 => { - let e28 = { - let l22 = *((ptr13 + 8) as *const i32); - let l23 = *((ptr13 + 12) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) - }; - RpcError::NotFound(e28) + let e28 = { + let l22 = *ptr13.add(8).cast::<*mut u8>(); + let l23 = *ptr13.add(12).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts( + l22.cast(), + len24, + len24, + ); + + _rt::string_lift(bytes24) + }; + RpcError::NotFound(e28) } n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e28 = { - let l25 = *((ptr13 + 8) as *const i32); - let l26 = *((ptr13 + 12) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) - }; - RpcError::RemoteInternalError(e28) + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e28 = { + let l25 = *ptr13.add(8).cast::<*mut u8>(); + let l26 = *ptr13.add(12).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts( + l25.cast(), + len27, + len27, + ); + + _rt::string_lift(bytes27) + }; + RpcError::RemoteInternalError(e28) } - }; - - v28 }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + + v28 + }; + Err(e) } - } - + _ => _rt::invalid_enum_discriminant(), } - - } } - pub mod rpc { - pub mod counters_stub { - - #[allow(clippy::all)] - pub mod stub_counters { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Api{ - handle: wit_bindgen::rt::Resource, - } - - impl Api{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Api{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-drop]api"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - - #[derive(Debug)] - #[repr(transparent)] - pub struct Counter{ - handle: wit_bindgen::rt::Resource, - } - - impl Counter{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Counter{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-drop]counter"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::golem::rpc::types::Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[constructor]api"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - Api::from_handle(ret as u32) - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn blocking_inc_global_by(&self,value: u64,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]api.blocking-inc-global-by"] - fn wit_import(_: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(value)); - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn inc_global_by(&self,value: u64,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]api.inc-global-by"] - fn wit_import(_: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(value)); - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn get_global_value(&self,) -> u64{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]api.get-global-value"] - fn wit_import(_: i32, ) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i64{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u64 - } - } - } - impl Api { - #[allow(unused_unsafe, clippy::all)] - pub fn get_all_dropped(&self,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,u64,)>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]api.get-all-dropped"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base7 = l1; - let len7 = l2; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 16; - let e7 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((base + 8) as *const i64); - - (wit_bindgen::rt::string_lift(bytes5), l6 as u64) - }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 16, 8); - result7 - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,name: &str,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let super::super::super::golem::rpc::types::Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let vec2 = name; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[constructor]counter"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1, ptr2, len2); - Counter::from_handle(ret as u32) - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn blocking_inc_by(&self,value: u64,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]counter.blocking-inc-by"] - fn wit_import(_: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(value)); - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn inc_by(&self,value: u64,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]counter.inc-by"] - fn wit_import(_: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(value)); - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn get_value(&self,) -> u64{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]counter.get-value"] - fn wit_import(_: i32, ) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i64{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u64 - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn get_args(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]counter.get-args"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base6 = l1; - let len6 = l2; - let mut result6 = Vec::with_capacity(len6 as usize); - for i in 0..len6 { - let base = base6 + i * 8; - let e6 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) - }; - result6.push(e6); - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 8, 4); - result6 - } - } - } - impl Counter { - #[allow(unused_unsafe, clippy::all)] - pub fn get_env(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[method]counter.get-env"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base9 = l1; - let len9 = l2; - let mut result9 = Vec::with_capacity(len9 as usize); - for i in 0..len9 { - let base = base9 + i * 16; - let e9 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((base + 8) as *const i32); - let l7 = *((base + 12) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - - (wit_bindgen::rt::string_lift(bytes5), wit_bindgen::rt::string_lift(bytes8)) - }; - result9.push(e9); - } - wit_bindgen::rt::dealloc(base9, (len9 as usize) * 16, 4); - result9 - } - } - } - - } - - } + } + } + } + } +} +#[allow(dead_code)] +pub mod rpc { + #[allow(dead_code)] + pub mod counters_stub { + #[allow(dead_code, clippy::all)] + pub mod stub_counters { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Api { + handle: _rt::Resource, + } + + impl Api { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), } - + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Api { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:caller"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1546] = [3, 0, 6, 99, 97, 108, 108, 101, 114, 0, 97, 115, 109, 13, 0, 1, 0, 7, 142, 11, 1, 65, 2, 1, 65, 18, 1, 66, 29, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 17, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 3, 0, 18, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 19, 1, 104, 17, 1, 112, 14, 1, 106, 1, 14, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 22, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 23, 1, 106, 0, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 24, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 1, 25, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 3, 117, 114, 105, 1, 66, 33, 2, 3, 2, 1, 1, 4, 0, 3, 117, 114, 105, 3, 0, 0, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 7, 99, 111, 117, 110, 116, 101, 114, 3, 1, 1, 105, 2, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 4, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 5, 1, 104, 2, 1, 64, 2, 4, 115, 101, 108, 102, 6, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 119, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 103, 108, 111, 98, 97, 108, 45, 118, 97, 108, 117, 101, 1, 8, 1, 111, 2, 115, 119, 1, 112, 9, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 10, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 97, 108, 108, 45, 100, 114, 111, 112, 112, 101, 100, 1, 11, 1, 105, 3, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 4, 110, 97, 109, 101, 115, 0, 12, 4, 0, 20, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 111, 117, 110, 116, 101, 114, 1, 13, 1, 104, 3, 1, 64, 2, 4, 115, 101, 108, 102, 14, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 98, 121, 1, 15, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 105, 110, 99, 45, 98, 121, 1, 15, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 119, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 118, 97, 108, 117, 101, 1, 16, 1, 112, 115, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 17, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 97, 114, 103, 115, 1, 18, 1, 111, 2, 115, 115, 1, 112, 19, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 20, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 101, 110, 118, 1, 21, 3, 1, 31, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 5, 2, 1, 111, 2, 115, 119, 1, 112, 3, 1, 64, 0, 0, 4, 4, 0, 5, 116, 101, 115, 116, 49, 1, 5, 1, 64, 0, 0, 119, 4, 0, 5, 116, 101, 115, 116, 50, 1, 6, 4, 0, 5, 116, 101, 115, 116, 51, 1, 6, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 8, 1, 111, 2, 7, 9, 1, 64, 0, 0, 10, 4, 0, 5, 116, 101, 115, 116, 52, 1, 11, 4, 1, 17, 114, 112, 99, 58, 99, 97, 108, 108, 101, 114, 47, 99, 97, 108, 108, 101, 114, 4, 0, 11, 12, 1, 0, 6, 99, 97, 108, 108, 101, 114, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] + { + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-drop]api"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Counter { + handle: _rt::Resource, + } + + impl Counter { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Counter { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + { + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-drop]counter"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let super::super::super::golem::rpc::types::Uri { value: value0 } = + location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[constructor]api"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + Api::from_handle(ret as u32) + } + } + } + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn blocking_inc_global_by(&self, value: u64) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]api.blocking-inc-global-by"] + fn wit_import(_: i32, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&value)); + } + } + } + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn inc_global_by(&self, value: u64) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]api.inc-global-by"] + fn wit_import(_: i32, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&value)); + } + } + } + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn get_global_value(&self) -> u64 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]api.get-global-value"] + fn wit_import(_: i32) -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i64 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u64 + } + } + } + impl Api { + #[allow(unused_unsafe, clippy::all)] + pub fn get_all_dropped(&self) -> _rt::Vec<(_rt::String, u64)> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]api.get-all-dropped"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base7 = l1; + let len7 = l2; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 16); + let e7 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::(); + + (_rt::string_lift(bytes5), l6 as u64) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 16, 8); + result7 + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri, name: &str) -> Self { + unsafe { + let super::super::super::golem::rpc::types::Uri { value: value0 } = + location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = name; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[constructor]counter"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1, ptr2.cast_mut(), len2); + Counter::from_handle(ret as u32) + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn blocking_inc_by(&self, value: u64) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]counter.blocking-inc-by"] + fn wit_import(_: i32, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&value)); + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn inc_by(&self, value: u64) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]counter.inc-by"] + fn wit_import(_: i32, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&value)); + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn get_value(&self) -> u64 { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]counter.get-value"] + fn wit_import(_: i32) -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i64 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u64 + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn get_args(&self) -> _rt::Vec<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]counter.get-args"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base6 = l1; + let len6 = l2; + let mut result6 = _rt::Vec::with_capacity(len6); + for i in 0..len6 { + let base = base6.add(i * 8); + let e6 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + result6.push(e6); + } + _rt::cabi_dealloc(base6, len6 * 8, 4); + result6 + } + } + } + impl Counter { + #[allow(unused_unsafe, clippy::all)] + pub fn get_env(&self) -> _rt::Vec<(_rt::String, _rt::String)> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[method]counter.get-env"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base9 = l1; + let len9 = l2; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 16); + let e9 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + (_rt::string_lift(bytes5), _rt::string_lift(bytes8)) + }; + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 16, 4); + result9 + } + } + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_caller_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_caller_cabi!($ty with_types_in $($path_to_types_root)*); + ) + } +#[doc(inline)] +pub(crate) use __export_caller_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:caller:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1547] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8e\x0b\x01A\x02\x01\ +A\x12\x01B\x1d\x01z\x04\0\x0anode-index\x03\0\0\x01r\x01\x05values\x04\0\x03uri\x03\ +\0\x02\x01p\x01\x01k\x01\x01o\x02y\x05\x01p\x7f\x01j\x01\x05\x01\x05\x01o\x02\x03\ +w\x01q\x16\x0crecord-value\x01\x04\0\x0dvariant-value\x01\x06\0\x0aenum-value\x01\ +y\0\x0bflags-value\x01\x07\0\x0btuple-value\x01\x04\0\x0alist-value\x01\x04\0\x0c\ +option-value\x01\x05\0\x0cresult-value\x01\x08\0\x07prim-u8\x01}\0\x08prim-u16\x01\ +{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\0\x08prim-s16\x01|\0\x08\ +prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\0\x0cprim-float64\x01u\0\ +\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-string\x01s\0\x06handle\x01\x09\ +\0\x04\0\x08wit-node\x03\0\x0a\x01p\x0b\x01r\x01\x05nodes\x0c\x04\0\x09wit-value\ +\x03\0\x0d\x01q\x04\x0eprotocol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\ +\x15remote-internal-error\x01s\0\x04\0\x09rpc-error\x03\0\x0f\x04\0\x08wasm-rpc\x03\ +\x01\x01i\x11\x01@\x01\x08location\x03\0\x12\x04\0\x15[constructor]wasm-rpc\x01\x13\ +\x01h\x11\x01p\x0e\x01j\x01\x0e\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0f\ +function-params\x15\0\x16\x04\0![method]wasm-rpc.invoke-and-await\x01\x17\x01j\0\ +\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0ffunction-params\x15\0\x18\x04\ +\0\x17[method]wasm-rpc.invoke\x01\x19\x03\x01\x15golem:rpc/types@0.1.0\x05\0\x02\ +\x03\0\0\x03uri\x01B!\x02\x03\x02\x01\x01\x04\0\x03uri\x03\0\0\x04\0\x03api\x03\x01\ +\x04\0\x07counter\x03\x01\x01i\x02\x01@\x01\x08location\x01\0\x04\x04\0\x10[cons\ +tructor]api\x01\x05\x01h\x02\x01@\x02\x04self\x06\x05valuew\x01\0\x04\0\"[method\ +]api.blocking-inc-global-by\x01\x07\x04\0\x19[method]api.inc-global-by\x01\x07\x01\ +@\x01\x04self\x06\0w\x04\0\x1c[method]api.get-global-value\x01\x08\x01o\x02sw\x01\ +p\x09\x01@\x01\x04self\x06\0\x0a\x04\0\x1b[method]api.get-all-dropped\x01\x0b\x01\ +i\x03\x01@\x02\x08location\x01\x04names\0\x0c\x04\0\x14[constructor]counter\x01\x0d\ +\x01h\x03\x01@\x02\x04self\x0e\x05valuew\x01\0\x04\0\x1f[method]counter.blocking\ +-inc-by\x01\x0f\x04\0\x16[method]counter.inc-by\x01\x0f\x01@\x01\x04self\x0e\0w\x04\ +\0\x19[method]counter.get-value\x01\x10\x01ps\x01@\x01\x04self\x0e\0\x11\x04\0\x18\ +[method]counter.get-args\x01\x12\x01o\x02ss\x01p\x13\x01@\x01\x04self\x0e\0\x14\x04\ +\0\x17[method]counter.get-env\x01\x15\x03\x01\x1frpc:counters-stub/stub-counters\ +\x05\x02\x01o\x02sw\x01p\x03\x01@\0\0\x04\x04\0\x05test1\x01\x05\x01@\0\0w\x04\0\ +\x05test2\x01\x06\x04\0\x05test3\x01\x06\x01ps\x01o\x02ss\x01p\x08\x01o\x02\x07\x09\ +\x01@\0\0\x0a\x04\0\x05test4\x01\x0b\x04\x01\x11rpc:caller/caller\x04\0\x0b\x0c\x01\ +\0\x06caller\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x07\ +0.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/rpc/caller/src/lib.rs b/test-components/rpc/caller/src/lib.rs index 2854f09254..f92647a7d9 100644 --- a/test-components/rpc/caller/src/lib.rs +++ b/test-components/rpc/caller/src/lib.rs @@ -99,3 +99,5 @@ fn create_use_and_drop_counters(counters_uri: &Uri) { println!("Counter2 value: {}", value2); println!("Counter3 value: {}", value3); } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rpc/counters-stub/Cargo.toml b/test-components/rpc/counters-stub/Cargo.toml index 8effe00246..4d50c99cfc 100644 --- a/test-components/rpc/counters-stub/Cargo.toml +++ b/test-components/rpc/counters-stub/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "counters-stub" -edition = "2021" version = "0.0.1" +edition = "2021" [package.metadata.component] package = "rpc:counters" @@ -17,14 +17,13 @@ path = "wit/deps/wasm-rpc" path = "wit/deps/rpc_counters" [dependencies.golem-wasm-rpc] -version = "0.0.25" +version = "0.0.29" features = ["stub"] default-features = false -[dependencies.wit-bindgen] -version = "0.17.0" -features = ["realloc"] -default-features = false +[dependencies.wit-bindgen-rt] +version = "0.26.0" +features = ["bitflags"] [lib] path = "src/lib.rs" diff --git a/test-components/rpc/counters-stub/src/bindings.rs b/test-components/rpc/counters-stub/src/bindings.rs index 95eb87e1bf..9cdce7799f 100644 --- a/test-components/rpc/counters-stub/src/bindings.rs +++ b/test-components/rpc/counters-stub/src/bindings.rs @@ -1,1820 +1,2465 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod golem { - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - Handle((Uri,u64,)), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + Handle((Uri, u64)), } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + WitNode::Handle(e) => f.debug_tuple("WitNode::Handle").field(e).finish(), + } + } } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } } - WitNode::Handle(e) => { - f.debug_tuple("WitNode::Handle").field(e).finish() + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, - } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } + } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); } - } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); } - - } - match l14 { - 0 => { - let e = { - let l15 = *((ptr13 + 4) as *const i32); - let l16 = *((ptr13 + 8) as *const i32); - let base62 = l15; - let len62 = l16; - let mut result62 = Vec::with_capacity(len62 as usize); - for i in 0..len62 { - let base = base62 + i * 24; - let e62 = { - let l17 = i32::from(*((base + 0) as *const u8)); - let v61 = match l17 { - 0 => { - let e61 = { - let l18 = *((base + 8) as *const i32); - let l19 = *((base + 12) as *const i32); - let len20 = l19 as usize; - - Vec::from_raw_parts(l18 as *mut _, len20, len20) - }; - WitNode::RecordValue(e61) - } - 1 => { - let e61 = { - let l21 = *((base + 8) as *const i32); - let l22 = i32::from(*((base + 12) as *const u8)); - - (l21 as u32, match l22 { + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = { + let l15 = *ptr13.add(4).cast::<*mut u8>(); + let l16 = *ptr13.add(8).cast::(); + let base62 = l15; + let len62 = l16; + let mut result62 = _rt::Vec::with_capacity(len62); + for i in 0..len62 { + let base = base62.add(i * 24); + let e62 = { + let l17 = i32::from(*base.add(0).cast::()); + let v61 = match l17 { + 0 => { + let e61 = { + let l18 = *base.add(8).cast::<*mut u8>(); + let l19 = *base.add(12).cast::(); + let len20 = l19; + + _rt::Vec::from_raw_parts( + l18.cast(), + len20, + len20, + ) + }; + WitNode::RecordValue(e61) + } + 1 => { + let e61 = + { + let l21 = *base.add(8).cast::(); + let l22 = i32::from( + *base.add(12).cast::(), + ); + + (l21 as u32, match l22 { 0 => None, 1 => { let e = { - let l23 = *((base + 16) as *const i32); - + let l23 = *base.add(16).cast::(); + l23 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }) - }; - WitNode::VariantValue(e61) - } - 2 => { - let e61 = { - let l24 = *((base + 8) as *const i32); - - l24 as u32 - }; - WitNode::EnumValue(e61) - } - 3 => { - let e61 = { - let l25 = *((base + 8) as *const i32); - let l26 = *((base + 12) as *const i32); - let base28 = l25; - let len28 = l26; - let mut result28 = Vec::with_capacity(len28 as usize); - for i in 0..len28 { - let base = base28 + i * 1; - let e28 = { - let l27 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l27 as u8) - }; - result28.push(e28); - } - wit_bindgen::rt::dealloc(base28, (len28 as usize) * 1, 1); - - result28 - }; - WitNode::FlagsValue(e61) - } - 4 => { - let e61 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::TupleValue(e61) - } - 5 => { - let e61 = { - let l32 = *((base + 8) as *const i32); - let l33 = *((base + 12) as *const i32); - let len34 = l33 as usize; - - Vec::from_raw_parts(l32 as *mut _, len34, len34) - }; - WitNode::ListValue(e61) - } - 6 => { - let e61 = { - let l35 = i32::from(*((base + 8) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((base + 12) as *const i32); - - l36 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e61) - } - 7 => { - let e61 = { - let l37 = i32::from(*((base + 8) as *const u8)); - - match l37 { - 0 => { - let e = { - let l38 = i32::from(*((base + 12) as *const u8)); - - match l38 { + }; + WitNode::VariantValue(e61) + } + 2 => { + let e61 = { + let l24 = *base.add(8).cast::(); + + l24 as u32 + }; + WitNode::EnumValue(e61) + } + 3 => { + let e61 = { + let l25 = *base.add(8).cast::<*mut u8>(); + let l26 = *base.add(12).cast::(); + let base28 = l25; + let len28 = l26; + let mut result28 = + _rt::Vec::with_capacity(len28); + for i in 0..len28 { + let base = base28.add(i * 1); + let e28 = { + let l27 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l27 as u8) + }; + result28.push(e28); + } + _rt::cabi_dealloc(base28, len28 * 1, 1); + + result28 + }; + WitNode::FlagsValue(e61) + } + 4 => { + let e61 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::TupleValue(e61) + } + 5 => { + let e61 = { + let l32 = *base.add(8).cast::<*mut u8>(); + let l33 = *base.add(12).cast::(); + let len34 = l33; + + _rt::Vec::from_raw_parts( + l32.cast(), + len34, + len34, + ) + }; + WitNode::ListValue(e61) + } + 6 => { + let e61 = { + let l35 = + i32::from(*base.add(8).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = + *base.add(12).cast::(); + + l36 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e61) + } + 7 => { + let e61 = { + let l37 = + i32::from(*base.add(8).cast::()); + + match l37 { + 0 => { + let e = { + let l38 = i32::from( + *base.add(12).cast::(), + ); + + match l38 { 0 => None, 1 => { let e = { - let l39 = *((base + 16) as *const i32); - + let l39 = *base.add(16).cast::(); + l39 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l40 = i32::from(*((base + 12) as *const u8)); - - match l40 { + }; + Ok(e) + } + 1 => { + let e = { + let l40 = i32::from( + *base.add(12).cast::(), + ); + + match l40 { 0 => None, 1 => { let e = { - let l41 = *((base + 16) as *const i32); - + let l41 = *base.add(16).cast::(); + l41 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e61) + } + 8 => { + let e61 = { + let l42 = + i32::from(*base.add(8).cast::()); + + l42 as u8 + }; + WitNode::PrimU8(e61) + } + 9 => { + let e61 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as u16 + }; + WitNode::PrimU16(e61) + } + 10 => { + let e61 = { + let l44 = *base.add(8).cast::(); + + l44 as u32 + }; + WitNode::PrimU32(e61) + } + 11 => { + let e61 = { + let l45 = *base.add(8).cast::(); + + l45 as u64 + }; + WitNode::PrimU64(e61) + } + 12 => { + let e61 = { + let l46 = + i32::from(*base.add(8).cast::()); + + l46 as i8 + }; + WitNode::PrimS8(e61) + } + 13 => { + let e61 = { + let l47 = + i32::from(*base.add(8).cast::()); + + l47 as i16 + }; + WitNode::PrimS16(e61) + } + 14 => { + let e61 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimS32(e61) + } + 15 => { + let e61 = { + let l49 = *base.add(8).cast::(); + + l49 + }; + WitNode::PrimS64(e61) + } + 16 => { + let e61 = { + let l50 = *base.add(8).cast::(); + + l50 + }; + WitNode::PrimFloat32(e61) + } + 17 => { + let e61 = { + let l51 = *base.add(8).cast::(); + + l51 + }; + WitNode::PrimFloat64(e61) + } + 18 => { + let e61 = { + let l52 = *base.add(8).cast::(); + + _rt::char_lift(l52 as u32) + }; + WitNode::PrimChar(e61) + } + 19 => { + let e61 = { + let l53 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l53 as u8) + }; + WitNode::PrimBool(e61) + } + 20 => { + let e61 = { + let l54 = *base.add(8).cast::<*mut u8>(); + let l55 = *base.add(12).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + WitNode::PrimString(e61) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e61 = { + let l57 = *base.add(8).cast::<*mut u8>(); + let l58 = *base.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + let l60 = *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift(bytes59), + }, + l60 as u64, + ) + }; + WitNode::Handle(e61) + } + }; + + v61 + }; + result62.push(e62); + } + _rt::cabi_dealloc(base62, len62 * 24, 8); + + WitValue { nodes: result62 } + }; + Ok(e) + } + 1 => { + let e = { + let l63 = i32::from(*ptr13.add(4).cast::()); + let v76 = match l63 { + 0 => { + let e76 = { + let l64 = *ptr13.add(8).cast::<*mut u8>(); + let l65 = *ptr13.add(12).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts( + l64.cast(), + len66, + len66, + ); + + _rt::string_lift(bytes66) + }; + RpcError::ProtocolError(e76) + } + 1 => { + let e76 = { + let l67 = *ptr13.add(8).cast::<*mut u8>(); + let l68 = *ptr13.add(12).cast::(); + let len69 = l68; + let bytes69 = _rt::Vec::from_raw_parts( + l67.cast(), + len69, + len69, + ); + + _rt::string_lift(bytes69) + }; + RpcError::Denied(e76) + } + 2 => { + let e76 = { + let l70 = *ptr13.add(8).cast::<*mut u8>(); + let l71 = *ptr13.add(12).cast::(); + let len72 = l71; + let bytes72 = _rt::Vec::from_raw_parts( + l70.cast(), + len72, + len72, + ); + + _rt::string_lift(bytes72) + }; + RpcError::NotFound(e76) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e76 = { + let l73 = *ptr13.add(8).cast::<*mut u8>(); + let l74 = *ptr13.add(12).cast::(); + let len75 = l74; + let bytes75 = _rt::Vec::from_raw_parts( + l73.cast(), + len75, + len75, + ); + + _rt::string_lift(bytes75) + }; + RpcError::RemoteInternalError(e76) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e61) - } - 8 => { - let e61 = { - let l42 = i32::from(*((base + 8) as *const u8)); - - l42 as u8 - }; - WitNode::PrimU8(e61) - } - 9 => { - let e61 = { - let l43 = i32::from(*((base + 8) as *const u16)); - - l43 as u16 - }; - WitNode::PrimU16(e61) - } - 10 => { - let e61 = { - let l44 = *((base + 8) as *const i32); - - l44 as u32 - }; - WitNode::PrimU32(e61) - } - 11 => { - let e61 = { - let l45 = *((base + 8) as *const i64); - - l45 as u64 - }; - WitNode::PrimU64(e61) - } - 12 => { - let e61 = { - let l46 = i32::from(*((base + 8) as *const i8)); - - l46 as i8 - }; - WitNode::PrimS8(e61) - } - 13 => { - let e61 = { - let l47 = i32::from(*((base + 8) as *const i16)); - - l47 as i16 - }; - WitNode::PrimS16(e61) - } - 14 => { - let e61 = { - let l48 = *((base + 8) as *const i32); - - l48 - }; - WitNode::PrimS32(e61) - } - 15 => { - let e61 = { - let l49 = *((base + 8) as *const i64); - - l49 - }; - WitNode::PrimS64(e61) - } - 16 => { - let e61 = { - let l50 = *((base + 8) as *const f32); - - l50 - }; - WitNode::PrimFloat32(e61) - } - 17 => { - let e61 = { - let l51 = *((base + 8) as *const f64); - - l51 - }; - WitNode::PrimFloat64(e61) - } - 18 => { - let e61 = { - let l52 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l52 as u32) - }; - WitNode::PrimChar(e61) - } - 19 => { - let e61 = { - let l53 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l53 as u8) - }; - WitNode::PrimBool(e61) - } - 20 => { - let e61 = { - let l54 = *((base + 8) as *const i32); - let l55 = *((base + 12) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - WitNode::PrimString(e61) - } - n => { - debug_assert_eq!(n, 21, "invalid enum discriminant"); - let e61 = { - let l57 = *((base + 8) as *const i32); - let l58 = *((base + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - let l60 = *((base + 16) as *const i64); - - (Uri{ - value: wit_bindgen::rt::string_lift(bytes59), - }, l60 as u64) }; - WitNode::Handle(e61) - } + + v76 }; - - v61 - }; - result62.push(e62); + Err(e) } - wit_bindgen::rt::dealloc(base62, (len62 as usize) * 24, 8); - - WitValue{ - nodes: result62, - } - }; - Ok(e) - } - 1 => { - let e = { - let l63 = i32::from(*((ptr13 + 4) as *const u8)); - let v76 = match l63 { - 0 => { - let e76 = { - let l64 = *((ptr13 + 8) as *const i32); - let l65 = *((ptr13 + 12) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) - }; - RpcError::ProtocolError(e76) - } - 1 => { - let e76 = { - let l67 = *((ptr13 + 8) as *const i32); - let l68 = *((ptr13 + 12) as *const i32); - let len69 = l68 as usize; - let bytes69 = Vec::from_raw_parts(l67 as *mut _, len69, len69); - - wit_bindgen::rt::string_lift(bytes69) - }; - RpcError::Denied(e76) - } - 2 => { - let e76 = { - let l70 = *((ptr13 + 8) as *const i32); - let l71 = *((ptr13 + 12) as *const i32); - let len72 = l71 as usize; - let bytes72 = Vec::from_raw_parts(l70 as *mut _, len72, len72); - - wit_bindgen::rt::string_lift(bytes72) - }; - RpcError::NotFound(e76) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e76 = { - let l73 = *((ptr13 + 8) as *const i32); - let l74 = *((ptr13 + 12) as *const i32); - let len75 = l74 as usize; - let bytes75 = Vec::from_raw_parts(l73 as *mut _, len75, len75); - - wit_bindgen::rt::string_lift(bytes75) - }; - RpcError::RemoteInternalError(e76) - } - }; - - v76 - }; - Err(e) + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke(&self,function_name: &str,function_params: &[WitValue],) -> Result<(),RpcError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result<(), RpcError> { unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec12 = function_params; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec11 = nodes1; - let len11 = vec11.len() as i32; - let layout11 = alloc::Layout::from_size_align_unchecked(vec11.len() * 24, 8); - let result11 = if layout11.size() != 0 - { - let ptr = alloc::alloc(layout11); - if ptr.is_null() - { - alloc::handle_alloc_error(layout11); + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec11.into_iter().enumerate() { - let base = result11 as i32 + (i as i32) * 24; + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; - { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - } + ::core::ptr::null_mut() } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - WitNode::Handle(e) => { - *((base + 0) as *mut u8) = (21i32) as u8; - let (t8_0, t8_1, ) = e; - let Uri{ value:value9, } = t8_0; - let vec10 = value9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(t8_1); - }, + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } } - } } - *((base + 4) as *mut i32) = len11; - *((base + 0) as *mut i32) = result11 as i32; - cleanup_list.extend_from_slice(&[(result11, layout11),]); - } - } - let ptr13 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result12 as i32, len12, ptr13); - let l14 = i32::from(*((ptr13 + 0) as *const u8)); - if layout12.size() != 0 { - alloc::dealloc(result12, layout12); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l14 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l15 = i32::from(*((ptr13 + 4) as *const u8)); - let v28 = match l15 { + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(4).cast::()); + let v28 = match l15 { 0 => { - let e28 = { - let l16 = *((ptr13 + 8) as *const i32); - let l17 = *((ptr13 + 12) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) - }; - RpcError::ProtocolError(e28) + let e28 = { + let l16 = *ptr13.add(8).cast::<*mut u8>(); + let l17 = *ptr13.add(12).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, + ); + + _rt::string_lift(bytes18) + }; + RpcError::ProtocolError(e28) } 1 => { - let e28 = { - let l19 = *((ptr13 + 8) as *const i32); - let l20 = *((ptr13 + 12) as *const i32); - let len21 = l20 as usize; - let bytes21 = Vec::from_raw_parts(l19 as *mut _, len21, len21); - - wit_bindgen::rt::string_lift(bytes21) - }; - RpcError::Denied(e28) + let e28 = { + let l19 = *ptr13.add(8).cast::<*mut u8>(); + let l20 = *ptr13.add(12).cast::(); + let len21 = l20; + let bytes21 = _rt::Vec::from_raw_parts( + l19.cast(), + len21, + len21, + ); + + _rt::string_lift(bytes21) + }; + RpcError::Denied(e28) } 2 => { - let e28 = { - let l22 = *((ptr13 + 8) as *const i32); - let l23 = *((ptr13 + 12) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) - }; - RpcError::NotFound(e28) + let e28 = { + let l22 = *ptr13.add(8).cast::<*mut u8>(); + let l23 = *ptr13.add(12).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts( + l22.cast(), + len24, + len24, + ); + + _rt::string_lift(bytes24) + }; + RpcError::NotFound(e28) } n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e28 = { - let l25 = *((ptr13 + 8) as *const i32); - let l26 = *((ptr13 + 12) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) - }; - RpcError::RemoteInternalError(e28) + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e28 = { + let l25 = *ptr13.add(8).cast::<*mut u8>(); + let l26 = *ptr13.add(12).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts( + l25.cast(), + len27, + len27, + ); + + _rt::string_lift(bytes27) + }; + RpcError::RemoteInternalError(e28) } - }; - - v28 }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } + + v28 + }; + Err(e) } - } - + _ => _rt::invalid_enum_discriminant(), } - - } } - pub mod exports { - pub mod rpc { - pub mod counters_stub { - - #[allow(clippy::all)] - pub mod stub_counters { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type Uri = super::super::super::super::golem::rpc::types::Uri; - - pub use super::super::super::super::super::Api as Api; - const _: () = { - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[dtor]api"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Api{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-new]api"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-rep]api"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } + } + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code)] + pub mod counters_stub { + #[allow(dead_code, clippy::all)] + pub mod stub_counters { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type Uri = super::super::super::super::golem::rpc::types::Uri; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Api { + handle: _rt::Resource, + } + + type _ApiRep = Option; + + impl Api { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Api`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ApiRep = Some(val); + let ptr: *mut _ApiRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestApi` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), } - pub type OwnApi = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Api{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-drop]api"] - fn drop(_: u32); - } - - drop(_handle); - } - } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ApiRep); + } + + fn as_ptr(&self) -> *mut _ApiRep { + Api::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Api`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ApiBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Api>, + } + + impl<'a> ApiBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ApiRep { + Api::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Api { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-drop]api"] + fn drop(_: u32); } - - - pub use super::super::super::super::super::Counter as Counter; - const _: () = { - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[dtor]counter"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Counter{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-new]counter"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-rep]counter"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Counter { + handle: _rt::Resource, + } + + type _CounterRep = Option; + + impl Counter { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Counter`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CounterRep = Some(val); + let ptr: *mut _CounterRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCounter` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), } - pub type OwnCounter = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Counter{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] - extern "C" { - #[link_name = "[resource-drop]counter"] - fn drop(_: u32); - } - - drop(_handle); - } - } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CounterRep); + } + + fn as_ptr(&self) -> *mut _CounterRep { + Counter::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Counter`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CounterBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Counter>, + } + + impl<'a> CounterBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CounterRep { + Counter::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Counter { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-drop]counter"] + fn drop(_: u32); } - - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[constructor]api"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_api(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = OwnApi::new(<_ApiImpl as GuestApi>::new(super::super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes0), - })); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]api.blocking-inc-global-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_blocking_inc_global_by(arg0: i32,arg1: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_ApiImpl as GuestApi>::blocking_inc_global_by(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), arg1 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]api.inc-global-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_inc_global_by(arg0: i32,arg1: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_ApiImpl as GuestApi>::inc_global_by(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), arg1 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]api.get-global-value"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_get_global_value(arg0: i32,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_ApiImpl as GuestApi>::get_global_value(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]api.get-all-dropped"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_api_get_all_dropped(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_ApiImpl as GuestApi>::get_all_dropped(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec4 = result0; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(t2_1); - } - } - *((ptr1 + 4) as *mut i32) = len4; - *((ptr1 + 0) as *mut i32) = result4 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]api.get-all-dropped"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_api_get_all_dropped(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *16; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 16, 8); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[constructor]counter"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_counter(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - let result2 = OwnCounter::new(<_CounterImpl as GuestCounter>::new(super::super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes0), - }, wit_bindgen::rt::string_lift(bytes1))); - wit_bindgen::rt::Resource::into_handle(result2) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]counter.blocking-inc-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_blocking_inc_by(arg0: i32,arg1: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_CounterImpl as GuestCounter>::blocking_inc_by(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), arg1 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]counter.inc-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_inc_by(arg0: i32,arg1: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_CounterImpl as GuestCounter>::inc_by(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), arg1 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-value"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_value(arg0: i32,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_value(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-args"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_args(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_args(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = result0; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 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) * 8; - { - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((base + 4) as *mut i32) = len2; - *((base + 0) as *mut i32) = ptr2; - } - } - *((ptr1 + 4) as *mut i32) = len3; - *((ptr1 + 0) as *mut i32) = result3 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]counter.get-args"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_counter_get_args(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-env"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_env(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_env(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec5 = result0; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let vec4 = (t2_1.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = ptr4; - } - } - *((ptr1 + 4) as *mut i32) = len5; - *((ptr1 + 0) as *mut i32) = result5 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]counter.get-env"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_counter_get_env(arg0: i32,) { - let l4 = *((arg0 + 0) as *const i32); - let l5 = *((arg0 + 4) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *16; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 8) as *const i32); - let l3 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 16, 4); - } - }; - }; - use super::super::super::super::super::Api as _ApiImpl; - pub trait GuestApi { - fn new(location: Uri,) -> Self; - fn blocking_inc_global_by(&self,value: u64,); - fn inc_global_by(&self,value: u64,); - fn get_global_value(&self,) -> u64; - fn get_all_dropped(&self,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,u64,)>; + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_api_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = + Api::new(T::new(super::super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes0), + })); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_blocking_inc_global_by_cabi( + arg0: *mut u8, + arg1: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::blocking_inc_global_by( + ApiBorrow::lift(arg0 as u32 as usize).get(), + arg1 as u64, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_inc_global_by_cabi( + arg0: *mut u8, + arg1: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::inc_global_by(ApiBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_get_global_value_cabi( + arg0: *mut u8, + ) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_global_value(ApiBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_api_get_all_dropped_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_all_dropped(ApiBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec4 = result0; + let len4 = vec4.len(); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); + let result4 = if layout4.size() != 0 { + let ptr = _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + *base.add(8).cast::() = _rt::as_i64(t2_1); + } + } + *ptr1.add(4).cast::() = len4; + *ptr1.add(0).cast::<*mut u8>() = result4; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_api_get_all_dropped(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 16); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 16, 8); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_counter_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = Counter::new(T::new( + super::super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes0), + }, + _rt::string_lift(bytes1), + )); + (result2).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_blocking_inc_by_cabi( + arg0: *mut u8, + arg1: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::blocking_inc_by( + CounterBorrow::lift(arg0 as u32 as usize).get(), + arg1 as u64, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_inc_by_cabi( + arg0: *mut u8, + arg1: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::inc_by(CounterBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_value_cabi( + arg0: *mut u8, + ) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_value(CounterBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_args_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_args(CounterBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_counter_get_args( + arg0: *mut u8, + ) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_env_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_env(CounterBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec5 = result0; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec4 = (t2_1.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + } + } + *ptr1.add(4).cast::() = len5; + *ptr1.add(0).cast::<*mut u8>() = result5; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_counter_get_env(arg0: *mut u8) { + let l4 = *arg0.add(0).cast::<*mut u8>(); + let l5 = *arg0.add(4).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 16); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(8).cast::<*mut u8>(); + let l3 = *base.add(12).cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + _rt::cabi_dealloc(base6, len6 * 16, 4); + } + pub trait Guest { + type Api: GuestApi; + type Counter: GuestCounter; + } + pub trait GuestApi: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-new]api"] + fn new(_: *mut u8) -> u32; } - use super::super::super::super::super::Counter as _CounterImpl; - pub trait GuestCounter { - fn new(location: Uri,name: wit_bindgen::rt::string::String,) -> Self; - fn blocking_inc_by(&self,value: u64,); - fn inc_by(&self,value: u64,); - fn get_value(&self,) -> u64; - fn get_args(&self,) -> wit_bindgen::rt::vec::Vec::; - fn get_env(&self,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>; + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-rep]api"] + fn rep(_: u32) -> *mut u8; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - + unsafe { rep(handle) } } - } } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:wasm-rpc-stub-counters"] + + fn new(location: Uri) -> Self; + fn blocking_inc_global_by(&self, value: u64); + fn inc_global_by(&self, value: u64); + fn get_global_value(&self) -> u64; + fn get_all_dropped(&self) -> _rt::Vec<(_rt::String, u64)>; + } + pub trait GuestCounter: 'static { #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2651] = [3, 0, 22, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 209, 8, 1, 65, 5, 1, 66, 18, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 3, 117, 114, 105, 1, 66, 33, 2, 3, 2, 1, 1, 4, 0, 3, 117, 114, 105, 3, 0, 0, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 7, 99, 111, 117, 110, 116, 101, 114, 3, 1, 1, 105, 2, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 4, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 5, 1, 104, 2, 1, 64, 2, 4, 115, 101, 108, 102, 6, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 119, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 103, 108, 111, 98, 97, 108, 45, 118, 97, 108, 117, 101, 1, 8, 1, 111, 2, 115, 119, 1, 112, 9, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 10, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 97, 108, 108, 45, 100, 114, 111, 112, 112, 101, 100, 1, 11, 1, 105, 3, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 4, 110, 97, 109, 101, 115, 0, 12, 4, 0, 20, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 111, 117, 110, 116, 101, 114, 1, 13, 1, 104, 3, 1, 64, 2, 4, 115, 101, 108, 102, 14, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 98, 121, 1, 15, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 105, 110, 99, 45, 98, 121, 1, 15, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 119, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 118, 97, 108, 117, 101, 1, 16, 1, 112, 115, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 17, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 97, 114, 103, 115, 1, 18, 1, 111, 2, 115, 115, 1, 112, 19, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 20, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 101, 110, 118, 1, 21, 4, 1, 31, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 5, 2, 11, 19, 1, 0, 13, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 3, 0, 0, 7, 214, 10, 1, 65, 2, 1, 65, 5, 1, 66, 29, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 2, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 5, 1, 112, 127, 1, 106, 1, 5, 1, 5, 1, 111, 2, 3, 119, 1, 113, 22, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 4, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 7, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 5, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 8, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 6, 104, 97, 110, 100, 108, 101, 1, 9, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 10, 1, 112, 11, 1, 114, 1, 5, 110, 111, 100, 101, 115, 12, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 13, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 15, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 17, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 3, 0, 18, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 19, 1, 104, 17, 1, 112, 14, 1, 106, 1, 14, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 22, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 23, 1, 106, 0, 1, 16, 1, 64, 3, 4, 115, 101, 108, 102, 20, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 21, 0, 24, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 1, 25, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 3, 117, 114, 105, 1, 66, 33, 2, 3, 2, 1, 1, 4, 0, 3, 117, 114, 105, 3, 0, 0, 4, 0, 3, 97, 112, 105, 3, 1, 4, 0, 7, 99, 111, 117, 110, 116, 101, 114, 3, 1, 1, 105, 2, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 0, 4, 4, 0, 16, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 97, 112, 105, 1, 5, 1, 104, 2, 1, 64, 2, 4, 115, 101, 108, 102, 6, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 119, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 103, 108, 111, 98, 97, 108, 45, 118, 97, 108, 117, 101, 1, 8, 1, 111, 2, 115, 119, 1, 112, 9, 1, 64, 1, 4, 115, 101, 108, 102, 6, 0, 10, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 97, 112, 105, 46, 103, 101, 116, 45, 97, 108, 108, 45, 100, 114, 111, 112, 112, 101, 100, 1, 11, 1, 105, 3, 1, 64, 2, 8, 108, 111, 99, 97, 116, 105, 111, 110, 1, 4, 110, 97, 109, 101, 115, 0, 12, 4, 0, 20, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 111, 117, 110, 116, 101, 114, 1, 13, 1, 104, 3, 1, 64, 2, 4, 115, 101, 108, 102, 14, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 105, 110, 99, 45, 98, 121, 1, 15, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 105, 110, 99, 45, 98, 121, 1, 15, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 119, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 118, 97, 108, 117, 101, 1, 16, 1, 112, 115, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 17, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 97, 114, 103, 115, 1, 18, 1, 111, 2, 115, 115, 1, 112, 19, 1, 64, 1, 4, 115, 101, 108, 102, 14, 0, 20, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 101, 110, 118, 1, 21, 4, 1, 31, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 45, 115, 116, 117, 98, 47, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 5, 2, 4, 1, 40, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 45, 115, 116, 117, 98, 47, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 4, 0, 11, 28, 1, 0, 22, 119, 97, 115, 109, 45, 114, 112, 99, 45, 115, 116, 117, 98, 45, 99, 111, 117, 110, 116, 101, 114, 115, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-new]counter"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters-stub/stub-counters")] + extern "C" { + #[link_name = "[resource-rep]counter"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(location: Uri, name: _rt::String) -> Self; + fn blocking_inc_by(&self, value: u64); + fn inc_by(&self, value: u64); + fn get_value(&self) -> u64; + fn get_args(&self) -> _rt::Vec<_rt::String>; + fn get_env(&self) -> _rt::Vec<(_rt::String, _rt::String)>; + } + #[doc(hidden)] + + macro_rules! __export_rpc_counters_stub_stub_counters_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "rpc:counters-stub/stub-counters#[constructor]api"] + unsafe extern "C" fn export_constructor_api(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_constructor_api_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]api.blocking-inc-global-by"] + unsafe extern "C" fn export_method_api_blocking_inc_global_by(arg0: *mut u8,arg1: i64,) { + $($path_to_types)*::_export_method_api_blocking_inc_global_by_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]api.inc-global-by"] + unsafe extern "C" fn export_method_api_inc_global_by(arg0: *mut u8,arg1: i64,) { + $($path_to_types)*::_export_method_api_inc_global_by_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0, arg1) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]api.get-global-value"] + unsafe extern "C" fn export_method_api_get_global_value(arg0: *mut u8,) -> i64 { + $($path_to_types)*::_export_method_api_get_global_value_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]api.get-all-dropped"] + unsafe extern "C" fn export_method_api_get_all_dropped(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_api_get_all_dropped_cabi::<<$ty as $($path_to_types)*::Guest>::Api>(arg0) + } + #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]api.get-all-dropped"] + unsafe extern "C" fn _post_return_method_api_get_all_dropped(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_api_get_all_dropped::<<$ty as $($path_to_types)*::Guest>::Api>(arg0) + } + #[export_name = "rpc:counters-stub/stub-counters#[constructor]counter"] + unsafe extern "C" fn export_constructor_counter(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> i32 { + $($path_to_types)*::_export_constructor_counter_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0, arg1, arg2, arg3) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]counter.blocking-inc-by"] + unsafe extern "C" fn export_method_counter_blocking_inc_by(arg0: *mut u8,arg1: i64,) { + $($path_to_types)*::_export_method_counter_blocking_inc_by_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0, arg1) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]counter.inc-by"] + unsafe extern "C" fn export_method_counter_inc_by(arg0: *mut u8,arg1: i64,) { + $($path_to_types)*::_export_method_counter_inc_by_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0, arg1) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-value"] + unsafe extern "C" fn export_method_counter_get_value(arg0: *mut u8,) -> i64 { + $($path_to_types)*::_export_method_counter_get_value_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-args"] + unsafe extern "C" fn export_method_counter_get_args(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_counter_get_args_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]counter.get-args"] + unsafe extern "C" fn _post_return_method_counter_get_args(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_counter_get_args::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "rpc:counters-stub/stub-counters#[method]counter.get-env"] + unsafe extern "C" fn export_method_counter_get_env(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_counter_get_env_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "cabi_post_rpc:counters-stub/stub-counters#[method]counter.get-env"] + unsafe extern "C" fn _post_return_method_counter_get_env(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_counter_get_env::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "rpc:counters-stub/stub-counters#[dtor]api"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Api::dtor::< + <$ty as $($path_to_types)*::Guest>::Api + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "rpc:counters-stub/stub-counters#[dtor]counter"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Counter::dtor::< + <$ty as $($path_to_types)*::Guest>::Counter + >(rep) + } + }; + + };); + } + #[doc(hidden)] + pub(crate) use __export_rpc_counters_stub_stub_counters_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_wasm_rpc_stub_counters_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::rpc::counters_stub::stub_counters::__export_rpc_counters_stub_stub_counters_cabi!($ty with_types_in $($path_to_types_root)*::exports::rpc::counters_stub::stub_counters); + ) +} +#[doc(inline)] +pub(crate) use __export_wasm_rpc_stub_counters_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:wasm-rpc-stub-counters:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1507] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xd6\x0a\x01A\x02\x01\ +A\x05\x01B\x1d\x01z\x04\0\x0anode-index\x03\0\0\x01r\x01\x05values\x04\0\x03uri\x03\ +\0\x02\x01p\x01\x01k\x01\x01o\x02y\x05\x01p\x7f\x01j\x01\x05\x01\x05\x01o\x02\x03\ +w\x01q\x16\x0crecord-value\x01\x04\0\x0dvariant-value\x01\x06\0\x0aenum-value\x01\ +y\0\x0bflags-value\x01\x07\0\x0btuple-value\x01\x04\0\x0alist-value\x01\x04\0\x0c\ +option-value\x01\x05\0\x0cresult-value\x01\x08\0\x07prim-u8\x01}\0\x08prim-u16\x01\ +{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\0\x08prim-s16\x01|\0\x08\ +prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\0\x0cprim-float64\x01u\0\ +\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-string\x01s\0\x06handle\x01\x09\ +\0\x04\0\x08wit-node\x03\0\x0a\x01p\x0b\x01r\x01\x05nodes\x0c\x04\0\x09wit-value\ +\x03\0\x0d\x01q\x04\x0eprotocol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\ +\x15remote-internal-error\x01s\0\x04\0\x09rpc-error\x03\0\x0f\x04\0\x08wasm-rpc\x03\ +\x01\x01i\x11\x01@\x01\x08location\x03\0\x12\x04\0\x15[constructor]wasm-rpc\x01\x13\ +\x01h\x11\x01p\x0e\x01j\x01\x0e\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0f\ +function-params\x15\0\x16\x04\0![method]wasm-rpc.invoke-and-await\x01\x17\x01j\0\ +\x01\x10\x01@\x03\x04self\x14\x0dfunction-names\x0ffunction-params\x15\0\x18\x04\ +\0\x17[method]wasm-rpc.invoke\x01\x19\x03\x01\x15golem:rpc/types@0.1.0\x05\0\x02\ +\x03\0\0\x03uri\x01B!\x02\x03\x02\x01\x01\x04\0\x03uri\x03\0\0\x04\0\x03api\x03\x01\ +\x04\0\x07counter\x03\x01\x01i\x02\x01@\x01\x08location\x01\0\x04\x04\0\x10[cons\ +tructor]api\x01\x05\x01h\x02\x01@\x02\x04self\x06\x05valuew\x01\0\x04\0\"[method\ +]api.blocking-inc-global-by\x01\x07\x04\0\x19[method]api.inc-global-by\x01\x07\x01\ +@\x01\x04self\x06\0w\x04\0\x1c[method]api.get-global-value\x01\x08\x01o\x02sw\x01\ +p\x09\x01@\x01\x04self\x06\0\x0a\x04\0\x1b[method]api.get-all-dropped\x01\x0b\x01\ +i\x03\x01@\x02\x08location\x01\x04names\0\x0c\x04\0\x14[constructor]counter\x01\x0d\ +\x01h\x03\x01@\x02\x04self\x0e\x05valuew\x01\0\x04\0\x1f[method]counter.blocking\ +-inc-by\x01\x0f\x04\0\x16[method]counter.inc-by\x01\x0f\x01@\x01\x04self\x0e\0w\x04\ +\0\x19[method]counter.get-value\x01\x10\x01ps\x01@\x01\x04self\x0e\0\x11\x04\0\x18\ +[method]counter.get-args\x01\x12\x01o\x02ss\x01p\x13\x01@\x01\x04self\x0e\0\x14\x04\ +\0\x17[method]counter.get-env\x01\x15\x04\x01\x1frpc:counters-stub/stub-counters\ +\x05\x02\x04\x01(rpc:counters-stub/wasm-rpc-stub-counters\x04\0\x0b\x1c\x01\0\x16\ +wasm-rpc-stub-counters\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-co\ +mponent\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/rpc/counters-stub/src/lib.rs b/test-components/rpc/counters-stub/src/lib.rs index 774cf0f34c..4cebd0e559 100644 --- a/test-components/rpc/counters-stub/src/lib.rs +++ b/test-components/rpc/counters-stub/src/lib.rs @@ -20,6 +20,11 @@ impl Counter { } } } +struct Component; +impl crate::bindings::exports::rpc::counters_stub::stub_counters::Guest for Component { + type Api = crate::Api; + type Counter = crate::Counter; +} impl crate::bindings::exports::rpc::counters_stub::stub_counters::GuestApi for Api { fn new(location: crate::bindings::golem::rpc::types::Uri) -> Self { let location = golem_wasm_rpc::Uri { @@ -244,3 +249,4 @@ impl Drop for Counter { .expect("Failed to invoke remote drop"); } } +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rpc/counters/Cargo.toml b/test-components/rpc/counters/Cargo.toml index eab54488db..1ed90523ca 100644 --- a/test-components/rpc/counters/Cargo.toml +++ b/test-components/rpc/counters/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] once_cell = "1.17.1" rand = "0.8.5" uuid = { version = "1.4.1", features = ["v4"] } -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/rpc/counters/src/bindings.rs b/test-components/rpc/counters/src/bindings.rs index 4d3189feab..406576a9a0 100644 --- a/test-components/rpc/counters/src/bindings.rs +++ b/test-components/rpc/counters/src/bindings.rs @@ -1,486 +1,711 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod rpc { - pub mod counters { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - - pub use super::super::super::super::super::Counter as Counter; - const _: () = { - #[doc(hidden)] - #[export_name = "rpc:counters/api#[dtor]counter"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Counter{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters/api")] - extern "C" { - #[link_name = "[resource-new]counter"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters/api")] - extern "C" { - #[link_name = "[resource-rep]counter"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } - } - pub type OwnCounter = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Counter{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]rpc:counters/api")] - extern "C" { - #[link_name = "[resource-drop]counter"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#[constructor]counter"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_counter(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = OwnCounter::new(<_CounterImpl as GuestCounter>::new(wit_bindgen::rt::string_lift(bytes0))); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#[method]counter.inc-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_inc_by(arg0: i32,arg1: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_CounterImpl as GuestCounter>::inc_by(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), arg1 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#[method]counter.get-value"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_value(arg0: i32,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_value(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#[method]counter.get-args"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_args(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_args(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = result0; - let len3 = vec3.len() as i32; - let layout3 = alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 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) * 8; - { - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((base + 4) as *mut i32) = len2; - *((base + 0) as *mut i32) = ptr2; - } - } - *((ptr1 + 4) as *mut i32) = len3; - *((ptr1 + 0) as *mut i32) = result3 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters/api#[method]counter.get-args"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_counter_get_args(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *8; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code)] + pub mod counters { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Counter { + handle: _rt::Resource, } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 8, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#[method]counter.get-env"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_counter_get_env(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CounterImpl as GuestCounter>::get_env(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec5 = result0; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let vec4 = (t2_1.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = ptr4; - } - } - *((ptr1 + 4) as *mut i32) = len5; - *((ptr1 + 0) as *mut i32) = result5 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters/api#[method]counter.get-env"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_counter_get_env(arg0: i32,) { - let l4 = *((arg0 + 0) as *const i32); - let l5 = *((arg0 + 4) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *16; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 8) as *const i32); - let l3 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); + + type _CounterRep = Option; + + impl Counter { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Counter`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CounterRep = Some(val); + let ptr: *mut _CounterRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCounter` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CounterRep); + } + + fn as_ptr(&self) -> *mut _CounterRep { + Counter::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Counter`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CounterBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Counter>, } - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 16, 4); + + impl<'a> CounterBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CounterRep { + Counter::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Counter { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters/api")] + extern "C" { + #[link_name = "[resource-drop]counter"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_counter_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = Counter::new(T::new(_rt::string_lift(bytes0))); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_inc_by_cabi( + arg0: *mut u8, + arg1: i64, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::inc_by(CounterBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_value_cabi( + arg0: *mut u8, + ) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_value(CounterBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_args_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_args(CounterBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_counter_get_args( + arg0: *mut u8, + ) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_counter_get_env_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_env(CounterBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec5 = result0; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec4 = (t2_1.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + } + } + *ptr1.add(4).cast::() = len5; + *ptr1.add(0).cast::<*mut u8>() = result5; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_counter_get_env(arg0: *mut u8) { + let l4 = *arg0.add(0).cast::<*mut u8>(); + let l5 = *arg0.add(4).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 16); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(8).cast::<*mut u8>(); + let l3 = *base.add(12).cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + _rt::cabi_dealloc(base6, len6 * 16, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_inc_global_by_cabi(arg0: i64) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::inc_global_by(arg0 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_global_value_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_global_value(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_all_dropped_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_all_dropped(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec4 = result0; + let len4 = vec4.len(); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); + let result4 = if layout4.size() != 0 { + let ptr = _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 16); + { + let (t2_0, t2_1) = e; + let vec3 = (t2_0.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + *base.add(8).cast::() = _rt::as_i64(t2_1); + } + } + *ptr1.add(4).cast::() = len4; + *ptr1.add(0).cast::<*mut u8>() = result4; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_all_dropped(arg0: *mut u8) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 16); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 16, 8); + } + pub trait Guest { + type Counter: GuestCounter; + fn inc_global_by(value: u64); + fn get_global_value() -> u64; + fn get_all_dropped() -> _rt::Vec<(_rt::String, u64)>; + } + pub trait GuestCounter: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters/api")] + extern "C" { + #[link_name = "[resource-new]counter"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]rpc:counters/api")] + extern "C" { + #[link_name = "[resource-rep]counter"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(name: _rt::String) -> Self; + fn inc_by(&self, value: u64); + fn get_value(&self) -> u64; + fn get_args(&self) -> _rt::Vec<_rt::String>; + fn get_env(&self) -> _rt::Vec<(_rt::String, _rt::String)>; + } + #[doc(hidden)] + + macro_rules! __export_rpc_counters_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "rpc:counters/api#[constructor]counter"] + unsafe extern "C" fn export_constructor_counter(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_constructor_counter_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0, arg1) + } + #[export_name = "rpc:counters/api#[method]counter.inc-by"] + unsafe extern "C" fn export_method_counter_inc_by(arg0: *mut u8,arg1: i64,) { + $($path_to_types)*::_export_method_counter_inc_by_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0, arg1) + } + #[export_name = "rpc:counters/api#[method]counter.get-value"] + unsafe extern "C" fn export_method_counter_get_value(arg0: *mut u8,) -> i64 { + $($path_to_types)*::_export_method_counter_get_value_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "rpc:counters/api#[method]counter.get-args"] + unsafe extern "C" fn export_method_counter_get_args(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_counter_get_args_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "cabi_post_rpc:counters/api#[method]counter.get-args"] + unsafe extern "C" fn _post_return_method_counter_get_args(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_counter_get_args::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "rpc:counters/api#[method]counter.get-env"] + unsafe extern "C" fn export_method_counter_get_env(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_counter_get_env_cabi::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "cabi_post_rpc:counters/api#[method]counter.get-env"] + unsafe extern "C" fn _post_return_method_counter_get_env(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_counter_get_env::<<$ty as $($path_to_types)*::Guest>::Counter>(arg0) + } + #[export_name = "rpc:counters/api#inc-global-by"] + unsafe extern "C" fn export_inc_global_by(arg0: i64,) { + $($path_to_types)*::_export_inc_global_by_cabi::<$ty>(arg0) + } + #[export_name = "rpc:counters/api#get-global-value"] + unsafe extern "C" fn export_get_global_value() -> i64 { + $($path_to_types)*::_export_get_global_value_cabi::<$ty>() + } + #[export_name = "rpc:counters/api#get-all-dropped"] + unsafe extern "C" fn export_get_all_dropped() -> *mut u8 { + $($path_to_types)*::_export_get_all_dropped_cabi::<$ty>() + } + #[export_name = "cabi_post_rpc:counters/api#get-all-dropped"] + unsafe extern "C" fn _post_return_get_all_dropped(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_all_dropped::<$ty>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "rpc:counters/api#[dtor]counter"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Counter::dtor::< + <$ty as $($path_to_types)*::Guest>::Counter + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub(crate) use __export_rpc_counters_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#inc-global-by"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_inc_global_by(arg0: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::inc_global_by(arg0 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#get-global-value"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_global_value() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_global_value(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "rpc:counters/api#get-all-dropped"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_all_dropped() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_all_dropped(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec4 = result0; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 16, 8); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 16; - { - let (t2_0, t2_1, ) = e; - let vec3 = (t2_0.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(t2_1); - } + } + } +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, } - *((ptr1 + 4) as *mut i32) = len4; - *((ptr1 + 0) as *mut i32) = result4 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_rpc:counters/api#get-all-dropped"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_all_dropped(arg0: i32,) { - let l2 = *((arg0 + 0) as *const i32); - let l3 = *((arg0 + 4) as *const i32); - let base4 = l2; - let len4 = l3; - for i in 0..len4 { - let base = base4 + i *16; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), } - } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 16, 8); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn inc_global_by(value: u64,); - fn get_global_value() -> u64; - fn get_all_dropped() -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,u64,)>; } - use super::super::super::super::super::Counter as _CounterImpl; - pub trait GuestCounter { - fn new(name: wit_bindgen::rt::string::String,) -> Self; - fn inc_by(&self,value: u64,); - fn get_value(&self,) -> u64; - fn get_args(&self,) -> wit_bindgen::rt::vec::Vec::; - fn get_env(&self,) -> wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>; + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub use alloc_crate::string::String; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - } - } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + extern crate alloc as alloc_crate; } +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_counters_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::rpc::counters::api::__export_rpc_counters_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::rpc::counters::api); + ) +} +#[doc(inline)] +pub(crate) use __export_counters_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:counters"] +#[link_section = "component-type:wit-bindgen:0.25.0:counters:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 863] = [3, 0, 8, 99, 111, 117, 110, 116, 101, 114, 115, 0, 97, 115, 109, 13, 0, 1, 0, 7, 218, 2, 1, 65, 2, 1, 66, 24, 4, 0, 7, 99, 111, 117, 110, 116, 101, 114, 3, 1, 1, 105, 0, 1, 64, 1, 4, 110, 97, 109, 101, 115, 0, 1, 4, 0, 20, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 111, 117, 110, 116, 101, 114, 1, 2, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 3, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 105, 110, 99, 45, 98, 121, 1, 4, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 119, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 118, 97, 108, 117, 101, 1, 5, 1, 112, 115, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 6, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 97, 114, 103, 115, 1, 7, 1, 111, 2, 115, 115, 1, 112, 8, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 9, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 101, 110, 118, 1, 10, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 13, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 11, 1, 64, 0, 0, 119, 4, 0, 16, 103, 101, 116, 45, 103, 108, 111, 98, 97, 108, 45, 118, 97, 108, 117, 101, 1, 12, 1, 111, 2, 115, 119, 1, 112, 13, 1, 64, 0, 0, 14, 4, 0, 15, 103, 101, 116, 45, 97, 108, 108, 45, 100, 114, 111, 112, 112, 101, 100, 1, 15, 4, 1, 16, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 247, 2, 1, 65, 2, 1, 65, 2, 1, 66, 24, 4, 0, 7, 99, 111, 117, 110, 116, 101, 114, 3, 1, 1, 105, 0, 1, 64, 1, 4, 110, 97, 109, 101, 115, 0, 1, 4, 0, 20, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 111, 117, 110, 116, 101, 114, 1, 2, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 3, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 105, 110, 99, 45, 98, 121, 1, 4, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 119, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 118, 97, 108, 117, 101, 1, 5, 1, 112, 115, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 6, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 97, 114, 103, 115, 1, 7, 1, 111, 2, 115, 115, 1, 112, 8, 1, 64, 1, 4, 115, 101, 108, 102, 3, 0, 9, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 111, 117, 110, 116, 101, 114, 46, 103, 101, 116, 45, 101, 110, 118, 1, 10, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 1, 0, 4, 0, 13, 105, 110, 99, 45, 103, 108, 111, 98, 97, 108, 45, 98, 121, 1, 11, 1, 64, 0, 0, 119, 4, 0, 16, 103, 101, 116, 45, 103, 108, 111, 98, 97, 108, 45, 118, 97, 108, 117, 101, 1, 12, 1, 111, 2, 115, 119, 1, 112, 13, 1, 64, 0, 0, 14, 4, 0, 15, 103, 101, 116, 45, 97, 108, 108, 45, 100, 114, 111, 112, 112, 101, 100, 1, 15, 4, 1, 16, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 47, 97, 112, 105, 5, 0, 4, 1, 21, 114, 112, 99, 58, 99, 111, 117, 110, 116, 101, 114, 115, 47, 99, 111, 117, 110, 116, 101, 114, 115, 4, 0, 11, 14, 1, 0, 8, 99, 111, 117, 110, 116, 101, 114, 115, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 502] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf7\x02\x01A\x02\x01\ +A\x02\x01B\x18\x04\0\x07counter\x03\x01\x01i\0\x01@\x01\x04names\0\x01\x04\0\x14\ +[constructor]counter\x01\x02\x01h\0\x01@\x02\x04self\x03\x05valuew\x01\0\x04\0\x16\ +[method]counter.inc-by\x01\x04\x01@\x01\x04self\x03\0w\x04\0\x19[method]counter.\ +get-value\x01\x05\x01ps\x01@\x01\x04self\x03\0\x06\x04\0\x18[method]counter.get-\ +args\x01\x07\x01o\x02ss\x01p\x08\x01@\x01\x04self\x03\0\x09\x04\0\x17[method]cou\ +nter.get-env\x01\x0a\x01@\x01\x05valuew\x01\0\x04\0\x0dinc-global-by\x01\x0b\x01\ +@\0\0w\x04\0\x10get-global-value\x01\x0c\x01o\x02sw\x01p\x0d\x01@\0\0\x0e\x04\0\x0f\ +get-all-dropped\x01\x0f\x04\x01\x10rpc:counters/api\x05\0\x04\x01\x15rpc:counter\ +s/counters\x04\0\x0b\x0e\x01\0\x08counters\x03\0\0\0G\x09producers\x01\x0cproces\ +sed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/rpc/counters/src/lib.rs b/test-components/rpc/counters/src/lib.rs index fb48a8b13f..2647d6d0e6 100644 --- a/test-components/rpc/counters/src/lib.rs +++ b/test-components/rpc/counters/src/lib.rs @@ -24,6 +24,8 @@ fn with_state(f: impl FnOnce(&mut State) -> T) -> T { } impl Guest for Component { + type Counter = crate::Counter; + fn get_all_dropped() -> Vec<(String, u64)> { with_state(|state| state.dropped_counters.clone()) } @@ -82,3 +84,5 @@ impl Drop for Counter { }); } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rpc/stubgen.sh b/test-components/rpc/stubgen.sh index ae81f54797..79ab8e7384 100755 --- a/test-components/rpc/stubgen.sh +++ b/test-components/rpc/stubgen.sh @@ -2,7 +2,7 @@ set -uox pipefail rm -rf counters-stub -wasm-rpc-stubgen generate --source-wit-root counters/wit --dest-crate-root counters-stub --wasm-rpc-path-override ../../../wasm-rpc/wasm-rpc +wasm-rpc-stubgen generate --source-wit-root counters/wit --dest-crate-root counters-stub rm -rf caller/wit/deps mkdir -pv caller/wit/deps cp -rv counters-stub/wit/deps/* caller/wit/deps diff --git a/test-components/runtime-service.wasm b/test-components/runtime-service.wasm index 9f092f20fa..8ec229e686 100755 Binary files a/test-components/runtime-service.wasm and b/test-components/runtime-service.wasm differ diff --git a/test-components/runtime-service/Cargo.lock b/test-components/runtime-service/Cargo.lock index 605e1109d8..6e2dbdb39b 100644 --- a/test-components/runtime-service/Cargo.lock +++ b/test-components/runtime-service/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -19,15 +19,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -46,33 +46,27 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -98,9 +92,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -113,9 +107,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -123,9 +117,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fnv" @@ -198,9 +192,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -209,15 +203,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -234,9 +228,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57fa0ae458eb99874f54c09f4f9174f8b45fb87e854536a4e608696247f0c23" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "http" @@ -262,9 +256,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -274,9 +268,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -321,9 +315,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -337,9 +331,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" @@ -350,23 +344,17 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.147" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -376,9 +364,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -388,18 +376,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", @@ -408,11 +396,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -426,18 +413,18 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" @@ -445,7 +432,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -473,9 +460,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -491,9 +478,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -515,18 +502,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -561,19 +548,10 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "reqwest" version = "0.11.18" -source = "git+https://github.com/zivergetech/reqwest?branch=update-apr-2024#313324b1c9867e520f537a2205eaf4333f1a5300" +source = "git+https://github.com/zivergetech/reqwest?branch=update-jun-2024#bd7f40be61748668b054742e64e9d10d3ab29014" dependencies = [ "base64", "bytes", @@ -604,7 +582,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "winreg", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -614,33 +592,33 @@ dependencies = [ "once_cell", "rand", "reqwest", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.0", + "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" @@ -653,11 +631,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -666,9 +644,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -676,18 +654,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -696,9 +674,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -728,19 +706,19 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "syn" -version = "2.0.53" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -749,15 +727,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -777,9 +754,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -802,16 +779,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -868,9 +844,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -989,7 +965,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -1009,17 +985,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -1030,9 +1007,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -1042,9 +1019,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -1054,9 +1031,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -1066,9 +1049,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -1078,9 +1061,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -1090,9 +1073,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -1102,9 +1085,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winreg" @@ -1117,10 +1100,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ - "bitflags 2.4.0", + "bitflags", ] diff --git a/test-components/runtime-service/cargo.toml b/test-components/runtime-service/cargo.toml index a5114ffff5..f6b5ec8dc9 100644 --- a/test-components/runtime-service/cargo.toml +++ b/test-components/runtime-service/cargo.toml @@ -15,8 +15,8 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-apr-2024", features = ["json"] } -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +reqwest = { git = "https://github.com/zivergetech/reqwest", branch = "update-jun-2024", features = ["json"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/runtime-service/src/bindings.rs b/test-components/runtime-service/src/bindings.rs index 547be16cd7..2a39e94b6e 100644 --- a/test-components/runtime-service/src/bindings.rs +++ b/test-components/runtime-service/src/bindings.rs @@ -1,5843 +1,6340 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod host { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - /// An index into the persistent log storing all performed operations of a worker - pub type OplogIndex = u64; - /// Represents a Golem component's version - pub type ComponentVersion = u64; - /// UUID - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Uuid { - pub high_bits: u64, - pub low_bits: u64, - } - impl ::core::fmt::Debug for Uuid { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uuid").field("high-bits", &self.high_bits).field("low-bits", &self.low_bits).finish() - } - } - /// Represents a Golem component - #[repr(C)] - #[derive(Clone, Copy)] - pub struct ComponentId { - pub uuid: Uuid, - } - impl ::core::fmt::Debug for ComponentId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ComponentId").field("uuid", &self.uuid).finish() - } - } - /// Represents a Golem worker - #[derive(Clone)] - pub struct WorkerId { - pub component_id: ComponentId, - pub worker_name: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerId").field("component-id", &self.component_id).field("worker-name", &self.worker_name).finish() - } - } - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - #[derive(Clone)] - pub struct PromiseId { - pub worker_id: WorkerId, - pub oplog_idx: OplogIndex, - } - impl ::core::fmt::Debug for PromiseId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("PromiseId").field("worker-id", &self.worker_id).field("oplog-idx", &self.oplog_idx).finish() - } - } - /// Configures how the executor retries failures - #[repr(C)] - #[derive(Clone, Copy)] - pub struct RetryPolicy { - /// The maximum number of retries before the worker becomes permanently failed - pub max_attempts: u32, - /// The minimum delay between retries (applied to the first retry) - pub min_delay: Duration, - /// The maximum delay between retries - pub max_delay: Duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - pub multiplier: u32, - } - impl ::core::fmt::Debug for RetryPolicy { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RetryPolicy").field("max-attempts", &self.max_attempts).field("min-delay", &self.min_delay).field("max-delay", &self.max_delay).field("multiplier", &self.multiplier).finish() - } - } - /// Configurable persistence level for workers - #[derive(Clone, Copy)] - pub enum PersistenceLevel{ - PersistNothing, - PersistRemoteSideEffects, - Smart, - } - impl ::core::fmt::Debug for PersistenceLevel { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - PersistenceLevel::PersistNothing => { - f.debug_tuple("PersistenceLevel::PersistNothing").finish() - } - PersistenceLevel::PersistRemoteSideEffects => { - f.debug_tuple("PersistenceLevel::PersistRemoteSideEffects").finish() - } - PersistenceLevel::Smart => { - f.debug_tuple("PersistenceLevel::Smart").finish() - } - } - } - } - /// Describes how to update a worker to a different component version - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum UpdateMode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - Automatic, - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - SnapshotBased, - } - impl ::core::fmt::Debug for UpdateMode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - UpdateMode::Automatic => { - f.debug_tuple("UpdateMode::Automatic").finish() - } - UpdateMode::SnapshotBased => { - f.debug_tuple("UpdateMode::SnapshotBased").finish() - } - } - } - } - - impl UpdateMode{ - pub(crate) unsafe fn _lift(val: u8) -> UpdateMode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => UpdateMode::Automatic, - 1 => UpdateMode::SnapshotBased, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum FilterComparator { - Equal, - NotEqual, - GreaterEqual, - Greater, - LessEqual, - Less, - } - impl ::core::fmt::Debug for FilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - FilterComparator::Equal => { - f.debug_tuple("FilterComparator::Equal").finish() - } - FilterComparator::NotEqual => { - f.debug_tuple("FilterComparator::NotEqual").finish() - } - FilterComparator::GreaterEqual => { - f.debug_tuple("FilterComparator::GreaterEqual").finish() - } - FilterComparator::Greater => { - f.debug_tuple("FilterComparator::Greater").finish() - } - FilterComparator::LessEqual => { - f.debug_tuple("FilterComparator::LessEqual").finish() - } - FilterComparator::Less => { - f.debug_tuple("FilterComparator::Less").finish() - } - } - } - } - - impl FilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> FilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => FilterComparator::Equal, - 1 => FilterComparator::NotEqual, - 2 => FilterComparator::GreaterEqual, - 3 => FilterComparator::Greater, - 4 => FilterComparator::LessEqual, - 5 => FilterComparator::Less, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum StringFilterComparator { - Equal, - NotEqual, - Like, - NotLike, - } - impl ::core::fmt::Debug for StringFilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StringFilterComparator::Equal => { - f.debug_tuple("StringFilterComparator::Equal").finish() - } - StringFilterComparator::NotEqual => { - f.debug_tuple("StringFilterComparator::NotEqual").finish() - } - StringFilterComparator::Like => { - f.debug_tuple("StringFilterComparator::Like").finish() - } - StringFilterComparator::NotLike => { - f.debug_tuple("StringFilterComparator::NotLike").finish() - } - } - } - } - - impl StringFilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> StringFilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => StringFilterComparator::Equal, - 1 => StringFilterComparator::NotEqual, - 2 => StringFilterComparator::Like, - 3 => StringFilterComparator::NotLike, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum WorkerStatus { - /// The worker is running an invoked function - Running, - /// The worker is ready to run an invoked function - Idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - Suspended, - /// The last invocation was interrupted but will be resumed - Interrupted, - /// The last invocation failed and a retry was scheduled - Retrying, - /// The last invocation failed and the worker can no longer be used - Failed, - /// The worker exited after a successful invocation and can no longer be invoked - Exited, - } - impl ::core::fmt::Debug for WorkerStatus { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerStatus::Running => { - f.debug_tuple("WorkerStatus::Running").finish() - } - WorkerStatus::Idle => { - f.debug_tuple("WorkerStatus::Idle").finish() - } - WorkerStatus::Suspended => { - f.debug_tuple("WorkerStatus::Suspended").finish() - } - WorkerStatus::Interrupted => { - f.debug_tuple("WorkerStatus::Interrupted").finish() - } - WorkerStatus::Retrying => { - f.debug_tuple("WorkerStatus::Retrying").finish() - } - WorkerStatus::Failed => { - f.debug_tuple("WorkerStatus::Failed").finish() - } - WorkerStatus::Exited => { - f.debug_tuple("WorkerStatus::Exited").finish() - } - } - } - } - - impl WorkerStatus{ - pub(crate) unsafe fn _lift(val: u8) -> WorkerStatus{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => WorkerStatus::Running, - 1 => WorkerStatus::Idle, - 2 => WorkerStatus::Suspended, - 3 => WorkerStatus::Interrupted, - 4 => WorkerStatus::Retrying, - 5 => WorkerStatus::Failed, - 6 => WorkerStatus::Exited, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[derive(Clone)] - pub struct WorkerNameFilter { - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerNameFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerNameFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerStatusFilter { - pub comparator: FilterComparator, - pub value: WorkerStatus, - } - impl ::core::fmt::Debug for WorkerStatusFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerStatusFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerVersionFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerVersionFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerVersionFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerCreatedAtFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerCreatedAtFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerCreatedAtFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub struct WorkerEnvFilter { - pub name: wit_bindgen::rt::string::String, - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerEnvFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerEnvFilter").field("name", &self.name).field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WorkerPropertyFilter{ - Name(WorkerNameFilter), - Status(WorkerStatusFilter), - Version(WorkerVersionFilter), - CreatedAt(WorkerCreatedAtFilter), - Env(WorkerEnvFilter), - } - impl ::core::fmt::Debug for WorkerPropertyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerPropertyFilter::Name(e) => { - f.debug_tuple("WorkerPropertyFilter::Name").field(e).finish() - } - WorkerPropertyFilter::Status(e) => { - f.debug_tuple("WorkerPropertyFilter::Status").field(e).finish() - } - WorkerPropertyFilter::Version(e) => { - f.debug_tuple("WorkerPropertyFilter::Version").field(e).finish() - } - WorkerPropertyFilter::CreatedAt(e) => { - f.debug_tuple("WorkerPropertyFilter::CreatedAt").field(e).finish() - } - WorkerPropertyFilter::Env(e) => { - f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WorkerAllFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAllFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAllFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerAnyFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAnyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAnyFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerMetadata { - pub worker_id: WorkerId, - pub args: wit_bindgen::rt::vec::Vec::, - pub env: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>, - pub status: WorkerStatus, - pub component_version: u64, - pub retry_count: u64, - } - impl ::core::fmt::Debug for WorkerMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerMetadata").field("worker-id", &self.worker_id).field("args", &self.args).field("env", &self.env).field("status", &self.status).field("component-version", &self.component_version).field("retry-count", &self.retry_count).finish() - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct GetWorkers{ - handle: wit_bindgen::rt::Resource, - } - - impl GetWorkers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod host { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + /// An index into the persistent log storing all performed operations of a worker + pub type OplogIndex = u64; + /// Represents a Golem component's version + pub type ComponentVersion = u64; + /// UUID + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Uuid { + pub high_bits: u64, + pub low_bits: u64, + } + impl ::core::fmt::Debug for Uuid { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uuid") + .field("high-bits", &self.high_bits) + .field("low-bits", &self.low_bits) + .finish() + } + } + /// Represents a Golem component + #[repr(C)] + #[derive(Clone, Copy)] + pub struct ComponentId { + pub uuid: Uuid, + } + impl ::core::fmt::Debug for ComponentId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ComponentId") + .field("uuid", &self.uuid) + .finish() + } + } + /// Represents a Golem worker + #[derive(Clone)] + pub struct WorkerId { + pub component_id: ComponentId, + pub worker_name: _rt::String, + } + impl ::core::fmt::Debug for WorkerId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerId") + .field("component-id", &self.component_id) + .field("worker-name", &self.worker_name) + .finish() + } + } + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + #[derive(Clone)] + pub struct PromiseId { + pub worker_id: WorkerId, + pub oplog_idx: OplogIndex, + } + impl ::core::fmt::Debug for PromiseId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PromiseId") + .field("worker-id", &self.worker_id) + .field("oplog-idx", &self.oplog_idx) + .finish() + } + } + /// Configures how the executor retries failures + #[repr(C)] + #[derive(Clone, Copy)] + pub struct RetryPolicy { + /// The maximum number of retries before the worker becomes permanently failed + pub max_attempts: u32, + /// The minimum delay between retries (applied to the first retry) + pub min_delay: Duration, + /// The maximum delay between retries + pub max_delay: Duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + pub multiplier: u32, + } + impl ::core::fmt::Debug for RetryPolicy { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RetryPolicy") + .field("max-attempts", &self.max_attempts) + .field("min-delay", &self.min_delay) + .field("max-delay", &self.max_delay) + .field("multiplier", &self.multiplier) + .finish() + } + } + /// Configurable persistence level for workers + #[derive(Clone, Copy)] + pub enum PersistenceLevel { + PersistNothing, + PersistRemoteSideEffects, + Smart, + } + impl ::core::fmt::Debug for PersistenceLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + PersistenceLevel::PersistNothing => { + f.debug_tuple("PersistenceLevel::PersistNothing").finish() + } + PersistenceLevel::PersistRemoteSideEffects => f + .debug_tuple("PersistenceLevel::PersistRemoteSideEffects") + .finish(), + PersistenceLevel::Smart => { + f.debug_tuple("PersistenceLevel::Smart").finish() + } + } + } + } + /// Describes how to update a worker to a different component version + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum UpdateMode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + Automatic, + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + SnapshotBased, + } + impl ::core::fmt::Debug for UpdateMode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + UpdateMode::Automatic => f.debug_tuple("UpdateMode::Automatic").finish(), + UpdateMode::SnapshotBased => { + f.debug_tuple("UpdateMode::SnapshotBased").finish() + } + } + } + } + + impl UpdateMode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> UpdateMode { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => UpdateMode::Automatic, + 1 => UpdateMode::SnapshotBased, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum FilterComparator { + Equal, + NotEqual, + GreaterEqual, + Greater, + LessEqual, + Less, + } + impl ::core::fmt::Debug for FilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + FilterComparator::Equal => { + f.debug_tuple("FilterComparator::Equal").finish() + } + FilterComparator::NotEqual => { + f.debug_tuple("FilterComparator::NotEqual").finish() + } + FilterComparator::GreaterEqual => { + f.debug_tuple("FilterComparator::GreaterEqual").finish() + } + FilterComparator::Greater => { + f.debug_tuple("FilterComparator::Greater").finish() + } + FilterComparator::LessEqual => { + f.debug_tuple("FilterComparator::LessEqual").finish() + } + FilterComparator::Less => f.debug_tuple("FilterComparator::Less").finish(), + } + } + } + + impl FilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> FilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => FilterComparator::Equal, + 1 => FilterComparator::NotEqual, + 2 => FilterComparator::GreaterEqual, + 3 => FilterComparator::Greater, + 4 => FilterComparator::LessEqual, + 5 => FilterComparator::Less, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum StringFilterComparator { + Equal, + NotEqual, + Like, + NotLike, + } + impl ::core::fmt::Debug for StringFilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StringFilterComparator::Equal => { + f.debug_tuple("StringFilterComparator::Equal").finish() + } + StringFilterComparator::NotEqual => { + f.debug_tuple("StringFilterComparator::NotEqual").finish() + } + StringFilterComparator::Like => { + f.debug_tuple("StringFilterComparator::Like").finish() + } + StringFilterComparator::NotLike => { + f.debug_tuple("StringFilterComparator::NotLike").finish() + } + } + } + } + + impl StringFilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> StringFilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => StringFilterComparator::Equal, + 1 => StringFilterComparator::NotEqual, + 2 => StringFilterComparator::Like, + 3 => StringFilterComparator::NotLike, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum WorkerStatus { + /// The worker is running an invoked function + Running, + /// The worker is ready to run an invoked function + Idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + Suspended, + /// The last invocation was interrupted but will be resumed + Interrupted, + /// The last invocation failed and a retry was scheduled + Retrying, + /// The last invocation failed and the worker can no longer be used + Failed, + /// The worker exited after a successful invocation and can no longer be invoked + Exited, + } + impl ::core::fmt::Debug for WorkerStatus { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerStatus::Running => f.debug_tuple("WorkerStatus::Running").finish(), + WorkerStatus::Idle => f.debug_tuple("WorkerStatus::Idle").finish(), + WorkerStatus::Suspended => { + f.debug_tuple("WorkerStatus::Suspended").finish() + } + WorkerStatus::Interrupted => { + f.debug_tuple("WorkerStatus::Interrupted").finish() + } + WorkerStatus::Retrying => f.debug_tuple("WorkerStatus::Retrying").finish(), + WorkerStatus::Failed => f.debug_tuple("WorkerStatus::Failed").finish(), + WorkerStatus::Exited => f.debug_tuple("WorkerStatus::Exited").finish(), + } + } + } + + impl WorkerStatus { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> WorkerStatus { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => WorkerStatus::Running, + 1 => WorkerStatus::Idle, + 2 => WorkerStatus::Suspended, + 3 => WorkerStatus::Interrupted, + 4 => WorkerStatus::Retrying, + 5 => WorkerStatus::Failed, + 6 => WorkerStatus::Exited, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Clone)] + pub struct WorkerNameFilter { + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerNameFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerNameFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerStatusFilter { + pub comparator: FilterComparator, + pub value: WorkerStatus, + } + impl ::core::fmt::Debug for WorkerStatusFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerStatusFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerVersionFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerVersionFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerVersionFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerCreatedAtFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerCreatedAtFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerCreatedAtFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerEnvFilter { + pub name: _rt::String, + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerEnvFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerEnvFilter") + .field("name", &self.name) + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub enum WorkerPropertyFilter { + Name(WorkerNameFilter), + Status(WorkerStatusFilter), + Version(WorkerVersionFilter), + CreatedAt(WorkerCreatedAtFilter), + Env(WorkerEnvFilter), + } + impl ::core::fmt::Debug for WorkerPropertyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerPropertyFilter::Name(e) => f + .debug_tuple("WorkerPropertyFilter::Name") + .field(e) + .finish(), + WorkerPropertyFilter::Status(e) => f + .debug_tuple("WorkerPropertyFilter::Status") + .field(e) + .finish(), + WorkerPropertyFilter::Version(e) => f + .debug_tuple("WorkerPropertyFilter::Version") + .field(e) + .finish(), + WorkerPropertyFilter::CreatedAt(e) => f + .debug_tuple("WorkerPropertyFilter::CreatedAt") + .field(e) + .finish(), + WorkerPropertyFilter::Env(e) => { + f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WorkerAllFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAllFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAllFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerAnyFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAnyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAnyFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerMetadata { + pub worker_id: WorkerId, + pub args: _rt::Vec<_rt::String>, + pub env: _rt::Vec<(_rt::String, _rt::String)>, + pub status: WorkerStatus, + pub component_version: u64, + pub retry_count: u64, + } + impl ::core::fmt::Debug for WorkerMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerMetadata") + .field("worker-id", &self.worker_id) + .field("args", &self.args) + .field("env", &self.env) + .field("status", &self.status) + .field("component-version", &self.component_version) + .field("retry-count", &self.retry_count) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct GetWorkers { + handle: _rt::Resource, + } + + impl GetWorkers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for GetWorkers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]get-workers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn new( + component_id: ComponentId, + filter: Option<&WorkerAnyFilter>, + precise: bool, + ) -> Self { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let ComponentId { uuid: uuid0 } = component_id; + let Uuid { + high_bits: high_bits1, + low_bits: low_bits1, + } = uuid0; + let (result14_0, result14_1, result14_2) = match filter { + Some(e) => { + let WorkerAnyFilter { filters: filters2 } = e; + let vec13 = filters2; + let len13 = vec13.len(); + let layout13 = _rt::alloc::Layout::from_size_align_unchecked( + vec13.len() * 8, + 4, + ); + let result13 = if layout13.size() != 0 { + let ptr = _rt::alloc::alloc(layout13).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout13); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec13.into_iter().enumerate() { + let base = result13.add(i * 8); + { + let WorkerAllFilter { filters: filters3 } = e; + let vec12 = filters3; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked( + vec12.len() * 32, + 8, + ); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 32); + { + match e { + WorkerPropertyFilter::Name(e) => { + *base.add(0).cast::() = (0i32) as u8; + let WorkerNameFilter { + comparator: comparator4, + value: value4, + } = e; + *base.add(8).cast::() = + (comparator4.clone() as i32) as u8; + let vec5 = value4; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(16).cast::() = len5; + *base.add(12).cast::<*mut u8>() = + ptr5.cast_mut(); + } + WorkerPropertyFilter::Status(e) => { + *base.add(0).cast::() = (1i32) as u8; + let WorkerStatusFilter { + comparator: comparator6, + value: value6, + } = e; + *base.add(8).cast::() = + (comparator6.clone() as i32) as u8; + *base.add(9).cast::() = + (value6.clone() as i32) as u8; + } + WorkerPropertyFilter::Version(e) => { + *base.add(0).cast::() = (2i32) as u8; + let WorkerVersionFilter { + comparator: comparator7, + value: value7, + } = e; + *base.add(8).cast::() = + (comparator7.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value7); + } + WorkerPropertyFilter::CreatedAt(e) => { + *base.add(0).cast::() = (3i32) as u8; + let WorkerCreatedAtFilter { + comparator: comparator8, + value: value8, + } = e; + *base.add(8).cast::() = + (comparator8.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value8); + } + WorkerPropertyFilter::Env(e) => { + *base.add(0).cast::() = (4i32) as u8; + let WorkerEnvFilter { + name: name9, + comparator: comparator9, + value: value9, + } = e; + let vec10 = name9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = + ptr10.cast_mut(); + *base.add(16).cast::() = + (comparator9.clone() as i32) as u8; + let vec11 = value9; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + *base.add(24).cast::() = len11; + *base.add(20).cast::<*mut u8>() = + ptr11.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len12; + *base.add(0).cast::<*mut u8>() = result12; + cleanup_list.extend_from_slice(&[(result12, layout12)]); + } + } + cleanup_list.extend_from_slice(&[(result13, layout13)]); + + (1i32, result13, len13) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[constructor]get-workers"] + fn wit_import( + _: i64, + _: i64, + _: i32, + _: *mut u8, + _: usize, + _: i32, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: i32, _: *mut u8, _: usize, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits1), + _rt::as_i64(low_bits1), + result14_0, + result14_1, + result14_2, + match &precise { + true => 1, + false => 0, + }, + ); + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + GetWorkers::from_handle(ret as u32) + } + } + } + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn get_next(&self) -> Option<_rt::Vec> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[method]get-workers.get-next"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base27 = l2; + let len27 = l3; + let mut result27 = _rt::Vec::with_capacity(len27); + for i in 0..len27 { + let base = base27.add(i * 64); + let e27 = { + let l4 = *base.add(0).cast::(); + let l5 = *base.add(8).cast::(); + let l6 = *base.add(16).cast::<*mut u8>(); + let l7 = *base.add(20).cast::(); + let len8 = l7; + let bytes8 = + _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + let l9 = *base.add(24).cast::<*mut u8>(); + let l10 = *base.add(28).cast::(); + let base14 = l9; + let len14 = l10; + let mut result14 = _rt::Vec::with_capacity(len14); + for i in 0..len14 { + let base = base14.add(i * 8); + let e14 = { + let l11 = *base.add(0).cast::<*mut u8>(); + let l12 = *base.add(4).cast::(); + let len13 = l12; + let bytes13 = _rt::Vec::from_raw_parts( + l11.cast(), + len13, + len13, + ); + + _rt::string_lift(bytes13) + }; + result14.push(e14); + } + _rt::cabi_dealloc(base14, len14 * 8, 4); + let l15 = *base.add(32).cast::<*mut u8>(); + let l16 = *base.add(36).cast::(); + let base23 = l15; + let len23 = l16; + let mut result23 = _rt::Vec::with_capacity(len23); + for i in 0..len23 { + let base = base23.add(i * 16); + let e23 = { + let l17 = *base.add(0).cast::<*mut u8>(); + let l18 = *base.add(4).cast::(); + let len19 = l18; + let bytes19 = _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ); + let l20 = *base.add(8).cast::<*mut u8>(); + let l21 = *base.add(12).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ); + + ( + _rt::string_lift(bytes19), + _rt::string_lift(bytes22), + ) + }; + result23.push(e23); + } + _rt::cabi_dealloc(base23, len23 * 16, 4); + let l24 = i32::from(*base.add(40).cast::()); + let l25 = *base.add(48).cast::(); + let l26 = *base.add(56).cast::(); + + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l4 as u64, + low_bits: l5 as u64, + }, + }, + worker_name: _rt::string_lift(bytes8), + }, + args: result14, + env: result23, + status: WorkerStatus::_lift(l24 as u8), + component_version: l25 as u64, + retry_count: l26 as u64, + } + }; + result27.push(e27); + } + _rt::cabi_dealloc(base27, len27 * 64, 8); + + result27 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a new promise + pub fn golem_create_promise() -> PromiseId { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-create-promise"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::<*mut u8>(); + let l4 = *ptr0.add(20).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *ptr0.add(24).cast::(); + PromiseId { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + }, + }, + worker_name: _rt::string_lift(bytes5), + }, + oplog_idx: l6 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + pub fn golem_await_promise(promise_id: &PromiseId) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let ptr5 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-await-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5, + ); + let l6 = *ptr5.add(0).cast::<*mut u8>(); + let l7 = *ptr5.add(4).cast::(); + let len8 = l7; + _rt::Vec::from_raw_parts(l6.cast(), len8, len8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + pub fn golem_complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = data; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-complete-promise"] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5.cast_mut(), + len5, + ); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Deletes the given promise + pub fn golem_delete_promise(promise_id: &PromiseId) { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-delete-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + pub fn get_self_uri(function_name: &str) -> Uri { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-self-uri"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes4), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns the current position in the persistent op log + pub fn get_oplog_index() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-index"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + pub fn set_oplog_index(oplog_idx: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-index"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(oplog_idx)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + pub fn oplog_commit(replicas: u8) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "oplog-commit"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(_rt::as_i32(&replicas)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + pub fn mark_begin_operation() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-begin-operation"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + pub fn mark_end_operation(begin: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-end-operation"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(begin)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current retry policy associated with the worker + pub fn get_retry_policy() -> RetryPolicy { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-retry-policy"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + RetryPolicy { + max_attempts: l1 as u32, + min_delay: l2 as u64, + max_delay: l3 as u64, + multiplier: l4 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + pub fn set_retry_policy(new_retry_policy: RetryPolicy) { + unsafe { + let RetryPolicy { + max_attempts: max_attempts0, + min_delay: min_delay0, + max_delay: max_delay0, + multiplier: multiplier0, + } = new_retry_policy; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-retry-policy"] + fn wit_import(_: i32, _: i64, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i32(max_attempts0), + _rt::as_i64(min_delay0), + _rt::as_i64(max_delay0), + _rt::as_i32(multiplier0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the worker's current persistence level. + pub fn get_oplog_persistence_level() -> PersistenceLevel { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-persistence-level"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + let v0 = match ret { + 0 => PersistenceLevel::PersistNothing, + 1 => PersistenceLevel::PersistRemoteSideEffects, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + PersistenceLevel::Smart + } + }; + v0 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel) { + unsafe { + let result0 = match new_persistence_level { + PersistenceLevel::PersistNothing => 0i32, + PersistenceLevel::PersistRemoteSideEffects => 1i32, + PersistenceLevel::Smart => 2i32, + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-persistence-level"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(result0); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + pub fn get_idempotence_mode() -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-idempotence-mode"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + pub fn set_idempotence_mode(idempotent: bool) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-idempotence-mode"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(match &idempotent { + true => 1, + false => 0, + }); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + pub fn generate_idempotency_key() -> Uuid { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "generate-idempotency-key"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + pub fn update_worker( + worker_id: &WorkerId, + target_version: ComponentVersion, + mode: UpdateMode, + ) { + unsafe { + let WorkerId { + component_id: component_id0, + worker_name: worker_name0, + } = worker_id; + let ComponentId { uuid: uuid1 } = component_id0; + let Uuid { + high_bits: high_bits2, + low_bits: low_bits2, + } = uuid1; + let vec3 = worker_name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "update-worker"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits2), + _rt::as_i64(low_bits2), + ptr3.cast_mut(), + len3, + _rt::as_i64(target_version), + mode.clone() as i32, + ); + } + } } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) + } + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + } + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } + WitNode::EnumValue(e) => { + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } + WitNode::FlagsValue(e) => { + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, + } + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } + } + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, + } + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } + } + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), + } + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } + } + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, + } + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec9 = function_params; + let len9 = vec9.len(); + let layout9 = + _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); + let result9 = if layout9.size() != 0 { + let ptr = _rt::alloc::alloc(layout9).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout9); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec9.into_iter().enumerate() { + let base = result9.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec8 = nodes1; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked( + vec8.len() * 24, + 8, + ); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec8.into_iter().enumerate() { + let base = result8.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len8; + *base.add(0).cast::<*mut u8>() = result8; + cleanup_list.extend_from_slice(&[(result8, layout8)]); + } + } + let ptr10 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result9, + len9, + ptr10, + ); + let l11 = i32::from(*ptr10.add(0).cast::()); + if layout9.size() != 0 { + _rt::alloc::dealloc(result9.cast(), layout9); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l11 { + 0 => { + let e = { + let l12 = *ptr10.add(4).cast::<*mut u8>(); + let l13 = *ptr10.add(8).cast::(); + let base55 = l12; + let len55 = l13; + let mut result55 = _rt::Vec::with_capacity(len55); + for i in 0..len55 { + let base = base55.add(i * 24); + let e55 = { + let l14 = i32::from(*base.add(0).cast::()); + let v54 = match l14 { + 0 => { + let e54 = { + let l15 = *base.add(8).cast::<*mut u8>(); + let l16 = *base.add(12).cast::(); + let len17 = l16; + + _rt::Vec::from_raw_parts( + l15.cast(), + len17, + len17, + ) + }; + WitNode::RecordValue(e54) + } + 1 => { + let e54 = + { + let l18 = *base.add(8).cast::(); + let l19 = i32::from( + *base.add(12).cast::(), + ); + + (l18 as u32, match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *base.add(16).cast::(); + + l20 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }) + }; + WitNode::VariantValue(e54) + } + 2 => { + let e54 = { + let l21 = *base.add(8).cast::(); + + l21 as u32 + }; + WitNode::EnumValue(e54) + } + 3 => { + let e54 = { + let l22 = *base.add(8).cast::<*mut u8>(); + let l23 = *base.add(12).cast::(); + let base25 = l22; + let len25 = l23; + let mut result25 = + _rt::Vec::with_capacity(len25); + for i in 0..len25 { + let base = base25.add(i * 1); + let e25 = { + let l24 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l24 as u8) + }; + result25.push(e25); + } + _rt::cabi_dealloc(base25, len25 * 1, 1); + + result25 + }; + WitNode::FlagsValue(e54) + } + 4 => { + let e54 = { + let l26 = *base.add(8).cast::<*mut u8>(); + let l27 = *base.add(12).cast::(); + let len28 = l27; + + _rt::Vec::from_raw_parts( + l26.cast(), + len28, + len28, + ) + }; + WitNode::TupleValue(e54) + } + 5 => { + let e54 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::ListValue(e54) + } + 6 => { + let e54 = { + let l32 = + i32::from(*base.add(8).cast::()); + + match l32 { + 0 => None, + 1 => { + let e = { + let l33 = + *base.add(12).cast::(); + + l33 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e54) + } + 7 => { + let e54 = { + let l34 = + i32::from(*base.add(8).cast::()); + + match l34 { + 0 => { + let e = { + let l35 = i32::from( + *base.add(12).cast::(), + ); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = *base.add(16).cast::(); + + l36 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = { + let l37 = i32::from( + *base.add(12).cast::(), + ); + + match l37 { + 0 => None, + 1 => { + let e = { + let l38 = *base.add(16).cast::(); + + l38 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e54) + } + 8 => { + let e54 = { + let l39 = + i32::from(*base.add(8).cast::()); + + l39 as u8 + }; + WitNode::PrimU8(e54) + } + 9 => { + let e54 = { + let l40 = + i32::from(*base.add(8).cast::()); + + l40 as u16 + }; + WitNode::PrimU16(e54) + } + 10 => { + let e54 = { + let l41 = *base.add(8).cast::(); + + l41 as u32 + }; + WitNode::PrimU32(e54) + } + 11 => { + let e54 = { + let l42 = *base.add(8).cast::(); + + l42 as u64 + }; + WitNode::PrimU64(e54) + } + 12 => { + let e54 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as i8 + }; + WitNode::PrimS8(e54) + } + 13 => { + let e54 = { + let l44 = + i32::from(*base.add(8).cast::()); + + l44 as i16 + }; + WitNode::PrimS16(e54) + } + 14 => { + let e54 = { + let l45 = *base.add(8).cast::(); + + l45 + }; + WitNode::PrimS32(e54) + } + 15 => { + let e54 = { + let l46 = *base.add(8).cast::(); + + l46 + }; + WitNode::PrimS64(e54) + } + 16 => { + let e54 = { + let l47 = *base.add(8).cast::(); + + l47 + }; + WitNode::PrimFloat32(e54) + } + 17 => { + let e54 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimFloat64(e54) + } + 18 => { + let e54 = { + let l49 = *base.add(8).cast::(); + + _rt::char_lift(l49 as u32) + }; + WitNode::PrimChar(e54) + } + 19 => { + let e54 = { + let l50 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l50 as u8) + }; + WitNode::PrimBool(e54) + } + n => { + debug_assert_eq!( + n, 20, + "invalid enum discriminant" + ); + let e54 = { + let l51 = *base.add(8).cast::<*mut u8>(); + let l52 = *base.add(12).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts( + l51.cast(), + len53, + len53, + ); + + _rt::string_lift(bytes53) + }; + WitNode::PrimString(e54) + } + }; + + v54 + }; + result55.push(e55); + } + _rt::cabi_dealloc(base55, len55 * 24, 8); + + WitValue { nodes: result55 } + }; + Ok(e) + } + 1 => { + let e = { + let l56 = i32::from(*ptr10.add(4).cast::()); + let v69 = match l56 { + 0 => { + let e69 = { + let l57 = *ptr10.add(8).cast::<*mut u8>(); + let l58 = *ptr10.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + RpcError::ProtocolError(e69) + } + 1 => { + let e69 = { + let l60 = *ptr10.add(8).cast::<*mut u8>(); + let l61 = *ptr10.add(12).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts( + l60.cast(), + len62, + len62, + ); + + _rt::string_lift(bytes62) + }; + RpcError::Denied(e69) + } + 2 => { + let e69 = { + let l63 = *ptr10.add(8).cast::<*mut u8>(); + let l64 = *ptr10.add(12).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + RpcError::NotFound(e69) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e69 = { + let l66 = *ptr10.add(8).cast::<*mut u8>(); + let l67 = *ptr10.add(12).cast::(); + let len68 = l67; + let bytes68 = _rt::Vec::from_raw_parts( + l66.cast(), + len68, + len68, + ); + + _rt::string_lift(bytes68) + }; + RpcError::RemoteInternalError(e69) + } + }; + + v69 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } } - } - - - unsafe impl wit_bindgen::rt::WasmResource for GetWorkers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]get-workers"] - fn drop(_: u32); - } - - drop(_handle); - } + } +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "now"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "resolution"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the specified instant + /// occured. + pub fn subscribe_instant(when: Instant) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "subscribe-instant"] + fn wit_import(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + pub fn subscribe_duration(when: Duration) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "subscribe-duration"] + fn wit_import(_: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } } - } - - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn new(component_id: ComponentId,filter: Option<&WorkerAnyFilter>,precise: bool,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - let ComponentId{ uuid:uuid0, } = component_id; - let Uuid{ high_bits:high_bits1, low_bits:low_bits1, } = uuid0; - let (result14_0,result14_1,result14_2,) = match filter { - Some(e) => { - let WorkerAnyFilter{ filters:filters2, } = e; - let vec13 = filters2; - let len13 = vec13.len() as i32; - let layout13 = alloc::Layout::from_size_align_unchecked(vec13.len() * 8, 4); - let result13 = if layout13.size() != 0 - { - let ptr = alloc::alloc(layout13); - if ptr.is_null() - { - alloc::handle_alloc_error(layout13); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec13.into_iter().enumerate() { - let base = result13 as i32 + (i as i32) * 8; - { - let WorkerAllFilter{ filters:filters3, } = e; - let vec12 = filters3; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 32, 8); - let result12 = if layout12.size() != 0 + } + #[allow(dead_code)] + pub mod http { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type IoError = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// This type corresponds to HTTP standard Methods. + #[derive(Clone)] + pub enum Method { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(_rt::String), + } + 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(), + } + } + } + /// This type corresponds to HTTP standard Related Schemes. + #[derive(Clone)] + pub enum Scheme { + Http, + Https, + Other(_rt::String), + } + 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(), + } + } + } + /// Defines the case payload type for `DNS-error` above: + #[derive(Clone)] + pub struct DnsErrorPayload { + pub rcode: Option<_rt::String>, + pub info_code: Option, + } + impl ::core::fmt::Debug for DnsErrorPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DnsErrorPayload") + .field("rcode", &self.rcode) + .field("info-code", &self.info_code) + .finish() + } + } + /// Defines the case payload type for `TLS-alert-received` above: + #[derive(Clone)] + pub struct TlsAlertReceivedPayload { + pub alert_id: Option, + pub alert_message: Option<_rt::String>, + } + impl ::core::fmt::Debug for TlsAlertReceivedPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TlsAlertReceivedPayload") + .field("alert-id", &self.alert_id) + .field("alert-message", &self.alert_message) + .finish() + } + } + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + #[derive(Clone)] + pub struct FieldSizePayload { + pub field_name: Option<_rt::String>, + pub field_size: Option, + } + impl ::core::fmt::Debug for FieldSizePayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FieldSizePayload") + .field("field-name", &self.field_name) + .field("field-size", &self.field_size) + .finish() + } + } + /// These cases are inspired by the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + #[derive(Clone)] + pub enum ErrorCode { + DnsTimeout, + DnsError(DnsErrorPayload), + DestinationNotFound, + DestinationUnavailable, + DestinationIpProhibited, + DestinationIpUnroutable, + ConnectionRefused, + ConnectionTerminated, + ConnectionTimeout, + ConnectionReadTimeout, + ConnectionWriteTimeout, + ConnectionLimitReached, + TlsProtocolError, + TlsCertificateError, + TlsAlertReceived(TlsAlertReceivedPayload), + HttpRequestDenied, + HttpRequestLengthRequired, + HttpRequestBodySize(Option), + HttpRequestMethodInvalid, + HttpRequestUriInvalid, + HttpRequestUriTooLong, + HttpRequestHeaderSectionSize(Option), + HttpRequestHeaderSize(Option), + HttpRequestTrailerSectionSize(Option), + HttpRequestTrailerSize(FieldSizePayload), + HttpResponseIncomplete, + HttpResponseHeaderSectionSize(Option), + HttpResponseHeaderSize(FieldSizePayload), + HttpResponseBodySize(Option), + HttpResponseTrailerSectionSize(Option), + HttpResponseTrailerSize(FieldSizePayload), + HttpResponseTransferCoding(Option<_rt::String>), + HttpResponseContentCoding(Option<_rt::String>), + HttpResponseTimeout, + HttpUpgradeFailed, + HttpProtocolError, + LoopDetected, + ConfigurationError, + /// This is a catch-all error for anything that doesn't fit cleanly into a + /// more specific case. It also includes an optional string for an + /// unstructured description of the error. Users should not depend on the + /// string for diagnosing errors, as it's not required to be consistent + /// between implementations. + InternalError(Option<_rt::String>), + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + ErrorCode::DnsTimeout => f.debug_tuple("ErrorCode::DnsTimeout").finish(), + ErrorCode::DnsError(e) => { + f.debug_tuple("ErrorCode::DnsError").field(e).finish() + } + ErrorCode::DestinationNotFound => { + f.debug_tuple("ErrorCode::DestinationNotFound").finish() + } + ErrorCode::DestinationUnavailable => { + f.debug_tuple("ErrorCode::DestinationUnavailable").finish() + } + ErrorCode::DestinationIpProhibited => { + f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() + } + ErrorCode::DestinationIpUnroutable => { + f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() + } + ErrorCode::ConnectionRefused => { + f.debug_tuple("ErrorCode::ConnectionRefused").finish() + } + ErrorCode::ConnectionTerminated => { + f.debug_tuple("ErrorCode::ConnectionTerminated").finish() + } + ErrorCode::ConnectionTimeout => { + f.debug_tuple("ErrorCode::ConnectionTimeout").finish() + } + ErrorCode::ConnectionReadTimeout => { + f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() + } + ErrorCode::ConnectionWriteTimeout => { + f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() + } + ErrorCode::ConnectionLimitReached => { + f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() + } + ErrorCode::TlsProtocolError => { + f.debug_tuple("ErrorCode::TlsProtocolError").finish() + } + ErrorCode::TlsCertificateError => { + f.debug_tuple("ErrorCode::TlsCertificateError").finish() + } + ErrorCode::TlsAlertReceived(e) => f + .debug_tuple("ErrorCode::TlsAlertReceived") + .field(e) + .finish(), + ErrorCode::HttpRequestDenied => { + f.debug_tuple("ErrorCode::HttpRequestDenied").finish() + } + ErrorCode::HttpRequestLengthRequired => f + .debug_tuple("ErrorCode::HttpRequestLengthRequired") + .finish(), + ErrorCode::HttpRequestBodySize(e) => f + .debug_tuple("ErrorCode::HttpRequestBodySize") + .field(e) + .finish(), + ErrorCode::HttpRequestMethodInvalid => f + .debug_tuple("ErrorCode::HttpRequestMethodInvalid") + .finish(), + ErrorCode::HttpRequestUriInvalid => { + f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() + } + ErrorCode::HttpRequestUriTooLong => { + f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() + } + ErrorCode::HttpRequestHeaderSectionSize(e) => f + .debug_tuple("ErrorCode::HttpRequestHeaderSectionSize") + .field(e) + .finish(), + ErrorCode::HttpRequestHeaderSize(e) => f + .debug_tuple("ErrorCode::HttpRequestHeaderSize") + .field(e) + .finish(), + ErrorCode::HttpRequestTrailerSectionSize(e) => f + .debug_tuple("ErrorCode::HttpRequestTrailerSectionSize") + .field(e) + .finish(), + ErrorCode::HttpRequestTrailerSize(e) => f + .debug_tuple("ErrorCode::HttpRequestTrailerSize") + .field(e) + .finish(), + ErrorCode::HttpResponseIncomplete => { + f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() + } + ErrorCode::HttpResponseHeaderSectionSize(e) => f + .debug_tuple("ErrorCode::HttpResponseHeaderSectionSize") + .field(e) + .finish(), + ErrorCode::HttpResponseHeaderSize(e) => f + .debug_tuple("ErrorCode::HttpResponseHeaderSize") + .field(e) + .finish(), + ErrorCode::HttpResponseBodySize(e) => f + .debug_tuple("ErrorCode::HttpResponseBodySize") + .field(e) + .finish(), + ErrorCode::HttpResponseTrailerSectionSize(e) => f + .debug_tuple("ErrorCode::HttpResponseTrailerSectionSize") + .field(e) + .finish(), + ErrorCode::HttpResponseTrailerSize(e) => f + .debug_tuple("ErrorCode::HttpResponseTrailerSize") + .field(e) + .finish(), + ErrorCode::HttpResponseTransferCoding(e) => f + .debug_tuple("ErrorCode::HttpResponseTransferCoding") + .field(e) + .finish(), + ErrorCode::HttpResponseContentCoding(e) => f + .debug_tuple("ErrorCode::HttpResponseContentCoding") + .field(e) + .finish(), + ErrorCode::HttpResponseTimeout => { + f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() + } + ErrorCode::HttpUpgradeFailed => { + f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() + } + ErrorCode::HttpProtocolError => { + f.debug_tuple("ErrorCode::HttpProtocolError").finish() + } + ErrorCode::LoopDetected => { + f.debug_tuple("ErrorCode::LoopDetected").finish() + } + ErrorCode::ConfigurationError => { + f.debug_tuple("ErrorCode::ConfigurationError").finish() + } + ErrorCode::InternalError(e) => { + f.debug_tuple("ErrorCode::InternalError").field(e).finish() + } + } + } + } + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for ErrorCode {} + /// This type enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + #[derive(Clone, Copy)] + pub enum HeaderError { + /// This error indicates that a `field-key` or `field-value` was + /// syntactically invalid when used with an operation that sets headers in a + /// `fields`. + InvalidSyntax, + /// This error indicates that a forbidden `field-key` was used when trying + /// to set a header in a `fields`. + Forbidden, + /// This error indicates that the operation on the `fields` was not + /// permitted because the fields are immutable. + Immutable, + } + impl ::core::fmt::Debug for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + HeaderError::InvalidSyntax => { + f.debug_tuple("HeaderError::InvalidSyntax").finish() + } + HeaderError::Forbidden => f.debug_tuple("HeaderError::Forbidden").finish(), + HeaderError::Immutable => f.debug_tuple("HeaderError::Immutable").finish(), + } + } + } + impl ::core::fmt::Display for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for HeaderError {} + /// Field keys are always strings. + pub type FieldKey = _rt::String; + /// Field values should always be ASCII strings. However, in + /// reality, HTTP implementations often have to interpret malformed values, + /// so they are provided as a list of bytes. + pub type FieldValue = _rt::Vec; + /// This following block defines the `fields` resource which corresponds to + /// HTTP standard Fields. Fields are a common representation used for both + /// Headers and Trailers. + /// + /// A `fields` may be mutable or immutable. A `fields` created using the + /// constructor, `from-list`, or `clone` will be mutable, but a `fields` + /// resource given by other means (including, but not limited to, + /// `incoming-request.headers`, `outgoing-request.headers`) might be be + /// immutable. In an immutable fields, the `set`, `append`, and `delete` + /// operations will fail with `header-error.immutable`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Fields { + handle: _rt::Resource, + } + + impl Fields { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Fields { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]fields"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Headers is an alias for Fields. + pub type Headers = Fields; + /// Trailers is an alias for Fields. + pub type Trailers = Fields; + /// Represents an incoming HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingRequest { + handle: _rt::Resource, + } + + impl IncomingRequest { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingRequest { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingRequest { + handle: _rt::Resource, + } + + impl OutgoingRequest { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingRequest { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Parameters for making an HTTP Request. Each of these parameters is + /// currently an optional timeout applicable to the transport layer of the + /// HTTP protocol. + /// + /// These timeouts are separate from any the user may use to bound a + /// blocking call to `wasi:io/poll.poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct RequestOptions { + handle: _rt::Resource, + } + + impl RequestOptions { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for RequestOptions { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]request-options"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents the ability to send an HTTP Response. + /// + /// This resource is used by the `wasi:http/incoming-handler` interface to + /// allow a Response to be sent corresponding to the Request provided as the + /// other argument to `incoming-handler.handle`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct ResponseOutparam { + handle: _rt::Resource, + } + + impl ResponseOutparam { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for ResponseOutparam { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 32; - { - match e { - WorkerPropertyFilter::Name(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let WorkerNameFilter{ comparator:comparator4, value:value4, } = e; - *((base + 8) as *mut u8) = (comparator4.clone() as i32) as u8; - let vec5 = value4; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 16) as *mut i32) = len5; - *((base + 12) as *mut i32) = ptr5; - }, - WorkerPropertyFilter::Status(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let WorkerStatusFilter{ comparator:comparator6, value:value6, } = e; - *((base + 8) as *mut u8) = (comparator6.clone() as i32) as u8; - *((base + 9) as *mut u8) = (value6.clone() as i32) as u8; - }, - WorkerPropertyFilter::Version(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - let WorkerVersionFilter{ comparator:comparator7, value:value7, } = e; - *((base + 8) as *mut u8) = (comparator7.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value7); - }, - WorkerPropertyFilter::CreatedAt(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let WorkerCreatedAtFilter{ comparator:comparator8, value:value8, } = e; - *((base + 8) as *mut u8) = (comparator8.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value8); - }, - WorkerPropertyFilter::Env(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let WorkerEnvFilter{ name:name9, comparator:comparator9, value:value9, } = e; - let vec10 = name9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut u8) = (comparator9.clone() as i32) as u8; - let vec11 = value9; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - *((base + 24) as *mut i32) = len11; - *((base + 20) as *mut i32) = ptr11; - }, - } - } - } - *((base + 4) as *mut i32) = len12; - *((base + 0) as *mut i32) = result12 as i32; - cleanup_list.extend_from_slice(&[(result12, layout12),]); - } - } - cleanup_list.extend_from_slice(&[(result13, layout13),]); - - (1i32, result13 as i32, len13) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[constructor]get-workers"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits1), wit_bindgen::rt::as_i64(low_bits1), result14_0, result14_1, result14_2, match precise { true => 1, false => 0 }); - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]response-outparam"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// This type corresponds to the HTTP standard Status Code. + pub type StatusCode = u16; + /// Represents an incoming HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingResponse { + handle: _rt::Resource, + } + + impl IncomingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an incoming HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, indicating that the full contents of the + /// body have been received. This resource represents the contents as + /// an `input-stream` and the delivery of trailers as a `future-trailers`, + /// and ensures that the user of this interface may only be consuming either + /// the body contents or waiting on trailers at any given time. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingBody { + handle: _rt::Resource, + } + + impl IncomingBody { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for IncomingBody { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return trailers, or an error. + /// + /// In the case that the incoming HTTP Request or Response did not have any + /// trailers, this future will resolve to the empty set of trailers once the + /// complete Request or Response body has been received. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureTrailers { + handle: _rt::Resource, + } + + impl FutureTrailers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for FutureTrailers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-trailers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingResponse { + handle: _rt::Resource, + } + + impl OutgoingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, inducating the full contents of the body + /// have been sent. This resource represents the contents as an + /// `output-stream` child resource, and the completion of the body (with + /// optional trailers) with a static function that consumes the + /// `outgoing-body` resource, and ensures that the user of this interface + /// may not write to the body contents after the body has been finished. + /// + /// If the user code drops this resource, as opposed to calling the static + /// method `finish`, the implementation should treat the body as incomplete, + /// and that an error has occured. The implementation should propogate this + /// error to the HTTP protocol by whatever means it has available, + /// including: corrupting the body on the wire, aborting the associated + /// Request, or sending a late status code for the Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingBody { + handle: _rt::Resource, + } + + impl OutgoingBody { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutgoingBody { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return an incoming HTTP + /// Response, or an error. + /// + /// This resource is returned by the `wasi:http/outgoing-handler` interface to + /// provide the HTTP Response corresponding to the sent Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureIncomingResponse { + handle: _rt::Resource, + } + + impl FutureIncomingResponse { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for FutureIncomingResponse { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-incoming-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Attempts to extract a http-related `error` from the wasi:io `error` + /// provided. + /// + /// Stream operations which return + /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of + /// type `wasi:io/error/error` with more information about the operation + /// that failed. This payload can be passed through to this function to see + /// if there's http-related information about the error to return. + /// + /// Note that this function is fallible because not all io-errors are + /// http-related errors. + pub fn http_error_code(err: &IoError) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "http-error-code"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((err).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + let v64 = match l2 { + 0 => ErrorCode::DnsTimeout, + 1 => { + let e64 = { + let l3 = i32::from(*ptr0.add(16).cast::()); + let l7 = i32::from(*ptr0.add(28).cast::()); + + DnsErrorPayload { + rcode: match l3 { + 0 => None, + 1 => { + let e = { + let l4 = + *ptr0.add(20).cast::<*mut u8>(); + let l5 = *ptr0.add(24).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, + ); + + _rt::string_lift(bytes6) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = i32::from( + *ptr0.add(30).cast::(), + ); + + l8 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e64) + } + 2 => ErrorCode::DestinationNotFound, + 3 => ErrorCode::DestinationUnavailable, + 4 => ErrorCode::DestinationIpProhibited, + 5 => ErrorCode::DestinationIpUnroutable, + 6 => ErrorCode::ConnectionRefused, + 7 => ErrorCode::ConnectionTerminated, + 8 => ErrorCode::ConnectionTimeout, + 9 => ErrorCode::ConnectionReadTimeout, + 10 => ErrorCode::ConnectionWriteTimeout, + 11 => ErrorCode::ConnectionLimitReached, + 12 => ErrorCode::TlsProtocolError, + 13 => ErrorCode::TlsCertificateError, + 14 => { + let e64 = { + let l9 = i32::from(*ptr0.add(16).cast::()); + let l11 = i32::from(*ptr0.add(20).cast::()); + + TlsAlertReceivedPayload { + alert_id: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = i32::from( + *ptr0.add(17).cast::(), + ); + + l10 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = + *ptr0.add(24).cast::<*mut u8>(); + let l13 = *ptr0.add(28).cast::(); + let len14 = l13; + let bytes14 = _rt::Vec::from_raw_parts( + l12.cast(), + len14, + len14, + ); + + _rt::string_lift(bytes14) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e64) + } + 15 => ErrorCode::HttpRequestDenied, + 16 => ErrorCode::HttpRequestLengthRequired, + 17 => { + let e64 = { + let l15 = i32::from(*ptr0.add(16).cast::()); + + match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *ptr0.add(24).cast::(); + + l16 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e64) + } + 18 => ErrorCode::HttpRequestMethodInvalid, + 19 => ErrorCode::HttpRequestUriInvalid, + 20 => ErrorCode::HttpRequestUriTooLong, + 21 => { + let e64 = { + let l17 = i32::from(*ptr0.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr0.add(20).cast::(); + + l18 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e64) + } + 22 => { + let e64 = { + let l19 = i32::from(*ptr0.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = + i32::from(*ptr0.add(20).cast::()); + let l24 = + i32::from(*ptr0.add(32).cast::()); + + FieldSizePayload { + field_name: match l20 { + 0 => None, + 1 => { + let e = { + let l21 = *ptr0 + .add(24) + .cast::<*mut u8>( + ); + let l22 = *ptr0 + .add(28) + .cast::(); + let len23 = l22; + let bytes23 = _rt::Vec::from_raw_parts(l21.cast(), len23, len23); + + _rt::string_lift(bytes23) + }; + Some(e) + } + _ => { + _rt::invalid_enum_discriminant() + } + }, + field_size: match l24 { + 0 => None, + 1 => { + let e = { + let l25 = *ptr0 + .add(36) + .cast::(); + + l25 as u32 + }; + Some(e) + } + _ => { + _rt::invalid_enum_discriminant() + } + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e64) + } + 23 => { + let e64 = { + let l26 = i32::from(*ptr0.add(16).cast::()); + + match l26 { + 0 => None, + 1 => { + let e = { + let l27 = *ptr0.add(20).cast::(); + + l27 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e64) + } + 24 => { + let e64 = { + let l28 = i32::from(*ptr0.add(16).cast::()); + let l32 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l28 { + 0 => None, + 1 => { + let e = { + let l29 = + *ptr0.add(20).cast::<*mut u8>(); + let l30 = *ptr0.add(24).cast::(); + let len31 = l30; + let bytes31 = _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ); + + _rt::string_lift(bytes31) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l32 { + 0 => None, + 1 => { + let e = { + let l33 = *ptr0.add(32).cast::(); + + l33 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e64) + } + 25 => ErrorCode::HttpResponseIncomplete, + 26 => { + let e64 = { + let l34 = i32::from(*ptr0.add(16).cast::()); + + match l34 { + 0 => None, + 1 => { + let e = { + let l35 = *ptr0.add(20).cast::(); + + l35 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e64) + } + 27 => { + let e64 = { + let l36 = i32::from(*ptr0.add(16).cast::()); + let l40 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l36 { + 0 => None, + 1 => { + let e = { + let l37 = + *ptr0.add(20).cast::<*mut u8>(); + let l38 = *ptr0.add(24).cast::(); + let len39 = l38; + let bytes39 = _rt::Vec::from_raw_parts( + l37.cast(), + len39, + len39, + ); + + _rt::string_lift(bytes39) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l40 { + 0 => None, + 1 => { + let e = { + let l41 = *ptr0.add(32).cast::(); + + l41 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e64) + } + 28 => { + let e64 = { + let l42 = i32::from(*ptr0.add(16).cast::()); + + match l42 { + 0 => None, + 1 => { + let e = { + let l43 = *ptr0.add(24).cast::(); + + l43 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e64) + } + 29 => { + let e64 = { + let l44 = i32::from(*ptr0.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr0.add(20).cast::(); + + l45 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e64) + } + 30 => { + let e64 = { + let l46 = i32::from(*ptr0.add(16).cast::()); + let l50 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload { + field_name: match l46 { + 0 => None, + 1 => { + let e = { + let l47 = + *ptr0.add(20).cast::<*mut u8>(); + let l48 = *ptr0.add(24).cast::(); + let len49 = l48; + let bytes49 = _rt::Vec::from_raw_parts( + l47.cast(), + len49, + len49, + ); + + _rt::string_lift(bytes49) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l50 { + 0 => None, + 1 => { + let e = { + let l51 = *ptr0.add(32).cast::(); + + l51 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e64) + } + 31 => { + let e64 = { + let l52 = i32::from(*ptr0.add(16).cast::()); + + match l52 { + 0 => None, + 1 => { + let e = { + let l53 = *ptr0.add(20).cast::<*mut u8>(); + let l54 = *ptr0.add(24).cast::(); + let len55 = l54; + let bytes55 = _rt::Vec::from_raw_parts( + l53.cast(), + len55, + len55, + ); + + _rt::string_lift(bytes55) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e64) + } + 32 => { + let e64 = { + let l56 = i32::from(*ptr0.add(16).cast::()); + + match l56 { + 0 => None, + 1 => { + let e = { + let l57 = *ptr0.add(20).cast::<*mut u8>(); + let l58 = *ptr0.add(24).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e64) + } + 33 => ErrorCode::HttpResponseTimeout, + 34 => ErrorCode::HttpUpgradeFailed, + 35 => ErrorCode::HttpProtocolError, + 36 => ErrorCode::LoopDetected, + 37 => ErrorCode::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e64 = { + let l60 = i32::from(*ptr0.add(16).cast::()); + + match l60 { + 0 => None, + 1 => { + let e = { + let l61 = *ptr0.add(20).cast::<*mut u8>(); + let l62 = *ptr0.add(24).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts( + l61.cast(), + len63, + len63, + ); + + _rt::string_lift(bytes63) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e64) + } + }; + + v64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } } - GetWorkers::from_handle(ret as u32) - } - } - } - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn get_next(&self,) -> Option>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[method]get-workers.get-next"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base27 = l2; - let len27 = l3; - let mut result27 = Vec::with_capacity(len27 as usize); - for i in 0..len27 { - let base = base27 + i * 64; - let e27 = { - let l4 = *((base + 0) as *const i64); - let l5 = *((base + 8) as *const i64); - let l6 = *((base + 16) as *const i32); - let l7 = *((base + 20) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - let l9 = *((base + 24) as *const i32); - let l10 = *((base + 28) as *const i32); - let base14 = l9; - let len14 = l10; - let mut result14 = Vec::with_capacity(len14 as usize); - for i in 0..len14 { - let base = base14 + i * 8; - let e14 = { - let l11 = *((base + 0) as *const i32); - let l12 = *((base + 4) as *const i32); - let len13 = l12 as usize; - let bytes13 = Vec::from_raw_parts(l11 as *mut _, len13, len13); - - wit_bindgen::rt::string_lift(bytes13) - }; - result14.push(e14); - } - wit_bindgen::rt::dealloc(base14, (len14 as usize) * 8, 4); - let l15 = *((base + 32) as *const i32); - let l16 = *((base + 36) as *const i32); - let base23 = l15; - let len23 = l16; - let mut result23 = Vec::with_capacity(len23 as usize); - for i in 0..len23 { - let base = base23 + i * 16; - let e23 = { - let l17 = *((base + 0) as *const i32); - let l18 = *((base + 4) as *const i32); - let len19 = l18 as usize; - let bytes19 = Vec::from_raw_parts(l17 as *mut _, len19, len19); - let l20 = *((base + 8) as *const i32); - let l21 = *((base + 12) as *const i32); - let len22 = l21 as usize; - let bytes22 = Vec::from_raw_parts(l20 as *mut _, len22, len22); - - (wit_bindgen::rt::string_lift(bytes19), wit_bindgen::rt::string_lift(bytes22)) - }; - result23.push(e23); - } - wit_bindgen::rt::dealloc(base23, (len23 as usize) * 16, 4); - let l24 = i32::from(*((base + 40) as *const u8)); - let l25 = *((base + 48) as *const i64); - let l26 = *((base + 56) as *const i64); - - WorkerMetadata{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l4 as u64, - low_bits: l5 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes8), - }, - args: result14, - env: result23, - status: WorkerStatus::_lift(l24 as u8), - component_version: l25 as u64, - retry_count: l26 as u64, - } - }; - result27.push(e27); - } - wit_bindgen::rt::dealloc(base27, (len27 as usize) * 64, 8); - - result27 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an empty HTTP Fields. + /// + /// The resulting `fields` is mutable. + pub fn new() -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]fields"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + Fields::from_handle(ret as u32) + } + } } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a new promise - pub fn golem_create_promise() -> PromiseId{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-create-promise"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i32); - let l4 = *((ptr0 + 20) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((ptr0 + 24) as *const i64); - PromiseId{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes5), - }, - oplog_idx: l6 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - pub fn golem_await_promise(promise_id: &PromiseId,) -> 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 PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let ptr5 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-await-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5); - let l6 = *((ptr5 + 0) as *const i32); - let l7 = *((ptr5 + 4) as *const i32); - let len8 = l7 as usize; - Vec::from_raw_parts(l6 as *mut _, len8, len8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - pub fn golem_complete_promise(promise_id: &PromiseId,data: &[u8],) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = data; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-complete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5, len5); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Deletes the given promise - pub fn golem_delete_promise(promise_id: &PromiseId,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-delete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - pub fn get_self_uri(function_name: &str,) -> Uri{ - - #[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 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-self-uri"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes4), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the current position in the persistent op log - pub fn get_oplog_index() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-index"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - pub fn set_oplog_index(oplog_idx: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-index"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(oplog_idx)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - pub fn oplog_commit(replicas: u8,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "oplog-commit"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(replicas)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - pub fn mark_begin_operation() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-begin-operation"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - pub fn mark_end_operation(begin: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-end-operation"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(begin)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current retry policy associated with the worker - pub fn get_retry_policy() -> RetryPolicy{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-retry-policy"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i32); - RetryPolicy{ - max_attempts: l1 as u32, - min_delay: l2 as u64, - max_delay: l3 as u64, - multiplier: l4 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - pub fn set_retry_policy(new_retry_policy: RetryPolicy,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RetryPolicy{ max_attempts:max_attempts0, min_delay:min_delay0, max_delay:max_delay0, multiplier:multiplier0, } = new_retry_policy; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-retry-policy"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(max_attempts0), wit_bindgen::rt::as_i64(min_delay0), wit_bindgen::rt::as_i64(max_delay0), wit_bindgen::rt::as_i32(multiplier0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the worker's current persistence level. - pub fn get_oplog_persistence_level() -> PersistenceLevel{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-persistence-level"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - let v0 = match ret { - 0 => { - PersistenceLevel::PersistNothing - } - 1 => { - PersistenceLevel::PersistRemoteSideEffects - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - PersistenceLevel::Smart - } - }; - v0 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let result0 = match new_persistence_level { - PersistenceLevel::PersistNothing=> { - 0i32 - } - PersistenceLevel::PersistRemoteSideEffects=> { - 1i32 - } - PersistenceLevel::Smart=> { - 2i32 - } - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-persistence-level"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(result0); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - pub fn get_idempotence_mode() -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-idempotence-mode"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - pub fn set_idempotence_mode(idempotent: bool,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-idempotence-mode"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(match idempotent { true => 1, false => 0 }); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - pub fn generate_idempotency_key() -> Uuid{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "generate-idempotency-key"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - pub fn update_worker(worker_id: &WorkerId,target_version: ComponentVersion,mode: UpdateMode,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let WorkerId{ component_id:component_id0, worker_name:worker_name0, } = worker_id; - let ComponentId{ uuid:uuid1, } = component_id0; - let Uuid{ high_bits:high_bits2, low_bits:low_bits2, } = uuid1; - let vec3 = worker_name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "update-worker"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits2), wit_bindgen::rt::as_i64(low_bits2), ptr3, len3, wit_bindgen::rt::as_i64(target_version), mode.clone() as i32); - } - } - - } - - } - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() - } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() - } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() - } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() - } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() - } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() - } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() - } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() - } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() - } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec9 = function_params; - let len9 = vec9.len() as i32; - let layout9 = alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); - let result9 = if layout9.size() != 0 - { - let ptr = alloc::alloc(layout9); - if ptr.is_null() - { - alloc::handle_alloc_error(layout9); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec8 = nodes1; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 24, 8); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an HTTP Fields. + /// + /// The resulting `fields` is mutable. + /// + /// The list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + /// + /// The tuple is a pair of the field key, represented as a string, and + /// Value, represented as a list of bytes. In a valid Fields, all keys + /// and values are valid UTF-8 strings. However, values are not always + /// well-formed, so they are represented as a raw list of bytes. + /// + /// An error result will be returned if any header or value was + /// syntactically invalid, or if a header was forbidden. + pub fn from_list( + entries: &[(FieldKey, FieldValue)], + ) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec3 = entries; + let len3 = vec3.len(); + let layout3 = + _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); } - }, - };}, - WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() + ptr + } else { { - alloc::handle_alloc_error(layout4); + ::core::ptr::null_mut() } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 16); { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + let (t0_0, t0_1) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + let vec2 = t0_1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - } + } + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]fields.from-list"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result3, len3, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + if layout3.size() != 0 { + _rt::alloc::dealloc(result3.cast(), layout3); + } + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::(); + + Fields::from_handle(l6 as u32) + }; + Ok(e) } - } - *((base + 4) as *mut i32) = len8; - *((base + 0) as *mut i32) = result8 as i32; - cleanup_list.extend_from_slice(&[(result8, layout8),]); - } - } - let ptr10 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result9 as i32, len9, ptr10); - let l11 = i32::from(*((ptr10 + 0) as *const u8)); - if layout9.size() != 0 { - alloc::dealloc(result9, layout9); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l11 { - 0 => { - let e = { - let l12 = *((ptr10 + 4) as *const i32); - let l13 = *((ptr10 + 8) as *const i32); - let base55 = l12; - let len55 = l13; - let mut result55 = Vec::with_capacity(len55 as usize); - for i in 0..len55 { - let base = base55 + i * 24; - let e55 = { - let l14 = i32::from(*((base + 0) as *const u8)); - let v54 = match l14 { - 0 => { - let e54 = { - let l15 = *((base + 8) as *const i32); - let l16 = *((base + 12) as *const i32); - let len17 = l16 as usize; - - Vec::from_raw_parts(l15 as *mut _, len17, len17) - }; - WitNode::RecordValue(e54) - } - 1 => { - let e54 = { - let l18 = *((base + 8) as *const i32); - let l19 = i32::from(*((base + 12) as *const u8)); - - (l18 as u32, match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *((base + 16) as *const i32); - - l20 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }) - }; - WitNode::VariantValue(e54) - } - 2 => { - let e54 = { - let l21 = *((base + 8) as *const i32); - - l21 as u32 - }; - WitNode::EnumValue(e54) - } - 3 => { - let e54 = { - let l22 = *((base + 8) as *const i32); - let l23 = *((base + 12) as *const i32); - let base25 = l22; - let len25 = l23; - let mut result25 = Vec::with_capacity(len25 as usize); - for i in 0..len25 { - let base = base25 + i * 1; - let e25 = { - let l24 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l24 as u8) - }; - result25.push(e25); - } - wit_bindgen::rt::dealloc(base25, (len25 as usize) * 1, 1); - - result25 - }; - WitNode::FlagsValue(e54) - } - 4 => { - let e54 = { - let l26 = *((base + 8) as *const i32); - let l27 = *((base + 12) as *const i32); - let len28 = l27 as usize; - - Vec::from_raw_parts(l26 as *mut _, len28, len28) - }; - WitNode::TupleValue(e54) - } - 5 => { - let e54 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::ListValue(e54) - } - 6 => { - let e54 = { - let l32 = i32::from(*((base + 8) as *const u8)); - - match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *((base + 12) as *const i32); - - l33 - }; - Some(e) + 1 => { + let e = { + let l7 = i32::from(*ptr4.add(4).cast::()); + let v8 = match l7 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } }; - WitNode::OptionValue(e54) - } - 7 => { - let e54 = { - let l34 = i32::from(*((base + 8) as *const u8)); - - match l34 { - 0 => { - let e = { - let l35 = i32::from(*((base + 12) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((base + 16) as *const i32); - - l36 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = { - let l37 = i32::from(*((base + 12) as *const u8)); - - match l37 { - 0 => None, - 1 => { - let e = { - let l38 = *((base + 16) as *const i32); - - l38 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - Err(e) + + v8 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Get all of the values corresponding to a key. If the key is not present + /// in this `fields`, an empty list is returned. However, if the key is + /// present but empty, this is represented by a list with one or more + /// empty field-values present. + pub fn get(&self, name: &FieldKey) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.get"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + result7 + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Returns `true` when the key is present in this `fields`. If the key is + /// syntactically invalid, `false` is returned. + pub fn has(&self, name: &FieldKey) -> bool { + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.has"] + fn wit_import(_: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); + _rt::bool_lift(ret as u8) + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Set all of the values for a key. Clears any existing values for that + /// key, if they have been set. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn set( + &self, + name: &FieldKey, + value: &[FieldValue], + ) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec2 = value; + let len2 = vec2.len(); + let layout2 = + _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + } + } + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.set"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result2, + len2, + ptr3, + ); + let l4 = i32::from(*ptr3.add(0).cast::()); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(1).cast::()); + let v6 = match l5 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e54) - } - 8 => { - let e54 = { - let l39 = i32::from(*((base + 8) as *const u8)); - - l39 as u8 }; - WitNode::PrimU8(e54) - } - 9 => { - let e54 = { - let l40 = i32::from(*((base + 8) as *const u16)); - - l40 as u16 - }; - WitNode::PrimU16(e54) - } - 10 => { - let e54 = { - let l41 = *((base + 8) as *const i32); - - l41 as u32 - }; - WitNode::PrimU32(e54) - } - 11 => { - let e54 = { - let l42 = *((base + 8) as *const i64); - - l42 as u64 - }; - WitNode::PrimU64(e54) - } - 12 => { - let e54 = { - let l43 = i32::from(*((base + 8) as *const i8)); - - l43 as i8 - }; - WitNode::PrimS8(e54) - } - 13 => { - let e54 = { - let l44 = i32::from(*((base + 8) as *const i16)); - - l44 as i16 - }; - WitNode::PrimS16(e54) - } - 14 => { - let e54 = { - let l45 = *((base + 8) as *const i32); - - l45 - }; - WitNode::PrimS32(e54) - } - 15 => { - let e54 = { - let l46 = *((base + 8) as *const i64); - - l46 - }; - WitNode::PrimS64(e54) - } - 16 => { - let e54 = { - let l47 = *((base + 8) as *const f32); - - l47 - }; - WitNode::PrimFloat32(e54) - } - 17 => { - let e54 = { - let l48 = *((base + 8) as *const f64); - - l48 - }; - WitNode::PrimFloat64(e54) - } - 18 => { - let e54 = { - let l49 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l49 as u32) - }; - WitNode::PrimChar(e54) - } - 19 => { - let e54 = { - let l50 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l50 as u8) - }; - WitNode::PrimBool(e54) - } - n => { - debug_assert_eq!(n, 20, "invalid enum discriminant"); - let e54 = { - let l51 = *((base + 8) as *const i32); - let l52 = *((base + 12) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) + + v6 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Delete all values for a key. Does nothing if no values for the key + /// exist. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn delete(&self, name: &FieldKey) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.delete"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + let v4 = match l3 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } }; - WitNode::PrimString(e54) - } + + v4 }; - - v54 - }; - result55.push(e55); - } - wit_bindgen::rt::dealloc(base55, (len55 as usize) * 24, 8); - - WitValue{ - nodes: result55, + Err(e) } - }; - Ok(e) - } - 1 => { - let e = { - let l56 = i32::from(*((ptr10 + 4) as *const u8)); - let v69 = match l56 { - 0 => { - let e69 = { - let l57 = *((ptr10 + 8) as *const i32); - let l58 = *((ptr10 + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - RpcError::ProtocolError(e69) - } - 1 => { - let e69 = { - let l60 = *((ptr10 + 8) as *const i32); - let l61 = *((ptr10 + 12) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) - }; - RpcError::Denied(e69) - } - 2 => { - let e69 = { - let l63 = *((ptr10 + 8) as *const i32); - let l64 = *((ptr10 + 12) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - RpcError::NotFound(e69) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e69 = { - let l66 = *((ptr10 + 8) as *const i32); - let l67 = *((ptr10 + 12) as *const i32); - let len68 = l67 as usize; - let bytes68 = Vec::from_raw_parts(l66 as *mut _, len68, len68); - - wit_bindgen::rt::string_lift(bytes68) - }; - RpcError::RemoteInternalError(e69) - } - }; - - v69 - }; - Err(e) + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - - } - - } - } - pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; + } + impl Fields { #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; + /// Append a value for a key. Does not change or delete any existing + /// values for that key. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn append( + &self, + name: &FieldKey, + value: &FieldValue, + ) -> Result<(), HeaderError> { + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = value; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.append"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + ptr1.cast_mut(), + len1, + ptr2, + ); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + let v5 = match l4 { + 0 => HeaderError::InvalidSyntax, + 1 => HeaderError::Forbidden, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } } + } + impl Fields { #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; + /// Retrieve the full set of keys and values in the Fields. Like the + /// constructor, the list represents each key-value pair. + /// + /// The outer list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + pub fn entries(&self) -> _rt::Vec<(FieldKey, FieldValue)> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.entries"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base9 = l1; + let len9 = l2; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 16); + let e9 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let len8 = l7; + + ( + _rt::string_lift(bytes5), + _rt::Vec::from_raw_parts(l6.cast(), len8, len8), + ) + }; + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 16, 4); + result9 } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } } + } + impl Fields { #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the specified instant - /// occured. - pub fn subscribe_instant(when: Instant,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import(_: i64, ) -> i32; + /// Make a deep copy of the Fields. Equivelant in behavior to calling the + /// `fields` constructor on the return value of `entries`. The resulting + /// `fields` is mutable. + pub fn clone(&self) -> Fields { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.clone"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } + } + impl IncomingRequest { #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. - pub fn subscribe_duration(when: Duration,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import(_: i64, ) -> i32; + /// Returns the method of the incoming request. + pub fn method(&self) -> Method { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.method"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + let v5 = match l1 { + 0 => Method::Get, + 1 => Method::Head, + 2 => Method::Post, + 3 => Method::Put, + 4 => Method::Delete, + 5 => Method::Connect, + 6 => Method::Options, + 7 => Method::Trace, + 8 => Method::Patch, + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) + } + }; + v5 } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - - } - } - pub mod http { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type IoError = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// This type corresponds to HTTP standard Methods. - #[derive(Clone)] - pub enum Method{ - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(wit_bindgen::rt::string::String), - } - 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() - } - } - } - } - /// This type corresponds to HTTP standard Related Schemes. - #[derive(Clone)] - pub enum Scheme{ - Http, - Https, - Other(wit_bindgen::rt::string::String), - } - 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() - } - } - } - } - /// Defines the case payload type for `DNS-error` above: - #[derive(Clone)] - pub struct DnsErrorPayload { - pub rcode: Option, - pub info_code: Option, - } - impl ::core::fmt::Debug for DnsErrorPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DnsErrorPayload").field("rcode", &self.rcode).field("info-code", &self.info_code).finish() - } - } - /// Defines the case payload type for `TLS-alert-received` above: - #[derive(Clone)] - pub struct TlsAlertReceivedPayload { - pub alert_id: Option, - pub alert_message: Option, - } - impl ::core::fmt::Debug for TlsAlertReceivedPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("TlsAlertReceivedPayload").field("alert-id", &self.alert_id).field("alert-message", &self.alert_message).finish() - } - } - /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: - #[derive(Clone)] - pub struct FieldSizePayload { - pub field_name: Option, - pub field_size: Option, - } - impl ::core::fmt::Debug for FieldSizePayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FieldSizePayload").field("field-name", &self.field_name).field("field-size", &self.field_size).finish() - } - } - /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types - #[derive(Clone)] - pub enum ErrorCode{ - DnsTimeout, - DnsError(DnsErrorPayload), - DestinationNotFound, - DestinationUnavailable, - DestinationIpProhibited, - DestinationIpUnroutable, - ConnectionRefused, - ConnectionTerminated, - ConnectionTimeout, - ConnectionReadTimeout, - ConnectionWriteTimeout, - ConnectionLimitReached, - TlsProtocolError, - TlsCertificateError, - TlsAlertReceived(TlsAlertReceivedPayload), - HttpRequestDenied, - HttpRequestLengthRequired, - HttpRequestBodySize(Option), - HttpRequestMethodInvalid, - HttpRequestUriInvalid, - HttpRequestUriTooLong, - HttpRequestHeaderSectionSize(Option), - HttpRequestHeaderSize(Option), - HttpRequestTrailerSectionSize(Option), - HttpRequestTrailerSize(FieldSizePayload), - HttpResponseIncomplete, - HttpResponseHeaderSectionSize(Option), - HttpResponseHeaderSize(FieldSizePayload), - HttpResponseBodySize(Option), - HttpResponseTrailerSectionSize(Option), - HttpResponseTrailerSize(FieldSizePayload), - HttpResponseTransferCoding(Option), - HttpResponseContentCoding(Option), - HttpResponseTimeout, - HttpUpgradeFailed, - HttpProtocolError, - LoopDetected, - ConfigurationError, - /// This is a catch-all error for anything that doesn't fit cleanly into a - /// more specific case. It also includes an optional string for an - /// unstructured description of the error. Users should not depend on the - /// string for diagnosing errors, as it's not required to be consistent - /// between implementations. - InternalError(Option), - } - impl ::core::fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - ErrorCode::DnsTimeout => { - f.debug_tuple("ErrorCode::DnsTimeout").finish() - } - ErrorCode::DnsError(e) => { - f.debug_tuple("ErrorCode::DnsError").field(e).finish() - } - ErrorCode::DestinationNotFound => { - f.debug_tuple("ErrorCode::DestinationNotFound").finish() - } - ErrorCode::DestinationUnavailable => { - f.debug_tuple("ErrorCode::DestinationUnavailable").finish() - } - ErrorCode::DestinationIpProhibited => { - f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() - } - ErrorCode::DestinationIpUnroutable => { - f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() - } - ErrorCode::ConnectionRefused => { - f.debug_tuple("ErrorCode::ConnectionRefused").finish() - } - ErrorCode::ConnectionTerminated => { - f.debug_tuple("ErrorCode::ConnectionTerminated").finish() - } - ErrorCode::ConnectionTimeout => { - f.debug_tuple("ErrorCode::ConnectionTimeout").finish() - } - ErrorCode::ConnectionReadTimeout => { - f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() - } - ErrorCode::ConnectionWriteTimeout => { - f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() - } - ErrorCode::ConnectionLimitReached => { - f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() - } - ErrorCode::TlsProtocolError => { - f.debug_tuple("ErrorCode::TlsProtocolError").finish() - } - ErrorCode::TlsCertificateError => { - f.debug_tuple("ErrorCode::TlsCertificateError").finish() - } - ErrorCode::TlsAlertReceived(e) => { - f.debug_tuple("ErrorCode::TlsAlertReceived").field(e).finish() - } - ErrorCode::HttpRequestDenied => { - f.debug_tuple("ErrorCode::HttpRequestDenied").finish() - } - ErrorCode::HttpRequestLengthRequired => { - f.debug_tuple("ErrorCode::HttpRequestLengthRequired").finish() - } - ErrorCode::HttpRequestBodySize(e) => { - f.debug_tuple("ErrorCode::HttpRequestBodySize").field(e).finish() - } - ErrorCode::HttpRequestMethodInvalid => { - f.debug_tuple("ErrorCode::HttpRequestMethodInvalid").finish() - } - ErrorCode::HttpRequestUriInvalid => { - f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() - } - ErrorCode::HttpRequestUriTooLong => { - f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() - } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize").field(e).finish() - } - ErrorCode::HttpRequestHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSize").field(e).finish() - } - ErrorCode::HttpRequestTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSectionSize").field(e).finish() - } - ErrorCode::HttpRequestTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSize").field(e).finish() - } - ErrorCode::HttpResponseIncomplete => { - f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() - } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSectionSize").field(e).finish() - } - ErrorCode::HttpResponseHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSize").field(e).finish() - } - ErrorCode::HttpResponseBodySize(e) => { - f.debug_tuple("ErrorCode::HttpResponseBodySize").field(e).finish() - } - ErrorCode::HttpResponseTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSectionSize").field(e).finish() - } - ErrorCode::HttpResponseTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSize").field(e).finish() - } - ErrorCode::HttpResponseTransferCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseTransferCoding").field(e).finish() - } - ErrorCode::HttpResponseContentCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseContentCoding").field(e).finish() - } - ErrorCode::HttpResponseTimeout => { - f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() - } - ErrorCode::HttpUpgradeFailed => { - f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() - } - ErrorCode::HttpProtocolError => { - f.debug_tuple("ErrorCode::HttpProtocolError").finish() - } - ErrorCode::LoopDetected => { - f.debug_tuple("ErrorCode::LoopDetected").finish() - } - ErrorCode::ConfigurationError => { - f.debug_tuple("ErrorCode::ConfigurationError").finish() - } - ErrorCode::InternalError(e) => { - f.debug_tuple("ErrorCode::InternalError").field(e).finish() - } - } - } - } - impl ::core::fmt::Display for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for ErrorCode {} - /// This type enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. - #[derive(Clone, Copy)] - pub enum HeaderError{ - /// This error indicates that a `field-key` or `field-value` was - /// syntactically invalid when used with an operation that sets headers in a - /// `fields`. - InvalidSyntax, - /// This error indicates that a forbidden `field-key` was used when trying - /// to set a header in a `fields`. - Forbidden, - /// This error indicates that the operation on the `fields` was not - /// permitted because the fields are immutable. - Immutable, - } - impl ::core::fmt::Debug for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - HeaderError::InvalidSyntax => { - f.debug_tuple("HeaderError::InvalidSyntax").finish() - } - HeaderError::Forbidden => { - f.debug_tuple("HeaderError::Forbidden").finish() - } - HeaderError::Immutable => { - f.debug_tuple("HeaderError::Immutable").finish() - } - } - } - } - impl ::core::fmt::Display for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for HeaderError {} - /// Field keys are always strings. - pub type FieldKey = wit_bindgen::rt::string::String; - /// Field values should always be ASCII strings. However, in - /// reality, HTTP implementations often have to interpret malformed values, - /// so they are provided as a list of bytes. - pub type FieldValue = wit_bindgen::rt::vec::Vec::; - /// This following block defines the `fields` resource which corresponds to - /// HTTP standard Fields. Fields are a common representation used for both - /// Headers and Trailers. - /// - /// A `fields` may be mutable or immutable. A `fields` created using the - /// constructor, `from-list`, or `clone` will be mutable, but a `fields` - /// resource given by other means (including, but not limited to, - /// `incoming-request.headers`, `outgoing-request.headers`) might be be - /// immutable. In an immutable fields, the `set`, `append`, and `delete` - /// operations will fail with `header-error.immutable`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Fields{ - handle: wit_bindgen::rt::Resource, - } - - impl Fields{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Fields{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]fields"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Headers is an alias for Fields. - pub type Headers = Fields; - /// Trailers is an alias for Fields. - pub type Trailers = Fields; - /// Represents an incoming HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingRequest{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingRequest{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingRequest{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingRequest{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Parameters for making an HTTP Request. Each of these parameters is - /// currently an optional timeout applicable to the transport layer of the - /// HTTP protocol. - /// - /// These timeouts are separate from any the user may use to bound a - /// blocking call to `wasi:io/poll.poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct RequestOptions{ - handle: wit_bindgen::rt::Resource, - } - - impl RequestOptions{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for RequestOptions{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]request-options"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents the ability to send an HTTP Response. - /// - /// This resource is used by the `wasi:http/incoming-handler` interface to - /// allow a Response to be sent corresponding to the Request provided as the - /// other argument to `incoming-handler.handle`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct ResponseOutparam{ - handle: wit_bindgen::rt::Resource, - } - - impl ResponseOutparam{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for ResponseOutparam{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]response-outparam"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// This type corresponds to the HTTP standard Status Code. - pub type StatusCode = u16; - /// Represents an incoming HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an incoming HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, indicating that the full contents of the - /// body have been received. This resource represents the contents as - /// an `input-stream` and the delivery of trailers as a `future-trailers`, - /// and ensures that the user of this interface may only be consuming either - /// the body contents or waiting on trailers at any given time. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingBody{ - handle: wit_bindgen::rt::Resource, - } - - impl IncomingBody{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for IncomingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return trailers, or an error. - /// - /// In the case that the incoming HTTP Request or Response did not have any - /// trailers, this future will resolve to the empty set of trailers once the - /// complete Request or Response body has been received. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureTrailers{ - handle: wit_bindgen::rt::Resource, - } - - impl FutureTrailers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for FutureTrailers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-trailers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, inducating the full contents of the body - /// have been sent. This resource represents the contents as an - /// `output-stream` child resource, and the completion of the body (with - /// optional trailers) with a static function that consumes the - /// `outgoing-body` resource, and ensures that the user of this interface - /// may not write to the body contents after the body has been finished. - /// - /// If the user code drops this resource, as opposed to calling the static - /// method `finish`, the implementation should treat the body as incomplete, - /// and that an error has occured. The implementation should propogate this - /// error to the HTTP protocol by whatever means it has available, - /// including: corrupting the body on the wire, aborting the associated - /// Request, or sending a late status code for the Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingBody{ - handle: wit_bindgen::rt::Resource, - } - - impl OutgoingBody{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutgoingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return an incoming HTTP - /// Response, or an error. - /// - /// This resource is returned by the `wasi:http/outgoing-handler` interface to - /// provide the HTTP Response corresponding to the sent Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureIncomingResponse{ - handle: wit_bindgen::rt::Resource, - } - - impl FutureIncomingResponse{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for FutureIncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-incoming-response"] - fn drop(_: u32); - } - - drop(_handle); + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the path with query parameters from the request, as a string. + pub fn path_with_query(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.path-with-query"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - } } - + } + impl IncomingRequest { #[allow(unused_unsafe, clippy::all)] - /// Attempts to extract a http-related `error` from the wasi:io `error` - /// provided. - /// - /// Stream operations which return - /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of - /// type `wasi:io/error/error` with more information about the operation - /// that failed. This payload can be passed through to this function to see - /// if there's http-related information about the error to return. - /// - /// Note that this function is fallible because not all io-errors are - /// http-related errors. - pub fn http_error_code(err: &IoError,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "http-error-code"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((err).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - let v64 = match l2 { - 0 => { - ErrorCode::DnsTimeout - } + /// Returns the protocol scheme from the request. + pub fn scheme(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.scheme"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, 1 => { - let e64 = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - let l7 = i32::from(*((ptr0 + 28) as *const u8)); - - DnsErrorPayload{ - rcode: match l3 { - 0 => None, - 1 => { - let e = { - let l4 = *((ptr0 + 20) as *const i32); - let l5 = *((ptr0 + 24) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - wit_bindgen::rt::string_lift(bytes6) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - info_code: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = i32::from(*((ptr0 + 30) as *const u16)); - - l8 as u16 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e64) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout - } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError - } - 14 => { - let e64 = { - let l9 = i32::from(*((ptr0 + 16) as *const u8)); - let l11 = i32::from(*((ptr0 + 20) as *const u8)); - - TlsAlertReceivedPayload{ - alert_id: match l9 { - 0 => None, - 1 => { - let e = { - let l10 = i32::from(*((ptr0 + 17) as *const u8)); - - l10 as u8 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - alert_message: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *((ptr0 + 24) as *const i32); - let l13 = *((ptr0 + 28) as *const i32); - let len14 = l13 as usize; - let bytes14 = Vec::from_raw_parts(l12 as *mut _, len14, len14); - - wit_bindgen::rt::string_lift(bytes14) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e64) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e64 = { - let l15 = i32::from(*((ptr0 + 16) as *const u8)); - - match l15 { - 0 => None, - 1 => { - let e = { - let l16 = *((ptr0 + 24) as *const i64); - - l16 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e64) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e64 = { - let l17 = i32::from(*((ptr0 + 16) as *const u8)); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *((ptr0 + 20) as *const i32); - - l18 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e64) - } - 22 => { - let e64 = { - let l19 = i32::from(*((ptr0 + 16) as *const u8)); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = i32::from(*((ptr0 + 20) as *const u8)); - let l24 = i32::from(*((ptr0 + 32) as *const u8)); - - FieldSizePayload{ - field_name: match l20 { - 0 => None, - 1 => { - let e = { - let l21 = *((ptr0 + 24) as *const i32); - let l22 = *((ptr0 + 28) as *const i32); - let len23 = l22 as usize; - let bytes23 = Vec::from_raw_parts(l21 as *mut _, len23, len23); - - wit_bindgen::rt::string_lift(bytes23) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l24 { - 0 => None, - 1 => { - let e = { - let l25 = *((ptr0 + 36) as *const i32); - - l25 as u32 + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v6 = match l2 { + 0 => Scheme::Http, + 1 => Scheme::Https, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = + _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } + Scheme::Other(e6) + } }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e64) + + v6 + }; + Some(e) } - 23 => { - let e64 = { - let l26 = i32::from(*((ptr0 + 16) as *const u8)); - - match l26 { - 0 => None, - 1 => { - let e = { - let l27 = *((ptr0 + 20) as *const i32); - - l27 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e64) + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the authority from the request, if it was present. + pub fn authority(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.authority"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) } - 24 => { - let e64 = { - let l28 = i32::from(*((ptr0 + 16) as *const u8)); - let l32 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *((ptr0 + 20) as *const i32); - let l30 = *((ptr0 + 24) as *const i32); - let len31 = l30 as usize; - let bytes31 = Vec::from_raw_parts(l29 as *mut _, len31, len31); - - wit_bindgen::rt::string_lift(bytes31) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *((ptr0 + 32) as *const i32); - - l33 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e64) + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the `headers` associated with the request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// The `headers` returned are a child resource: it must be dropped before + /// the parent `incoming-request` is dropped. Dropping this + /// `incoming-request` before all children are dropped will trap. + pub fn headers(&self) -> Headers { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.headers"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Gives the `incoming-body` associated with this request. Will only + /// return success at most once, and subsequent calls will return error. + pub fn consume(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.consume"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) } - 25 => { - ErrorCode::HttpResponseIncomplete + 1 => { + let e = (); + Err(e) } - 26 => { - let e64 = { - let l34 = i32::from(*((ptr0 + 16) as *const u8)); - - match l34 { - 0 => None, - 1 => { - let e = { - let l35 = *((ptr0 + 20) as *const i32); - - l35 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e64) + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Construct a new `outgoing-request` with a default `method` of `GET`, and + /// `none` values for `path-with-query`, `scheme`, and `authority`. + /// + /// * `headers` is the HTTP Headers for the Request. + /// + /// It is possible to construct, or manipulate with the accessor functions + /// below, an `outgoing-request` with an invalid combination of `scheme` + /// and `authority`, or `headers` which are not permitted to be sent. + /// It is the obligation of the `outgoing-handler.handle` implementation + /// to reject invalid constructions of `outgoing-request`. + pub fn new(headers: Headers) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-request"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingRequest::from_handle(ret as u32) + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this + /// Request. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-request` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.body"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) + }; + Ok(e) } - 27 => { - let e64 = { - let l36 = i32::from(*((ptr0 + 16) as *const u8)); - let l40 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *((ptr0 + 20) as *const i32); - let l38 = *((ptr0 + 24) as *const i32); - let len39 = l38 as usize; - let bytes39 = Vec::from_raw_parts(l37 as *mut _, len39, len39); - - wit_bindgen::rt::string_lift(bytes39) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l40 { - 0 => None, - 1 => { - let e = { - let l41 = *((ptr0 + 32) as *const i32); - - l41 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e64) + 1 => { + let e = (); + Err(e) } - 28 => { - let e64 = { - let l42 = i32::from(*((ptr0 + 16) as *const u8)); - - match l42 { - 0 => None, - 1 => { - let e = { - let l43 = *((ptr0 + 24) as *const i64); - - l43 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e64) + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the Method for the Request. + pub fn method(&self) -> Method { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.method"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + let v5 = match l1 { + 0 => Method::Get, + 1 => Method::Head, + 2 => Method::Post, + 3 => Method::Put, + 4 => Method::Delete, + 5 => Method::Connect, + 6 => Method::Options, + 7 => Method::Trace, + 8 => Method::Patch, + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) } - 29 => { - let e64 = { - let l44 = i32::from(*((ptr0 + 16) as *const u8)); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *((ptr0 + 20) as *const i32); - - l45 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e64) + }; + v5 + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the Method for the Request. Fails if the string present in a + /// `method.other` argument is not a syntactically valid method. + pub fn set_method(&self, method: &Method) -> Result<(), ()> { + unsafe { + let (result1_0, result1_1, result1_2) = match method { + Method::Get => (0i32, ::core::ptr::null_mut(), 0usize), + Method::Head => (1i32, ::core::ptr::null_mut(), 0usize), + Method::Post => (2i32, ::core::ptr::null_mut(), 0usize), + Method::Put => (3i32, ::core::ptr::null_mut(), 0usize), + Method::Delete => (4i32, ::core::ptr::null_mut(), 0usize), + Method::Connect => (5i32, ::core::ptr::null_mut(), 0usize), + Method::Options => (6i32, ::core::ptr::null_mut(), 0usize), + Method::Trace => (7i32, ::core::ptr::null_mut(), 0usize), + Method::Patch => (8i32, ::core::ptr::null_mut(), 0usize), + Method::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (9i32, ptr0.cast_mut(), len0) } - 30 => { - let e64 = { - let l46 = i32::from(*((ptr0 + 16) as *const u8)); - let l50 = i32::from(*((ptr0 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *((ptr0 + 20) as *const i32); - let l48 = *((ptr0 + 24) as *const i32); - let len49 = l48 as usize; - let bytes49 = Vec::from_raw_parts(l47 as *mut _, len49, len49); - - wit_bindgen::rt::string_lift(bytes49) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l50 { - 0 => None, - 1 => { - let e = { - let l51 = *((ptr0 + 32) as *const i32); - - l51 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e64) + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-method"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) } - 31 => { - let e64 = { - let l52 = i32::from(*((ptr0 + 16) as *const u8)); - - match l52 { - 0 => None, - 1 => { - let e = { - let l53 = *((ptr0 + 20) as *const i32); - let l54 = *((ptr0 + 24) as *const i32); - let len55 = l54 as usize; - let bytes55 = Vec::from_raw_parts(l53 as *mut _, len55, len55); - - wit_bindgen::rt::string_lift(bytes55) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e64) + 1 => { + let e = (); + Err(e) } - 32 => { - let e64 = { - let l56 = i32::from(*((ptr0 + 16) as *const u8)); - - match l56 { - 0 => None, - 1 => { - let e = { - let l57 = *((ptr0 + 20) as *const i32); - let l58 = *((ptr0 + 24) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e64) + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. + pub fn path_with_query(&self) -> Option<_rt::String> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.path-with-query"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. Fails is the + /// string given is not a syntactically valid path and query uri component. + pub fn set_path_with_query(&self, path_with_query: Option<&str>) -> Result<(), ()> { + unsafe { + let (result1_0, result1_1, result1_2) = match path_with_query { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) } - 33 => { - ErrorCode::HttpResponseTimeout + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-path-with-query"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) } - 34 => { - ErrorCode::HttpUpgradeFailed + 1 => { + let e = (); + Err(e) } - 35 => { - ErrorCode::HttpProtocolError + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. + pub fn scheme(&self) -> Option { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.scheme"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v6 = match l2 { + 0 => Scheme::Http, + 1 => Scheme::Https, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = + _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Scheme::Other(e6) + } + }; + + v6 + }; + Some(e) } - 36 => { - ErrorCode::LoopDetected + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. Fails if the + /// string given is not a syntactically valid uri scheme. + pub fn set_scheme(&self, scheme: Option<&Scheme>) -> Result<(), ()> { + unsafe { + let (result2_0, result2_1, result2_2, result2_3) = match scheme { + Some(e) => { + let (result1_0, result1_1, result1_2) = match e { + Scheme::Http => (0i32, ::core::ptr::null_mut(), 0usize), + Scheme::Https => (1i32, ::core::ptr::null_mut(), 0usize), + Scheme::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (2i32, ptr0.cast_mut(), len0) + } + }; + + (1i32, result1_0, result1_1, result1_2) } - 37 => { - ErrorCode::ConfigurationError + None => (0i32, 0i32, ::core::ptr::null_mut(), 0usize), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-scheme"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + result2_0, + result2_1, + result2_2, + result2_3, + ); + match ret { + 0 => { + let e = (); + Ok(e) } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e64 = { - let l60 = i32::from(*((ptr0 + 16) as *const u8)); - - match l60 { - 0 => None, - 1 => { - let e = { - let l61 = *((ptr0 + 20) as *const i32); - let l62 = *((ptr0 + 24) as *const i32); - let len63 = l62 as usize; - let bytes63 = Vec::from_raw_parts(l61 as *mut _, len63, len63); - - wit_bindgen::rt::string_lift(bytes63) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e64) + 1 => { + let e = (); + Err(e) } - }; - - v64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an empty HTTP Fields. - /// - /// The resulting `fields` is mutable. - pub fn new() -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]fields"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - Fields::from_handle(ret as u32) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an HTTP Fields. - /// - /// The resulting `fields` is mutable. - /// - /// The list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - /// - /// The tuple is a pair of the field key, represented as a string, and - /// Value, represented as a list of bytes. In a valid Fields, all keys - /// and values are valid UTF-8 strings. However, values are not always - /// well-formed, so they are represented as a raw list of bytes. - /// - /// An error result will be returned if any header or value was - /// syntactically invalid, or if a header was forbidden. - pub fn from_list(entries: &[(FieldKey,FieldValue,)],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. + pub fn authority(&self) -> Option<_rt::String> { unsafe { - - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - 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); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.authority"] + fn wit_import(_: i32, _: *mut u8); } - 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; - } - } - let ptr4 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]fields.from-list"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result3 as i32, len3, ptr4); - let l5 = i32::from(*((ptr4 + 0) as *const u8)); - if layout3.size() != 0 { - alloc::dealloc(result3, layout3); - } - match l5 { - 0 => { - let e = { - let l6 = *((ptr4 + 4) as *const i32); - - Fields::from_handle(l6 as u32) - }; - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - 1 => { - let e = { - let l7 = i32::from(*((ptr4 + 4) as *const u8)); - let v8 = match l7 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v8 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Get all of the values corresponding to a key. If the key is not present - /// in this `fields`, an empty list is returned. However, if the key is - /// present but empty, this is represented by a list with one or more - /// empty field-values present. - pub fn get(&self,name: &FieldKey,) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. Fails if the string given is + /// not a syntactically valid uri authority. + pub fn set_authority(&self, authority: Option<&str>) -> Result<(), ()> { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.get"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let base7 = l2; - let len7 = l3; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 8; - let e7 = { - let l4 = *((base + 0) as *const i32); - let l5 = *((base + 4) as *const i32); - let len6 = l5 as usize; - - Vec::from_raw_parts(l4 as *mut _, len6, len6) + let (result1_0, result1_1, result1_2) = match authority { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), }; - result7.push(e7); - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 8, 4); - result7 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Returns `true` when the key is present in this `fields`. If the key is - /// syntactically invalid, `false` is returned. - pub fn has(&self,name: &FieldKey,) -> bool{ - - #[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; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.has"] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0, len0); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Set all of the values for a key. Clears any existing values for that - /// key, if they have been set. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn set(&self,name: &FieldKey,value: &[FieldValue],) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-authority"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = + wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self) -> Headers { unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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 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); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.headers"] + fn wit_import(_: i32) -> i32; } - 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; - } - } - let ptr3 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result2 as i32, len2, ptr3); - let l4 = i32::from(*((ptr3 + 0) as *const u8)); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - match l4 { - 0 => { - let e = (); - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - 1 => { - let e = { - let l5 = i32::from(*((ptr3 + 1) as *const u8)); - let v6 = match l5 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v6 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Delete all values for a key. Does nothing if no values for the key - /// exist. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn delete(&self,name: &FieldKey,) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Construct a default `request-options` value. + pub fn new() -> Self { unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.delete"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]request-options"] + fn wit_import() -> i32; } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 1) as *const u8)); - let v4 = match l3 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Append a value for a key. Does not change or delete any existing - /// values for that key. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn append(&self,name: &FieldKey,value: &FieldValue,) -> Result<(),HeaderError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + RequestOptions::from_handle(ret as u32) + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for the initial connect to the HTTP Server. + pub fn connect_timeout(&self) -> Option { unsafe { - - #[repr(align(1))] - struct RetArea([u8; 2]); - 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 vec1 = value; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let ptr2 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.append"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1, len1, ptr2); - let l3 = i32::from(*((ptr2 + 0) as *const u8)); - match l3 { - 0 => { - let e = (); - Ok(e) + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.connect-timeout"] + fn wit_import(_: i32, _: *mut u8); } - 1 => { - let e = { - let l4 = i32::from(*((ptr2 + 1) as *const u8)); - let v5 = match l4 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Retrieve the full set of keys and values in the Fields. Like the - /// constructor, the list represents each key-value pair. - /// - /// The outer list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - pub fn entries(&self,) -> wit_bindgen::rt::vec::Vec::<(FieldKey,FieldValue,)>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for the initial connect to the HTTP Server. An error + /// return value indicates that this timeout is not supported. + pub fn set_connect_timeout(&self, duration: Option) -> Result<(), ()> { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.entries"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let base9 = l1; - let len9 = l2; - let mut result9 = Vec::with_capacity(len9 as usize); - for i in 0..len9 { - let base = base9 + i * 16; - let e9 = { - let l3 = *((base + 0) as *const i32); - let l4 = *((base + 4) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((base + 8) as *const i32); - let l7 = *((base + 12) as *const i32); - let len8 = l7 as usize; - - (wit_bindgen::rt::string_lift(bytes5), Vec::from_raw_parts(l6 as *mut _, len8, len8)) + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), }; - result9.push(e9); - } - wit_bindgen::rt::dealloc(base9, (len9 as usize) * 16, 4); - result9 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Make a deep copy of the Fields. Equivelant in behavior to calling the - /// `fields` constructor on the return value of `entries`. The resulting - /// `fields` is mutable. - pub fn clone(&self,) -> Fields{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.clone"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the method of the incoming request. - pub fn method(&self,) -> Method{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.method"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - let v5 = match l1 { - 0 => { - Method::Get + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-connect-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; } - 1 => { - Method::Head + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() } - 2 => { - Method::Post + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - 3 => { - Method::Put + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving the first byte of the Response body. + pub fn first_byte_timeout(&self) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.first-byte-timeout"] + fn wit_import(_: i32, _: *mut u8); } - 4 => { - Method::Delete + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - 5 => { - Method::Connect + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), } - 6 => { - Method::Options + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving the first byte of the Response body. An + /// error return value indicates that this timeout is not supported. + pub fn set_first_byte_timeout(&self, duration: Option) -> Result<(), ()> { + unsafe { + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-first-byte-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; } - 7 => { - Method::Trace + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() } - 8 => { - Method::Patch + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the path with query parameters from the request, as a string. - pub fn path_with_query(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.path-with-query"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the protocol scheme from the request. - pub fn scheme(&self,) -> Option{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving subsequent chunks of bytes in the Response + /// body stream. + pub fn between_bytes_timeout(&self) -> Option { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.scheme"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v6 = match l2 { - 0 => { - Scheme::Http - } - 1 => { - Scheme::Https - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *((ptr0 + 8) as *const i32); - let l4 = *((ptr0 + 12) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.between-bytes-timeout"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 }; - Scheme::Other(e6) - } - }; - - v6 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the authority from the request, if it was present. - pub fn authority(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.authority"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the `headers` associated with the request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// The `headers` returned are a child resource: it must be dropped before - /// the parent `incoming-request` is dropped. Dropping this - /// `incoming-request` before all children are dropped will trap. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Gives the `incoming-body` associated with this request. Will only - /// return success at most once, and subsequent calls will return error. - pub fn consume(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.consume"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) + Some(e) + } + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Construct a new `outgoing-request` with a default `method` of `GET`, and - /// `none` values for `path-with-query`, `scheme`, and `authority`. - /// - /// * `headers` is the HTTP Headers for the Request. - /// - /// It is possible to construct, or manipulate with the accessor functions - /// below, an `outgoing-request` with an invalid combination of `scheme` - /// and `authority`, or `headers` which are not permitted to be sent. - /// It is the obligation of the `outgoing-handler.handle` implementation - /// to reject invalid constructions of `outgoing-request`. - pub fn new(headers: Headers,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving subsequent chunks of bytes in the Response + /// body stream. An error return value indicates that this timeout is not + /// supported. + pub fn set_between_bytes_timeout( + &self, + duration: Option, + ) -> Result<(), ()> { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-request"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((headers).into_handle() as i32); - OutgoingRequest::from_handle(ret as u32) - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this - /// Request. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-request` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + let (result0_0, result0_1) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-between-bytes-timeout"] + fn wit_import(_: i32, _: i32, _: i64) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl ResponseOutparam { + #[allow(unused_unsafe, clippy::all)] + /// Set the value of the `response-outparam` to either send a response, + /// or indicate an error. + /// + /// This method consumes the `response-outparam` to ensure that it is + /// called at most once. If it is never called, the implementation + /// will respond with an error. + /// + /// The user may provide an `error` to `response` to allow the + /// implementation determine how to respond with an HTTP error response. + pub fn set(param: ResponseOutparam, response: Result) { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.body"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) + let ( + result38_0, + result38_1, + result38_2, + result38_3, + result38_4, + result38_5, + result38_6, + result38_7, + ) = match &response { + Ok(e) => ( + 0i32, + (e).take_handle() as i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + Err(e) => { + let ( + result37_0, + result37_1, + result37_2, + result37_3, + result37_4, + result37_5, + result37_6, + ) = match e { + ErrorCode::DnsTimeout => ( + 0i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DnsError(e) => { + let DnsErrorPayload { + rcode: rcode0, + info_code: info_code0, + } = e; + let (result2_0, result2_1, result2_2) = match rcode0 { + Some(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (1i32, ptr1.cast_mut(), len1) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result3_0, result3_1) = match info_code0 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 1i32, + result2_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result2_1); + t + }, + result2_2 as *mut u8, + result3_0 as *mut u8, + result3_1 as usize, + 0i32, + ) + } + ErrorCode::DestinationNotFound => ( + 2i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationUnavailable => ( + 3i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationIpProhibited => ( + 4i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::DestinationIpUnroutable => ( + 5i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionRefused => ( + 6i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionTerminated => ( + 7i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionTimeout => ( + 8i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionReadTimeout => ( + 9i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionWriteTimeout => ( + 10i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConnectionLimitReached => ( + 11i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsProtocolError => ( + 12i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsCertificateError => ( + 13i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::TlsAlertReceived(e) => { + let TlsAlertReceivedPayload { + alert_id: alert_id4, + alert_message: alert_message4, + } = e; + let (result5_0, result5_1) = match alert_id4 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + let (result7_0, result7_1, result7_2) = match alert_message4 + { + Some(e) => { + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + + (1i32, ptr6.cast_mut(), len6) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 14i32, + result5_0, + ::core::mem::MaybeUninit::new( + i64::from(result5_1) as u64 + ), + result7_0 as *mut u8, + result7_1, + result7_2, + 0i32, + ) + } + ErrorCode::HttpRequestDenied => ( + 15i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestLengthRequired => ( + 16i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestBodySize(e) => { + let (result8_0, result8_1) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + ( + 17i32, + result8_0, + ::core::mem::MaybeUninit::new(result8_1 as u64), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestMethodInvalid => ( + 18i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestUriInvalid => ( + 19i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestUriTooLong => ( + 20i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpRequestHeaderSectionSize(e) => { + let (result9_0, result9_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 21i32, + result9_0, + ::core::mem::MaybeUninit::new( + i64::from(result9_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestHeaderSize(e) => { + let ( + result14_0, + result14_1, + result14_2, + result14_3, + result14_4, + result14_5, + ) = match e { + Some(e) => { + let FieldSizePayload { + field_name: field_name10, + field_size: field_size10, + } = e; + let (result12_0, result12_1, result12_2) = + match field_name10 { + Some(e) => { + let vec11 = e; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + + (1i32, ptr11.cast_mut(), len11) + } + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + } + }; + let (result13_0, result13_1) = match field_size10 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 1i32, result12_0, result12_1, result12_2, + result13_0, result13_1, + ) + } + None => ( + 0i32, + 0i32, + ::core::ptr::null_mut(), + 0usize, + 0i32, + 0i32, + ), + }; + ( + 22i32, + result14_0, + ::core::mem::MaybeUninit::new( + i64::from(result14_1) as u64 + ), + result14_2, + result14_3 as *mut u8, + result14_4 as usize, + result14_5, + ) + } + ErrorCode::HttpRequestTrailerSectionSize(e) => { + let (result15_0, result15_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 23i32, + result15_0, + ::core::mem::MaybeUninit::new( + i64::from(result15_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpRequestTrailerSize(e) => { + let FieldSizePayload { + field_name: field_name16, + field_size: field_size16, + } = e; + let (result18_0, result18_1, result18_2) = + match field_name16 { + Some(e) => { + let vec17 = e; + let ptr17 = vec17.as_ptr().cast::(); + let len17 = vec17.len(); + + (1i32, ptr17.cast_mut(), len17) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result19_0, result19_1) = match field_size16 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 24i32, + result18_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result18_1); + t + }, + result18_2 as *mut u8, + result19_0 as *mut u8, + result19_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseIncomplete => ( + 25i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpResponseHeaderSectionSize(e) => { + let (result20_0, result20_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 26i32, + result20_0, + ::core::mem::MaybeUninit::new( + i64::from(result20_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseHeaderSize(e) => { + let FieldSizePayload { + field_name: field_name21, + field_size: field_size21, + } = e; + let (result23_0, result23_1, result23_2) = + match field_name21 { + Some(e) => { + let vec22 = e; + let ptr22 = vec22.as_ptr().cast::(); + let len22 = vec22.len(); + + (1i32, ptr22.cast_mut(), len22) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result24_0, result24_1) = match field_size21 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 27i32, + result23_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result23_1); + t + }, + result23_2 as *mut u8, + result24_0 as *mut u8, + result24_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseBodySize(e) => { + let (result25_0, result25_1) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => (0i32, 0i64), + }; + ( + 28i32, + result25_0, + ::core::mem::MaybeUninit::new(result25_1 as u64), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTrailerSectionSize(e) => { + let (result26_0, result26_1) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 29i32, + result26_0, + ::core::mem::MaybeUninit::new( + i64::from(result26_1) as u64 + ), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTrailerSize(e) => { + let FieldSizePayload { + field_name: field_name27, + field_size: field_size27, + } = e; + let (result29_0, result29_1, result29_2) = + match field_name27 { + Some(e) => { + let vec28 = e; + let ptr28 = vec28.as_ptr().cast::(); + let len28 = vec28.len(); + + (1i32, ptr28.cast_mut(), len28) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + let (result30_0, result30_1) = match field_size27 { + Some(e) => (1i32, _rt::as_i32(e)), + None => (0i32, 0i32), + }; + ( + 30i32, + result29_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result29_1); + t + }, + result29_2 as *mut u8, + result30_0 as *mut u8, + result30_1 as usize, + 0i32, + ) + } + ErrorCode::HttpResponseTransferCoding(e) => { + let (result32_0, result32_1, result32_2) = match e { + Some(e) => { + let vec31 = e; + let ptr31 = vec31.as_ptr().cast::(); + let len31 = vec31.len(); + + (1i32, ptr31.cast_mut(), len31) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 31i32, + result32_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result32_1); + t + }, + result32_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseContentCoding(e) => { + let (result34_0, result34_1, result34_2) = match e { + Some(e) => { + let vec33 = e; + let ptr33 = vec33.as_ptr().cast::(); + let len33 = vec33.len(); + + (1i32, ptr33.cast_mut(), len33) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 32i32, + result34_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result34_1); + t + }, + result34_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + ErrorCode::HttpResponseTimeout => ( + 33i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpUpgradeFailed => ( + 34i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::HttpProtocolError => ( + 35i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::LoopDetected => ( + 36i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::ConfigurationError => ( + 37i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ), + ErrorCode::InternalError(e) => { + let (result36_0, result36_1, result36_2) = match e { + Some(e) => { + let vec35 = e; + let ptr35 = vec35.as_ptr().cast::(); + let len35 = vec35.len(); + + (1i32, ptr35.cast_mut(), len35) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), + }; + ( + 38i32, + result36_0, + { + let mut t = + ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result36_1); + t + }, + result36_2 as *mut u8, + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } + }; + + ( + 1i32, result37_0, result37_1, result37_2, result37_3, + result37_4, result37_5, result37_6, + ) + } + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]response-outparam.set"] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: ::core::mem::MaybeUninit, + _: *mut u8, + _: *mut u8, + _: usize, + _: i32, + ); } - 1 => { - let e = (); - Err(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: i32, + _: i32, + _: i32, + _: ::core::mem::MaybeUninit, + _: *mut u8, + _: *mut u8, + _: usize, + _: i32, + ) { + unreachable!() } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + wit_import( + (¶m).take_handle() as i32, + result38_0, + result38_1, + result38_2, + result38_3, + result38_4, + result38_5, + result38_6, + result38_7, + ); } - } } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the Method for the Request. - pub fn method(&self,) -> Method{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the status code from the incoming response. + pub fn status(&self) -> StatusCode { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.method"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - let v5 = match l1 { - 0 => { - Method::Get - } - 1 => { - Method::Head - } - 2 => { - Method::Post - } - 3 => { - Method::Put - } - 4 => { - Method::Delete - } - 5 => { - Method::Connect - } - 6 => { - Method::Options - } - 7 => { - Method::Trace + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.status"] + fn wit_import(_: i32) -> i32; } - 8 => { - Method::Patch + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the Method for the Request. Fails if the string present in a - /// `method.other` argument is not a syntactically valid method. - pub fn set_method(&self,method: &Method,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the headers from the incoming response. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `incoming-response` is dropped. + pub fn headers(&self) -> Headers { unsafe { - let (result1_0,result1_1,result1_2,) = match method { - Method::Get=> { - (0i32, 0i32, 0i32) - } - Method::Head=> { - (1i32, 0i32, 0i32) - } - Method::Post=> { - (2i32, 0i32, 0i32) - } - Method::Put=> { - (3i32, 0i32, 0i32) - } - Method::Delete=> { - (4i32, 0i32, 0i32) - } - Method::Connect=> { - (5i32, 0i32, 0i32) + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.headers"] + fn wit_import(_: i32) -> i32; } - Method::Options=> { - (6i32, 0i32, 0i32) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - Method::Trace=> { - (7i32, 0i32, 0i32) + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the incoming body. May be called at most once. Returns error + /// if called additional times. + pub fn consume(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.consume"] + fn wit_import(_: i32, _: *mut u8); } - Method::Patch=> { - (8i32, 0i32, 0i32) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - Method::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (9i32, ptr0, len0) - }, - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-method"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. - pub fn path_with_query(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.path-with-query"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. Fails is the - /// string given is not a syntactically valid path and query uri component. - pub fn set_path_with_query(&self,path_with_query: Option<&str>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns the contents of the body, as a stream of bytes. + /// + /// Returns success on first call: the stream representing the contents + /// can be retrieved at most once. Subsequent calls will return error. + /// + /// The returned `input-stream` resource is a child: it must be dropped + /// before the parent `incoming-body` is dropped, or consumed by + /// `incoming-body.finish`. + /// + /// This invariant ensures that the implementation can determine whether + /// the user is consuming the contents of the body, waiting on the + /// `future-trailers` to be ready, or neither. This allows for network + /// backpressure is to be applied when the user is consuming the body, + /// and for that backpressure to not inhibit delivery of the trailers if + /// the user does not read the entire body. + pub fn stream(&self) -> Result { unsafe { - let (result1_0,result1_1,result1_2,) = match path_with_query { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (1i32, ptr0, len0) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-path-with-query"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-body.stream"] + fn wit_import(_: i32, _: *mut u8); } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. - pub fn scheme(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.scheme"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v6 = match l2 { - 0 => { - Scheme::Http - } - 1 => { - Scheme::Https - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *((ptr0 + 8) as *const i32); - let l4 = *((ptr0 + 12) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - - wit_bindgen::rt::string_lift(bytes5) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle( + l2 as u32, + ) }; - Scheme::Other(e6) - } - }; - - v6 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. Fails if the - /// string given is not a syntactically valid uri scheme. - pub fn set_scheme(&self,scheme: Option<&Scheme>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result2_0,result2_1,result2_2,result2_3,) = match scheme { - Some(e) => { - let (result1_0,result1_1,result1_2,) = match e { - Scheme::Http=> { - (0i32, 0i32, 0i32) + Ok(e) } - Scheme::Https=> { - (1i32, 0i32, 0i32) + 1 => { + let e = (); + Err(e) } - Scheme::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (2i32, ptr0, len0) - }, - }; - - (1i32, result1_0, result1_1, result1_2) - }, - None => { - (0i32, 0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-scheme"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result2_0, result2_1, result2_2, result2_3); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. - pub fn authority(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.authority"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - - wit_bindgen::rt::string_lift(bytes4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. Fails if the string given is - /// not a syntactically valid uri authority. - pub fn set_authority(&self,authority: Option<&str>,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result1_0,result1_1,result1_2,) = match authority { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - (1i32, ptr0, len0) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-authority"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Construct a default `request-options` value. - pub fn new() -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]request-options"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - RequestOptions::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for the initial connect to the HTTP Server. - pub fn connect_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.connect-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for the initial connect to the HTTP Server. An error - /// return value indicates that this timeout is not supported. - pub fn set_connect_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Takes ownership of `incoming-body`, and returns a `future-trailers`. + /// This function will trap if the `input-stream` child is still alive. + pub fn finish(this: IncomingBody) -> FutureTrailers { unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-connect-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]incoming-body.finish"] + fn wit_import(_: i32) -> i32; } - 1 => { - let e = (); - Err(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + let ret = wit_import((&this).take_handle() as i32); + FutureTrailers::from_handle(ret as u32) } - } } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving the first byte of the Response body. - pub fn first_byte_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.first-byte-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving the first byte of the Response body. An - /// error return value indicates that this timeout is not supported. - pub fn set_first_byte_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl FutureTrailers { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the trailers have + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + pub fn subscribe(&self) -> Pollable { unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-first-byte-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-trailers.subscribe"] + fn wit_import(_: i32) -> i32; } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving subsequent chunks of bytes in the Response - /// body stream. - pub fn between_bytes_timeout(&self,) -> Option{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.between-bytes-timeout"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving subsequent chunks of bytes in the Response - /// body stream. An error return value indicates that this timeout is not - /// supported. - pub fn set_between_bytes_timeout(&self,duration: Option,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-between-bytes-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl ResponseOutparam { - #[allow(unused_unsafe, clippy::all)] - /// Set the value of the `response-outparam` to either send a response, - /// or indicate an error. - /// - /// This method consumes the `response-outparam` to ensure that it is - /// called at most once. If it is never called, the implementation - /// will respond with an error. - /// - /// The user may provide an `error` to `response` to allow the - /// implementation determine how to respond with an HTTP error response. - pub fn set(param: ResponseOutparam,response: Result,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let (result38_0,result38_1,result38_2,result38_3,result38_4,result38_5,result38_6,result38_7,) = match response { - Ok(e) => { (0i32, (e).into_handle() as i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) }, - Err(e) => { { - let (result37_0,result37_1,result37_2,result37_3,result37_4,result37_5,result37_6,) = match e { - ErrorCode::DnsTimeout=> { - (0i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DnsError(e) => { - let DnsErrorPayload{ rcode:rcode0, info_code:info_code0, } = e; - let (result2_0,result2_1,result2_2,) = match rcode0 { - Some(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - (1i32, ptr1, len1) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result3_0,result3_1,) = match info_code0 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result2_0, i64::from(result2_1), result2_2, result3_0, result3_1, 0i32) - }, - ErrorCode::DestinationNotFound=> { - (2i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationUnavailable=> { - (3i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationIpProhibited=> { - (4i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::DestinationIpUnroutable=> { - (5i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionRefused=> { - (6i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionTerminated=> { - (7i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionTimeout=> { - (8i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionReadTimeout=> { - (9i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionWriteTimeout=> { - (10i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConnectionLimitReached=> { - (11i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsProtocolError=> { - (12i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsCertificateError=> { - (13i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::TlsAlertReceived(e) => { - let TlsAlertReceivedPayload{ alert_id:alert_id4, alert_message:alert_message4, } = e; - let (result5_0,result5_1,) = match alert_id4 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result7_0,result7_1,result7_2,) = match alert_message4 { - Some(e) => { - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - - (1i32, ptr6, len6) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (14i32, result5_0, i64::from(result5_1), result7_0, result7_1, result7_2, 0i32) - }, - ErrorCode::HttpRequestDenied=> { - (15i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestLengthRequired=> { - (16i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestBodySize(e) => { - let (result8_0,result8_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (17i32, result8_0, result8_1, 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestMethodInvalid=> { - (18i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestUriInvalid=> { - (19i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestUriTooLong=> { - (20i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - let (result9_0,result9_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (21i32, result9_0, i64::from(result9_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestHeaderSize(e) => { - let (result14_0,result14_1,result14_2,result14_3,result14_4,result14_5,) = match e { - Some(e) => { - let FieldSizePayload{ field_name:field_name10, field_size:field_size10, } = e; - let (result12_0,result12_1,result12_2,) = match field_name10 { - Some(e) => { - let vec11 = e; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - - (1i32, ptr11, len11) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result13_0,result13_1,) = match field_size10 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result12_0, result12_1, result12_2, result13_0, result13_1) - }, - None => { - (0i32, 0i32, 0i32, 0i32, 0i32, 0i32) - }, - }; - (22i32, result14_0, i64::from(result14_1), result14_2, result14_3, result14_4, result14_5) - }, - ErrorCode::HttpRequestTrailerSectionSize(e) => { - let (result15_0,result15_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (23i32, result15_0, i64::from(result15_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpRequestTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name16, field_size:field_size16, } = e; - let (result18_0,result18_1,result18_2,) = match field_name16 { - Some(e) => { - let vec17 = e; - let ptr17 = vec17.as_ptr() as i32; - let len17 = vec17.len() as i32; - - (1i32, ptr17, len17) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result19_0,result19_1,) = match field_size16 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (24i32, result18_0, i64::from(result18_1), result18_2, result19_0, result19_1, 0i32) - }, - ErrorCode::HttpResponseIncomplete=> { - (25i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - let (result20_0,result20_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (26i32, result20_0, i64::from(result20_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseHeaderSize(e) => { - let FieldSizePayload{ field_name:field_name21, field_size:field_size21, } = e; - let (result23_0,result23_1,result23_2,) = match field_name21 { - Some(e) => { - let vec22 = e; - let ptr22 = vec22.as_ptr() as i32; - let len22 = vec22.len() as i32; - - (1i32, ptr22, len22) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result24_0,result24_1,) = match field_size21 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (27i32, result23_0, i64::from(result23_1), result23_2, result24_0, result24_1, 0i32) - }, - ErrorCode::HttpResponseBodySize(e) => { - let (result25_0,result25_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (28i32, result25_0, result25_1, 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTrailerSectionSize(e) => { - let (result26_0,result26_1,) = match e { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (29i32, result26_0, i64::from(result26_1), 0i32, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name27, field_size:field_size27, } = e; - let (result29_0,result29_1,result29_2,) = match field_name27 { - Some(e) => { - let vec28 = e; - let ptr28 = vec28.as_ptr() as i32; - let len28 = vec28.len() as i32; - - (1i32, ptr28, len28) - }, - None => { - (0i32, 0i32, 0i32) - }, - };let (result30_0,result30_1,) = match field_size27 { - Some(e) => (1i32, wit_bindgen::rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (30i32, result29_0, i64::from(result29_1), result29_2, result30_0, result30_1, 0i32) - }, - ErrorCode::HttpResponseTransferCoding(e) => { - let (result32_0,result32_1,result32_2,) = match e { - Some(e) => { - let vec31 = e; - let ptr31 = vec31.as_ptr() as i32; - let len31 = vec31.len() as i32; - - (1i32, ptr31, len31) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (31i32, result32_0, i64::from(result32_1), result32_2, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseContentCoding(e) => { - let (result34_0,result34_1,result34_2,) = match e { - Some(e) => { - let vec33 = e; - let ptr33 = vec33.as_ptr() as i32; - let len33 = vec33.len() as i32; - - (1i32, ptr33, len33) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (32i32, result34_0, i64::from(result34_1), result34_2, 0i32, 0i32, 0i32) - }, - ErrorCode::HttpResponseTimeout=> { - (33i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpUpgradeFailed=> { - (34i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::HttpProtocolError=> { - (35i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::LoopDetected=> { - (36i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::ConfigurationError=> { - (37i32, 0i32, 0i64, 0i32, 0i32, 0i32, 0i32) - } - ErrorCode::InternalError(e) => { - let (result36_0,result36_1,result36_2,) = match e { - Some(e) => { - let vec35 = e; - let ptr35 = vec35.as_ptr() as i32; - let len35 = vec35.len() as i32; - - (1i32, ptr35, len35) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - (38i32, result36_0, i64::from(result36_1), result36_2, 0i32, 0i32, 0i32) - }, - }; - - (1i32, result37_0, result37_1, result37_2, result37_3, result37_4, result37_5, result37_6) - } }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]response-outparam.set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i64, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((param).into_handle() as i32, result38_0, result38_1, result38_2, result38_3, result38_4, result38_5, result38_6, result38_7); - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the status code from the incoming response. - pub fn status(&self,) -> StatusCode{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.status"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the headers from the incoming response. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `incoming-response` is dropped. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the incoming body. May be called at most once. Returns error - /// if called additional times. - pub fn consume(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl FutureTrailers { + #[allow(unused_unsafe, clippy::all)] + /// Returns the contents of the trailers, or an error which occured, + /// once the future is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the trailers or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the HTTP Request or Response + /// body, as well as any trailers, were received successfully, or that an + /// error occured receiving them. The optional `trailers` indicates whether + /// or not trailers were present in the body. + /// + /// When some `trailers` are returned by this method, the `trailers` + /// resource is immutable, and a child. Use of the `set`, `append`, or + /// `delete` methods will return an error, and the resource must be + /// dropped before the parent `future-trailers` is dropped. + pub fn get(&self) -> Option, ErrorCode>, ()>> { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.consume"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-trailers.get"] + fn wit_import(_: i32, _: *mut u8); } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns the contents of the body, as a stream of bytes. - /// - /// Returns success on first call: the stream representing the contents - /// can be retrieved at most once. Subsequent calls will return error. - /// - /// The returned `input-stream` resource is a child: it must be dropped - /// before the parent `incoming-body` is dropped, or consumed by - /// `incoming-body.finish`. - /// - /// This invariant ensures that the implementation can determine whether - /// the user is consuming the contents of the body, waiting on the - /// `future-trailers` to be ready, or neither. This allows for network - /// backpressure is to be applied when the user is consuming the body, - /// and for that backpressure to not inhibit delivery of the trailers if - /// the user does not read the entire body. - pub fn stream(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-body.stream"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Takes ownership of `incoming-body`, and returns a `future-trailers`. - /// This function will trap if the `input-stream` child is still alive. - pub fn finish(this: IncomingBody,) -> FutureTrailers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]incoming-body.finish"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((this).into_handle() as i32); - FutureTrailers::from_handle(ret as u32) - } - } - } - impl FutureTrailers { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the trailers have - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-trailers.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl FutureTrailers { - #[allow(unused_unsafe, clippy::all)] - /// Returns the contents of the trailers, or an error which occured, - /// once the future is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the trailers or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the HTTP Request or Response - /// body, as well as any trailers, were received successfully, or that an - /// error occured receiving them. The optional `trailers` indicates whether - /// or not trailers were present in the body. - /// - /// When some `trailers` are returned by this method, the `trailers` - /// resource is immutable, and a child. Use of the `set`, `append`, or - /// `delete` methods will return an error, and the resource must be - /// dropped before the parent `future-trailers` is dropped. - pub fn get(&self,) -> Option,ErrorCode>,()>>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 56]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-trailers.get"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - - match l2 { - 0 => { + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { let e = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - - match l3 { - 0 => { - let e = { - let l4 = i32::from(*((ptr0 + 24) as *const u8)); - - match l4 { + let l2 = i32::from(*ptr0.add(8).cast::()); + + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); + + match l3 { + 0 => { + let e = + { + let l4 = i32::from( + *ptr0.add(24).cast::(), + ); + + match l4 { 0 => None, 1 => { let e = { - let l5 = *((ptr0 + 28) as *const i32); - + let l5 = *ptr0.add(28).cast::(); + Fields::from_handle(l5 as u32) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*((ptr0 + 24) as *const u8)); - let v68 = match l6 { + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from( + *ptr0.add(24).cast::(), + ); + let v68 = match l6 { 0 => { ErrorCode::DnsTimeout } 1 => { let e68 = { - let l7 = i32::from(*((ptr0 + 32) as *const u8)); - let l11 = i32::from(*((ptr0 + 44) as *const u8)); - + let l7 = i32::from(*ptr0.add(32).cast::()); + let l11 = i32::from(*ptr0.add(44).cast::()); + DnsErrorPayload{ rcode: match l7 { 0 => None, 1 => { let e = { - let l8 = *((ptr0 + 36) as *const i32); - let l9 = *((ptr0 + 40) as *const i32); - let len10 = l9 as usize; - let bytes10 = Vec::from_raw_parts(l8 as *mut _, len10, len10); - - wit_bindgen::rt::string_lift(bytes10) + let l8 = *ptr0.add(36).cast::<*mut u8>(); + let l9 = *ptr0.add(40).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l11 { 0 => None, 1 => { let e = { - let l12 = i32::from(*((ptr0 + 46) as *const u16)); - + let l12 = i32::from(*ptr0.add(46).cast::()); + l12 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5881,36 +6378,36 @@ pub mod golem { } 14 => { let e68 = { - let l13 = i32::from(*((ptr0 + 32) as *const u8)); - let l15 = i32::from(*((ptr0 + 36) as *const u8)); - + let l13 = i32::from(*ptr0.add(32).cast::()); + let l15 = i32::from(*ptr0.add(36).cast::()); + TlsAlertReceivedPayload{ alert_id: match l13 { 0 => None, 1 => { let e = { - let l14 = i32::from(*((ptr0 + 33) as *const u8)); - + let l14 = i32::from(*ptr0.add(33).cast::()); + l14 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l15 { 0 => None, 1 => { let e = { - let l16 = *((ptr0 + 40) as *const i32); - let l17 = *((ptr0 + 44) as *const i32); - let len18 = l17 as usize; - let bytes18 = Vec::from_raw_parts(l16 as *mut _, len18, len18); - - wit_bindgen::rt::string_lift(bytes18) + let l16 = *ptr0.add(40).cast::<*mut u8>(); + let l17 = *ptr0.add(44).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -5924,19 +6421,19 @@ pub mod golem { } 17 => { let e68 = { - let l19 = i32::from(*((ptr0 + 32) as *const u8)); - + let l19 = i32::from(*ptr0.add(32).cast::()); + match l19 { 0 => None, 1 => { let e = { - let l20 = *((ptr0 + 40) as *const i64); - + let l20 = *ptr0.add(40).cast::(); + l20 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestBodySize(e68) @@ -5952,122 +6449,122 @@ pub mod golem { } 21 => { let e68 = { - let l21 = i32::from(*((ptr0 + 32) as *const u8)); - + let l21 = i32::from(*ptr0.add(32).cast::()); + match l21 { 0 => None, 1 => { let e = { - let l22 = *((ptr0 + 36) as *const i32); - + let l22 = *ptr0.add(36).cast::(); + l22 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSectionSize(e68) } 22 => { let e68 = { - let l23 = i32::from(*((ptr0 + 32) as *const u8)); - + let l23 = i32::from(*ptr0.add(32).cast::()); + match l23 { 0 => None, 1 => { let e = { - let l24 = i32::from(*((ptr0 + 36) as *const u8)); - let l28 = i32::from(*((ptr0 + 48) as *const u8)); - + let l24 = i32::from(*ptr0.add(36).cast::()); + let l28 = i32::from(*ptr0.add(48).cast::()); + FieldSizePayload{ field_name: match l24 { 0 => None, 1 => { let e = { - let l25 = *((ptr0 + 40) as *const i32); - let l26 = *((ptr0 + 44) as *const i32); - let len27 = l26 as usize; - let bytes27 = Vec::from_raw_parts(l25 as *mut _, len27, len27); - - wit_bindgen::rt::string_lift(bytes27) + let l25 = *ptr0.add(40).cast::<*mut u8>(); + let l26 = *ptr0.add(44).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts(l25.cast(), len27, len27); + + _rt::string_lift(bytes27) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l28 { 0 => None, 1 => { let e = { - let l29 = *((ptr0 + 52) as *const i32); - + let l29 = *ptr0.add(52).cast::(); + l29 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSize(e68) } 23 => { let e68 = { - let l30 = i32::from(*((ptr0 + 32) as *const u8)); - + let l30 = i32::from(*ptr0.add(32).cast::()); + match l30 { 0 => None, 1 => { let e = { - let l31 = *((ptr0 + 36) as *const i32); - + let l31 = *ptr0.add(36).cast::(); + l31 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestTrailerSectionSize(e68) } 24 => { let e68 = { - let l32 = i32::from(*((ptr0 + 32) as *const u8)); - let l36 = i32::from(*((ptr0 + 44) as *const u8)); - + let l32 = i32::from(*ptr0.add(32).cast::()); + let l36 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l32 { 0 => None, 1 => { let e = { - let l33 = *((ptr0 + 36) as *const i32); - let l34 = *((ptr0 + 40) as *const i32); - let len35 = l34 as usize; - let bytes35 = Vec::from_raw_parts(l33 as *mut _, len35, len35); - - wit_bindgen::rt::string_lift(bytes35) + let l33 = *ptr0.add(36).cast::<*mut u8>(); + let l34 = *ptr0.add(40).cast::(); + let len35 = l34; + let bytes35 = _rt::Vec::from_raw_parts(l33.cast(), len35, len35); + + _rt::string_lift(bytes35) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l36 { 0 => None, 1 => { let e = { - let l37 = *((ptr0 + 48) as *const i32); - + let l37 = *ptr0.add(48).cast::(); + l37 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -6078,55 +6575,55 @@ pub mod golem { } 26 => { let e68 = { - let l38 = i32::from(*((ptr0 + 32) as *const u8)); - + let l38 = i32::from(*ptr0.add(32).cast::()); + match l38 { 0 => None, 1 => { let e = { - let l39 = *((ptr0 + 36) as *const i32); - + let l39 = *ptr0.add(36).cast::(); + l39 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseHeaderSectionSize(e68) } 27 => { let e68 = { - let l40 = i32::from(*((ptr0 + 32) as *const u8)); - let l44 = i32::from(*((ptr0 + 44) as *const u8)); - + let l40 = i32::from(*ptr0.add(32).cast::()); + let l44 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l40 { 0 => None, 1 => { let e = { - let l41 = *((ptr0 + 36) as *const i32); - let l42 = *((ptr0 + 40) as *const i32); - let len43 = l42 as usize; - let bytes43 = Vec::from_raw_parts(l41 as *mut _, len43, len43); - - wit_bindgen::rt::string_lift(bytes43) + let l41 = *ptr0.add(36).cast::<*mut u8>(); + let l42 = *ptr0.add(40).cast::(); + let len43 = l42; + let bytes43 = _rt::Vec::from_raw_parts(l41.cast(), len43, len43); + + _rt::string_lift(bytes43) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l44 { 0 => None, 1 => { let e = { - let l45 = *((ptr0 + 48) as *const i32); - + let l45 = *ptr0.add(48).cast::(); + l45 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -6134,74 +6631,74 @@ pub mod golem { } 28 => { let e68 = { - let l46 = i32::from(*((ptr0 + 32) as *const u8)); - + let l46 = i32::from(*ptr0.add(32).cast::()); + match l46 { 0 => None, 1 => { let e = { - let l47 = *((ptr0 + 40) as *const i64); - + let l47 = *ptr0.add(40).cast::(); + l47 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseBodySize(e68) } 29 => { let e68 = { - let l48 = i32::from(*((ptr0 + 32) as *const u8)); - + let l48 = i32::from(*ptr0.add(32).cast::()); + match l48 { 0 => None, 1 => { let e = { - let l49 = *((ptr0 + 36) as *const i32); - + let l49 = *ptr0.add(36).cast::(); + l49 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTrailerSectionSize(e68) } 30 => { let e68 = { - let l50 = i32::from(*((ptr0 + 32) as *const u8)); - let l54 = i32::from(*((ptr0 + 44) as *const u8)); - + let l50 = i32::from(*ptr0.add(32).cast::()); + let l54 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l50 { 0 => None, 1 => { let e = { - let l51 = *((ptr0 + 36) as *const i32); - let l52 = *((ptr0 + 40) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) + let l51 = *ptr0.add(36).cast::<*mut u8>(); + let l52 = *ptr0.add(40).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts(l51.cast(), len53, len53); + + _rt::string_lift(bytes53) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l54 { 0 => None, 1 => { let e = { - let l55 = *((ptr0 + 48) as *const i32); - + let l55 = *ptr0.add(48).cast::(); + l55 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -6209,44 +6706,44 @@ pub mod golem { } 31 => { let e68 = { - let l56 = i32::from(*((ptr0 + 32) as *const u8)); - + let l56 = i32::from(*ptr0.add(32).cast::()); + match l56 { 0 => None, 1 => { let e = { - let l57 = *((ptr0 + 36) as *const i32); - let l58 = *((ptr0 + 40) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) + let l57 = *ptr0.add(36).cast::<*mut u8>(); + let l58 = *ptr0.add(40).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts(l57.cast(), len59, len59); + + _rt::string_lift(bytes59) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTransferCoding(e68) } 32 => { let e68 = { - let l60 = i32::from(*((ptr0 + 32) as *const u8)); - + let l60 = i32::from(*ptr0.add(32).cast::()); + match l60 { 0 => None, 1 => { let e = { - let l61 = *((ptr0 + 36) as *const i32); - let l62 = *((ptr0 + 40) as *const i32); - let len63 = l62 as usize; - let bytes63 = Vec::from_raw_parts(l61 as *mut _, len63, len63); - - wit_bindgen::rt::string_lift(bytes63) + let l61 = *ptr0.add(36).cast::<*mut u8>(); + let l62 = *ptr0.add(40).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts(l61.cast(), len63, len63); + + _rt::string_lift(bytes63) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseContentCoding(e68) @@ -6269,925 +6766,924 @@ pub mod golem { n => { debug_assert_eq!(n, 38, "invalid enum discriminant"); let e68 = { - let l64 = i32::from(*((ptr0 + 32) as *const u8)); - + let l64 = i32::from(*ptr0.add(32).cast::()); + match l64 { 0 => None, 1 => { let e = { - let l65 = *((ptr0 + 36) as *const i32); - let l66 = *((ptr0 + 40) as *const i32); - let len67 = l66 as usize; - let bytes67 = Vec::from_raw_parts(l65 as *mut _, len67, len67); - - wit_bindgen::rt::string_lift(bytes67) + let l65 = *ptr0.add(36).cast::<*mut u8>(); + let l66 = *ptr0.add(40).cast::(); + let len67 = l66; + let bytes67 = _rt::Vec::from_raw_parts(l65.cast(), len67, len67); + + _rt::string_lift(bytes67) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::InternalError(e68) } }; - - v68 - }; - Err(e) + + v68 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Construct an `outgoing-response`, with a default `status-code` of `200`. + /// If a different `status-code` is needed, it must be set via the + /// `set-status-code` method. + /// + /// * `headers` is the HTTP Headers for the Response. + pub fn new(headers: Headers) -> Self { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-response"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingResponse::from_handle(ret as u32) + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Status Code for the Response. + pub fn status_code(&self) -> StatusCode { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.status-code"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Status Code for the Response. Fails if the status-code + /// given is not a valid http status code. + pub fn set_status_code(&self, status_code: StatusCode) -> Result<(), ()> { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.set-status-code"] + fn wit_import(_: i32, _: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32, _rt::as_i32(status_code)); + match ret { + 0 => { + let e = (); Ok(e) - } - 1 => { + } + 1 => { let e = (); Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Construct an `outgoing-response`, with a default `status-code` of `200`. - /// If a different `status-code` is needed, it must be set via the - /// `set-status-code` method. - /// - /// * `headers` is the HTTP Headers for the Response. - pub fn new(headers: Headers,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-response"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((headers).into_handle() as i32); - OutgoingResponse::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Status Code for the Response. - pub fn status_code(&self,) -> StatusCode{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.status-code"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Status Code for the Response. Fails if the status-code - /// given is not a valid http status code. - pub fn set_status_code(&self,status_code: StatusCode,) -> Result<(),()>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.set-status-code"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, wit_bindgen::rt::as_i32(status_code)); - match ret { - 0 => { - let e = (); - Ok(e) + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this Response. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-response` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self) -> Headers { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.body"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.headers"] + fn wit_import(_: i32) -> i32; } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns a stream for writing the body contents. - /// - /// The returned `output-stream` is a child resource: it must be dropped - /// before the parent `outgoing-body` resource is dropped (or finished), - /// otherwise the `outgoing-body` drop or `finish` will trap. - /// - /// Returns success on the first call: the `output-stream` resource for - /// this `outgoing-body` may be retrieved at most once. Subsequent calls - /// will return error. - pub fn write(&self,) -> 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-body.write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Finalize an outgoing body, optionally providing trailers. This must be - /// called to signal that the response is complete. If the `outgoing-body` - /// is dropped without calling `outgoing-body.finalize`, the implementation - /// should treat the body as corrupted. - /// - /// Fails if the body's `outgoing-request` or `outgoing-response` was - /// constructed with a Content-Length header, and the contents written - /// to the body (via `write`) does not match the value given in the - /// Content-Length. - pub fn finish(this: OutgoingBody,trailers: Option,) -> Result<(),ErrorCode>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this Response. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-response` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self) -> Result { unsafe { - - #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let (result0_0,result0_1,) = match trailers { - Some(e) => (1i32, (e).into_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]outgoing-body.finish"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((this).into_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.body"] + fn wit_import(_: i32, _: *mut u8); } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 8) as *const u8)); - let v65 = match l3 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e65 = { - let l4 = i32::from(*((ptr1 + 16) as *const u8)); - let l8 = i32::from(*((ptr1 + 28) as *const u8)); - - DnsErrorPayload{ - rcode: match l4 { - 0 => None, - 1 => { - let e = { - let l5 = *((ptr1 + 20) as *const i32); - let l6 = *((ptr1 + 24) as *const i32); - let len7 = l6 as usize; - let bytes7 = Vec::from_raw_parts(l5 as *mut _, len7, len7); - - wit_bindgen::rt::string_lift(bytes7) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - info_code: match l8 { - 0 => None, - 1 => { - let e = { - let l9 = i32::from(*((ptr1 + 30) as *const u16)); - - l9 as u16 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e65) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout - } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError - } - 14 => { - let e65 = { - let l10 = i32::from(*((ptr1 + 16) as *const u8)); - let l12 = i32::from(*((ptr1 + 20) as *const u8)); - - TlsAlertReceivedPayload{ - alert_id: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = i32::from(*((ptr1 + 17) as *const u8)); - - l11 as u8 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - alert_message: match l12 { - 0 => None, - 1 => { - let e = { - let l13 = *((ptr1 + 24) as *const i32); - let l14 = *((ptr1 + 28) as *const i32); - let len15 = l14 as usize; - let bytes15 = Vec::from_raw_parts(l13 as *mut _, len15, len15); - - wit_bindgen::rt::string_lift(bytes15) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e65) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e65 = { - let l16 = i32::from(*((ptr1 + 16) as *const u8)); - - match l16 { - 0 => None, - 1 => { - let e = { - let l17 = *((ptr1 + 24) as *const i64); - - l17 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) }; - ErrorCode::HttpRequestBodySize(e65) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e65 = { - let l18 = i32::from(*((ptr1 + 16) as *const u8)); - - match l18 { - 0 => None, - 1 => { - let e = { - let l19 = *((ptr1 + 20) as *const i32); - - l19 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns a stream for writing the body contents. + /// + /// The returned `output-stream` is a child resource: it must be dropped + /// before the parent `outgoing-body` resource is dropped (or finished), + /// otherwise the `outgoing-body` drop or `finish` will trap. + /// + /// Returns success on the first call: the `output-stream` resource for + /// this `outgoing-body` may be retrieved at most once. Subsequent calls + /// will return error. + pub fn write(&self) -> Result { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-body.write"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) }; - ErrorCode::HttpRequestHeaderSectionSize(e65) - } - 22 => { - let e65 = { - let l20 = i32::from(*((ptr1 + 16) as *const u8)); - - match l20 { - 0 => None, - 1 => { - let e = { - let l21 = i32::from(*((ptr1 + 20) as *const u8)); - let l25 = i32::from(*((ptr1 + 32) as *const u8)); - - FieldSizePayload{ + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Finalize an outgoing body, optionally providing trailers. This must be + /// called to signal that the response is complete. If the `outgoing-body` + /// is dropped without calling `outgoing-body.finalize`, the implementation + /// should treat the body as corrupted. + /// + /// Fails if the body's `outgoing-request` or `outgoing-response` was + /// constructed with a Content-Length header, and the contents written + /// to the body (via `write`) does not match the value given in the + /// Content-Length. + pub fn finish( + this: OutgoingBody, + trailers: Option, + ) -> Result<(), ErrorCode> { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0, result0_1) = match &trailers { + Some(e) => (1i32, (e).take_handle() as i32), + None => (0i32, 0i32), + }; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]outgoing-body.finish"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import((&this).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v65 = match l3 { + 0 => ErrorCode::DnsTimeout, + 1 => { + let e65 = { + let l4 = i32::from(*ptr1.add(16).cast::()); + let l8 = i32::from(*ptr1.add(28).cast::()); + + DnsErrorPayload { + rcode: match l4 { + 0 => None, + 1 => { + let e = { + let l5 = + *ptr1.add(20).cast::<*mut u8>(); + let l6 = + *ptr1.add(24).cast::(); + let len7 = l6; + let bytes7 = + _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + + _rt::string_lift(bytes7) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from( + *ptr1.add(30).cast::(), + ); + + l9 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e65) + } + 2 => ErrorCode::DestinationNotFound, + 3 => ErrorCode::DestinationUnavailable, + 4 => ErrorCode::DestinationIpProhibited, + 5 => ErrorCode::DestinationIpUnroutable, + 6 => ErrorCode::ConnectionRefused, + 7 => ErrorCode::ConnectionTerminated, + 8 => ErrorCode::ConnectionTimeout, + 9 => ErrorCode::ConnectionReadTimeout, + 10 => ErrorCode::ConnectionWriteTimeout, + 11 => ErrorCode::ConnectionLimitReached, + 12 => ErrorCode::TlsProtocolError, + 13 => ErrorCode::TlsCertificateError, + 14 => { + let e65 = { + let l10 = i32::from(*ptr1.add(16).cast::()); + let l12 = i32::from(*ptr1.add(20).cast::()); + + TlsAlertReceivedPayload { + alert_id: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = i32::from( + *ptr1.add(17).cast::(), + ); + + l11 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = + *ptr1.add(24).cast::<*mut u8>(); + let l14 = + *ptr1.add(28).cast::(); + let len15 = l14; + let bytes15 = + _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); + + _rt::string_lift(bytes15) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e65) + } + 15 => ErrorCode::HttpRequestDenied, + 16 => ErrorCode::HttpRequestLengthRequired, + 17 => { + let e65 = { + let l16 = i32::from(*ptr1.add(16).cast::()); + + match l16 { + 0 => None, + 1 => { + let e = { + let l17 = *ptr1.add(24).cast::(); + + l17 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e65) + } + 18 => ErrorCode::HttpRequestMethodInvalid, + 19 => ErrorCode::HttpRequestUriInvalid, + 20 => ErrorCode::HttpRequestUriTooLong, + 21 => { + let e65 = { + let l18 = i32::from(*ptr1.add(16).cast::()); + + match l18 { + 0 => None, + 1 => { + let e = { + let l19 = *ptr1.add(20).cast::(); + + l19 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e65) + } + 22 => { + let e65 = { + let l20 = i32::from(*ptr1.add(16).cast::()); + + match l20 { + 0 => None, + 1 => { + let e = { + let l21 = i32::from( + *ptr1.add(20).cast::(), + ); + let l25 = i32::from( + *ptr1.add(32).cast::(), + ); + + FieldSizePayload{ field_name: match l21 { 0 => None, 1 => { let e = { - let l22 = *((ptr1 + 24) as *const i32); - let l23 = *((ptr1 + 28) as *const i32); - let len24 = l23 as usize; - let bytes24 = Vec::from_raw_parts(l22 as *mut _, len24, len24); - - wit_bindgen::rt::string_lift(bytes24) + let l22 = *ptr1.add(24).cast::<*mut u8>(); + let l23 = *ptr1.add(28).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l25 { 0 => None, 1 => { let e = { - let l26 = *((ptr1 + 36) as *const i32); - + let l26 = *ptr1.add(36).cast::(); + l26 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e65) - } - 23 => { - let e65 = { - let l27 = i32::from(*((ptr1 + 16) as *const u8)); - - match l27 { - 0 => None, - 1 => { - let e = { - let l28 = *((ptr1 + 20) as *const i32); - - l28 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e65) - } - 24 => { - let e65 = { - let l29 = i32::from(*((ptr1 + 16) as *const u8)); - let l33 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l29 { - 0 => None, - 1 => { - let e = { - let l30 = *((ptr1 + 20) as *const i32); - let l31 = *((ptr1 + 24) as *const i32); - let len32 = l31 as usize; - let bytes32 = Vec::from_raw_parts(l30 as *mut _, len32, len32); - - wit_bindgen::rt::string_lift(bytes32) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l33 { - 0 => None, - 1 => { - let e = { - let l34 = *((ptr1 + 32) as *const i32); - - l34 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e65) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e65 = { - let l35 = i32::from(*((ptr1 + 16) as *const u8)); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *((ptr1 + 20) as *const i32); - - l36 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e65) - } - 27 => { - let e65 = { - let l37 = i32::from(*((ptr1 + 16) as *const u8)); - let l41 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l37 { - 0 => None, - 1 => { - let e = { - let l38 = *((ptr1 + 20) as *const i32); - let l39 = *((ptr1 + 24) as *const i32); - let len40 = l39 as usize; - let bytes40 = Vec::from_raw_parts(l38 as *mut _, len40, len40); - - wit_bindgen::rt::string_lift(bytes40) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l41 { - 0 => None, - 1 => { - let e = { - let l42 = *((ptr1 + 32) as *const i32); - - l42 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e65) - } - 28 => { - let e65 = { - let l43 = i32::from(*((ptr1 + 16) as *const u8)); - - match l43 { - 0 => None, - 1 => { - let e = { - let l44 = *((ptr1 + 24) as *const i64); - - l44 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e65) - } - 29 => { - let e65 = { - let l45 = i32::from(*((ptr1 + 16) as *const u8)); - - match l45 { - 0 => None, - 1 => { - let e = { - let l46 = *((ptr1 + 20) as *const i32); - - l46 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e65) - } - 30 => { - let e65 = { - let l47 = i32::from(*((ptr1 + 16) as *const u8)); - let l51 = i32::from(*((ptr1 + 28) as *const u8)); - - FieldSizePayload{ - field_name: match l47 { - 0 => None, - 1 => { - let e = { - let l48 = *((ptr1 + 20) as *const i32); - let l49 = *((ptr1 + 24) as *const i32); - let len50 = l49 as usize; - let bytes50 = Vec::from_raw_parts(l48 as *mut _, len50, len50); - - wit_bindgen::rt::string_lift(bytes50) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - field_size: match l51 { - 0 => None, - 1 => { - let e = { - let l52 = *((ptr1 + 32) as *const i32); - - l52 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e65) - } - 31 => { - let e65 = { - let l53 = i32::from(*((ptr1 + 16) as *const u8)); - - match l53 { - 0 => None, - 1 => { - let e = { - let l54 = *((ptr1 + 20) as *const i32); - let l55 = *((ptr1 + 24) as *const i32); - let len56 = l55 as usize; - let bytes56 = Vec::from_raw_parts(l54 as *mut _, len56, len56); - - wit_bindgen::rt::string_lift(bytes56) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e65) - } - 32 => { - let e65 = { - let l57 = i32::from(*((ptr1 + 16) as *const u8)); - - match l57 { - 0 => None, - 1 => { - let e = { - let l58 = *((ptr1 + 20) as *const i32); - let l59 = *((ptr1 + 24) as *const i32); - let len60 = l59 as usize; - let bytes60 = Vec::from_raw_parts(l58 as *mut _, len60, len60); - - wit_bindgen::rt::string_lift(bytes60) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e65) - } - 33 => { - ErrorCode::HttpResponseTimeout - } - 34 => { - ErrorCode::HttpUpgradeFailed - } - 35 => { - ErrorCode::HttpProtocolError - } - 36 => { - ErrorCode::LoopDetected - } - 37 => { - ErrorCode::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e65 = { - let l61 = i32::from(*((ptr1 + 16) as *const u8)); - - match l61 { - 0 => None, - 1 => { - let e = { - let l62 = *((ptr1 + 20) as *const i32); - let l63 = *((ptr1 + 24) as *const i32); - let len64 = l63 as usize; - let bytes64 = Vec::from_raw_parts(l62 as *mut _, len64, len64); - - wit_bindgen::rt::string_lift(bytes64) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e65) + } + 23 => { + let e65 = { + let l27 = i32::from(*ptr1.add(16).cast::()); + + match l27 { + 0 => None, + 1 => { + let e = { + let l28 = *ptr1.add(20).cast::(); + + l28 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e65) + } + 24 => { + let e65 = { + let l29 = i32::from(*ptr1.add(16).cast::()); + let l33 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l29 { + 0 => None, + 1 => { + let e = { + let l30 = + *ptr1.add(20).cast::<*mut u8>(); + let l31 = + *ptr1.add(24).cast::(); + let len32 = l31; + let bytes32 = + _rt::Vec::from_raw_parts( + l30.cast(), + len32, + len32, + ); + + _rt::string_lift(bytes32) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l33 { + 0 => None, + 1 => { + let e = { + let l34 = + *ptr1.add(32).cast::(); + + l34 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e65) + } + 25 => ErrorCode::HttpResponseIncomplete, + 26 => { + let e65 = { + let l35 = i32::from(*ptr1.add(16).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = *ptr1.add(20).cast::(); + + l36 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e65) + } + 27 => { + let e65 = { + let l37 = i32::from(*ptr1.add(16).cast::()); + let l41 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l37 { + 0 => None, + 1 => { + let e = { + let l38 = + *ptr1.add(20).cast::<*mut u8>(); + let l39 = + *ptr1.add(24).cast::(); + let len40 = l39; + let bytes40 = + _rt::Vec::from_raw_parts( + l38.cast(), + len40, + len40, + ); + + _rt::string_lift(bytes40) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l41 { + 0 => None, + 1 => { + let e = { + let l42 = + *ptr1.add(32).cast::(); + + l42 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e65) + } + 28 => { + let e65 = { + let l43 = i32::from(*ptr1.add(16).cast::()); + + match l43 { + 0 => None, + 1 => { + let e = { + let l44 = *ptr1.add(24).cast::(); + + l44 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e65) + } + 29 => { + let e65 = { + let l45 = i32::from(*ptr1.add(16).cast::()); + + match l45 { + 0 => None, + 1 => { + let e = { + let l46 = *ptr1.add(20).cast::(); + + l46 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e65) + } + 30 => { + let e65 = { + let l47 = i32::from(*ptr1.add(16).cast::()); + let l51 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload { + field_name: match l47 { + 0 => None, + 1 => { + let e = { + let l48 = + *ptr1.add(20).cast::<*mut u8>(); + let l49 = + *ptr1.add(24).cast::(); + let len50 = l49; + let bytes50 = + _rt::Vec::from_raw_parts( + l48.cast(), + len50, + len50, + ); + + _rt::string_lift(bytes50) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l51 { + 0 => None, + 1 => { + let e = { + let l52 = + *ptr1.add(32).cast::(); + + l52 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e65) + } + 31 => { + let e65 = { + let l53 = i32::from(*ptr1.add(16).cast::()); + + match l53 { + 0 => None, + 1 => { + let e = { + let l54 = + *ptr1.add(20).cast::<*mut u8>(); + let l55 = *ptr1.add(24).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e65) + } + 32 => { + let e65 = { + let l57 = i32::from(*ptr1.add(16).cast::()); + + match l57 { + 0 => None, + 1 => { + let e = { + let l58 = + *ptr1.add(20).cast::<*mut u8>(); + let l59 = *ptr1.add(24).cast::(); + let len60 = l59; + let bytes60 = _rt::Vec::from_raw_parts( + l58.cast(), + len60, + len60, + ); + + _rt::string_lift(bytes60) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e65) + } + 33 => ErrorCode::HttpResponseTimeout, + 34 => ErrorCode::HttpUpgradeFailed, + 35 => ErrorCode::HttpProtocolError, + 36 => ErrorCode::LoopDetected, + 37 => ErrorCode::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e65 = { + let l61 = i32::from(*ptr1.add(16).cast::()); + + match l61 { + 0 => None, + 1 => { + let e = { + let l62 = + *ptr1.add(20).cast::<*mut u8>(); + let l63 = *ptr1.add(24).cast::(); + let len64 = l63; + let bytes64 = _rt::Vec::from_raw_parts( + l62.cast(), + len64, + len64, + ); + + _rt::string_lift(bytes64) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e65) + } + }; + + v65 }; - ErrorCode::InternalError(e65) - } - }; - - v65 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl FutureIncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the Response has - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl FutureIncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the Response has + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + pub fn subscribe(&self) -> Pollable { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-incoming-response.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl FutureIncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the incoming HTTP Response, or an error, once one is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the response or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the incoming HTTP Response - /// status and headers have recieved successfully, or that an error - /// occured. Errors may also occur while consuming the response body, - /// but those will be reported by the `incoming-body` and its - /// `output-stream` child. - pub fn get(&self,) -> Option,()>>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-incoming-response.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl FutureIncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the incoming HTTP Response, or an error, once one is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the response or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the incoming HTTP Response + /// status and headers have recieved successfully, or that an error + /// occured. Errors may also occur while consuming the response body, + /// but those will be reported by the `incoming-body` and its + /// `output-stream` child. + pub fn get(&self) -> Option, ()>> { unsafe { - - #[repr(align(8))] - struct RetArea([u8; 56]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-incoming-response.get"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 8) as *const u8)); - - match l2 { - 0 => { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-incoming-response.get"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { let e = { - let l3 = i32::from(*((ptr0 + 16) as *const u8)); - - match l3 { - 0 => { - let e = { - let l4 = *((ptr0 + 24) as *const i32); - - IncomingResponse::from_handle(l4 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 24) as *const u8)); - let v67 = match l5 { + let l2 = i32::from(*ptr0.add(8).cast::()); + + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); + + match l3 { + 0 => { + let e = { + let l4 = *ptr0.add(24).cast::(); + + IncomingResponse::from_handle(l4 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from( + *ptr0.add(24).cast::(), + ); + let v67 = match l5 { 0 => { ErrorCode::DnsTimeout } 1 => { let e67 = { - let l6 = i32::from(*((ptr0 + 32) as *const u8)); - let l10 = i32::from(*((ptr0 + 44) as *const u8)); - + let l6 = i32::from(*ptr0.add(32).cast::()); + let l10 = i32::from(*ptr0.add(44).cast::()); + DnsErrorPayload{ rcode: match l6 { 0 => None, 1 => { let e = { - let l7 = *((ptr0 + 36) as *const i32); - let l8 = *((ptr0 + 40) as *const i32); - let len9 = l8 as usize; - let bytes9 = Vec::from_raw_parts(l7 as *mut _, len9, len9); - - wit_bindgen::rt::string_lift(bytes9) + let l7 = *ptr0.add(36).cast::<*mut u8>(); + let l8 = *ptr0.add(40).cast::(); + let len9 = l8; + let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9); + + _rt::string_lift(bytes9) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l10 { 0 => None, 1 => { let e = { - let l11 = i32::from(*((ptr0 + 46) as *const u16)); - + let l11 = i32::from(*ptr0.add(46).cast::()); + l11 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7231,36 +7727,36 @@ pub mod golem { } 14 => { let e67 = { - let l12 = i32::from(*((ptr0 + 32) as *const u8)); - let l14 = i32::from(*((ptr0 + 36) as *const u8)); - + let l12 = i32::from(*ptr0.add(32).cast::()); + let l14 = i32::from(*ptr0.add(36).cast::()); + TlsAlertReceivedPayload{ alert_id: match l12 { 0 => None, 1 => { let e = { - let l13 = i32::from(*((ptr0 + 33) as *const u8)); - + let l13 = i32::from(*ptr0.add(33).cast::()); + l13 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l14 { 0 => None, 1 => { let e = { - let l15 = *((ptr0 + 40) as *const i32); - let l16 = *((ptr0 + 44) as *const i32); - let len17 = l16 as usize; - let bytes17 = Vec::from_raw_parts(l15 as *mut _, len17, len17); - - wit_bindgen::rt::string_lift(bytes17) + let l15 = *ptr0.add(40).cast::<*mut u8>(); + let l16 = *ptr0.add(44).cast::(); + let len17 = l16; + let bytes17 = _rt::Vec::from_raw_parts(l15.cast(), len17, len17); + + _rt::string_lift(bytes17) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7274,19 +7770,19 @@ pub mod golem { } 17 => { let e67 = { - let l18 = i32::from(*((ptr0 + 32) as *const u8)); - + let l18 = i32::from(*ptr0.add(32).cast::()); + match l18 { 0 => None, 1 => { let e = { - let l19 = *((ptr0 + 40) as *const i64); - + let l19 = *ptr0.add(40).cast::(); + l19 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestBodySize(e67) @@ -7302,122 +7798,122 @@ pub mod golem { } 21 => { let e67 = { - let l20 = i32::from(*((ptr0 + 32) as *const u8)); - + let l20 = i32::from(*ptr0.add(32).cast::()); + match l20 { 0 => None, 1 => { let e = { - let l21 = *((ptr0 + 36) as *const i32); - + let l21 = *ptr0.add(36).cast::(); + l21 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSectionSize(e67) } 22 => { let e67 = { - let l22 = i32::from(*((ptr0 + 32) as *const u8)); - + let l22 = i32::from(*ptr0.add(32).cast::()); + match l22 { 0 => None, 1 => { let e = { - let l23 = i32::from(*((ptr0 + 36) as *const u8)); - let l27 = i32::from(*((ptr0 + 48) as *const u8)); - + let l23 = i32::from(*ptr0.add(36).cast::()); + let l27 = i32::from(*ptr0.add(48).cast::()); + FieldSizePayload{ field_name: match l23 { 0 => None, 1 => { let e = { - let l24 = *((ptr0 + 40) as *const i32); - let l25 = *((ptr0 + 44) as *const i32); - let len26 = l25 as usize; - let bytes26 = Vec::from_raw_parts(l24 as *mut _, len26, len26); - - wit_bindgen::rt::string_lift(bytes26) + let l24 = *ptr0.add(40).cast::<*mut u8>(); + let l25 = *ptr0.add(44).cast::(); + let len26 = l25; + let bytes26 = _rt::Vec::from_raw_parts(l24.cast(), len26, len26); + + _rt::string_lift(bytes26) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l27 { 0 => None, 1 => { let e = { - let l28 = *((ptr0 + 52) as *const i32); - + let l28 = *ptr0.add(52).cast::(); + l28 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestHeaderSize(e67) } 23 => { let e67 = { - let l29 = i32::from(*((ptr0 + 32) as *const u8)); - + let l29 = i32::from(*ptr0.add(32).cast::()); + match l29 { 0 => None, 1 => { let e = { - let l30 = *((ptr0 + 36) as *const i32); - + let l30 = *ptr0.add(36).cast::(); + l30 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpRequestTrailerSectionSize(e67) } 24 => { let e67 = { - let l31 = i32::from(*((ptr0 + 32) as *const u8)); - let l35 = i32::from(*((ptr0 + 44) as *const u8)); - + let l31 = i32::from(*ptr0.add(32).cast::()); + let l35 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l31 { 0 => None, 1 => { let e = { - let l32 = *((ptr0 + 36) as *const i32); - let l33 = *((ptr0 + 40) as *const i32); - let len34 = l33 as usize; - let bytes34 = Vec::from_raw_parts(l32 as *mut _, len34, len34); - - wit_bindgen::rt::string_lift(bytes34) + let l32 = *ptr0.add(36).cast::<*mut u8>(); + let l33 = *ptr0.add(40).cast::(); + let len34 = l33; + let bytes34 = _rt::Vec::from_raw_parts(l32.cast(), len34, len34); + + _rt::string_lift(bytes34) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l35 { 0 => None, 1 => { let e = { - let l36 = *((ptr0 + 48) as *const i32); - + let l36 = *ptr0.add(48).cast::(); + l36 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7428,55 +7924,55 @@ pub mod golem { } 26 => { let e67 = { - let l37 = i32::from(*((ptr0 + 32) as *const u8)); - + let l37 = i32::from(*ptr0.add(32).cast::()); + match l37 { 0 => None, 1 => { let e = { - let l38 = *((ptr0 + 36) as *const i32); - + let l38 = *ptr0.add(36).cast::(); + l38 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseHeaderSectionSize(e67) } 27 => { let e67 = { - let l39 = i32::from(*((ptr0 + 32) as *const u8)); - let l43 = i32::from(*((ptr0 + 44) as *const u8)); - + let l39 = i32::from(*ptr0.add(32).cast::()); + let l43 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l39 { 0 => None, 1 => { let e = { - let l40 = *((ptr0 + 36) as *const i32); - let l41 = *((ptr0 + 40) as *const i32); - let len42 = l41 as usize; - let bytes42 = Vec::from_raw_parts(l40 as *mut _, len42, len42); - - wit_bindgen::rt::string_lift(bytes42) + let l40 = *ptr0.add(36).cast::<*mut u8>(); + let l41 = *ptr0.add(40).cast::(); + let len42 = l41; + let bytes42 = _rt::Vec::from_raw_parts(l40.cast(), len42, len42); + + _rt::string_lift(bytes42) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l43 { 0 => None, 1 => { let e = { - let l44 = *((ptr0 + 48) as *const i32); - + let l44 = *ptr0.add(48).cast::(); + l44 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7484,74 +7980,74 @@ pub mod golem { } 28 => { let e67 = { - let l45 = i32::from(*((ptr0 + 32) as *const u8)); - + let l45 = i32::from(*ptr0.add(32).cast::()); + match l45 { 0 => None, 1 => { let e = { - let l46 = *((ptr0 + 40) as *const i64); - + let l46 = *ptr0.add(40).cast::(); + l46 as u64 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseBodySize(e67) } 29 => { let e67 = { - let l47 = i32::from(*((ptr0 + 32) as *const u8)); - + let l47 = i32::from(*ptr0.add(32).cast::()); + match l47 { 0 => None, 1 => { let e = { - let l48 = *((ptr0 + 36) as *const i32); - + let l48 = *ptr0.add(36).cast::(); + l48 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTrailerSectionSize(e67) } 30 => { let e67 = { - let l49 = i32::from(*((ptr0 + 32) as *const u8)); - let l53 = i32::from(*((ptr0 + 44) as *const u8)); - + let l49 = i32::from(*ptr0.add(32).cast::()); + let l53 = i32::from(*ptr0.add(44).cast::()); + FieldSizePayload{ field_name: match l49 { 0 => None, 1 => { let e = { - let l50 = *((ptr0 + 36) as *const i32); - let l51 = *((ptr0 + 40) as *const i32); - let len52 = l51 as usize; - let bytes52 = Vec::from_raw_parts(l50 as *mut _, len52, len52); - - wit_bindgen::rt::string_lift(bytes52) + let l50 = *ptr0.add(36).cast::<*mut u8>(); + let l51 = *ptr0.add(40).cast::(); + let len52 = l51; + let bytes52 = _rt::Vec::from_raw_parts(l50.cast(), len52, len52); + + _rt::string_lift(bytes52) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l53 { 0 => None, 1 => { let e = { - let l54 = *((ptr0 + 48) as *const i32); - + let l54 = *ptr0.add(48).cast::(); + l54 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7559,44 +8055,44 @@ pub mod golem { } 31 => { let e67 = { - let l55 = i32::from(*((ptr0 + 32) as *const u8)); - + let l55 = i32::from(*ptr0.add(32).cast::()); + match l55 { 0 => None, 1 => { let e = { - let l56 = *((ptr0 + 36) as *const i32); - let l57 = *((ptr0 + 40) as *const i32); - let len58 = l57 as usize; - let bytes58 = Vec::from_raw_parts(l56 as *mut _, len58, len58); - - wit_bindgen::rt::string_lift(bytes58) + let l56 = *ptr0.add(36).cast::<*mut u8>(); + let l57 = *ptr0.add(40).cast::(); + let len58 = l57; + let bytes58 = _rt::Vec::from_raw_parts(l56.cast(), len58, len58); + + _rt::string_lift(bytes58) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseTransferCoding(e67) } 32 => { let e67 = { - let l59 = i32::from(*((ptr0 + 32) as *const u8)); - + let l59 = i32::from(*ptr0.add(32).cast::()); + match l59 { 0 => None, 1 => { let e = { - let l60 = *((ptr0 + 36) as *const i32); - let l61 = *((ptr0 + 40) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) + let l60 = *ptr0.add(36).cast::<*mut u8>(); + let l61 = *ptr0.add(40).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts(l60.cast(), len62, len62); + + _rt::string_lift(bytes62) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::HttpResponseContentCoding(e67) @@ -7619,2584 +8115,2994 @@ pub mod golem { n => { debug_assert_eq!(n, 38, "invalid enum discriminant"); let e67 = { - let l63 = i32::from(*((ptr0 + 32) as *const u8)); - + let l63 = i32::from(*ptr0.add(32).cast::()); + match l63 { 0 => None, 1 => { let e = { - let l64 = *((ptr0 + 36) as *const i32); - let l65 = *((ptr0 + 40) as *const i32); - let len66 = l65 as usize; - let bytes66 = Vec::from_raw_parts(l64 as *mut _, len66, len66); - - wit_bindgen::rt::string_lift(bytes66) + let l64 = *ptr0.add(36).cast::<*mut u8>(); + let l65 = *ptr0.add(40).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts(l64.cast(), len66, len66); + + _rt::string_lift(bytes66) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } }; ErrorCode::InternalError(e67) } }; - - v67 - }; - Err(e) + + v67 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + Some(e) } - }; - Some(e) + _ => _rt::invalid_enum_discriminant(), } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } } - } } - - } - - - #[allow(clippy::all)] - pub mod outgoing_handler { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; - pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; - pub type FutureIncomingResponse = super::super::super::wasi::http::types::FutureIncomingResponse; - pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; - #[allow(unused_unsafe, clippy::all)] - /// This function is invoked with an outgoing HTTP Request, and it returns - /// a resource `future-incoming-response` which represents an HTTP Response - /// which may arrive in the future. - /// - /// The `options` argument accepts optional parameters for the HTTP - /// protocol's transport layer. - /// - /// This function may return an error if the `outgoing-request` is invalid - /// or not allowed to be made. Otherwise, protocol errors are reported - /// through the `future-incoming-response`. - pub fn handle(request: OutgoingRequest,options: Option,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + } + + #[allow(dead_code, clippy::all)] + pub mod outgoing_handler { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; + pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; + pub type FutureIncomingResponse = + super::super::super::wasi::http::types::FutureIncomingResponse; + pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; + #[allow(unused_unsafe, clippy::all)] + /// This function is invoked with an outgoing HTTP Request, and it returns + /// a resource `future-incoming-response` which represents an HTTP Response + /// which may arrive in the future. + /// + /// The `options` argument accepts optional parameters for the HTTP + /// protocol's transport layer. + /// + /// This function may return an error if the `outgoing-request` is invalid + /// or not allowed to be made. Otherwise, protocol errors are reported + /// through the `future-incoming-response`. + pub fn handle( + request: OutgoingRequest, + options: Option, + ) -> Result { + unsafe { #[repr(align(8))] - struct RetArea([u8; 40]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let (result0_0,result0_1,) = match options { - Some(e) => (1i32, (e).into_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.as_mut_ptr() as i32; + struct RetArea([::core::mem::MaybeUninit; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0, result0_1) = match &options { + Some(e) => (1i32, (e).take_handle() as i32), + None => (0i32, 0i32), + }; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.0")] extern "C" { - #[link_name = "handle"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + #[link_name = "handle"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((request).into_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8) { + unreachable!() + } + wit_import((&request).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); match l2 { - 0 => { - let e = { - let l3 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*((ptr1 + 8) as *const u8)); - use super::super::super::wasi::http::types::ErrorCode as V66; - let v66 = match l4 { - 0 => { - V66::DnsTimeout - } - 1 => { - let e66 = { - let l5 = i32::from(*((ptr1 + 16) as *const u8)); - let l9 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::DnsErrorPayload{ + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::(); + + super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(8).cast::()); + use super::super::super::wasi::http::types::ErrorCode as V66; + let v66 = match l4 { + 0 => V66::DnsTimeout, + 1 => { + let e66 = { + let l5 = i32::from(*ptr1.add(16).cast::()); + let l9 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::DnsErrorPayload{ rcode: match l5 { 0 => None, 1 => { let e = { - let l6 = *((ptr1 + 20) as *const i32); - let l7 = *((ptr1 + 24) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - - wit_bindgen::rt::string_lift(bytes8) + let l6 = *ptr1.add(20).cast::<*mut u8>(); + let l7 = *ptr1.add(24).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + _rt::string_lift(bytes8) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, info_code: match l9 { 0 => None, 1 => { let e = { - let l10 = i32::from(*((ptr1 + 30) as *const u16)); - + let l10 = i32::from(*ptr1.add(30).cast::()); + l10 as u16 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::DnsError(e66) - } - 2 => { - V66::DestinationNotFound - } - 3 => { - V66::DestinationUnavailable - } - 4 => { - V66::DestinationIpProhibited - } - 5 => { - V66::DestinationIpUnroutable - } - 6 => { - V66::ConnectionRefused - } - 7 => { - V66::ConnectionTerminated - } - 8 => { - V66::ConnectionTimeout - } - 9 => { - V66::ConnectionReadTimeout - } - 10 => { - V66::ConnectionWriteTimeout - } - 11 => { - V66::ConnectionLimitReached - } - 12 => { - V66::TlsProtocolError - } - 13 => { - V66::TlsCertificateError - } - 14 => { - let e66 = { - let l11 = i32::from(*((ptr1 + 16) as *const u8)); - let l13 = i32::from(*((ptr1 + 20) as *const u8)); - - super::super::super::wasi::http::types::TlsAlertReceivedPayload{ + }; + V66::DnsError(e66) + } + 2 => V66::DestinationNotFound, + 3 => V66::DestinationUnavailable, + 4 => V66::DestinationIpProhibited, + 5 => V66::DestinationIpUnroutable, + 6 => V66::ConnectionRefused, + 7 => V66::ConnectionTerminated, + 8 => V66::ConnectionTimeout, + 9 => V66::ConnectionReadTimeout, + 10 => V66::ConnectionWriteTimeout, + 11 => V66::ConnectionLimitReached, + 12 => V66::TlsProtocolError, + 13 => V66::TlsCertificateError, + 14 => { + let e66 = { + let l11 = i32::from(*ptr1.add(16).cast::()); + let l13 = i32::from(*ptr1.add(20).cast::()); + + super::super::super::wasi::http::types::TlsAlertReceivedPayload{ alert_id: match l11 { 0 => None, 1 => { let e = { - let l12 = i32::from(*((ptr1 + 17) as *const u8)); - + let l12 = i32::from(*ptr1.add(17).cast::()); + l12 as u8 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, alert_message: match l13 { 0 => None, 1 => { let e = { - let l14 = *((ptr1 + 24) as *const i32); - let l15 = *((ptr1 + 28) as *const i32); - let len16 = l15 as usize; - let bytes16 = Vec::from_raw_parts(l14 as *mut _, len16, len16); - - wit_bindgen::rt::string_lift(bytes16) + let l14 = *ptr1.add(24).cast::<*mut u8>(); + let l15 = *ptr1.add(28).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + + _rt::string_lift(bytes16) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::TlsAlertReceived(e66) - } - 15 => { - V66::HttpRequestDenied - } - 16 => { - V66::HttpRequestLengthRequired - } - 17 => { - let e66 = { - let l17 = i32::from(*((ptr1 + 16) as *const u8)); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *((ptr1 + 24) as *const i64); - - l18 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestBodySize(e66) - } - 18 => { - V66::HttpRequestMethodInvalid - } - 19 => { - V66::HttpRequestUriInvalid - } - 20 => { - V66::HttpRequestUriTooLong - } - 21 => { - let e66 = { - let l19 = i32::from(*((ptr1 + 16) as *const u8)); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *((ptr1 + 20) as *const i32); - - l20 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestHeaderSectionSize(e66) - } - 22 => { - let e66 = { - let l21 = i32::from(*((ptr1 + 16) as *const u8)); - - match l21 { - 0 => None, - 1 => { - let e = { - let l22 = i32::from(*((ptr1 + 20) as *const u8)); - let l26 = i32::from(*((ptr1 + 32) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::TlsAlertReceived(e66) + } + 15 => V66::HttpRequestDenied, + 16 => V66::HttpRequestLengthRequired, + 17 => { + let e66 = { + let l17 = i32::from(*ptr1.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr1.add(24).cast::(); + + l18 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestBodySize(e66) + } + 18 => V66::HttpRequestMethodInvalid, + 19 => V66::HttpRequestUriInvalid, + 20 => V66::HttpRequestUriTooLong, + 21 => { + let e66 = { + let l19 = i32::from(*ptr1.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *ptr1.add(20).cast::(); + + l20 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSectionSize(e66) + } + 22 => { + let e66 = { + let l21 = i32::from(*ptr1.add(16).cast::()); + + match l21 { + 0 => None, + 1 => { + let e = { + let l22 = + i32::from(*ptr1.add(20).cast::()); + let l26 = + i32::from(*ptr1.add(32).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l22 { 0 => None, 1 => { let e = { - let l23 = *((ptr1 + 24) as *const i32); - let l24 = *((ptr1 + 28) as *const i32); - let len25 = l24 as usize; - let bytes25 = Vec::from_raw_parts(l23 as *mut _, len25, len25); - - wit_bindgen::rt::string_lift(bytes25) + let l23 = *ptr1.add(24).cast::<*mut u8>(); + let l24 = *ptr1.add(28).cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts(l23.cast(), len25, len25); + + _rt::string_lift(bytes25) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l26 { 0 => None, 1 => { let e = { - let l27 = *((ptr1 + 36) as *const i32); - + let l27 = *ptr1.add(36).cast::(); + l27 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestHeaderSize(e66) - } - 23 => { - let e66 = { - let l28 = i32::from(*((ptr1 + 16) as *const u8)); - - match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *((ptr1 + 20) as *const i32); - - l29 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestTrailerSectionSize(e66) - } - 24 => { - let e66 = { - let l30 = i32::from(*((ptr1 + 16) as *const u8)); - let l34 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSize(e66) + } + 23 => { + let e66 = { + let l28 = i32::from(*ptr1.add(16).cast::()); + + match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *ptr1.add(20).cast::(); + + l29 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestTrailerSectionSize(e66) + } + 24 => { + let e66 = { + let l30 = i32::from(*ptr1.add(16).cast::()); + let l34 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l30 { 0 => None, 1 => { let e = { - let l31 = *((ptr1 + 20) as *const i32); - let l32 = *((ptr1 + 24) as *const i32); - let len33 = l32 as usize; - let bytes33 = Vec::from_raw_parts(l31 as *mut _, len33, len33); - - wit_bindgen::rt::string_lift(bytes33) + let l31 = *ptr1.add(20).cast::<*mut u8>(); + let l32 = *ptr1.add(24).cast::(); + let len33 = l32; + let bytes33 = _rt::Vec::from_raw_parts(l31.cast(), len33, len33); + + _rt::string_lift(bytes33) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l34 { 0 => None, 1 => { let e = { - let l35 = *((ptr1 + 32) as *const i32); - + let l35 = *ptr1.add(32).cast::(); + l35 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::HttpRequestTrailerSize(e66) - } - 25 => { - V66::HttpResponseIncomplete - } - 26 => { - let e66 = { - let l36 = i32::from(*((ptr1 + 16) as *const u8)); - - match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *((ptr1 + 20) as *const i32); - - l37 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseHeaderSectionSize(e66) - } - 27 => { - let e66 = { - let l38 = i32::from(*((ptr1 + 16) as *const u8)); - let l42 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::HttpRequestTrailerSize(e66) + } + 25 => V66::HttpResponseIncomplete, + 26 => { + let e66 = { + let l36 = i32::from(*ptr1.add(16).cast::()); + + match l36 { + 0 => None, + 1 => { + let e = { + let l37 = *ptr1.add(20).cast::(); + + l37 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseHeaderSectionSize(e66) + } + 27 => { + let e66 = { + let l38 = i32::from(*ptr1.add(16).cast::()); + let l42 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l38 { 0 => None, 1 => { let e = { - let l39 = *((ptr1 + 20) as *const i32); - let l40 = *((ptr1 + 24) as *const i32); - let len41 = l40 as usize; - let bytes41 = Vec::from_raw_parts(l39 as *mut _, len41, len41); - - wit_bindgen::rt::string_lift(bytes41) + let l39 = *ptr1.add(20).cast::<*mut u8>(); + let l40 = *ptr1.add(24).cast::(); + let len41 = l40; + let bytes41 = _rt::Vec::from_raw_parts(l39.cast(), len41, len41); + + _rt::string_lift(bytes41) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l42 { 0 => None, 1 => { let e = { - let l43 = *((ptr1 + 32) as *const i32); - + let l43 = *ptr1.add(32).cast::(); + l43 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::HttpResponseHeaderSize(e66) - } - 28 => { - let e66 = { - let l44 = i32::from(*((ptr1 + 16) as *const u8)); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *((ptr1 + 24) as *const i64); - - l45 as u64 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseBodySize(e66) - } - 29 => { - let e66 = { - let l46 = i32::from(*((ptr1 + 16) as *const u8)); - - match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *((ptr1 + 20) as *const i32); - - l47 as u32 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTrailerSectionSize(e66) - } - 30 => { - let e66 = { - let l48 = i32::from(*((ptr1 + 16) as *const u8)); - let l52 = i32::from(*((ptr1 + 28) as *const u8)); - - super::super::super::wasi::http::types::FieldSizePayload{ + }; + V66::HttpResponseHeaderSize(e66) + } + 28 => { + let e66 = { + let l44 = i32::from(*ptr1.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr1.add(24).cast::(); + + l45 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseBodySize(e66) + } + 29 => { + let e66 = { + let l46 = i32::from(*ptr1.add(16).cast::()); + + match l46 { + 0 => None, + 1 => { + let e = { + let l47 = *ptr1.add(20).cast::(); + + l47 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTrailerSectionSize(e66) + } + 30 => { + let e66 = { + let l48 = i32::from(*ptr1.add(16).cast::()); + let l52 = i32::from(*ptr1.add(28).cast::()); + + super::super::super::wasi::http::types::FieldSizePayload{ field_name: match l48 { 0 => None, 1 => { let e = { - let l49 = *((ptr1 + 20) as *const i32); - let l50 = *((ptr1 + 24) as *const i32); - let len51 = l50 as usize; - let bytes51 = Vec::from_raw_parts(l49 as *mut _, len51, len51); - - wit_bindgen::rt::string_lift(bytes51) + let l49 = *ptr1.add(20).cast::<*mut u8>(); + let l50 = *ptr1.add(24).cast::(); + let len51 = l50; + let bytes51 = _rt::Vec::from_raw_parts(l49.cast(), len51, len51); + + _rt::string_lift(bytes51) }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, field_size: match l52 { 0 => None, 1 => { let e = { - let l53 = *((ptr1 + 32) as *const i32); - + let l53 = *ptr1.add(32).cast::(); + l53 as u32 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), }, } - }; - V66::HttpResponseTrailerSize(e66) - } - 31 => { - let e66 = { - let l54 = i32::from(*((ptr1 + 16) as *const u8)); - - match l54 { - 0 => None, - 1 => { - let e = { - let l55 = *((ptr1 + 20) as *const i32); - let l56 = *((ptr1 + 24) as *const i32); - let len57 = l56 as usize; - let bytes57 = Vec::from_raw_parts(l55 as *mut _, len57, len57); - - wit_bindgen::rt::string_lift(bytes57) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTransferCoding(e66) - } - 32 => { - let e66 = { - let l58 = i32::from(*((ptr1 + 16) as *const u8)); - - match l58 { - 0 => None, - 1 => { - let e = { - let l59 = *((ptr1 + 20) as *const i32); - let l60 = *((ptr1 + 24) as *const i32); - let len61 = l60 as usize; - let bytes61 = Vec::from_raw_parts(l59 as *mut _, len61, len61); - - wit_bindgen::rt::string_lift(bytes61) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseContentCoding(e66) - } - 33 => { - V66::HttpResponseTimeout - } - 34 => { - V66::HttpUpgradeFailed - } - 35 => { - V66::HttpProtocolError - } - 36 => { - V66::LoopDetected - } - 37 => { - V66::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e66 = { - let l62 = i32::from(*((ptr1 + 16) as *const u8)); - - match l62 { - 0 => None, - 1 => { - let e = { - let l63 = *((ptr1 + 20) as *const i32); - let l64 = *((ptr1 + 24) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - V66::InternalError(e66) - } - }; - - v66 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + }; + V66::HttpResponseTrailerSize(e66) + } + 31 => { + let e66 = { + let l54 = i32::from(*ptr1.add(16).cast::()); + + match l54 { + 0 => None, + 1 => { + let e = { + let l55 = *ptr1.add(20).cast::<*mut u8>(); + let l56 = *ptr1.add(24).cast::(); + let len57 = l56; + let bytes57 = _rt::Vec::from_raw_parts( + l55.cast(), + len57, + len57, + ); + + _rt::string_lift(bytes57) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTransferCoding(e66) + } + 32 => { + let e66 = { + let l58 = i32::from(*ptr1.add(16).cast::()); + + match l58 { + 0 => None, + 1 => { + let e = { + let l59 = *ptr1.add(20).cast::<*mut u8>(); + let l60 = *ptr1.add(24).cast::(); + let len61 = l60; + let bytes61 = _rt::Vec::from_raw_parts( + l59.cast(), + len61, + len61, + ); + + _rt::string_lift(bytes61) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseContentCoding(e66) + } + 33 => V66::HttpResponseTimeout, + 34 => V66::HttpUpgradeFailed, + 35 => V66::HttpProtocolError, + 36 => V66::LoopDetected, + 37 => V66::ConfigurationError, + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e66 = { + let l62 = i32::from(*ptr1.add(16).cast::()); + + match l62 { + 0 => None, + 1 => { + let e = { + let l63 = *ptr1.add(20).cast::<*mut u8>(); + let l64 = *ptr1.add(24).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::InternalError(e66) + } + }; + + v66 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - } } - - } - } - pub mod io { - - #[allow(clippy::all)] - pub mod poll { - #[used] + } + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } } + } + impl Pollable { #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(in_: &[&Pollable],) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let vec0 = in_; - let len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } } - let ptr1 = ret_area.as_mut_ptr() as i32; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/poll@0.2.0")] extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; if layout0.size() != 0 { - alloc::dealloc(result0, layout0); + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error { + handle: _rt::Resource, + } + + impl Error { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Error { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self) -> _rt::String { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } + } + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, + } + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => f + .debug_tuple("StreamError::LastOperationFailed") + .field(e) + .finish(), + StreamError::Closed => f.debug_tuple("StreamError::Closed").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 input bytestream. + /// + /// `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` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream { + handle: _rt::Resource, + } + + impl InputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for InputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// An output bytestream. + /// + /// `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` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream { + handle: _rt::Resource, + } + + impl OutputStream { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for OutputStream { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } } - - } - - - #[allow(clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: wit_bindgen::rt::Resource, - } - - impl Error{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> wit_bindgen::rt::string::String{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl InputStream { + #[allow(unused_unsafe, 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. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); - wit_bindgen::rt::string_lift(bytes3) - } - } - } - - } - - - #[allow(clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Error = super::super::super::wasi::io::error::Error; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An error for input-stream and output-stream operations. - pub enum StreamError{ - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() - } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").finish() - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) } - } } - 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 input bytestream. - /// - /// `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` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl InputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for InputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `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` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: wit_bindgen::rt::Resource, - } - - impl OutputStream{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for OutputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result,StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self) -> Result { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + fn wit_import(_: i32, _: *mut u8); } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result,StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let len4 = l3 as usize; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() } - 1 => { - let e = { - let l5 = i32::from(*((ptr0 + 4) as *const u8)); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) + Err(e) + } + _ => _rt::invalid_enum_discriminant(), } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, 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. - /// The created `pollable` is a child resource of the `input-stream`. - /// Implementations may trap if the `input-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self, contents: &[u8]) -> Result<(), StreamError> { 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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); } - 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[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 vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); - match l2 { - 0 => { - let e = (); - Ok(e) + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + unsafe { #[repr(align(4))] - struct RetArea([u8; 12]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); let vec0 = contents; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/streams@0.2.0")] extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ); + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, ptr1); - let l2 = i32::from(*((ptr1 + 0) as *const u8)); + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*((ptr1 + 4) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr1 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self) -> Result<(), StreamError> { + 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; + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/streams@0.2.0")] extern "C" { - #[link_name = "[method]output-stream.flush"] - fn wit_import(_: i32, _: i32, ); + #[link_name = "[method]output-stream.flush"] + fn wit_import(_: i32, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); + let l1 = i32::from(*ptr0.add(0).cast::()); match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self) -> Result<(), StreamError> { + 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; + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/streams@0.2.0")] extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - fn wit_import(_: i32, _: i32, ); + #[link_name = "[method]output-stream.blocking-flush"] + fn wit_import(_: i32, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); + let l1 = i32::from(*ptr0.add(0).cast::()); match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - pub fn subscribe(&self,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + pub fn subscribe(&self) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/streams@0.2.0")] extern "C" { - #[link_name = "[method]output-stream.subscribe"] - fn wit_import(_: i32, ) -> i32; + #[link_name = "[method]output-stream.subscribe"] + fn wit_import(_: i32) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } + fn wit_import(_: i32) -> i32 { + unreachable!() + } let ret = wit_import((self).handle() as i32); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self, len: u64) -> Result<(), StreamError> { + 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; + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/streams@0.2.0")] extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: i32, ); + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { + fn wit_import(_: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => { - let e = (); - Ok(e) + let e = (); + Ok(e) } 1 => { - let e = { - let l2 = i32::from(*((ptr0 + 4) as *const u8)); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *((ptr0 + 8) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + + v4 }; - - v4 - }; - Err(e) + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self, src: &InputStream, len: u64) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) } 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + + v5 }; - - v5 - }; - Err(e) + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice( + &self, + src: &InputStream, + len: u64, + ) -> Result { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, wit_bindgen::rt::as_i64(len), ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + (self).handle() as i32, + (src).handle() as i32, + _rt::as_i64(&len), + ptr0, + ); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { 0 => { - let e = { - let l2 = *((ptr0 + 8) as *const i64); - - l2 as u64 - }; - Ok(e) + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) } 1 => { - let e = { - let l3 = i32::from(*((ptr0 + 8) as *const u8)); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *((ptr0 + 12) as *const i32); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } + + v5 }; - - v5 - }; - Err(e) + Err(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } + _ => _rt::invalid_enum_discriminant(), } - } } - - } - } - } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type ComponentId = super::super::super::super::golem::api::host::ComponentId; - pub type WorkerId = super::super::super::super::golem::api::host::WorkerId; - pub type ComponentVersion = super::super::super::super::golem::api::host::ComponentVersion; - pub type UpdateMode = super::super::super::super::golem::api::host::UpdateMode; - pub type WorkerAnyFilter = super::super::super::super::golem::api::host::WorkerAnyFilter; - pub type WorkerMetadata = super::super::super::super::golem::api::host::WorkerMetadata; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-self-uri"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_self_uri(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::get_self_uri(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = (result1.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 4) as *mut i32) = len3; - *((ptr2 + 0) as *mut i32) = ptr3; - ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-self-uri"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_self_uri(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#jump"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_jump() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::jump(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#fail-with-custom-max-retries"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_fail_with_custom_max_retries(arg0: i64,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::fail_with_custom_max_retries(arg0 as u64); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#explicit-commit"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_explicit_commit(arg0: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::explicit_commit(arg0 as u8); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#atomic-region"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_atomic_region() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::atomic_region(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#idempotence-flag"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_idempotence_flag(arg0: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::idempotence_flag(wit_bindgen::rt::bool_lift(arg0 as u8)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#persist-nothing"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_persist_nothing() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::persist_nothing(); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-workers"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_workers(arg0: i64,arg1: i64,arg2: i32,arg3: i32,arg4: i32,arg5: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result23 = <_GuestImpl as Guest>::get_workers(super::super::super::super::golem::api::host::ComponentId{ - uuid: super::super::super::super::golem::api::host::Uuid{ - high_bits: arg0 as u64, - low_bits: arg1 as u64, + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type ComponentId = super::super::super::super::golem::api::host::ComponentId; + pub type WorkerId = super::super::super::super::golem::api::host::WorkerId; + pub type ComponentVersion = + super::super::super::super::golem::api::host::ComponentVersion; + pub type UpdateMode = super::super::super::super::golem::api::host::UpdateMode; + pub type WorkerAnyFilter = + super::super::super::super::golem::api::host::WorkerAnyFilter; + pub type WorkerMetadata = + super::super::super::super::golem::api::host::WorkerMetadata; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_self_uri_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::get_self_uri(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = (result1.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(4).cast::() = len3; + *ptr2.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_self_uri(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_jump_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::jump(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_fail_with_custom_max_retries_cabi(arg0: i64) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::fail_with_custom_max_retries(arg0 as u64); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_explicit_commit_cabi(arg0: i32) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::explicit_commit(arg0 as u8); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_atomic_region_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::atomic_region(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_idempotence_flag_cabi(arg0: i32) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::idempotence_flag(_rt::bool_lift(arg0 as u8)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_persist_nothing_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::persist_nothing(); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_workers_cabi( + arg0: i64, + arg1: i64, + arg2: i32, + arg3: *mut u8, + arg4: usize, + arg5: i32, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result23 = T::get_workers( + super::super::super::super::golem::api::host::ComponentId { + uuid: super::super::super::super::golem::api::host::Uuid { + high_bits: arg0 as u64, + low_bits: arg1 as u64, }, - }, match arg2 { + }, + match arg2 { 0 => None, 1 => { - let e = { - let base22 = arg3; - let len22 = arg4; - let mut result22 = Vec::with_capacity(len22 as usize); - for i in 0..len22 { - let base = base22 + i * 8; - let e22 = { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - let base21 = l0; - let len21 = l1; - let mut result21 = Vec::with_capacity(len21 as usize); - for i in 0..len21 { - let base = base21 + i * 32; - let e21 = { - let l2 = i32::from(*((base + 0) as *const u8)); - use super::super::super::super::golem::api::host::WorkerPropertyFilter as V20; - let v20 = match l2 { - 0 => { - let e20 = { - let l3 = i32::from(*((base + 8) as *const u8)); - let l4 = *((base + 12) as *const i32); - let l5 = *((base + 16) as *const i32); - let len6 = l5 as usize; - let bytes6 = Vec::from_raw_parts(l4 as *mut _, len6, len6); - - super::super::super::super::golem::api::host::WorkerNameFilter{ - comparator: super::super::super::super::golem::api::host::StringFilterComparator::_lift(l3 as u8), - value: wit_bindgen::rt::string_lift(bytes6), - } - }; - V20::Name(e20) - } - 1 => { - let e20 = { - let l7 = i32::from(*((base + 8) as *const u8)); - let l8 = i32::from(*((base + 9) as *const u8)); - - super::super::super::super::golem::api::host::WorkerStatusFilter{ - comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l7 as u8), - value: super::super::super::super::golem::api::host::WorkerStatus::_lift(l8 as u8), - } - }; - V20::Status(e20) - } - 2 => { - let e20 = { - let l9 = i32::from(*((base + 8) as *const u8)); - let l10 = *((base + 16) as *const i64); - - super::super::super::super::golem::api::host::WorkerVersionFilter{ - comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l9 as u8), - value: l10 as u64, - } - }; - V20::Version(e20) - } - 3 => { - let e20 = { - let l11 = i32::from(*((base + 8) as *const u8)); - let l12 = *((base + 16) as *const i64); - - super::super::super::super::golem::api::host::WorkerCreatedAtFilter{ - comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l11 as u8), - value: l12 as u64, - } - }; - V20::CreatedAt(e20) - } - n => { - debug_assert_eq!(n, 4, "invalid enum discriminant"); - let e20 = { - let l13 = *((base + 8) as *const i32); - let l14 = *((base + 12) as *const i32); - let len15 = l14 as usize; - let bytes15 = Vec::from_raw_parts(l13 as *mut _, len15, len15); - let l16 = i32::from(*((base + 16) as *const u8)); - let l17 = *((base + 20) as *const i32); - let l18 = *((base + 24) as *const i32); - let len19 = l18 as usize; - let bytes19 = Vec::from_raw_parts(l17 as *mut _, len19, len19); - - super::super::super::super::golem::api::host::WorkerEnvFilter{ - name: wit_bindgen::rt::string_lift(bytes15), - comparator: super::super::super::super::golem::api::host::StringFilterComparator::_lift(l16 as u8), - value: wit_bindgen::rt::string_lift(bytes19), - } - }; - V20::Env(e20) - } + let e = { + let base22 = arg3; + let len22 = arg4; + let mut result22 = _rt::Vec::with_capacity(len22); + for i in 0..len22 { + let base = base22.add(i * 8); + let e22 = { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + let base21 = l0; + let len21 = l1; + let mut result21 = _rt::Vec::with_capacity(len21); + for i in 0..len21 { + let base = base21.add(i * 32); + let e21 = { + let l2 = i32::from(*base.add(0).cast::()); + use super::super::super::super::golem::api::host::WorkerPropertyFilter as V20; + let v20 = match l2 { + 0 => { + let e20 = { + let l3 = i32::from( + *base.add(8).cast::(), + ); + let l4 = + *base.add(12).cast::<*mut u8>(); + let l5 = + *base.add(16).cast::(); + let len6 = l5; + let bytes6 = + _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, + ); + + super::super::super::super::golem::api::host::WorkerNameFilter{ + comparator: super::super::super::super::golem::api::host::StringFilterComparator::_lift(l3 as u8), + value: _rt::string_lift(bytes6), + } + }; + V20::Name(e20) + } + 1 => { + let e20 = { + let l7 = i32::from( + *base.add(8).cast::(), + ); + let l8 = i32::from( + *base.add(9).cast::(), + ); + + super::super::super::super::golem::api::host::WorkerStatusFilter{ + comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l7 as u8), + value: super::super::super::super::golem::api::host::WorkerStatus::_lift(l8 as u8), + } + }; + V20::Status(e20) + } + 2 => { + let e20 = { + let l9 = i32::from( + *base.add(8).cast::(), + ); + let l10 = + *base.add(16).cast::(); + + super::super::super::super::golem::api::host::WorkerVersionFilter{ + comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l9 as u8), + value: l10 as u64, + } + }; + V20::Version(e20) + } + 3 => { + let e20 = { + let l11 = i32::from( + *base.add(8).cast::(), + ); + let l12 = + *base.add(16).cast::(); + + super::super::super::super::golem::api::host::WorkerCreatedAtFilter{ + comparator: super::super::super::super::golem::api::host::FilterComparator::_lift(l11 as u8), + value: l12 as u64, + } + }; + V20::CreatedAt(e20) + } + n => { + debug_assert_eq!( + n, 4, + "invalid enum discriminant" + ); + let e20 = { + let l13 = + *base.add(8).cast::<*mut u8>(); + let l14 = + *base.add(12).cast::(); + let len15 = l14; + let bytes15 = + _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); + let l16 = i32::from( + *base.add(16).cast::(), + ); + let l17 = + *base.add(20).cast::<*mut u8>(); + let l18 = + *base.add(24).cast::(); + let len19 = l18; + let bytes19 = + _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ); + + super::super::super::super::golem::api::host::WorkerEnvFilter{ + name: _rt::string_lift(bytes15), + comparator: super::super::super::super::golem::api::host::StringFilterComparator::_lift(l16 as u8), + value: _rt::string_lift(bytes19), + } + }; + V20::Env(e20) + } + }; + + v20 + }; + result21.push(e21); + } + _rt::cabi_dealloc(base21, len21 * 32, 8); + + super::super::super::super::golem::api::host::WorkerAllFilter{ + filters: result21, + } }; - - v20 - }; - result21.push(e21); + result22.push(e22); } - wit_bindgen::rt::dealloc(base21, (len21 as usize) * 32, 8); - - super::super::super::super::golem::api::host::WorkerAllFilter{ - filters: result21, + _rt::cabi_dealloc(base22, len22 * 8, 4); + + super::super::super::super::golem::api::host::WorkerAnyFilter { + filters: result22, } - }; - result22.push(e22); - } - wit_bindgen::rt::dealloc(base22, (len22 as usize) * 8, 4); - - super::super::super::super::golem::api::host::WorkerAnyFilter{ - filters: result22, - } - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }, wit_bindgen::rt::bool_lift(arg5 as u8)); - let ptr24 = _RET_AREA.0.as_mut_ptr() as i32; - let vec36 = result23; - let len36 = vec36.len() as i32; - let layout36 = alloc::Layout::from_size_align_unchecked(vec36.len() * 64, 8); - let result36 = if layout36.size() != 0 - { - let ptr = alloc::alloc(layout36); - if ptr.is_null() - { - alloc::handle_alloc_error(layout36); + }; + Some(e) } - ptr - }else {{ + _ => _rt::invalid_enum_discriminant(), + }, + _rt::bool_lift(arg5 as u8), + ); + let ptr24 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec36 = result23; + let len36 = vec36.len(); + let layout36 = + _rt::alloc::Layout::from_size_align_unchecked(vec36.len() * 64, 8); + let result36 = if layout36.size() != 0 { + let ptr = _rt::alloc::alloc(layout36).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout36); + } + ptr + } else { + { ::core::ptr::null_mut() - }}; - for (i, e) in vec36.into_iter().enumerate() { - let base = result36 as i32 + (i as i32) * 64; - { - let super::super::super::super::golem::api::host::WorkerMetadata{ worker_id:worker_id25, args:args25, env:env25, status:status25, component_version:component_version25, retry_count:retry_count25, } = e; - let super::super::super::super::golem::api::host::WorkerId{ component_id:component_id26, worker_name:worker_name26, } = worker_id25; - let super::super::super::super::golem::api::host::ComponentId{ uuid:uuid27, } = component_id26; - let super::super::super::super::golem::api::host::Uuid{ high_bits:high_bits28, low_bits:low_bits28, } = uuid27; - *((base + 0) as *mut i64) = wit_bindgen::rt::as_i64(high_bits28); - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(low_bits28); - let vec29 = (worker_name26.into_bytes()).into_boxed_slice(); - let ptr29 = vec29.as_ptr() as i32; - let len29 = vec29.len() as i32; - ::core::mem::forget(vec29); - *((base + 20) as *mut i32) = len29; - *((base + 16) as *mut i32) = ptr29; - let vec31 = args25; - let len31 = vec31.len() as i32; - let layout31 = alloc::Layout::from_size_align_unchecked(vec31.len() * 8, 4); - let result31 = if layout31.size() != 0 - { - let ptr = alloc::alloc(layout31); - if ptr.is_null() - { - alloc::handle_alloc_error(layout31); + } + }; + for (i, e) in vec36.into_iter().enumerate() { + let base = result36.add(i * 64); + { + let super::super::super::super::golem::api::host::WorkerMetadata { + worker_id: worker_id25, + args: args25, + env: env25, + status: status25, + component_version: component_version25, + retry_count: retry_count25, + } = e; + let super::super::super::super::golem::api::host::WorkerId { + component_id: component_id26, + worker_name: worker_name26, + } = worker_id25; + let super::super::super::super::golem::api::host::ComponentId { + uuid: uuid27, + } = component_id26; + let super::super::super::super::golem::api::host::Uuid { + high_bits: high_bits28, + low_bits: low_bits28, + } = uuid27; + *base.add(0).cast::() = _rt::as_i64(high_bits28); + *base.add(8).cast::() = _rt::as_i64(low_bits28); + let vec29 = (worker_name26.into_bytes()).into_boxed_slice(); + let ptr29 = vec29.as_ptr().cast::(); + let len29 = vec29.len(); + ::core::mem::forget(vec29); + *base.add(20).cast::() = len29; + *base.add(16).cast::<*mut u8>() = ptr29.cast_mut(); + let vec31 = args25; + let len31 = vec31.len(); + let layout31 = + _rt::alloc::Layout::from_size_align_unchecked(vec31.len() * 8, 4); + let result31 = if layout31.size() != 0 { + let ptr = _rt::alloc::alloc(layout31).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout31); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec31.into_iter().enumerate() { - let base = result31 as i32 + (i as i32) * 8; + } else { { - let vec30 = (e.into_bytes()).into_boxed_slice(); - let ptr30 = vec30.as_ptr() as i32; - let len30 = vec30.len() as i32; - ::core::mem::forget(vec30); - *((base + 4) as *mut i32) = len30; - *((base + 0) as *mut i32) = ptr30; + ::core::ptr::null_mut() } - } - *((base + 28) as *mut i32) = len31; - *((base + 24) as *mut i32) = result31 as i32; - let vec35 = env25; - let len35 = vec35.len() as i32; - let layout35 = alloc::Layout::from_size_align_unchecked(vec35.len() * 16, 4); - let result35 = if layout35.size() != 0 - { - let ptr = alloc::alloc(layout35); - if ptr.is_null() + }; + for (i, e) in vec31.into_iter().enumerate() { + let base = result31.add(i * 8); { - alloc::handle_alloc_error(layout35); + let vec30 = (e.into_bytes()).into_boxed_slice(); + let ptr30 = vec30.as_ptr().cast::(); + let len30 = vec30.len(); + ::core::mem::forget(vec30); + *base.add(4).cast::() = len30; + *base.add(0).cast::<*mut u8>() = ptr30.cast_mut(); + } + } + *base.add(28).cast::() = len31; + *base.add(24).cast::<*mut u8>() = result31; + let vec35 = env25; + let len35 = vec35.len(); + let layout35 = + _rt::alloc::Layout::from_size_align_unchecked(vec35.len() * 16, 4); + let result35 = if layout35.size() != 0 { + let ptr = _rt::alloc::alloc(layout35).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout35); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec35.into_iter().enumerate() { - let base = result35 as i32 + (i as i32) * 16; + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec35.into_iter().enumerate() { + let base = result35.add(i * 16); { - let (t32_0, t32_1, ) = e; - let vec33 = (t32_0.into_bytes()).into_boxed_slice(); - let ptr33 = vec33.as_ptr() as i32; - let len33 = vec33.len() as i32; - ::core::mem::forget(vec33); - *((base + 4) as *mut i32) = len33; - *((base + 0) as *mut i32) = ptr33; - let vec34 = (t32_1.into_bytes()).into_boxed_slice(); - let ptr34 = vec34.as_ptr() as i32; - let len34 = vec34.len() as i32; - ::core::mem::forget(vec34); - *((base + 12) as *mut i32) = len34; - *((base + 8) as *mut i32) = ptr34; + let (t32_0, t32_1) = e; + let vec33 = (t32_0.into_bytes()).into_boxed_slice(); + let ptr33 = vec33.as_ptr().cast::(); + let len33 = vec33.len(); + ::core::mem::forget(vec33); + *base.add(4).cast::() = len33; + *base.add(0).cast::<*mut u8>() = ptr33.cast_mut(); + let vec34 = (t32_1.into_bytes()).into_boxed_slice(); + let ptr34 = vec34.as_ptr().cast::(); + let len34 = vec34.len(); + ::core::mem::forget(vec34); + *base.add(12).cast::() = len34; + *base.add(8).cast::<*mut u8>() = ptr34.cast_mut(); } - } - *((base + 36) as *mut i32) = len35; - *((base + 32) as *mut i32) = result35 as i32; - *((base + 40) as *mut u8) = (status25.clone() as i32) as u8; - *((base + 48) as *mut i64) = wit_bindgen::rt::as_i64(component_version25); - *((base + 56) as *mut i64) = wit_bindgen::rt::as_i64(retry_count25); } - } - *((ptr24 + 4) as *mut i32) = len36; - *((ptr24 + 0) as *mut i32) = result36 as i32; - ptr24 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-workers"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_workers(arg0: i32,) { - let l14 = *((arg0 + 0) as *const i32); - let l15 = *((arg0 + 4) as *const i32); - let base16 = l14; - let len16 = l15; - for i in 0..len16 { - let base = base16 + i *64; - { - let l0 = *((base + 16) as *const i32); - let l1 = *((base + 20) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l4 = *((base + 24) as *const i32); - let l5 = *((base + 28) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *8; - { - let l2 = *((base + 0) as *const i32); - let l3 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); - } + *base.add(36).cast::() = len35; + *base.add(32).cast::<*mut u8>() = result35; + *base.add(40).cast::() = (status25.clone() as i32) as u8; + *base.add(48).cast::() = _rt::as_i64(component_version25); + *base.add(56).cast::() = _rt::as_i64(retry_count25); + } + } + *ptr24.add(4).cast::() = len36; + *ptr24.add(0).cast::<*mut u8>() = result36; + ptr24 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_workers(arg0: *mut u8) { + let l14 = *arg0.add(0).cast::<*mut u8>(); + let l15 = *arg0.add(4).cast::(); + let base16 = l14; + let len16 = l15; + for i in 0..len16 { + let base = base16.add(i * 64); + { + let l0 = *base.add(16).cast::<*mut u8>(); + let l1 = *base.add(20).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l4 = *base.add(24).cast::<*mut u8>(); + let l5 = *base.add(28).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 8); + { + let l2 = *base.add(0).cast::<*mut u8>(); + let l3 = *base.add(4).cast::(); + _rt::cabi_dealloc(l2, l3, 1); } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 8, 4); - let l11 = *((base + 32) as *const i32); - let l12 = *((base + 36) as *const i32); - let base13 = l11; - let len13 = l12; - for i in 0..len13 { - let base = base13 + i *16; - { - let l7 = *((base + 0) as *const i32); - let l8 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l7, (l8) as usize, 1); - let l9 = *((base + 8) as *const i32); - let l10 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l9, (l10) as usize, 1); - } + } + _rt::cabi_dealloc(base6, len6 * 8, 4); + let l11 = *base.add(32).cast::<*mut u8>(); + let l12 = *base.add(36).cast::(); + let base13 = l11; + let len13 = l12; + for i in 0..len13 { + let base = base13.add(i * 16); + { + let l7 = *base.add(0).cast::<*mut u8>(); + let l8 = *base.add(4).cast::(); + _rt::cabi_dealloc(l7, l8, 1); + let l9 = *base.add(8).cast::<*mut u8>(); + let l10 = *base.add(12).cast::(); + _rt::cabi_dealloc(l9, l10, 1); } - wit_bindgen::rt::dealloc(base13, (len13 as usize) * 16, 4); - } } - wit_bindgen::rt::dealloc(base16, (len16 as usize) * 64, 8); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#update-worker"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_update_worker(arg0: i64,arg1: i64,arg2: i32,arg3: i32,arg4: i64,arg5: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg3 as usize; - let bytes0 = Vec::from_raw_parts(arg2 as *mut _, len0, len0); - <_GuestImpl as Guest>::update_worker(super::super::super::super::golem::api::host::WorkerId{ - component_id: super::super::super::super::golem::api::host::ComponentId{ - uuid: super::super::super::super::golem::api::host::Uuid{ - high_bits: arg0 as u64, - low_bits: arg1 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes0), - }, arg4 as u64, super::super::super::super::golem::api::host::UpdateMode::_lift(arg5 as u8)); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn get_self_uri(function_name: wit_bindgen::rt::string::String,) -> wit_bindgen::rt::string::String; - fn jump() -> u64; - fn fail_with_custom_max_retries(max_retries: u64,); - fn explicit_commit(replicas: u8,); - fn atomic_region(); - fn idempotence_flag(enabled: bool,); - fn persist_nothing(); - fn get_workers(component_id: ComponentId,filter: Option,precise: bool,) -> wit_bindgen::rt::vec::Vec::; - fn update_worker(worker_id: WorkerId,component_version: ComponentVersion,update_mode: UpdateMode,); - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - - } + _rt::cabi_dealloc(base13, len13 * 16, 4); + } + } + _rt::cabi_dealloc(base16, len16 * 64, 8); } - } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:runtime-service"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 12223] = [3, 0, 15, 114, 117, 110, 116, 105, 109, 101, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 185, 19, 1, 65, 19, 1, 66, 17, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 3, 1, 112, 127, 1, 106, 1, 3, 1, 3, 1, 113, 21, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 2, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 5, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 2, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 2, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 3, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 7, 1, 112, 8, 1, 114, 1, 5, 110, 111, 100, 101, 115, 9, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 10, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 12, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 14, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 1, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 6, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 3, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 2, 8, 100, 117, 114, 97, 116, 105, 111, 110, 1, 66, 52, 2, 3, 2, 1, 4, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 2, 1, 119, 4, 0, 11, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 3, 0, 4, 1, 119, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 6, 1, 114, 2, 9, 104, 105, 103, 104, 45, 98, 105, 116, 115, 119, 8, 108, 111, 119, 45, 98, 105, 116, 115, 119, 4, 0, 4, 117, 117, 105, 100, 3, 0, 8, 1, 114, 1, 4, 117, 117, 105, 100, 9, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 10, 1, 114, 2, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 11, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 115, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 12, 1, 114, 2, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 4, 0, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 3, 0, 14, 1, 114, 4, 12, 109, 97, 120, 45, 97, 116, 116, 101, 109, 112, 116, 115, 121, 9, 109, 105, 110, 45, 100, 101, 108, 97, 121, 3, 9, 109, 97, 120, 45, 100, 101, 108, 97, 121, 3, 10, 109, 117, 108, 116, 105, 112, 108, 105, 101, 114, 121, 4, 0, 12, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 3, 0, 16, 1, 113, 3, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 0, 0, 27, 112, 101, 114, 115, 105, 115, 116, 45, 114, 101, 109, 111, 116, 101, 45, 115, 105, 100, 101, 45, 101, 102, 102, 101, 99, 116, 115, 0, 0, 5, 115, 109, 97, 114, 116, 0, 0, 4, 0, 17, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 3, 0, 18, 1, 109, 2, 9, 97, 117, 116, 111, 109, 97, 116, 105, 99, 14, 115, 110, 97, 112, 115, 104, 111, 116, 45, 98, 97, 115, 101, 100, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 20, 1, 109, 6, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 13, 103, 114, 101, 97, 116, 101, 114, 45, 101, 113, 117, 97, 108, 7, 103, 114, 101, 97, 116, 101, 114, 10, 108, 101, 115, 115, 45, 101, 113, 117, 97, 108, 4, 108, 101, 115, 115, 4, 0, 17, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 22, 1, 109, 4, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 4, 108, 105, 107, 101, 8, 110, 111, 116, 45, 108, 105, 107, 101, 4, 0, 24, 115, 116, 114, 105, 110, 103, 45, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 24, 1, 109, 7, 7, 114, 117, 110, 110, 105, 110, 103, 4, 105, 100, 108, 101, 9, 115, 117, 115, 112, 101, 110, 100, 101, 100, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 8, 114, 101, 116, 114, 121, 105, 110, 103, 6, 102, 97, 105, 108, 101, 100, 6, 101, 120, 105, 116, 101, 100, 4, 0, 13, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 3, 0, 26, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 18, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 45, 102, 105, 108, 116, 101, 114, 3, 0, 28, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 27, 4, 0, 20, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 45, 102, 105, 108, 116, 101, 114, 3, 0, 30, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 21, 119, 111, 114, 107, 101, 114, 45, 118, 101, 114, 115, 105, 111, 110, 45, 102, 105, 108, 116, 101, 114, 3, 0, 32, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 24, 119, 111, 114, 107, 101, 114, 45, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 45, 102, 105, 108, 116, 101, 114, 3, 0, 34, 1, 114, 3, 4, 110, 97, 109, 101, 115, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 101, 110, 118, 45, 102, 105, 108, 116, 101, 114, 3, 0, 36, 1, 113, 5, 4, 110, 97, 109, 101, 1, 29, 0, 6, 115, 116, 97, 116, 117, 115, 1, 31, 0, 7, 118, 101, 114, 115, 105, 111, 110, 1, 33, 0, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 1, 35, 0, 3, 101, 110, 118, 1, 37, 0, 4, 0, 22, 119, 111, 114, 107, 101, 114, 45, 112, 114, 111, 112, 101, 114, 116, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 38, 1, 112, 39, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 40, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 108, 108, 45, 102, 105, 108, 116, 101, 114, 3, 0, 41, 1, 112, 42, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 43, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 44, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 47, 1, 114, 6, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 4, 97, 114, 103, 115, 46, 3, 101, 110, 118, 48, 6, 115, 116, 97, 116, 117, 115, 27, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 119, 11, 114, 101, 116, 114, 121, 45, 99, 111, 117, 110, 116, 119, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 49, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 3, 1, 3, 1, 20, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 104, 111, 115, 116, 64, 48, 46, 50, 46, 48, 5, 6, 2, 3, 0, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 2, 3, 0, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 2, 3, 0, 3, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 2, 3, 0, 3, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 2, 3, 0, 3, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 2, 3, 0, 3, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 1, 66, 31, 2, 3, 2, 1, 7, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 0, 2, 3, 2, 1, 8, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 9, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 4, 2, 3, 2, 1, 10, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 6, 2, 3, 2, 1, 11, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 8, 2, 3, 2, 1, 12, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 10, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 115, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 12, 1, 64, 0, 0, 119, 4, 0, 4, 106, 117, 109, 112, 1, 13, 1, 64, 1, 11, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 119, 1, 0, 4, 0, 28, 102, 97, 105, 108, 45, 119, 105, 116, 104, 45, 99, 117, 115, 116, 111, 109, 45, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 1, 14, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 15, 101, 120, 112, 108, 105, 99, 105, 116, 45, 99, 111, 109, 109, 105, 116, 1, 15, 1, 64, 0, 1, 0, 4, 0, 13, 97, 116, 111, 109, 105, 99, 45, 114, 101, 103, 105, 111, 110, 1, 16, 1, 64, 1, 7, 101, 110, 97, 98, 108, 101, 100, 127, 1, 0, 4, 0, 16, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 102, 108, 97, 103, 1, 17, 4, 0, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 1, 16, 1, 107, 9, 1, 112, 11, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 1, 6, 102, 105, 108, 116, 101, 114, 18, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 19, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 20, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 5, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 7, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 21, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 13, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 234, 74, 1, 65, 2, 1, 65, 34, 1, 66, 25, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 3, 1, 112, 127, 1, 106, 1, 3, 1, 3, 1, 113, 21, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 2, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 5, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 2, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 2, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 3, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 7, 1, 112, 8, 1, 114, 1, 5, 110, 111, 100, 101, 115, 9, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 10, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 12, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 14, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 16, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 13, 0, 17, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 18, 1, 104, 16, 1, 112, 11, 1, 106, 1, 11, 1, 15, 1, 64, 3, 4, 115, 101, 108, 102, 19, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 20, 0, 21, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 22, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 1, 64, 0, 0, 3, 4, 0, 3, 110, 111, 119, 1, 6, 1, 64, 0, 0, 5, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 7, 1, 105, 1, 1, 64, 1, 4, 119, 104, 101, 110, 3, 0, 8, 4, 0, 17, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 105, 110, 115, 116, 97, 110, 116, 1, 9, 1, 64, 1, 4, 119, 104, 101, 110, 5, 0, 8, 4, 0, 18, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 100, 117, 114, 97, 116, 105, 111, 110, 1, 10, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 3, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 2, 8, 100, 117, 114, 97, 116, 105, 111, 110, 1, 66, 97, 2, 3, 2, 1, 4, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 2, 1, 119, 4, 0, 11, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 3, 0, 4, 1, 119, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 6, 1, 114, 2, 9, 104, 105, 103, 104, 45, 98, 105, 116, 115, 119, 8, 108, 111, 119, 45, 98, 105, 116, 115, 119, 4, 0, 4, 117, 117, 105, 100, 3, 0, 8, 1, 114, 1, 4, 117, 117, 105, 100, 9, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 10, 1, 114, 2, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 11, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 115, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 12, 1, 114, 2, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 4, 0, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 3, 0, 14, 1, 114, 4, 12, 109, 97, 120, 45, 97, 116, 116, 101, 109, 112, 116, 115, 121, 9, 109, 105, 110, 45, 100, 101, 108, 97, 121, 3, 9, 109, 97, 120, 45, 100, 101, 108, 97, 121, 3, 10, 109, 117, 108, 116, 105, 112, 108, 105, 101, 114, 121, 4, 0, 12, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 3, 0, 16, 1, 113, 3, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 0, 0, 27, 112, 101, 114, 115, 105, 115, 116, 45, 114, 101, 109, 111, 116, 101, 45, 115, 105, 100, 101, 45, 101, 102, 102, 101, 99, 116, 115, 0, 0, 5, 115, 109, 97, 114, 116, 0, 0, 4, 0, 17, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 3, 0, 18, 1, 109, 2, 9, 97, 117, 116, 111, 109, 97, 116, 105, 99, 14, 115, 110, 97, 112, 115, 104, 111, 116, 45, 98, 97, 115, 101, 100, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 20, 1, 109, 6, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 13, 103, 114, 101, 97, 116, 101, 114, 45, 101, 113, 117, 97, 108, 7, 103, 114, 101, 97, 116, 101, 114, 10, 108, 101, 115, 115, 45, 101, 113, 117, 97, 108, 4, 108, 101, 115, 115, 4, 0, 17, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 22, 1, 109, 4, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 4, 108, 105, 107, 101, 8, 110, 111, 116, 45, 108, 105, 107, 101, 4, 0, 24, 115, 116, 114, 105, 110, 103, 45, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 24, 1, 109, 7, 7, 114, 117, 110, 110, 105, 110, 103, 4, 105, 100, 108, 101, 9, 115, 117, 115, 112, 101, 110, 100, 101, 100, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 8, 114, 101, 116, 114, 121, 105, 110, 103, 6, 102, 97, 105, 108, 101, 100, 6, 101, 120, 105, 116, 101, 100, 4, 0, 13, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 3, 0, 26, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 18, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 45, 102, 105, 108, 116, 101, 114, 3, 0, 28, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 27, 4, 0, 20, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 45, 102, 105, 108, 116, 101, 114, 3, 0, 30, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 21, 119, 111, 114, 107, 101, 114, 45, 118, 101, 114, 115, 105, 111, 110, 45, 102, 105, 108, 116, 101, 114, 3, 0, 32, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 24, 119, 111, 114, 107, 101, 114, 45, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 45, 102, 105, 108, 116, 101, 114, 3, 0, 34, 1, 114, 3, 4, 110, 97, 109, 101, 115, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 101, 110, 118, 45, 102, 105, 108, 116, 101, 114, 3, 0, 36, 1, 113, 5, 4, 110, 97, 109, 101, 1, 29, 0, 6, 115, 116, 97, 116, 117, 115, 1, 31, 0, 7, 118, 101, 114, 115, 105, 111, 110, 1, 33, 0, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 1, 35, 0, 3, 101, 110, 118, 1, 37, 0, 4, 0, 22, 119, 111, 114, 107, 101, 114, 45, 112, 114, 111, 112, 101, 114, 116, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 38, 1, 112, 39, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 40, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 108, 108, 45, 102, 105, 108, 116, 101, 114, 3, 0, 41, 1, 112, 42, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 43, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 44, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 47, 1, 114, 6, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 4, 97, 114, 103, 115, 46, 3, 101, 110, 118, 48, 6, 115, 116, 97, 116, 117, 115, 27, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 119, 11, 114, 101, 116, 114, 121, 45, 99, 111, 117, 110, 116, 119, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 49, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 3, 1, 1, 107, 45, 1, 105, 51, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 6, 102, 105, 108, 116, 101, 114, 52, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 53, 4, 0, 24, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 54, 1, 104, 51, 1, 112, 50, 1, 107, 56, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 57, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 46, 103, 101, 116, 45, 110, 101, 120, 116, 1, 58, 1, 64, 0, 0, 15, 4, 0, 20, 103, 111, 108, 101, 109, 45, 99, 114, 101, 97, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 59, 1, 112, 125, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 0, 60, 4, 0, 19, 103, 111, 108, 101, 109, 45, 97, 119, 97, 105, 116, 45, 112, 114, 111, 109, 105, 115, 101, 1, 61, 1, 64, 2, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 4, 100, 97, 116, 97, 60, 0, 127, 4, 0, 22, 103, 111, 108, 101, 109, 45, 99, 111, 109, 112, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 62, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 1, 0, 4, 0, 20, 103, 111, 108, 101, 109, 45, 100, 101, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 63, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 1, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 64, 1, 64, 0, 0, 5, 4, 0, 15, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 65, 1, 64, 1, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 1, 0, 4, 0, 15, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 66, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 12, 111, 112, 108, 111, 103, 45, 99, 111, 109, 109, 105, 116, 1, 67, 4, 0, 20, 109, 97, 114, 107, 45, 98, 101, 103, 105, 110, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 65, 1, 64, 1, 5, 98, 101, 103, 105, 110, 5, 1, 0, 4, 0, 18, 109, 97, 114, 107, 45, 101, 110, 100, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 68, 1, 64, 0, 0, 17, 4, 0, 16, 103, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 69, 1, 64, 1, 16, 110, 101, 119, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 17, 1, 0, 4, 0, 16, 115, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 70, 1, 64, 0, 0, 19, 4, 0, 27, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 71, 1, 64, 1, 21, 110, 101, 119, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 19, 1, 0, 4, 0, 27, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 72, 1, 64, 0, 0, 127, 4, 0, 20, 103, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 73, 1, 64, 1, 10, 105, 100, 101, 109, 112, 111, 116, 101, 110, 116, 127, 1, 0, 4, 0, 20, 115, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 74, 1, 64, 0, 0, 9, 4, 0, 24, 103, 101, 110, 101, 114, 97, 116, 101, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 121, 45, 107, 101, 121, 1, 75, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 14, 116, 97, 114, 103, 101, 116, 45, 118, 101, 114, 115, 105, 111, 110, 7, 4, 109, 111, 100, 101, 21, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 76, 3, 1, 20, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 104, 111, 115, 116, 64, 48, 46, 50, 46, 48, 5, 6, 1, 66, 4, 4, 0, 5, 101, 114, 114, 111, 114, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 115, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 101, 114, 114, 111, 114, 46, 116, 111, 45, 100, 101, 98, 117, 103, 45, 115, 116, 114, 105, 110, 103, 1, 2, 3, 1, 19, 119, 97, 115, 105, 58, 105, 111, 47, 101, 114, 114, 111, 114, 64, 48, 46, 50, 46, 48, 5, 7, 2, 3, 0, 4, 5, 101, 114, 114, 111, 114, 1, 66, 40, 2, 3, 2, 1, 8, 4, 0, 5, 101, 114, 114, 111, 114, 3, 0, 0, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 2, 1, 105, 1, 1, 113, 2, 21, 108, 97, 115, 116, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 45, 102, 97, 105, 108, 101, 100, 1, 4, 0, 6, 99, 108, 111, 115, 101, 100, 0, 0, 4, 0, 12, 115, 116, 114, 101, 97, 109, 45, 101, 114, 114, 111, 114, 3, 0, 5, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 1, 1, 104, 7, 1, 112, 125, 1, 106, 1, 10, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 11, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 114, 101, 97, 100, 1, 12, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 114, 101, 97, 100, 1, 12, 1, 106, 1, 119, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 25, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 107, 105, 112, 1, 14, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 107, 105, 112, 1, 14, 1, 105, 3, 1, 64, 1, 4, 115, 101, 108, 102, 9, 0, 15, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 16, 1, 104, 8, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 13, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 99, 104, 101, 99, 107, 45, 119, 114, 105, 116, 101, 1, 18, 1, 106, 0, 1, 6, 1, 64, 2, 4, 115, 101, 108, 102, 17, 8, 99, 111, 110, 116, 101, 110, 116, 115, 10, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 1, 20, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 20, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 19, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 102, 108, 117, 115, 104, 1, 21, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 102, 108, 117, 115, 104, 1, 21, 1, 64, 1, 4, 115, 101, 108, 102, 17, 0, 15, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 22, 1, 64, 2, 4, 115, 101, 108, 102, 17, 3, 108, 101, 110, 119, 0, 19, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 1, 23, 4, 0, 53, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 119, 114, 105, 116, 101, 45, 122, 101, 114, 111, 101, 115, 45, 97, 110, 100, 45, 102, 108, 117, 115, 104, 1, 23, 1, 64, 3, 4, 115, 101, 108, 102, 17, 3, 115, 114, 99, 9, 3, 108, 101, 110, 119, 0, 13, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 115, 112, 108, 105, 99, 101, 1, 24, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 46, 98, 108, 111, 99, 107, 105, 110, 103, 45, 115, 112, 108, 105, 99, 101, 1, 24, 3, 1, 21, 119, 97, 115, 105, 58, 105, 111, 47, 115, 116, 114, 101, 97, 109, 115, 64, 48, 46, 50, 46, 48, 5, 9, 2, 3, 0, 5, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 2, 3, 0, 5, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 1, 66, 192, 1, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 0, 2, 3, 2, 1, 10, 4, 0, 12, 105, 110, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 2, 2, 3, 2, 1, 11, 4, 0, 13, 111, 117, 116, 112, 117, 116, 45, 115, 116, 114, 101, 97, 109, 3, 0, 4, 2, 3, 2, 1, 8, 4, 0, 8, 105, 111, 45, 101, 114, 114, 111, 114, 3, 0, 6, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 8, 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, 0, 6, 109, 101, 116, 104, 111, 100, 3, 0, 10, 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, 0, 6, 115, 99, 104, 101, 109, 101, 3, 0, 12, 1, 107, 115, 1, 107, 123, 1, 114, 2, 5, 114, 99, 111, 100, 101, 14, 9, 105, 110, 102, 111, 45, 99, 111, 100, 101, 15, 4, 0, 17, 68, 78, 83, 45, 101, 114, 114, 111, 114, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 16, 1, 107, 125, 1, 114, 2, 8, 97, 108, 101, 114, 116, 45, 105, 100, 18, 13, 97, 108, 101, 114, 116, 45, 109, 101, 115, 115, 97, 103, 101, 14, 4, 0, 26, 84, 76, 83, 45, 97, 108, 101, 114, 116, 45, 114, 101, 99, 101, 105, 118, 101, 100, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 19, 1, 107, 121, 1, 114, 2, 10, 102, 105, 101, 108, 100, 45, 110, 97, 109, 101, 14, 10, 102, 105, 101, 108, 100, 45, 115, 105, 122, 101, 21, 4, 0, 18, 102, 105, 101, 108, 100, 45, 115, 105, 122, 101, 45, 112, 97, 121, 108, 111, 97, 100, 3, 0, 22, 1, 107, 119, 1, 107, 23, 1, 113, 39, 11, 68, 78, 83, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 9, 68, 78, 83, 45, 101, 114, 114, 111, 114, 1, 17, 0, 21, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 110, 111, 116, 45, 102, 111, 117, 110, 100, 0, 0, 23, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 117, 110, 97, 118, 97, 105, 108, 97, 98, 108, 101, 0, 0, 25, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 73, 80, 45, 112, 114, 111, 104, 105, 98, 105, 116, 101, 100, 0, 0, 25, 100, 101, 115, 116, 105, 110, 97, 116, 105, 111, 110, 45, 73, 80, 45, 117, 110, 114, 111, 117, 116, 97, 98, 108, 101, 0, 0, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 102, 117, 115, 101, 100, 0, 0, 21, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 116, 101, 114, 109, 105, 110, 97, 116, 101, 100, 0, 0, 18, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 23, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 114, 101, 97, 100, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 24, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 119, 114, 105, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 24, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 45, 108, 105, 109, 105, 116, 45, 114, 101, 97, 99, 104, 101, 100, 0, 0, 18, 84, 76, 83, 45, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 0, 0, 21, 84, 76, 83, 45, 99, 101, 114, 116, 105, 102, 105, 99, 97, 116, 101, 45, 101, 114, 114, 111, 114, 0, 0, 18, 84, 76, 83, 45, 97, 108, 101, 114, 116, 45, 114, 101, 99, 101, 105, 118, 101, 100, 1, 20, 0, 19, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 100, 101, 110, 105, 101, 100, 0, 0, 28, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 108, 101, 110, 103, 116, 104, 45, 114, 101, 113, 117, 105, 114, 101, 100, 0, 0, 22, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 98, 111, 100, 121, 45, 115, 105, 122, 101, 1, 24, 0, 27, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 109, 101, 116, 104, 111, 100, 45, 105, 110, 118, 97, 108, 105, 100, 0, 0, 24, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 85, 82, 73, 45, 105, 110, 118, 97, 108, 105, 100, 0, 0, 25, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 85, 82, 73, 45, 116, 111, 111, 45, 108, 111, 110, 103, 0, 0, 32, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 24, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 104, 101, 97, 100, 101, 114, 45, 115, 105, 122, 101, 1, 25, 0, 33, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 25, 72, 84, 84, 80, 45, 114, 101, 113, 117, 101, 115, 116, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 24, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 105, 110, 99, 111, 109, 112, 108, 101, 116, 101, 0, 0, 33, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 25, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 104, 101, 97, 100, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 23, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 98, 111, 100, 121, 45, 115, 105, 122, 101, 1, 24, 0, 34, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 101, 99, 116, 105, 111, 110, 45, 115, 105, 122, 101, 1, 21, 0, 26, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 105, 108, 101, 114, 45, 115, 105, 122, 101, 1, 23, 0, 29, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 114, 97, 110, 115, 102, 101, 114, 45, 99, 111, 100, 105, 110, 103, 1, 14, 0, 28, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 99, 111, 110, 116, 101, 110, 116, 45, 99, 111, 100, 105, 110, 103, 1, 14, 0, 21, 72, 84, 84, 80, 45, 114, 101, 115, 112, 111, 110, 115, 101, 45, 116, 105, 109, 101, 111, 117, 116, 0, 0, 19, 72, 84, 84, 80, 45, 117, 112, 103, 114, 97, 100, 101, 45, 102, 97, 105, 108, 101, 100, 0, 0, 19, 72, 84, 84, 80, 45, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 0, 0, 13, 108, 111, 111, 112, 45, 100, 101, 116, 101, 99, 116, 101, 100, 0, 0, 19, 99, 111, 110, 102, 105, 103, 117, 114, 97, 116, 105, 111, 110, 45, 101, 114, 114, 111, 114, 0, 0, 14, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 14, 0, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 26, 1, 113, 3, 14, 105, 110, 118, 97, 108, 105, 100, 45, 115, 121, 110, 116, 97, 120, 0, 0, 9, 102, 111, 114, 98, 105, 100, 100, 101, 110, 0, 0, 9, 105, 109, 109, 117, 116, 97, 98, 108, 101, 0, 0, 4, 0, 12, 104, 101, 97, 100, 101, 114, 45, 101, 114, 114, 111, 114, 3, 0, 28, 1, 115, 4, 0, 9, 102, 105, 101, 108, 100, 45, 107, 101, 121, 3, 0, 30, 1, 112, 125, 4, 0, 11, 102, 105, 101, 108, 100, 45, 118, 97, 108, 117, 101, 3, 0, 32, 4, 0, 6, 102, 105, 101, 108, 100, 115, 3, 1, 4, 0, 7, 104, 101, 97, 100, 101, 114, 115, 3, 0, 34, 4, 0, 8, 116, 114, 97, 105, 108, 101, 114, 115, 3, 0, 34, 4, 0, 16, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 1, 4, 0, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 1, 4, 0, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 3, 1, 4, 0, 17, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 3, 1, 1, 123, 4, 0, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 3, 0, 41, 4, 0, 17, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 3, 1, 4, 0, 13, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 3, 1, 4, 0, 15, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 3, 1, 4, 0, 17, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 3, 1, 4, 0, 13, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 3, 1, 4, 0, 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, 3, 1, 1, 105, 34, 1, 64, 0, 0, 49, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 102, 105, 101, 108, 100, 115, 1, 50, 1, 111, 2, 31, 33, 1, 112, 51, 1, 106, 1, 49, 1, 29, 1, 64, 1, 7, 101, 110, 116, 114, 105, 101, 115, 52, 0, 53, 4, 0, 24, 91, 115, 116, 97, 116, 105, 99, 93, 102, 105, 101, 108, 100, 115, 46, 102, 114, 111, 109, 45, 108, 105, 115, 116, 1, 54, 1, 104, 34, 1, 112, 33, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 56, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 103, 101, 116, 1, 57, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 127, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 104, 97, 115, 1, 58, 1, 106, 0, 1, 29, 1, 64, 3, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 5, 118, 97, 108, 117, 101, 56, 0, 59, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 115, 101, 116, 1, 60, 1, 64, 2, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 0, 59, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 100, 101, 108, 101, 116, 101, 1, 61, 1, 64, 3, 4, 115, 101, 108, 102, 55, 4, 110, 97, 109, 101, 31, 5, 118, 97, 108, 117, 101, 33, 0, 59, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 97, 112, 112, 101, 110, 100, 1, 62, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 52, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 101, 110, 116, 114, 105, 101, 115, 1, 63, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 49, 4, 0, 20, 91, 109, 101, 116, 104, 111, 100, 93, 102, 105, 101, 108, 100, 115, 46, 99, 108, 111, 110, 101, 1, 64, 1, 104, 37, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 11, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 109, 101, 116, 104, 111, 100, 1, 66, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 14, 4, 0, 40, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 67, 1, 107, 13, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 196, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 99, 104, 101, 109, 101, 1, 69, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 67, 1, 105, 35, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 198, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 104, 101, 97, 100, 101, 114, 115, 1, 71, 1, 105, 44, 1, 106, 1, 200, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 193, 0, 0, 201, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 99, 111, 110, 115, 117, 109, 101, 1, 74, 1, 105, 38, 1, 64, 1, 7, 104, 101, 97, 100, 101, 114, 115, 198, 0, 0, 203, 0, 4, 0, 29, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 1, 76, 1, 104, 38, 1, 105, 47, 1, 106, 1, 206, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 207, 0, 4, 0, 29, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 98, 111, 100, 121, 1, 80, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 11, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 109, 101, 116, 104, 111, 100, 1, 81, 1, 106, 0, 0, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 6, 109, 101, 116, 104, 111, 100, 11, 0, 210, 0, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 109, 101, 116, 104, 111, 100, 1, 83, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 14, 4, 0, 40, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 84, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 15, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 14, 0, 210, 0, 4, 0, 44, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 112, 97, 116, 104, 45, 119, 105, 116, 104, 45, 113, 117, 101, 114, 121, 1, 85, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 196, 0, 4, 0, 31, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 99, 104, 101, 109, 101, 1, 86, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 6, 115, 99, 104, 101, 109, 101, 196, 0, 0, 210, 0, 4, 0, 35, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 115, 99, 104, 101, 109, 101, 1, 87, 4, 0, 34, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 84, 1, 64, 2, 4, 115, 101, 108, 102, 205, 0, 9, 97, 117, 116, 104, 111, 114, 105, 116, 121, 14, 0, 210, 0, 4, 0, 38, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 115, 101, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121, 1, 88, 1, 64, 1, 4, 115, 101, 108, 102, 205, 0, 0, 198, 0, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 46, 104, 101, 97, 100, 101, 114, 115, 1, 89, 1, 105, 39, 1, 64, 0, 0, 218, 0, 4, 0, 28, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 1, 91, 1, 104, 39, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 220, 0, 0, 221, 0, 4, 0, 39, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 1, 64, 2, 4, 115, 101, 108, 102, 220, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 221, 0, 0, 210, 0, 4, 0, 43, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 99, 111, 110, 110, 101, 99, 116, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 4, 0, 42, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 4, 0, 46, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 102, 105, 114, 115, 116, 45, 98, 121, 116, 101, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 4, 0, 45, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 1, 94, 4, 0, 49, 91, 109, 101, 116, 104, 111, 100, 93, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 46, 115, 101, 116, 45, 98, 101, 116, 119, 101, 101, 110, 45, 98, 121, 116, 101, 115, 45, 116, 105, 109, 101, 111, 117, 116, 1, 95, 1, 105, 40, 1, 105, 46, 1, 106, 1, 225, 0, 1, 27, 1, 64, 2, 5, 112, 97, 114, 97, 109, 224, 0, 8, 114, 101, 115, 112, 111, 110, 115, 101, 226, 0, 1, 0, 4, 0, 29, 91, 115, 116, 97, 116, 105, 99, 93, 114, 101, 115, 112, 111, 110, 115, 101, 45, 111, 117, 116, 112, 97, 114, 97, 109, 46, 115, 101, 116, 1, 99, 1, 104, 43, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 42, 4, 0, 32, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 116, 97, 116, 117, 115, 1, 101, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 198, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 104, 101, 97, 100, 101, 114, 115, 1, 102, 1, 64, 1, 4, 115, 101, 108, 102, 228, 0, 0, 201, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 99, 111, 110, 115, 117, 109, 101, 1, 103, 1, 104, 44, 1, 105, 3, 1, 106, 1, 233, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 232, 0, 0, 234, 0, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 46, 115, 116, 114, 101, 97, 109, 1, 107, 1, 105, 45, 1, 64, 1, 4, 116, 104, 105, 115, 200, 0, 0, 236, 0, 4, 0, 28, 91, 115, 116, 97, 116, 105, 99, 93, 105, 110, 99, 111, 109, 105, 110, 103, 45, 98, 111, 100, 121, 46, 102, 105, 110, 105, 115, 104, 1, 109, 1, 104, 45, 1, 105, 9, 1, 64, 1, 4, 115, 101, 108, 102, 238, 0, 0, 239, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 112, 1, 105, 36, 1, 107, 241, 0, 1, 106, 1, 242, 0, 1, 27, 1, 106, 1, 243, 0, 0, 1, 107, 244, 0, 1, 64, 1, 4, 115, 101, 108, 102, 238, 0, 0, 245, 0, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 116, 114, 97, 105, 108, 101, 114, 115, 46, 103, 101, 116, 1, 118, 1, 64, 1, 7, 104, 101, 97, 100, 101, 114, 115, 198, 0, 0, 225, 0, 4, 0, 30, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 1, 119, 1, 104, 46, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 42, 4, 0, 37, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 1, 121, 1, 64, 2, 4, 115, 101, 108, 102, 248, 0, 11, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 42, 0, 210, 0, 4, 0, 41, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 101, 116, 45, 115, 116, 97, 116, 117, 115, 45, 99, 111, 100, 101, 1, 122, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 198, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 104, 101, 97, 100, 101, 114, 115, 1, 123, 1, 64, 1, 4, 115, 101, 108, 102, 248, 0, 0, 207, 0, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 98, 111, 100, 121, 1, 124, 1, 104, 47, 1, 105, 5, 1, 106, 1, 254, 0, 0, 1, 64, 1, 4, 115, 101, 108, 102, 253, 0, 0, 255, 0, 4, 0, 27, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 46, 119, 114, 105, 116, 101, 1, 128, 1, 1, 106, 0, 1, 27, 1, 64, 2, 4, 116, 104, 105, 115, 206, 0, 8, 116, 114, 97, 105, 108, 101, 114, 115, 242, 0, 0, 129, 1, 4, 0, 28, 91, 115, 116, 97, 116, 105, 99, 93, 111, 117, 116, 103, 111, 105, 110, 103, 45, 98, 111, 100, 121, 46, 102, 105, 110, 105, 115, 104, 1, 130, 1, 1, 104, 48, 1, 64, 1, 4, 115, 101, 108, 102, 131, 1, 0, 239, 0, 4, 0, 42, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 115, 117, 98, 115, 99, 114, 105, 98, 101, 1, 132, 1, 1, 105, 43, 1, 106, 1, 133, 1, 1, 27, 1, 106, 1, 134, 1, 0, 1, 107, 135, 1, 1, 64, 1, 4, 115, 101, 108, 102, 131, 1, 0, 136, 1, 4, 0, 36, 91, 109, 101, 116, 104, 111, 100, 93, 102, 117, 116, 117, 114, 101, 45, 105, 110, 99, 111, 109, 105, 110, 103, 45, 114, 101, 115, 112, 111, 110, 115, 101, 46, 103, 101, 116, 1, 137, 1, 1, 104, 7, 1, 107, 27, 1, 64, 1, 3, 101, 114, 114, 138, 1, 0, 139, 1, 4, 0, 15, 104, 116, 116, 112, 45, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 1, 140, 1, 3, 1, 21, 119, 97, 115, 105, 58, 104, 116, 116, 112, 47, 116, 121, 112, 101, 115, 64, 48, 46, 50, 46, 48, 5, 12, 2, 3, 0, 6, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 2, 3, 0, 6, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 2, 3, 0, 6, 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, 2, 3, 0, 6, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 1, 66, 15, 2, 3, 2, 1, 13, 4, 0, 16, 111, 117, 116, 103, 111, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 0, 2, 3, 2, 1, 14, 4, 0, 15, 114, 101, 113, 117, 101, 115, 116, 45, 111, 112, 116, 105, 111, 110, 115, 3, 0, 2, 2, 3, 2, 1, 15, 4, 0, 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, 3, 0, 4, 2, 3, 2, 1, 16, 4, 0, 10, 101, 114, 114, 111, 114, 45, 99, 111, 100, 101, 3, 0, 6, 1, 105, 1, 1, 105, 3, 1, 107, 9, 1, 105, 5, 1, 106, 1, 11, 1, 7, 1, 64, 2, 7, 114, 101, 113, 117, 101, 115, 116, 8, 7, 111, 112, 116, 105, 111, 110, 115, 10, 0, 12, 4, 0, 6, 104, 97, 110, 100, 108, 101, 1, 13, 3, 1, 32, 119, 97, 115, 105, 58, 104, 116, 116, 112, 47, 111, 117, 116, 103, 111, 105, 110, 103, 45, 104, 97, 110, 100, 108, 101, 114, 64, 48, 46, 50, 46, 48, 5, 17, 2, 3, 0, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 2, 3, 0, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 2, 3, 0, 3, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 2, 3, 0, 3, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 2, 3, 0, 3, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 2, 3, 0, 3, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 1, 66, 31, 2, 3, 2, 1, 18, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 0, 2, 3, 2, 1, 19, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 2, 2, 3, 2, 1, 20, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 4, 2, 3, 2, 1, 21, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 6, 2, 3, 2, 1, 22, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 8, 2, 3, 2, 1, 23, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 10, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 115, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 12, 1, 64, 0, 0, 119, 4, 0, 4, 106, 117, 109, 112, 1, 13, 1, 64, 1, 11, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 119, 1, 0, 4, 0, 28, 102, 97, 105, 108, 45, 119, 105, 116, 104, 45, 99, 117, 115, 116, 111, 109, 45, 109, 97, 120, 45, 114, 101, 116, 114, 105, 101, 115, 1, 14, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 15, 101, 120, 112, 108, 105, 99, 105, 116, 45, 99, 111, 109, 109, 105, 116, 1, 15, 1, 64, 0, 1, 0, 4, 0, 13, 97, 116, 111, 109, 105, 99, 45, 114, 101, 103, 105, 111, 110, 1, 16, 1, 64, 1, 7, 101, 110, 97, 98, 108, 101, 100, 127, 1, 0, 4, 0, 16, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 102, 108, 97, 103, 1, 17, 4, 0, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 1, 16, 1, 107, 9, 1, 112, 11, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 1, 6, 102, 105, 108, 116, 101, 114, 18, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 19, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 20, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 5, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 7, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 21, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 24, 4, 1, 24, 103, 111, 108, 101, 109, 58, 105, 116, 47, 114, 117, 110, 116, 105, 109, 101, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 21, 1, 0, 15, 114, 117, 110, 116, 105, 109, 101, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_update_worker_cabi( + arg0: i64, + arg1: i64, + arg2: *mut u8, + arg3: usize, + arg4: i64, + arg5: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg3; + let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); + T::update_worker( + super::super::super::super::golem::api::host::WorkerId { + component_id: + super::super::super::super::golem::api::host::ComponentId { + uuid: super::super::super::super::golem::api::host::Uuid { + high_bits: arg0 as u64, + low_bits: arg1 as u64, + }, + }, + worker_name: _rt::string_lift(bytes0), + }, + arg4 as u64, + super::super::super::super::golem::api::host::UpdateMode::_lift(arg5 as u8), + ); + } + pub trait Guest { + fn get_self_uri(function_name: _rt::String) -> _rt::String; + fn jump() -> u64; + fn fail_with_custom_max_retries(max_retries: u64); + fn explicit_commit(replicas: u8); + fn atomic_region(); + fn idempotence_flag(enabled: bool); + fn persist_nothing(); + fn get_workers( + component_id: ComponentId, + filter: Option, + precise: bool, + ) -> _rt::Vec; + fn update_worker( + worker_id: WorkerId, + component_version: ComponentVersion, + update_mode: UpdateMode, + ); + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#get-self-uri"] + unsafe extern "C" fn export_get_self_uri(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_self_uri_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#get-self-uri"] + unsafe extern "C" fn _post_return_get_self_uri(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_self_uri::<$ty>(arg0) + } + #[export_name = "golem:it/api#jump"] + unsafe extern "C" fn export_jump() -> i64 { + $($path_to_types)*::_export_jump_cabi::<$ty>() + } + #[export_name = "golem:it/api#fail-with-custom-max-retries"] + unsafe extern "C" fn export_fail_with_custom_max_retries(arg0: i64,) { + $($path_to_types)*::_export_fail_with_custom_max_retries_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#explicit-commit"] + unsafe extern "C" fn export_explicit_commit(arg0: i32,) { + $($path_to_types)*::_export_explicit_commit_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#atomic-region"] + unsafe extern "C" fn export_atomic_region() { + $($path_to_types)*::_export_atomic_region_cabi::<$ty>() + } + #[export_name = "golem:it/api#idempotence-flag"] + unsafe extern "C" fn export_idempotence_flag(arg0: i32,) { + $($path_to_types)*::_export_idempotence_flag_cabi::<$ty>(arg0) + } + #[export_name = "golem:it/api#persist-nothing"] + unsafe extern "C" fn export_persist_nothing() { + $($path_to_types)*::_export_persist_nothing_cabi::<$ty>() + } + #[export_name = "golem:it/api#get-workers"] + unsafe extern "C" fn export_get_workers(arg0: i64,arg1: i64,arg2: i32,arg3: *mut u8,arg4: usize,arg5: i32,) -> *mut u8 { + $($path_to_types)*::_export_get_workers_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + #[export_name = "cabi_post_golem:it/api#get-workers"] + unsafe extern "C" fn _post_return_get_workers(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_workers::<$ty>(arg0) + } + #[export_name = "golem:it/api#update-worker"] + unsafe extern "C" fn export_update_worker(arg0: i64,arg1: i64,arg2: *mut u8,arg3: usize,arg4: i64,arg5: i32,) { + $($path_to_types)*::_export_update_worker_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_runtime_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_runtime_service_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:runtime-service:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 9712] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xeaJ\x01A\x02\x01A\"\ +\x01B\x19\x01z\x04\0\x0anode-index\x03\0\0\x01p\x01\x01k\x01\x01o\x02y\x03\x01p\x7f\ +\x01j\x01\x03\x01\x03\x01q\x15\x0crecord-value\x01\x02\0\x0dvariant-value\x01\x04\ +\0\x0aenum-value\x01y\0\x0bflags-value\x01\x05\0\x0btuple-value\x01\x02\0\x0alis\ +t-value\x01\x02\0\x0coption-value\x01\x03\0\x0cresult-value\x01\x06\0\x07prim-u8\ +\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\ +\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\ +\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-str\ +ing\x01s\0\x04\0\x08wit-node\x03\0\x07\x01p\x08\x01r\x01\x05nodes\x09\x04\0\x09w\ +it-value\x03\0\x0a\x01r\x01\x05values\x04\0\x03uri\x03\0\x0c\x01q\x04\x0eprotoco\ +l-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\x15remote-internal-error\x01\ +s\0\x04\0\x09rpc-error\x03\0\x0e\x04\0\x08wasm-rpc\x03\x01\x01i\x10\x01@\x01\x08\ +location\x0d\0\x11\x04\0\x15[constructor]wasm-rpc\x01\x12\x01h\x10\x01p\x0b\x01j\ +\x01\x0b\x01\x0f\x01@\x03\x04self\x13\x0dfunction-names\x0ffunction-params\x14\0\ +\x15\x04\0![method]wasm-rpc.invoke-and-await\x01\x16\x03\x01\x15golem:rpc/types@\ +0.1.0\x05\0\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\ +\x04\0\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[me\ +thod]pollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04pol\ +l\x01\x06\x03\x01\x12wasi:io/poll@0.2.0\x05\x01\x02\x03\0\x01\x08pollable\x01B\x0f\ +\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01\ +w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\ +\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-\ +instant\x01\x09\x01@\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\ +\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x03\x02\x03\0\0\x03uri\x02\x03\0\x02\x08\ +duration\x01Ba\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\ +\x08duration\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11compone\ +nt-version\x03\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\ +\x01r\x01\x04uuid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\ +\x0bworker-names\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog\ +-idx\x05\x04\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\ +\x09max-delay\x03\x0amultipliery\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fper\ +sist-nothing\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persis\ +tence-level\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mo\ +de\x03\0\x14\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-\ +equal\x04less\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equa\ +l\x04like\x08not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07ru\ +nning\x04idle\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0d\ +worker-status\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-nam\ +e-filter\x03\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-statu\ +s-filter\x03\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-\ +filter\x03\0\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at\ +-filter\x03\0\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-en\ +v-filter\x03\0$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\ +\x0acreated-at\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\ +\x01r\x01\x07filters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filter\ +s+\x04\0\x11worker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-i\ +d\x0d\x04args.\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\ +\x0fworker-metadata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0c\ +component-id\x0b\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x01\ +6\x01h3\x01p2\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01\ +:\x01@\0\0\x0f\x04\0\x14golem-create-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\ +\0<\x04\0\x13golem-await-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\ +\0\x16golem-complete-promise\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x14gole\ +m-delete-promise\x01?\x01@\x01\x0dfunction-names\0\x01\x04\0\x0cget-self-uri\x01\ +@\x01@\0\0\x05\x04\0\x0fget-oplog-index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\ +\0\x0fset-oplog-index\x01B\x01@\x01\x08replicas}\x01\0\x04\0\x0coplog-commit\x01\ +C\x04\0\x14mark-begin-operation\x01A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-e\ +nd-operation\x01D\x01@\0\0\x11\x04\0\x10get-retry-policy\x01E\x01@\x01\x10new-re\ +try-policy\x11\x01\0\x04\0\x10set-retry-policy\x01F\x01@\0\0\x13\x04\0\x1bget-op\ +log-persistence-level\x01G\x01@\x01\x15new-persistence-level\x13\x01\0\x04\0\x1b\ +set-oplog-persistence-level\x01H\x01@\0\0\x7f\x04\0\x14get-idempotence-mode\x01I\ +\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\x14set-idempotence-mode\x01J\x01@\0\0\x09\ +\x04\0\x18generate-idempotency-key\x01K\x01@\x03\x09worker-id\x0d\x0etarget-vers\ +ion\x07\x04mode\x15\x01\0\x04\0\x0dupdate-worker\x01L\x03\x01\x14golem:api/host@\ +0.2.0\x05\x06\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\ +\0\x1d[method]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\x07\ +\x02\x03\0\x04\x05error\x01B(\x02\x03\x02\x01\x08\x04\0\x05error\x03\0\0\x02\x03\ +\x02\x01\x02\x04\0\x08pollable\x03\0\x02\x01i\x01\x01q\x02\x15last-operation-fai\ +led\x01\x04\0\x06closed\0\0\x04\0\x0cstream-error\x03\0\x05\x04\0\x0cinput-strea\ +m\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01\ +@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19[method]input-stream.read\x01\x0c\x04\0\ +\"[method]input-stream.blocking-read\x01\x0c\x01j\x01w\x01\x06\x01@\x02\x04self\x09\ +\x03lenw\0\x0d\x04\0\x19[method]input-stream.skip\x01\x0e\x04\0\"[method]input-s\ +tream.blocking-skip\x01\x0e\x01i\x03\x01@\x01\x04self\x09\0\x0f\x04\0\x1e[method\ +]input-stream.subscribe\x01\x10\x01h\x08\x01@\x01\x04self\x11\0\x0d\x04\0![metho\ +d]output-stream.check-write\x01\x12\x01j\0\x01\x06\x01@\x02\x04self\x11\x08conte\ +nts\x0a\0\x13\x04\0\x1b[method]output-stream.write\x01\x14\x04\0.[method]output-\ +stream.blocking-write-and-flush\x01\x14\x01@\x01\x04self\x11\0\x13\x04\0\x1b[met\ +hod]output-stream.flush\x01\x15\x04\0$[method]output-stream.blocking-flush\x01\x15\ +\x01@\x01\x04self\x11\0\x0f\x04\0\x1f[method]output-stream.subscribe\x01\x16\x01\ +@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method]output-stream.write-zeroes\x01\x17\ +\x04\05[method]output-stream.blocking-write-zeroes-and-flush\x01\x17\x01@\x03\x04\ +self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[method]output-stream.splice\x01\x18\x04\ +\0%[method]output-stream.blocking-splice\x01\x18\x03\x01\x15wasi:io/streams@0.2.\ +0\x05\x09\x02\x03\0\x05\x0cinput-stream\x02\x03\0\x05\x0doutput-stream\x01B\xc0\x01\ +\x02\x03\x02\x01\x05\x04\0\x08duration\x03\0\0\x02\x03\x02\x01\x0a\x04\0\x0cinpu\ +t-stream\x03\0\x02\x02\x03\x02\x01\x0b\x04\0\x0doutput-stream\x03\0\x04\x02\x03\x02\ +\x01\x08\x04\0\x08io-error\x03\0\x06\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\ +\x08\x01q\x0a\x03get\0\0\x04head\0\0\x04post\0\0\x03put\0\0\x06delete\0\0\x07con\ +nect\0\0\x07options\0\0\x05trace\0\0\x05patch\0\0\x05other\x01s\0\x04\0\x06metho\ +d\x03\0\x0a\x01q\x03\x04HTTP\0\0\x05HTTPS\0\0\x05other\x01s\0\x04\0\x06scheme\x03\ +\0\x0c\x01ks\x01k{\x01r\x02\x05rcode\x0e\x09info-code\x0f\x04\0\x11DNS-error-pay\ +load\x03\0\x10\x01k}\x01r\x02\x08alert-id\x12\x0dalert-message\x0e\x04\0\x1aTLS-\ +alert-received-payload\x03\0\x13\x01ky\x01r\x02\x0afield-name\x0e\x0afield-size\x15\ +\x04\0\x12field-size-payload\x03\0\x16\x01kw\x01k\x17\x01q'\x0bDNS-timeout\0\0\x09\ +DNS-error\x01\x11\0\x15destination-not-found\0\0\x17destination-unavailable\0\0\x19\ +destination-IP-prohibited\0\0\x19destination-IP-unroutable\0\0\x12connection-ref\ +used\0\0\x15connection-terminated\0\0\x12connection-timeout\0\0\x17connection-re\ +ad-timeout\0\0\x18connection-write-timeout\0\0\x18connection-limit-reached\0\0\x12\ +TLS-protocol-error\0\0\x15TLS-certificate-error\0\0\x12TLS-alert-received\x01\x14\ +\0\x13HTTP-request-denied\0\0\x1cHTTP-request-length-required\0\0\x16HTTP-reques\ +t-body-size\x01\x18\0\x1bHTTP-request-method-invalid\0\0\x18HTTP-request-URI-inv\ +alid\0\0\x19HTTP-request-URI-too-long\0\0\x20HTTP-request-header-section-size\x01\ +\x15\0\x18HTTP-request-header-size\x01\x19\0!HTTP-request-trailer-section-size\x01\ +\x15\0\x19HTTP-request-trailer-size\x01\x17\0\x18HTTP-response-incomplete\0\0!HT\ +TP-response-header-section-size\x01\x15\0\x19HTTP-response-header-size\x01\x17\0\ +\x17HTTP-response-body-size\x01\x18\0\"HTTP-response-trailer-section-size\x01\x15\ +\0\x1aHTTP-response-trailer-size\x01\x17\0\x1dHTTP-response-transfer-coding\x01\x0e\ +\0\x1cHTTP-response-content-coding\x01\x0e\0\x15HTTP-response-timeout\0\0\x13HTT\ +P-upgrade-failed\0\0\x13HTTP-protocol-error\0\0\x0dloop-detected\0\0\x13configur\ +ation-error\0\0\x0einternal-error\x01\x0e\0\x04\0\x0aerror-code\x03\0\x1a\x01q\x03\ +\x0einvalid-syntax\0\0\x09forbidden\0\0\x09immutable\0\0\x04\0\x0cheader-error\x03\ +\0\x1c\x01s\x04\0\x09field-key\x03\0\x1e\x01p}\x04\0\x0bfield-value\x03\0\x20\x04\ +\0\x06fields\x03\x01\x04\0\x07headers\x03\0\"\x04\0\x08trailers\x03\0\"\x04\0\x10\ +incoming-request\x03\x01\x04\0\x10outgoing-request\x03\x01\x04\0\x0frequest-opti\ +ons\x03\x01\x04\0\x11response-outparam\x03\x01\x01{\x04\0\x0bstatus-code\x03\0)\x04\ +\0\x11incoming-response\x03\x01\x04\0\x0dincoming-body\x03\x01\x04\0\x0ffuture-t\ +railers\x03\x01\x04\0\x11outgoing-response\x03\x01\x04\0\x0doutgoing-body\x03\x01\ +\x04\0\x18future-incoming-response\x03\x01\x01i\"\x01@\0\01\x04\0\x13[constructo\ +r]fields\x012\x01o\x02\x1f!\x01p3\x01j\x011\x01\x1d\x01@\x01\x07entries4\05\x04\0\ +\x18[static]fields.from-list\x016\x01h\"\x01p!\x01@\x02\x04self7\x04name\x1f\08\x04\ +\0\x12[method]fields.get\x019\x01@\x02\x04self7\x04name\x1f\0\x7f\x04\0\x12[meth\ +od]fields.has\x01:\x01j\0\x01\x1d\x01@\x03\x04self7\x04name\x1f\x05value8\0;\x04\ +\0\x12[method]fields.set\x01<\x01@\x02\x04self7\x04name\x1f\0;\x04\0\x15[method]\ +fields.delete\x01=\x01@\x03\x04self7\x04name\x1f\x05value!\0;\x04\0\x15[method]f\ +ields.append\x01>\x01@\x01\x04self7\04\x04\0\x16[method]fields.entries\x01?\x01@\ +\x01\x04self7\01\x04\0\x14[method]fields.clone\x01@\x01h%\x01@\x01\x04self\xc1\0\ +\0\x0b\x04\0\x1f[method]incoming-request.method\x01B\x01@\x01\x04self\xc1\0\0\x0e\ +\x04\0([method]incoming-request.path-with-query\x01C\x01k\x0d\x01@\x01\x04self\xc1\ +\0\0\xc4\0\x04\0\x1f[method]incoming-request.scheme\x01E\x04\0\"[method]incoming\ +-request.authority\x01C\x01i#\x01@\x01\x04self\xc1\0\0\xc6\0\x04\0\x20[method]in\ +coming-request.headers\x01G\x01i,\x01j\x01\xc8\0\0\x01@\x01\x04self\xc1\0\0\xc9\0\ +\x04\0\x20[method]incoming-request.consume\x01J\x01i&\x01@\x01\x07headers\xc6\0\0\ +\xcb\0\x04\0\x1d[constructor]outgoing-request\x01L\x01h&\x01i/\x01j\x01\xce\0\0\x01\ +@\x01\x04self\xcd\0\0\xcf\0\x04\0\x1d[method]outgoing-request.body\x01P\x01@\x01\ +\x04self\xcd\0\0\x0b\x04\0\x1f[method]outgoing-request.method\x01Q\x01j\0\0\x01@\ +\x02\x04self\xcd\0\x06method\x0b\0\xd2\0\x04\0#[method]outgoing-request.set-meth\ +od\x01S\x01@\x01\x04self\xcd\0\0\x0e\x04\0([method]outgoing-request.path-with-qu\ +ery\x01T\x01@\x02\x04self\xcd\0\x0fpath-with-query\x0e\0\xd2\0\x04\0,[method]out\ +going-request.set-path-with-query\x01U\x01@\x01\x04self\xcd\0\0\xc4\0\x04\0\x1f[\ +method]outgoing-request.scheme\x01V\x01@\x02\x04self\xcd\0\x06scheme\xc4\0\0\xd2\ +\0\x04\0#[method]outgoing-request.set-scheme\x01W\x04\0\"[method]outgoing-reques\ +t.authority\x01T\x01@\x02\x04self\xcd\0\x09authority\x0e\0\xd2\0\x04\0&[method]o\ +utgoing-request.set-authority\x01X\x01@\x01\x04self\xcd\0\0\xc6\0\x04\0\x20[meth\ +od]outgoing-request.headers\x01Y\x01i'\x01@\0\0\xda\0\x04\0\x1c[constructor]requ\ +est-options\x01[\x01h'\x01k\x01\x01@\x01\x04self\xdc\0\0\xdd\0\x04\0'[method]req\ +uest-options.connect-timeout\x01^\x01@\x02\x04self\xdc\0\x08duration\xdd\0\0\xd2\ +\0\x04\0+[method]request-options.set-connect-timeout\x01_\x04\0*[method]request-\ +options.first-byte-timeout\x01^\x04\0.[method]request-options.set-first-byte-tim\ +eout\x01_\x04\0-[method]request-options.between-bytes-timeout\x01^\x04\01[method\ +]request-options.set-between-bytes-timeout\x01_\x01i(\x01i.\x01j\x01\xe1\0\x01\x1b\ +\x01@\x02\x05param\xe0\0\x08response\xe2\0\x01\0\x04\0\x1d[static]response-outpa\ +ram.set\x01c\x01h+\x01@\x01\x04self\xe4\0\0*\x04\0\x20[method]incoming-response.\ +status\x01e\x01@\x01\x04self\xe4\0\0\xc6\0\x04\0![method]incoming-response.heade\ +rs\x01f\x01@\x01\x04self\xe4\0\0\xc9\0\x04\0![method]incoming-response.consume\x01\ +g\x01h,\x01i\x03\x01j\x01\xe9\0\0\x01@\x01\x04self\xe8\0\0\xea\0\x04\0\x1c[metho\ +d]incoming-body.stream\x01k\x01i-\x01@\x01\x04this\xc8\0\0\xec\0\x04\0\x1c[stati\ +c]incoming-body.finish\x01m\x01h-\x01i\x09\x01@\x01\x04self\xee\0\0\xef\0\x04\0!\ +[method]future-trailers.subscribe\x01p\x01i$\x01k\xf1\0\x01j\x01\xf2\0\x01\x1b\x01\ +j\x01\xf3\0\0\x01k\xf4\0\x01@\x01\x04self\xee\0\0\xf5\0\x04\0\x1b[method]future-\ +trailers.get\x01v\x01@\x01\x07headers\xc6\0\0\xe1\0\x04\0\x1e[constructor]outgoi\ +ng-response\x01w\x01h.\x01@\x01\x04self\xf8\0\0*\x04\0%[method]outgoing-response\ +.status-code\x01y\x01@\x02\x04self\xf8\0\x0bstatus-code*\0\xd2\0\x04\0)[method]o\ +utgoing-response.set-status-code\x01z\x01@\x01\x04self\xf8\0\0\xc6\0\x04\0![meth\ +od]outgoing-response.headers\x01{\x01@\x01\x04self\xf8\0\0\xcf\0\x04\0\x1e[metho\ +d]outgoing-response.body\x01|\x01h/\x01i\x05\x01j\x01\xfe\0\0\x01@\x01\x04self\xfd\ +\0\0\xff\0\x04\0\x1b[method]outgoing-body.write\x01\x80\x01\x01j\0\x01\x1b\x01@\x02\ +\x04this\xce\0\x08trailers\xf2\0\0\x81\x01\x04\0\x1c[static]outgoing-body.finish\ +\x01\x82\x01\x01h0\x01@\x01\x04self\x83\x01\0\xef\0\x04\0*[method]future-incomin\ +g-response.subscribe\x01\x84\x01\x01i+\x01j\x01\x85\x01\x01\x1b\x01j\x01\x86\x01\ +\0\x01k\x87\x01\x01@\x01\x04self\x83\x01\0\x88\x01\x04\0$[method]future-incoming\ +-response.get\x01\x89\x01\x01h\x07\x01k\x1b\x01@\x01\x03err\x8a\x01\0\x8b\x01\x04\ +\0\x0fhttp-error-code\x01\x8c\x01\x03\x01\x15wasi:http/types@0.2.0\x05\x0c\x02\x03\ +\0\x06\x10outgoing-request\x02\x03\0\x06\x0frequest-options\x02\x03\0\x06\x18fut\ +ure-incoming-response\x02\x03\0\x06\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x0d\x04\ +\0\x10outgoing-request\x03\0\0\x02\x03\x02\x01\x0e\x04\0\x0frequest-options\x03\0\ +\x02\x02\x03\x02\x01\x0f\x04\0\x18future-incoming-response\x03\0\x04\x02\x03\x02\ +\x01\x10\x04\0\x0aerror-code\x03\0\x06\x01i\x01\x01i\x03\x01k\x09\x01i\x05\x01j\x01\ +\x0b\x01\x07\x01@\x02\x07request\x08\x07options\x0a\0\x0c\x04\0\x06handle\x01\x0d\ +\x03\x01\x20wasi:http/outgoing-handler@0.2.0\x05\x11\x02\x03\0\x03\x0ccomponent-\ +id\x02\x03\0\x03\x09worker-id\x02\x03\0\x03\x11component-version\x02\x03\0\x03\x0b\ +update-mode\x02\x03\0\x03\x11worker-any-filter\x02\x03\0\x03\x0fworker-metadata\x01\ +B\x1f\x02\x03\x02\x01\x12\x04\0\x0ccomponent-id\x03\0\0\x02\x03\x02\x01\x13\x04\0\ +\x09worker-id\x03\0\x02\x02\x03\x02\x01\x14\x04\0\x11component-version\x03\0\x04\ +\x02\x03\x02\x01\x15\x04\0\x0bupdate-mode\x03\0\x06\x02\x03\x02\x01\x16\x04\0\x11\ +worker-any-filter\x03\0\x08\x02\x03\x02\x01\x17\x04\0\x0fworker-metadata\x03\0\x0a\ +\x01@\x01\x0dfunction-names\0s\x04\0\x0cget-self-uri\x01\x0c\x01@\0\0w\x04\0\x04\ +jump\x01\x0d\x01@\x01\x0bmax-retriesw\x01\0\x04\0\x1cfail-with-custom-max-retrie\ +s\x01\x0e\x01@\x01\x08replicas}\x01\0\x04\0\x0fexplicit-commit\x01\x0f\x01@\0\x01\ +\0\x04\0\x0datomic-region\x01\x10\x01@\x01\x07enabled\x7f\x01\0\x04\0\x10idempot\ +ence-flag\x01\x11\x04\0\x0fpersist-nothing\x01\x10\x01k\x09\x01p\x0b\x01@\x03\x0c\ +component-id\x01\x06filter\x12\x07precise\x7f\0\x13\x04\0\x0bget-workers\x01\x14\ +\x01@\x03\x09worker-id\x03\x11component-version\x05\x0bupdate-mode\x07\x01\0\x04\ +\0\x0dupdate-worker\x01\x15\x04\x01\x0cgolem:it/api\x05\x18\x04\x01\x18golem:it/\ +runtime-service\x04\0\x0b\x15\x01\0\x0fruntime-service\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/runtime-service/src/lib.rs b/test-components/runtime-service/src/lib.rs index 67c245d56f..ac8c740b7a 100644 --- a/test-components/runtime-service/src/lib.rs +++ b/test-components/runtime-service/src/lib.rs @@ -304,3 +304,5 @@ fn read_body(incoming_response: &wasi::http::types::IncomingResponse) -> Vec } body } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rust-echo.wasm b/test-components/rust-echo.wasm index 10aeb59bc9..6ccc67dc40 100755 Binary files a/test-components/rust-echo.wasm and b/test-components/rust-echo.wasm differ diff --git a/test-components/rust-echo/Cargo.lock b/test-components/rust-echo/Cargo.lock index eb421287bf..2866d1af2b 100644 --- a/test-components/rust-echo/Cargo.lock +++ b/test-components/rust-echo/Cargo.lock @@ -79,7 +79,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/rust-echo/cargo.toml b/test-components/rust-echo/cargo.toml index 5f72b4adf3..16fbef32bb 100644 --- a/test-components/rust-echo/cargo.toml +++ b/test-components/rust-echo/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/rust-echo/src/bindings.rs b/test-components/rust-echo/src/bindings.rs index 36f88526af..b466ee8a82 100644 --- a/test-components/rust-echo/src/bindings.rs +++ b/test-components/rust-echo/src/bindings.rs @@ -1,85 +1,137 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_echo_cabi(arg0: *mut u8, arg1: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::echo(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = (result1.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(4).cast::() = len3; + *ptr2.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_echo(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + pub trait Guest { + fn echo(input: _rt::String) -> _rt::String; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "golem:it/api#echo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_echo(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = <_GuestImpl as Guest>::echo(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - let vec3 = (result1.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 4) as *mut i32) = len3; - *((ptr2 + 0) as *mut i32) = ptr3; - ptr2 + unsafe extern "C" fn export_echo(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_echo_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_golem:it/api#echo"] + unsafe extern "C" fn _post_return_echo(arg0: *mut u8,) { + $($path_to_types)*::__post_return_echo::<$ty>(arg0) } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#echo"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_echo(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn echo(input: wit_bindgen::rt::string::String,) -> wit_bindgen::rt::string::String; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; + pub use alloc_crate::alloc; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_rust_echo_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_rust_echo_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:rust-echo"] +#[link_section = "component-type:wit-bindgen:0.25.0:rust-echo:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 256] = [3, 0, 9, 114, 117, 115, 116, 45, 101, 99, 104, 111, 0, 97, 115, 109, 13, 0, 1, 0, 7, 44, 1, 65, 2, 1, 66, 2, 1, 64, 1, 5, 105, 110, 112, 117, 116, 115, 0, 115, 4, 0, 4, 101, 99, 104, 111, 1, 0, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 70, 1, 65, 2, 1, 65, 2, 1, 66, 2, 1, 64, 1, 5, 105, 110, 112, 117, 116, 115, 0, 115, 4, 0, 4, 101, 99, 104, 111, 1, 0, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 18, 103, 111, 108, 101, 109, 58, 105, 116, 47, 114, 117, 115, 116, 45, 101, 99, 104, 111, 4, 0, 11, 15, 1, 0, 9, 114, 117, 115, 116, 45, 101, 99, 104, 111, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 197] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07F\x01A\x02\x01A\x02\x01\ +B\x02\x01@\x01\x05inputs\0s\x04\0\x04echo\x01\0\x04\x01\x0cgolem:it/api\x05\0\x04\ +\x01\x12golem:it/rust-echo\x04\0\x0b\x0f\x01\0\x09rust-echo\x03\0\0\0G\x09produc\ +ers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060\ +.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/rust-echo/src/lib.rs b/test-components/rust-echo/src/lib.rs index b4b8f155fd..22867e5fab 100644 --- a/test-components/rust-echo/src/lib.rs +++ b/test-components/rust-echo/src/lib.rs @@ -9,3 +9,5 @@ impl Guest for Component { input } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rust-service/rpc/child-component/Cargo.toml b/test-components/rust-service/rpc/child-component/Cargo.toml index 9e000e6f89..7ad5b844d9 100644 --- a/test-components/rust-service/rpc/child-component/Cargo.toml +++ b/test-components/rust-service/rpc/child-component/Cargo.toml @@ -18,7 +18,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } common = { path = "../../common" } [package.metadata.component.target] diff --git a/test-components/rust-service/rpc/child-component/src/lib.rs b/test-components/rust-service/rpc/child-component/src/lib.rs index 8d56d95851..f1e60d0042 100644 --- a/test-components/rust-service/rpc/child-component/src/lib.rs +++ b/test-components/rust-service/rpc/child-component/src/lib.rs @@ -45,3 +45,5 @@ impl From for Data { } } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rust-service/rpc/parent-component/src/lib.rs b/test-components/rust-service/rpc/parent-component/src/lib.rs index 89bec7309f..85d327e2e5 100644 --- a/test-components/rust-service/rpc/parent-component/src/lib.rs +++ b/test-components/rust-service/rpc/parent-component/src/lib.rs @@ -50,4 +50,6 @@ impl Guest for Component { api.process(&input) } -} \ No newline at end of file +} + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/rust-service/rust-component-service/Cargo.toml b/test-components/rust-service/rust-component-service/Cargo.toml index 50135fbfe6..0ad09c91d8 100644 --- a/test-components/rust-service/rust-component-service/Cargo.toml +++ b/test-components/rust-service/rust-component-service/Cargo.toml @@ -18,7 +18,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } common = { path = "../common" } [package.metadata.component.target] diff --git a/test-components/rust-service/rust-component-service/src/lib.rs b/test-components/rust-service/rust-component-service/src/lib.rs index 3adea43d16..2beb47e889 100644 --- a/test-components/rust-service/rust-component-service/src/lib.rs +++ b/test-components/rust-service/rust-component-service/src/lib.rs @@ -42,3 +42,5 @@ impl From for Data { } } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/shopping-cart-resource.wasm b/test-components/shopping-cart-resource.wasm index 65d5275d71..9a8e28fb80 100755 Binary files a/test-components/shopping-cart-resource.wasm and b/test-components/shopping-cart-resource.wasm differ diff --git a/test-components/shopping-cart-resource/Cargo.lock b/test-components/shopping-cart-resource/Cargo.lock index 1c41b295ad..41e430576c 100644 --- a/test-components/shopping-cart-resource/Cargo.lock +++ b/test-components/shopping-cart-resource/Cargo.lock @@ -79,7 +79,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/shopping-cart-resource/Cargo.toml b/test-components/shopping-cart-resource/Cargo.toml index 80c8276071..09345e08ea 100644 --- a/test-components/shopping-cart-resource/Cargo.toml +++ b/test-components/shopping-cart-resource/Cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/shopping-cart-resource/src/bindings.rs b/test-components/shopping-cart-resource/src/bindings.rs index db6a58d5af..764165a9cd 100644 --- a/test-components/shopping-cart-resource/src/bindings.rs +++ b/test-components/shopping-cart-resource/src/bindings.rs @@ -1,449 +1,803 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - #[derive(Clone)] - pub struct ProductItem { - pub product_id: wit_bindgen::rt::string::String, - pub name: wit_bindgen::rt::string::String, - pub price: f32, - pub quantity: u32, + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[derive(Clone)] + pub struct ProductItem { + pub product_id: _rt::String, + pub name: _rt::String, + pub price: f32, + pub quantity: u32, + } + impl ::core::fmt::Debug for ProductItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProductItem") + .field("product-id", &self.product_id) + .field("name", &self.name) + .field("price", &self.price) + .field("quantity", &self.quantity) + .finish() + } + } + #[derive(Clone)] + pub struct OrderConfirmation { + pub order_id: _rt::String, + } + impl ::core::fmt::Debug for OrderConfirmation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OrderConfirmation") + .field("order-id", &self.order_id) + .finish() + } + } + #[derive(Clone)] + pub enum CheckoutResult { + Error(_rt::String), + Success(OrderConfirmation), + } + impl ::core::fmt::Debug for CheckoutResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + CheckoutResult::Error(e) => { + f.debug_tuple("CheckoutResult::Error").field(e).finish() + } + CheckoutResult::Success(e) => { + f.debug_tuple("CheckoutResult::Success").field(e).finish() + } + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Cart { + handle: _rt::Resource, + } + + type _CartRep = Option; + + impl Cart { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Cart`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CartRep = Some(val); + let ptr: *mut _CartRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCart` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CartRep); + } + + fn as_ptr(&self) -> *mut _CartRep { + Cart::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Cart`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CartBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Cart>, + } + + impl<'a> CartBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CartRep { + Cart::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Cart { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]golem:it/api")] + extern "C" { + #[link_name = "[resource-drop]cart"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_cart_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = Cart::new(T::new(_rt::string_lift(bytes0))); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_add_item_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: *mut u8, + arg4: usize, + arg5: f32, + arg6: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let len1 = arg4; + let bytes1 = _rt::Vec::from_raw_parts(arg3.cast(), len1, len1); + T::add_item( + CartBorrow::lift(arg0 as u32 as usize).get(), + ProductItem { + product_id: _rt::string_lift(bytes0), + name: _rt::string_lift(bytes1), + price: arg5, + quantity: arg6 as u32, + }, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_remove_item_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + T::remove_item( + CartBorrow::lift(arg0 as u32 as usize).get(), + _rt::string_lift(bytes0), + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_update_item_quantity_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + arg3: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + T::update_item_quantity( + CartBorrow::lift(arg0 as u32 as usize).get(), + _rt::string_lift(bytes0), + arg3 as u32, + ); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_checkout_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::checkout(CartBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + CheckoutResult::Error(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(8).cast::() = len2; + *ptr1.add(4).cast::<*mut u8>() = ptr2.cast_mut(); + } + CheckoutResult::Success(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let OrderConfirmation { + order_id: order_id3, + } = e; + let vec4 = (order_id3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr1.add(8).cast::() = len4; + *ptr1.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_cart_checkout(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + _ => { + let l3 = *arg0.add(4).cast::<*mut u8>(); + let l4 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_get_cart_contents_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::get_cart_contents(CartBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec5 = result0; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 24, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 24); + { + let ProductItem { + product_id: product_id2, + name: name2, + price: price2, + quantity: quantity2, + } = e; + let vec3 = (product_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec4 = (name2.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + *base.add(16).cast::() = _rt::as_f32(price2); + *base.add(20).cast::() = _rt::as_i32(quantity2); + } + } + *ptr1.add(4).cast::() = len5; + *ptr1.add(0).cast::<*mut u8>() = result5; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_cart_get_cart_contents( + arg0: *mut u8, + ) { + let l4 = *arg0.add(0).cast::<*mut u8>(); + let l5 = *arg0.add(4).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 24); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(8).cast::<*mut u8>(); + let l3 = *base.add(12).cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + _rt::cabi_dealloc(base6, len6 * 24, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cart_merge_with_cabi( + arg0: *mut u8, + arg1: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::merge_with( + CartBorrow::lift(arg0 as u32 as usize).get(), + CartBorrow::lift(arg1 as u32 as usize), + ); + } + pub trait Guest { + type Cart: GuestCart; + } + pub trait GuestCart: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]golem:it/api")] + extern "C" { + #[link_name = "[resource-new]cart"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]golem:it/api")] + extern "C" { + #[link_name = "[resource-rep]cart"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(user_id: _rt::String) -> Self; + fn add_item(&self, item: ProductItem); + fn remove_item(&self, product_id: _rt::String); + fn update_item_quantity(&self, product_id: _rt::String, quantity: u32); + fn checkout(&self) -> CheckoutResult; + fn get_cart_contents(&self) -> _rt::Vec; + fn merge_with(&self, other_cart: CartBorrow<'_>); + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#[constructor]cart"] + unsafe extern "C" fn export_constructor_cart(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_constructor_cart_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0, arg1) + } + #[export_name = "golem:it/api#[method]cart.add-item"] + unsafe extern "C" fn export_method_cart_add_item(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,arg5: f32,arg6: i32,) { + $($path_to_types)*::_export_method_cart_add_item_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0, arg1, arg2, arg3, arg4, arg5, arg6) + } + #[export_name = "golem:it/api#[method]cart.remove-item"] + unsafe extern "C" fn export_method_cart_remove_item(arg0: *mut u8,arg1: *mut u8,arg2: usize,) { + $($path_to_types)*::_export_method_cart_remove_item_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0, arg1, arg2) + } + #[export_name = "golem:it/api#[method]cart.update-item-quantity"] + unsafe extern "C" fn export_method_cart_update_item_quantity(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: i32,) { + $($path_to_types)*::_export_method_cart_update_item_quantity_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0, arg1, arg2, arg3) + } + #[export_name = "golem:it/api#[method]cart.checkout"] + unsafe extern "C" fn export_method_cart_checkout(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cart_checkout_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0) + } + #[export_name = "cabi_post_golem:it/api#[method]cart.checkout"] + unsafe extern "C" fn _post_return_method_cart_checkout(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_cart_checkout::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0) + } + #[export_name = "golem:it/api#[method]cart.get-cart-contents"] + unsafe extern "C" fn export_method_cart_get_cart_contents(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cart_get_cart_contents_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0) + } + #[export_name = "cabi_post_golem:it/api#[method]cart.get-cart-contents"] + unsafe extern "C" fn _post_return_method_cart_get_cart_contents(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_cart_get_cart_contents::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0) + } + #[export_name = "golem:it/api#[method]cart.merge-with"] + unsafe extern "C" fn export_method_cart_merge_with(arg0: *mut u8,arg1: i32,) { + $($path_to_types)*::_export_method_cart_merge_with_cabi::<<$ty as $($path_to_types)*::Guest>::Cart>(arg0, arg1) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "golem:it/api#[dtor]cart"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Cart::dtor::< + <$ty as $($path_to_types)*::Guest>::Cart + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); + } } - impl ::core::fmt::Debug for ProductItem { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ProductItem").field("product-id", &self.product_id).field("name", &self.name).field("price", &self.price).field("quantity", &self.quantity).finish() - } + } +} +mod _rt { + pub use alloc_crate::string::String; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } } - #[derive(Clone)] - pub struct OrderConfirmation { - pub order_id: wit_bindgen::rt::string::String, + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) } - impl ::core::fmt::Debug for OrderConfirmation { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("OrderConfirmation").field("order-id", &self.order_id).finish() - } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) } - #[derive(Clone)] - pub enum CheckoutResult{ - Error(wit_bindgen::rt::string::String), - Success(OrderConfirmation), + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() } - impl ::core::fmt::Debug for CheckoutResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - CheckoutResult::Error(e) => { - f.debug_tuple("CheckoutResult::Error").field(e).finish() - } - CheckoutResult::Success(e) => { - f.debug_tuple("CheckoutResult::Success").field(e).finish() - } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } } - } } - - pub use super::super::super::super::super::Cart as Cart; - const _: () = { - #[doc(hidden)] - #[export_name = "golem:it/api#[dtor]cart"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Cart{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]golem:it/api")] - extern "C" { - #[link_name = "[resource-new]cart"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]golem:it/api")] - extern "C" { - #[link_name = "[resource-rep]cart"] - fn rep(_: u32) -> usize; - } - rep(_handle) - } - } + } + pub use alloc_crate::boxed::Box; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) } - pub type OwnCart = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Cart{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]golem:it/api")] - extern "C" { - #[link_name = "[resource-drop]cart"] - fn drop(_: u32); - } - - drop(_handle); - } - } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; } - - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[constructor]cart"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_cart(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let result1 = OwnCart::new(<_CartImpl as GuestCart>::new(wit_bindgen::rt::string_lift(bytes0))); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.add-item"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_add_item(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: f32,arg6: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let len1 = arg4 as usize; - let bytes1 = Vec::from_raw_parts(arg3 as *mut _, len1, len1); - <_CartImpl as GuestCart>::add_item(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), ProductItem{ - product_id: wit_bindgen::rt::string_lift(bytes0), - name: wit_bindgen::rt::string_lift(bytes1), - price: arg5, - quantity: arg6 as u32, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.remove-item"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_remove_item(arg0: i32,arg1: i32,arg2: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - <_CartImpl as GuestCart>::remove_item(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.update-item-quantity"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_update_item_quantity(arg0: i32,arg1: i32,arg2: i32,arg3: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - <_CartImpl as GuestCart>::update_item_quantity(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), wit_bindgen::rt::string_lift(bytes0), arg3 as u32); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.checkout"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_checkout(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CartImpl as GuestCart>::checkout(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - CheckoutResult::Error(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 8) as *mut i32) = len2; - *((ptr1 + 4) as *mut i32) = ptr2; - }, - CheckoutResult::Success(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let OrderConfirmation{ order_id:order_id3, } = e; - let vec4 = (order_id3.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr1 + 8) as *mut i32) = len4; - *((ptr1 + 4) as *mut i32) = ptr4; - }, - } - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#[method]cart.checkout"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_cart_checkout(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - _ => { - let l3 = *((arg0 + 4) as *const i32); - let l4 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l3, (l4) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.get-cart-contents"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_get_cart_contents(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_CartImpl as GuestCart>::get_cart_contents(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec5 = result0; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 24, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 24; - { - let ProductItem{ product_id:product_id2, name:name2, price:price2, quantity:quantity2, } = e; - let vec3 = (product_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let vec4 = (name2.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = ptr4; - *((base + 16) as *mut f32) = wit_bindgen::rt::as_f32(price2); - *((base + 20) as *mut i32) = wit_bindgen::rt::as_i32(quantity2); - } - } - *((ptr1 + 4) as *mut i32) = len5; - *((ptr1 + 0) as *mut i32) = result5 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#[method]cart.get-cart-contents"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_cart_get_cart_contents(arg0: i32,) { - let l4 = *((arg0 + 0) as *const i32); - let l5 = *((arg0 + 4) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *24; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 8) as *const i32); - let l3 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 24, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#[method]cart.merge-with"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_cart_merge_with(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_CartImpl as GuestCart>::merge_with(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), wit_bindgen::rt::Resource::::lift_borrow(arg1 as u32 as usize)); - } - }; - use super::super::super::super::super::Cart as _CartImpl; - pub trait GuestCart { - fn new(user_id: wit_bindgen::rt::string::String,) -> Self; - fn add_item(&self,item: ProductItem,); - fn remove_item(&self,product_id: wit_bindgen::rt::string::String,); - fn update_item_quantity(&self,product_id: wit_bindgen::rt::string::String,quantity: u32,); - fn checkout(&self,) -> CheckoutResult; - fn get_cart_contents(&self,) -> wit_bindgen::rt::vec::Vec::; - fn merge_with(&self,other_cart: &Cart,); + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_shopping_cart_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) } +#[doc(inline)] +pub(crate) use __export_shopping_cart_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:shopping-cart"] +#[link_section = "component-type:wit-bindgen:0.25.0:shopping-cart:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1308] = [3, 0, 13, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 179, 4, 1, 65, 2, 1, 66, 26, 1, 114, 4, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 4, 110, 97, 109, 101, 115, 5, 112, 114, 105, 99, 101, 118, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 4, 0, 12, 112, 114, 111, 100, 117, 99, 116, 45, 105, 116, 101, 109, 3, 0, 0, 1, 112, 1, 1, 114, 4, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 5, 105, 116, 101, 109, 115, 2, 5, 116, 111, 116, 97, 108, 118, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 119, 4, 0, 5, 111, 114, 100, 101, 114, 3, 0, 3, 1, 114, 1, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 4, 0, 18, 111, 114, 100, 101, 114, 45, 99, 111, 110, 102, 105, 114, 109, 97, 116, 105, 111, 110, 3, 0, 5, 1, 113, 2, 5, 101, 114, 114, 111, 114, 1, 115, 0, 7, 115, 117, 99, 99, 101, 115, 115, 1, 6, 0, 4, 0, 15, 99, 104, 101, 99, 107, 111, 117, 116, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 4, 0, 4, 99, 97, 114, 116, 3, 1, 1, 105, 9, 1, 64, 1, 7, 117, 115, 101, 114, 45, 105, 100, 115, 0, 10, 4, 0, 17, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 97, 114, 116, 1, 11, 1, 104, 9, 1, 64, 2, 4, 115, 101, 108, 102, 12, 4, 105, 116, 101, 109, 1, 1, 0, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 97, 100, 100, 45, 105, 116, 101, 109, 1, 13, 1, 64, 2, 4, 115, 101, 108, 102, 12, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 1, 0, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 114, 101, 109, 111, 118, 101, 45, 105, 116, 101, 109, 1, 14, 1, 64, 3, 4, 115, 101, 108, 102, 12, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 1, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 117, 112, 100, 97, 116, 101, 45, 105, 116, 101, 109, 45, 113, 117, 97, 110, 116, 105, 116, 121, 1, 15, 1, 64, 1, 4, 115, 101, 108, 102, 12, 0, 8, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 99, 104, 101, 99, 107, 111, 117, 116, 1, 16, 1, 64, 1, 4, 115, 101, 108, 102, 12, 0, 2, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 103, 101, 116, 45, 99, 97, 114, 116, 45, 99, 111, 110, 116, 101, 110, 116, 115, 1, 17, 1, 64, 2, 4, 115, 101, 108, 102, 12, 10, 111, 116, 104, 101, 114, 45, 99, 97, 114, 116, 12, 1, 0, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 109, 101, 114, 103, 101, 45, 119, 105, 116, 104, 1, 18, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 209, 4, 1, 65, 2, 1, 65, 2, 1, 66, 26, 1, 114, 4, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 4, 110, 97, 109, 101, 115, 5, 112, 114, 105, 99, 101, 118, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 4, 0, 12, 112, 114, 111, 100, 117, 99, 116, 45, 105, 116, 101, 109, 3, 0, 0, 1, 112, 1, 1, 114, 4, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 5, 105, 116, 101, 109, 115, 2, 5, 116, 111, 116, 97, 108, 118, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 119, 4, 0, 5, 111, 114, 100, 101, 114, 3, 0, 3, 1, 114, 1, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 4, 0, 18, 111, 114, 100, 101, 114, 45, 99, 111, 110, 102, 105, 114, 109, 97, 116, 105, 111, 110, 3, 0, 5, 1, 113, 2, 5, 101, 114, 114, 111, 114, 1, 115, 0, 7, 115, 117, 99, 99, 101, 115, 115, 1, 6, 0, 4, 0, 15, 99, 104, 101, 99, 107, 111, 117, 116, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 4, 0, 4, 99, 97, 114, 116, 3, 1, 1, 105, 9, 1, 64, 1, 7, 117, 115, 101, 114, 45, 105, 100, 115, 0, 10, 4, 0, 17, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 99, 97, 114, 116, 1, 11, 1, 104, 9, 1, 64, 2, 4, 115, 101, 108, 102, 12, 4, 105, 116, 101, 109, 1, 1, 0, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 97, 100, 100, 45, 105, 116, 101, 109, 1, 13, 1, 64, 2, 4, 115, 101, 108, 102, 12, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 1, 0, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 114, 101, 109, 111, 118, 101, 45, 105, 116, 101, 109, 1, 14, 1, 64, 3, 4, 115, 101, 108, 102, 12, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 1, 0, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 117, 112, 100, 97, 116, 101, 45, 105, 116, 101, 109, 45, 113, 117, 97, 110, 116, 105, 116, 121, 1, 15, 1, 64, 1, 4, 115, 101, 108, 102, 12, 0, 8, 4, 0, 21, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 99, 104, 101, 99, 107, 111, 117, 116, 1, 16, 1, 64, 1, 4, 115, 101, 108, 102, 12, 0, 2, 4, 0, 30, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 103, 101, 116, 45, 99, 97, 114, 116, 45, 99, 111, 110, 116, 101, 110, 116, 115, 1, 17, 1, 64, 2, 4, 115, 101, 108, 102, 12, 10, 111, 116, 104, 101, 114, 45, 99, 97, 114, 116, 12, 1, 0, 4, 0, 23, 91, 109, 101, 116, 104, 111, 100, 93, 99, 97, 114, 116, 46, 109, 101, 114, 103, 101, 45, 119, 105, 116, 104, 1, 18, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 22, 103, 111, 108, 101, 109, 58, 105, 116, 47, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 4, 0, 11, 19, 1, 0, 13, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 725] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xd1\x04\x01A\x02\x01\ +A\x02\x01B\x1a\x01r\x04\x0aproduct-ids\x04names\x05pricev\x08quantityy\x04\0\x0c\ +product-item\x03\0\0\x01p\x01\x01r\x04\x08order-ids\x05items\x02\x05totalv\x09ti\ +mestampw\x04\0\x05order\x03\0\x03\x01r\x01\x08order-ids\x04\0\x12order-confirmat\ +ion\x03\0\x05\x01q\x02\x05error\x01s\0\x07success\x01\x06\0\x04\0\x0fcheckout-re\ +sult\x03\0\x07\x04\0\x04cart\x03\x01\x01i\x09\x01@\x01\x07user-ids\0\x0a\x04\0\x11\ +[constructor]cart\x01\x0b\x01h\x09\x01@\x02\x04self\x0c\x04item\x01\x01\0\x04\0\x15\ +[method]cart.add-item\x01\x0d\x01@\x02\x04self\x0c\x0aproduct-ids\x01\0\x04\0\x18\ +[method]cart.remove-item\x01\x0e\x01@\x03\x04self\x0c\x0aproduct-ids\x08quantity\ +y\x01\0\x04\0![method]cart.update-item-quantity\x01\x0f\x01@\x01\x04self\x0c\0\x08\ +\x04\0\x15[method]cart.checkout\x01\x10\x01@\x01\x04self\x0c\0\x02\x04\0\x1e[met\ +hod]cart.get-cart-contents\x01\x11\x01@\x02\x04self\x0c\x0aother-cart\x0c\x01\0\x04\ +\0\x17[method]cart.merge-with\x01\x12\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x16g\ +olem:it/shopping-cart\x04\0\x0b\x13\x01\0\x0dshopping-cart\x03\0\0\0G\x09produce\ +rs\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.\ +25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/shopping-cart-resource/src/lib.rs b/test-components/shopping-cart-resource/src/lib.rs index f5d1112589..b14166c934 100644 --- a/test-components/shopping-cart-resource/src/lib.rs +++ b/test-components/shopping-cart-resource/src/lib.rs @@ -1,10 +1,16 @@ mod bindings; -use std::cell::RefCell; use crate::bindings::exports::golem::it::api::*; +use std::cell::RefCell; use rand::prelude::*; +struct Component; + +impl Guest for Component { + type Cart = crate::Cart; +} + pub struct Cart { user_id: String, items: RefCell>, @@ -33,7 +39,9 @@ impl GuestCart for Cart { product_id, self.user_id ); - self.items.borrow_mut().retain(|item| item.product_id != product_id); + self.items + .borrow_mut() + .retain(|item| item.product_id != product_id); } fn update_item_quantity(&self, product_id: String, quantity: u32) { @@ -66,7 +74,7 @@ impl GuestCart for Cart { self.items.borrow().clone() } - fn merge_with(&self, other_cart: &Cart) { + fn merge_with(&self, _other_cart: CartBorrow<'_>) { todo!() } } @@ -125,3 +133,5 @@ fn dispatch_order() -> Result<(), &'static str> { // Otherwise, return a success result. Ok(()) } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/shopping-cart.wasm b/test-components/shopping-cart.wasm index 3eb6c34435..1640790d09 100644 Binary files a/test-components/shopping-cart.wasm and b/test-components/shopping-cart.wasm differ diff --git a/test-components/shopping-cart/Cargo.lock b/test-components/shopping-cart/Cargo.lock index 1c41b295ad..41e430576c 100644 --- a/test-components/shopping-cart/Cargo.lock +++ b/test-components/shopping-cart/Cargo.lock @@ -79,7 +79,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/shopping-cart/Cargo.toml b/test-components/shopping-cart/Cargo.toml index ddb97e4b2d..11c3a464eb 100644 --- a/test-components/shopping-cart/Cargo.toml +++ b/test-components/shopping-cart/Cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/shopping-cart/src/bindings.rs b/test-components/shopping-cart/src/bindings.rs index 29092baa21..9a08305f46 100644 --- a/test-components/shopping-cart/src/bindings.rs +++ b/test-components/shopping-cart/src/bindings.rs @@ -1,2718 +1,3254 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod host { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Uri = super::super::super::golem::rpc::types::Uri; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - /// An index into the persistent log storing all performed operations of a worker - pub type OplogIndex = u64; - /// Represents a Golem component's version - pub type ComponentVersion = u64; - /// UUID - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Uuid { - pub high_bits: u64, - pub low_bits: u64, - } - impl ::core::fmt::Debug for Uuid { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uuid").field("high-bits", &self.high_bits).field("low-bits", &self.low_bits).finish() - } - } - /// Represents a Golem component - #[repr(C)] - #[derive(Clone, Copy)] - pub struct ComponentId { - pub uuid: Uuid, - } - impl ::core::fmt::Debug for ComponentId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ComponentId").field("uuid", &self.uuid).finish() - } - } - /// Represents a Golem worker - #[derive(Clone)] - pub struct WorkerId { - pub component_id: ComponentId, - pub worker_name: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerId").field("component-id", &self.component_id).field("worker-name", &self.worker_name).finish() - } - } - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - #[derive(Clone)] - pub struct PromiseId { - pub worker_id: WorkerId, - pub oplog_idx: OplogIndex, - } - impl ::core::fmt::Debug for PromiseId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("PromiseId").field("worker-id", &self.worker_id).field("oplog-idx", &self.oplog_idx).finish() - } - } - /// Configures how the executor retries failures - #[repr(C)] - #[derive(Clone, Copy)] - pub struct RetryPolicy { - /// The maximum number of retries before the worker becomes permanently failed - pub max_attempts: u32, - /// The minimum delay between retries (applied to the first retry) - pub min_delay: Duration, - /// The maximum delay between retries - pub max_delay: Duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - pub multiplier: u32, - } - impl ::core::fmt::Debug for RetryPolicy { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RetryPolicy").field("max-attempts", &self.max_attempts).field("min-delay", &self.min_delay).field("max-delay", &self.max_delay).field("multiplier", &self.multiplier).finish() - } - } - /// Configurable persistence level for workers - #[derive(Clone, Copy)] - pub enum PersistenceLevel{ - PersistNothing, - PersistRemoteSideEffects, - Smart, - } - impl ::core::fmt::Debug for PersistenceLevel { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - PersistenceLevel::PersistNothing => { - f.debug_tuple("PersistenceLevel::PersistNothing").finish() - } - PersistenceLevel::PersistRemoteSideEffects => { - f.debug_tuple("PersistenceLevel::PersistRemoteSideEffects").finish() - } - PersistenceLevel::Smart => { - f.debug_tuple("PersistenceLevel::Smart").finish() - } - } - } - } - /// Describes how to update a worker to a different component version - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum UpdateMode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - Automatic, - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - SnapshotBased, - } - impl ::core::fmt::Debug for UpdateMode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - UpdateMode::Automatic => { - f.debug_tuple("UpdateMode::Automatic").finish() - } - UpdateMode::SnapshotBased => { - f.debug_tuple("UpdateMode::SnapshotBased").finish() - } - } - } - } - - impl UpdateMode{ - pub(crate) unsafe fn _lift(val: u8) -> UpdateMode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => UpdateMode::Automatic, - 1 => UpdateMode::SnapshotBased, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum FilterComparator { - Equal, - NotEqual, - GreaterEqual, - Greater, - LessEqual, - Less, - } - impl ::core::fmt::Debug for FilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - FilterComparator::Equal => { - f.debug_tuple("FilterComparator::Equal").finish() - } - FilterComparator::NotEqual => { - f.debug_tuple("FilterComparator::NotEqual").finish() - } - FilterComparator::GreaterEqual => { - f.debug_tuple("FilterComparator::GreaterEqual").finish() - } - FilterComparator::Greater => { - f.debug_tuple("FilterComparator::Greater").finish() - } - FilterComparator::LessEqual => { - f.debug_tuple("FilterComparator::LessEqual").finish() - } - FilterComparator::Less => { - f.debug_tuple("FilterComparator::Less").finish() - } - } - } - } - - impl FilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> FilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => FilterComparator::Equal, - 1 => FilterComparator::NotEqual, - 2 => FilterComparator::GreaterEqual, - 3 => FilterComparator::Greater, - 4 => FilterComparator::LessEqual, - 5 => FilterComparator::Less, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum StringFilterComparator { - Equal, - NotEqual, - Like, - NotLike, - } - impl ::core::fmt::Debug for StringFilterComparator { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StringFilterComparator::Equal => { - f.debug_tuple("StringFilterComparator::Equal").finish() - } - StringFilterComparator::NotEqual => { - f.debug_tuple("StringFilterComparator::NotEqual").finish() - } - StringFilterComparator::Like => { - f.debug_tuple("StringFilterComparator::Like").finish() - } - StringFilterComparator::NotLike => { - f.debug_tuple("StringFilterComparator::NotLike").finish() - } - } - } - } - - impl StringFilterComparator{ - pub(crate) unsafe fn _lift(val: u8) -> StringFilterComparator{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => StringFilterComparator::Equal, - 1 => StringFilterComparator::NotEqual, - 2 => StringFilterComparator::Like, - 3 => StringFilterComparator::NotLike, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum WorkerStatus { - /// The worker is running an invoked function - Running, - /// The worker is ready to run an invoked function - Idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - Suspended, - /// The last invocation was interrupted but will be resumed - Interrupted, - /// The last invocation failed and a retry was scheduled - Retrying, - /// The last invocation failed and the worker can no longer be used - Failed, - /// The worker exited after a successful invocation and can no longer be invoked - Exited, - } - impl ::core::fmt::Debug for WorkerStatus { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerStatus::Running => { - f.debug_tuple("WorkerStatus::Running").finish() - } - WorkerStatus::Idle => { - f.debug_tuple("WorkerStatus::Idle").finish() - } - WorkerStatus::Suspended => { - f.debug_tuple("WorkerStatus::Suspended").finish() - } - WorkerStatus::Interrupted => { - f.debug_tuple("WorkerStatus::Interrupted").finish() - } - WorkerStatus::Retrying => { - f.debug_tuple("WorkerStatus::Retrying").finish() - } - WorkerStatus::Failed => { - f.debug_tuple("WorkerStatus::Failed").finish() - } - WorkerStatus::Exited => { - f.debug_tuple("WorkerStatus::Exited").finish() - } - } - } - } - - impl WorkerStatus{ - pub(crate) unsafe fn _lift(val: u8) -> WorkerStatus{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => WorkerStatus::Running, - 1 => WorkerStatus::Idle, - 2 => WorkerStatus::Suspended, - 3 => WorkerStatus::Interrupted, - 4 => WorkerStatus::Retrying, - 5 => WorkerStatus::Failed, - 6 => WorkerStatus::Exited, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[derive(Clone)] - pub struct WorkerNameFilter { - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerNameFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerNameFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerStatusFilter { - pub comparator: FilterComparator, - pub value: WorkerStatus, - } - impl ::core::fmt::Debug for WorkerStatusFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerStatusFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerVersionFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerVersionFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerVersionFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct WorkerCreatedAtFilter { - pub comparator: FilterComparator, - pub value: u64, - } - impl ::core::fmt::Debug for WorkerCreatedAtFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerCreatedAtFilter").field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub struct WorkerEnvFilter { - pub name: wit_bindgen::rt::string::String, - pub comparator: StringFilterComparator, - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for WorkerEnvFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerEnvFilter").field("name", &self.name).field("comparator", &self.comparator).field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum WorkerPropertyFilter{ - Name(WorkerNameFilter), - Status(WorkerStatusFilter), - Version(WorkerVersionFilter), - CreatedAt(WorkerCreatedAtFilter), - Env(WorkerEnvFilter), - } - impl ::core::fmt::Debug for WorkerPropertyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WorkerPropertyFilter::Name(e) => { - f.debug_tuple("WorkerPropertyFilter::Name").field(e).finish() - } - WorkerPropertyFilter::Status(e) => { - f.debug_tuple("WorkerPropertyFilter::Status").field(e).finish() - } - WorkerPropertyFilter::Version(e) => { - f.debug_tuple("WorkerPropertyFilter::Version").field(e).finish() - } - WorkerPropertyFilter::CreatedAt(e) => { - f.debug_tuple("WorkerPropertyFilter::CreatedAt").field(e).finish() - } - WorkerPropertyFilter::Env(e) => { - f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WorkerAllFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAllFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAllFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerAnyFilter { - pub filters: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WorkerAnyFilter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerAnyFilter").field("filters", &self.filters).finish() - } - } - #[derive(Clone)] - pub struct WorkerMetadata { - pub worker_id: WorkerId, - pub args: wit_bindgen::rt::vec::Vec::, - pub env: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,wit_bindgen::rt::string::String,)>, - pub status: WorkerStatus, - pub component_version: u64, - pub retry_count: u64, - } - impl ::core::fmt::Debug for WorkerMetadata { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WorkerMetadata").field("worker-id", &self.worker_id).field("args", &self.args).field("env", &self.env).field("status", &self.status).field("component-version", &self.component_version).field("retry-count", &self.retry_count).finish() - } - } - - #[derive(Debug)] - #[repr(transparent)] - pub struct GetWorkers{ - handle: wit_bindgen::rt::Resource, - } - - impl GetWorkers{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for GetWorkers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]get-workers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn new(component_id: ComponentId,filter: Option<&WorkerAnyFilter>,precise: bool,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - let ComponentId{ uuid:uuid0, } = component_id; - let Uuid{ high_bits:high_bits1, low_bits:low_bits1, } = uuid0; - let (result14_0,result14_1,result14_2,) = match filter { - Some(e) => { - let WorkerAnyFilter{ filters:filters2, } = e; - let vec13 = filters2; - let len13 = vec13.len() as i32; - let layout13 = alloc::Layout::from_size_align_unchecked(vec13.len() * 8, 4); - let result13 = if layout13.size() != 0 - { - let ptr = alloc::alloc(layout13); - if ptr.is_null() - { - alloc::handle_alloc_error(layout13); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec13.into_iter().enumerate() { - let base = result13 as i32 + (i as i32) * 8; - { - let WorkerAllFilter{ filters:filters3, } = e; - let vec12 = filters3; - let len12 = vec12.len() as i32; - let layout12 = alloc::Layout::from_size_align_unchecked(vec12.len() * 32, 8); - let result12 = if layout12.size() != 0 - { - let ptr = alloc::alloc(layout12); - if ptr.is_null() - { - alloc::handle_alloc_error(layout12); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec12.into_iter().enumerate() { - let base = result12 as i32 + (i as i32) * 32; - { - match e { - WorkerPropertyFilter::Name(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let WorkerNameFilter{ comparator:comparator4, value:value4, } = e; - *((base + 8) as *mut u8) = (comparator4.clone() as i32) as u8; - let vec5 = value4; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 16) as *mut i32) = len5; - *((base + 12) as *mut i32) = ptr5; - }, - WorkerPropertyFilter::Status(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let WorkerStatusFilter{ comparator:comparator6, value:value6, } = e; - *((base + 8) as *mut u8) = (comparator6.clone() as i32) as u8; - *((base + 9) as *mut u8) = (value6.clone() as i32) as u8; - }, - WorkerPropertyFilter::Version(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - let WorkerVersionFilter{ comparator:comparator7, value:value7, } = e; - *((base + 8) as *mut u8) = (comparator7.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value7); - }, - WorkerPropertyFilter::CreatedAt(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let WorkerCreatedAtFilter{ comparator:comparator8, value:value8, } = e; - *((base + 8) as *mut u8) = (comparator8.clone() as i32) as u8; - *((base + 16) as *mut i64) = wit_bindgen::rt::as_i64(value8); - }, - WorkerPropertyFilter::Env(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let WorkerEnvFilter{ name:name9, comparator:comparator9, value:value9, } = e; - let vec10 = name9; - let ptr10 = vec10.as_ptr() as i32; - let len10 = vec10.len() as i32; - *((base + 12) as *mut i32) = len10; - *((base + 8) as *mut i32) = ptr10; - *((base + 16) as *mut u8) = (comparator9.clone() as i32) as u8; - let vec11 = value9; - let ptr11 = vec11.as_ptr() as i32; - let len11 = vec11.len() as i32; - *((base + 24) as *mut i32) = len11; - *((base + 20) as *mut i32) = ptr11; - }, - } - } - } - *((base + 4) as *mut i32) = len12; - *((base + 0) as *mut i32) = result12 as i32; - cleanup_list.extend_from_slice(&[(result12, layout12),]); - } - } - cleanup_list.extend_from_slice(&[(result13, layout13),]); - - (1i32, result13 as i32, len13) - }, - None => { - (0i32, 0i32, 0i32) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[constructor]get-workers"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits1), wit_bindgen::rt::as_i64(low_bits1), result14_0, result14_1, result14_2, match precise { true => 1, false => 0 }); - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - GetWorkers::from_handle(ret as u32) - } - } - } - impl GetWorkers { - #[allow(unused_unsafe, clippy::all)] - pub fn get_next(&self,) -> Option>{ - - #[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; + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod host { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "[method]get-workers.get-next"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*((ptr0 + 0) as *const u8)); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *((ptr0 + 4) as *const i32); - let l3 = *((ptr0 + 8) as *const i32); - let base27 = l2; - let len27 = l3; - let mut result27 = Vec::with_capacity(len27 as usize); - for i in 0..len27 { - let base = base27 + i * 64; - let e27 = { - let l4 = *((base + 0) as *const i64); - let l5 = *((base + 8) as *const i64); - let l6 = *((base + 16) as *const i32); - let l7 = *((base + 20) as *const i32); - let len8 = l7 as usize; - let bytes8 = Vec::from_raw_parts(l6 as *mut _, len8, len8); - let l9 = *((base + 24) as *const i32); - let l10 = *((base + 28) as *const i32); - let base14 = l9; - let len14 = l10; - let mut result14 = Vec::with_capacity(len14 as usize); - for i in 0..len14 { - let base = base14 + i * 8; - let e14 = { - let l11 = *((base + 0) as *const i32); - let l12 = *((base + 4) as *const i32); - let len13 = l12 as usize; - let bytes13 = Vec::from_raw_parts(l11 as *mut _, len13, len13); - - wit_bindgen::rt::string_lift(bytes13) - }; - result14.push(e14); - } - wit_bindgen::rt::dealloc(base14, (len14 as usize) * 8, 4); - let l15 = *((base + 32) as *const i32); - let l16 = *((base + 36) as *const i32); - let base23 = l15; - let len23 = l16; - let mut result23 = Vec::with_capacity(len23 as usize); - for i in 0..len23 { - let base = base23 + i * 16; - let e23 = { - let l17 = *((base + 0) as *const i32); - let l18 = *((base + 4) as *const i32); - let len19 = l18 as usize; - let bytes19 = Vec::from_raw_parts(l17 as *mut _, len19, len19); - let l20 = *((base + 8) as *const i32); - let l21 = *((base + 12) as *const i32); - let len22 = l21 as usize; - let bytes22 = Vec::from_raw_parts(l20 as *mut _, len22, len22); - - (wit_bindgen::rt::string_lift(bytes19), wit_bindgen::rt::string_lift(bytes22)) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Uri = super::super::super::golem::rpc::types::Uri; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + /// An index into the persistent log storing all performed operations of a worker + pub type OplogIndex = u64; + /// Represents a Golem component's version + pub type ComponentVersion = u64; + /// UUID + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Uuid { + pub high_bits: u64, + pub low_bits: u64, + } + impl ::core::fmt::Debug for Uuid { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uuid") + .field("high-bits", &self.high_bits) + .field("low-bits", &self.low_bits) + .finish() + } + } + /// Represents a Golem component + #[repr(C)] + #[derive(Clone, Copy)] + pub struct ComponentId { + pub uuid: Uuid, + } + impl ::core::fmt::Debug for ComponentId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ComponentId") + .field("uuid", &self.uuid) + .finish() + } + } + /// Represents a Golem worker + #[derive(Clone)] + pub struct WorkerId { + pub component_id: ComponentId, + pub worker_name: _rt::String, + } + impl ::core::fmt::Debug for WorkerId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerId") + .field("component-id", &self.component_id) + .field("worker-name", &self.worker_name) + .finish() + } + } + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + #[derive(Clone)] + pub struct PromiseId { + pub worker_id: WorkerId, + pub oplog_idx: OplogIndex, + } + impl ::core::fmt::Debug for PromiseId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PromiseId") + .field("worker-id", &self.worker_id) + .field("oplog-idx", &self.oplog_idx) + .finish() + } + } + /// Configures how the executor retries failures + #[repr(C)] + #[derive(Clone, Copy)] + pub struct RetryPolicy { + /// The maximum number of retries before the worker becomes permanently failed + pub max_attempts: u32, + /// The minimum delay between retries (applied to the first retry) + pub min_delay: Duration, + /// The maximum delay between retries + pub max_delay: Duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + pub multiplier: u32, + } + impl ::core::fmt::Debug for RetryPolicy { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RetryPolicy") + .field("max-attempts", &self.max_attempts) + .field("min-delay", &self.min_delay) + .field("max-delay", &self.max_delay) + .field("multiplier", &self.multiplier) + .finish() + } + } + /// Configurable persistence level for workers + #[derive(Clone, Copy)] + pub enum PersistenceLevel { + PersistNothing, + PersistRemoteSideEffects, + Smart, + } + impl ::core::fmt::Debug for PersistenceLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + PersistenceLevel::PersistNothing => { + f.debug_tuple("PersistenceLevel::PersistNothing").finish() + } + PersistenceLevel::PersistRemoteSideEffects => f + .debug_tuple("PersistenceLevel::PersistRemoteSideEffects") + .finish(), + PersistenceLevel::Smart => { + f.debug_tuple("PersistenceLevel::Smart").finish() + } + } + } + } + /// Describes how to update a worker to a different component version + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum UpdateMode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + Automatic, + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + SnapshotBased, + } + impl ::core::fmt::Debug for UpdateMode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + UpdateMode::Automatic => f.debug_tuple("UpdateMode::Automatic").finish(), + UpdateMode::SnapshotBased => { + f.debug_tuple("UpdateMode::SnapshotBased").finish() + } + } + } + } + + impl UpdateMode { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> UpdateMode { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => UpdateMode::Automatic, + 1 => UpdateMode::SnapshotBased, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum FilterComparator { + Equal, + NotEqual, + GreaterEqual, + Greater, + LessEqual, + Less, + } + impl ::core::fmt::Debug for FilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + FilterComparator::Equal => { + f.debug_tuple("FilterComparator::Equal").finish() + } + FilterComparator::NotEqual => { + f.debug_tuple("FilterComparator::NotEqual").finish() + } + FilterComparator::GreaterEqual => { + f.debug_tuple("FilterComparator::GreaterEqual").finish() + } + FilterComparator::Greater => { + f.debug_tuple("FilterComparator::Greater").finish() + } + FilterComparator::LessEqual => { + f.debug_tuple("FilterComparator::LessEqual").finish() + } + FilterComparator::Less => f.debug_tuple("FilterComparator::Less").finish(), + } + } + } + + impl FilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> FilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => FilterComparator::Equal, + 1 => FilterComparator::NotEqual, + 2 => FilterComparator::GreaterEqual, + 3 => FilterComparator::Greater, + 4 => FilterComparator::LessEqual, + 5 => FilterComparator::Less, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum StringFilterComparator { + Equal, + NotEqual, + Like, + NotLike, + } + impl ::core::fmt::Debug for StringFilterComparator { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StringFilterComparator::Equal => { + f.debug_tuple("StringFilterComparator::Equal").finish() + } + StringFilterComparator::NotEqual => { + f.debug_tuple("StringFilterComparator::NotEqual").finish() + } + StringFilterComparator::Like => { + f.debug_tuple("StringFilterComparator::Like").finish() + } + StringFilterComparator::NotLike => { + f.debug_tuple("StringFilterComparator::NotLike").finish() + } + } + } + } + + impl StringFilterComparator { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> StringFilterComparator { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => StringFilterComparator::Equal, + 1 => StringFilterComparator::NotEqual, + 2 => StringFilterComparator::Like, + 3 => StringFilterComparator::NotLike, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum WorkerStatus { + /// The worker is running an invoked function + Running, + /// The worker is ready to run an invoked function + Idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + Suspended, + /// The last invocation was interrupted but will be resumed + Interrupted, + /// The last invocation failed and a retry was scheduled + Retrying, + /// The last invocation failed and the worker can no longer be used + Failed, + /// The worker exited after a successful invocation and can no longer be invoked + Exited, + } + impl ::core::fmt::Debug for WorkerStatus { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerStatus::Running => f.debug_tuple("WorkerStatus::Running").finish(), + WorkerStatus::Idle => f.debug_tuple("WorkerStatus::Idle").finish(), + WorkerStatus::Suspended => { + f.debug_tuple("WorkerStatus::Suspended").finish() + } + WorkerStatus::Interrupted => { + f.debug_tuple("WorkerStatus::Interrupted").finish() + } + WorkerStatus::Retrying => f.debug_tuple("WorkerStatus::Retrying").finish(), + WorkerStatus::Failed => f.debug_tuple("WorkerStatus::Failed").finish(), + WorkerStatus::Exited => f.debug_tuple("WorkerStatus::Exited").finish(), + } + } + } + + impl WorkerStatus { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> WorkerStatus { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => WorkerStatus::Running, + 1 => WorkerStatus::Idle, + 2 => WorkerStatus::Suspended, + 3 => WorkerStatus::Interrupted, + 4 => WorkerStatus::Retrying, + 5 => WorkerStatus::Failed, + 6 => WorkerStatus::Exited, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Clone)] + pub struct WorkerNameFilter { + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerNameFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerNameFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerStatusFilter { + pub comparator: FilterComparator, + pub value: WorkerStatus, + } + impl ::core::fmt::Debug for WorkerStatusFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerStatusFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerVersionFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerVersionFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerVersionFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct WorkerCreatedAtFilter { + pub comparator: FilterComparator, + pub value: u64, + } + impl ::core::fmt::Debug for WorkerCreatedAtFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerCreatedAtFilter") + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerEnvFilter { + pub name: _rt::String, + pub comparator: StringFilterComparator, + pub value: _rt::String, + } + impl ::core::fmt::Debug for WorkerEnvFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerEnvFilter") + .field("name", &self.name) + .field("comparator", &self.comparator) + .field("value", &self.value) + .finish() + } + } + #[derive(Clone)] + pub enum WorkerPropertyFilter { + Name(WorkerNameFilter), + Status(WorkerStatusFilter), + Version(WorkerVersionFilter), + CreatedAt(WorkerCreatedAtFilter), + Env(WorkerEnvFilter), + } + impl ::core::fmt::Debug for WorkerPropertyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WorkerPropertyFilter::Name(e) => f + .debug_tuple("WorkerPropertyFilter::Name") + .field(e) + .finish(), + WorkerPropertyFilter::Status(e) => f + .debug_tuple("WorkerPropertyFilter::Status") + .field(e) + .finish(), + WorkerPropertyFilter::Version(e) => f + .debug_tuple("WorkerPropertyFilter::Version") + .field(e) + .finish(), + WorkerPropertyFilter::CreatedAt(e) => f + .debug_tuple("WorkerPropertyFilter::CreatedAt") + .field(e) + .finish(), + WorkerPropertyFilter::Env(e) => { + f.debug_tuple("WorkerPropertyFilter::Env").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WorkerAllFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAllFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAllFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerAnyFilter { + pub filters: _rt::Vec, + } + impl ::core::fmt::Debug for WorkerAnyFilter { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerAnyFilter") + .field("filters", &self.filters) + .finish() + } + } + #[derive(Clone)] + pub struct WorkerMetadata { + pub worker_id: WorkerId, + pub args: _rt::Vec<_rt::String>, + pub env: _rt::Vec<(_rt::String, _rt::String)>, + pub status: WorkerStatus, + pub component_version: u64, + pub retry_count: u64, + } + impl ::core::fmt::Debug for WorkerMetadata { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WorkerMetadata") + .field("worker-id", &self.worker_id) + .field("args", &self.args) + .field("env", &self.env) + .field("status", &self.status) + .field("component-version", &self.component_version) + .field("retry-count", &self.retry_count) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct GetWorkers { + handle: _rt::Resource, + } + + impl GetWorkers { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for GetWorkers { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]get-workers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn new( + component_id: ComponentId, + filter: Option<&WorkerAnyFilter>, + precise: bool, + ) -> Self { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let ComponentId { uuid: uuid0 } = component_id; + let Uuid { + high_bits: high_bits1, + low_bits: low_bits1, + } = uuid0; + let (result14_0, result14_1, result14_2) = match filter { + Some(e) => { + let WorkerAnyFilter { filters: filters2 } = e; + let vec13 = filters2; + let len13 = vec13.len(); + let layout13 = _rt::alloc::Layout::from_size_align_unchecked( + vec13.len() * 8, + 4, + ); + let result13 = if layout13.size() != 0 { + let ptr = _rt::alloc::alloc(layout13).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout13); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec13.into_iter().enumerate() { + let base = result13.add(i * 8); + { + let WorkerAllFilter { filters: filters3 } = e; + let vec12 = filters3; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked( + vec12.len() * 32, + 8, + ); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 32); + { + match e { + WorkerPropertyFilter::Name(e) => { + *base.add(0).cast::() = (0i32) as u8; + let WorkerNameFilter { + comparator: comparator4, + value: value4, + } = e; + *base.add(8).cast::() = + (comparator4.clone() as i32) as u8; + let vec5 = value4; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(16).cast::() = len5; + *base.add(12).cast::<*mut u8>() = + ptr5.cast_mut(); + } + WorkerPropertyFilter::Status(e) => { + *base.add(0).cast::() = (1i32) as u8; + let WorkerStatusFilter { + comparator: comparator6, + value: value6, + } = e; + *base.add(8).cast::() = + (comparator6.clone() as i32) as u8; + *base.add(9).cast::() = + (value6.clone() as i32) as u8; + } + WorkerPropertyFilter::Version(e) => { + *base.add(0).cast::() = (2i32) as u8; + let WorkerVersionFilter { + comparator: comparator7, + value: value7, + } = e; + *base.add(8).cast::() = + (comparator7.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value7); + } + WorkerPropertyFilter::CreatedAt(e) => { + *base.add(0).cast::() = (3i32) as u8; + let WorkerCreatedAtFilter { + comparator: comparator8, + value: value8, + } = e; + *base.add(8).cast::() = + (comparator8.clone() as i32) as u8; + *base.add(16).cast::() = + _rt::as_i64(value8); + } + WorkerPropertyFilter::Env(e) => { + *base.add(0).cast::() = (4i32) as u8; + let WorkerEnvFilter { + name: name9, + comparator: comparator9, + value: value9, + } = e; + let vec10 = name9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = + ptr10.cast_mut(); + *base.add(16).cast::() = + (comparator9.clone() as i32) as u8; + let vec11 = value9; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + *base.add(24).cast::() = len11; + *base.add(20).cast::<*mut u8>() = + ptr11.cast_mut(); + } + } + } + } + *base.add(4).cast::() = len12; + *base.add(0).cast::<*mut u8>() = result12; + cleanup_list.extend_from_slice(&[(result12, layout12)]); + } + } + cleanup_list.extend_from_slice(&[(result13, layout13)]); + + (1i32, result13, len13) + } + None => (0i32, ::core::ptr::null_mut(), 0usize), }; - result23.push(e23); - } - wit_bindgen::rt::dealloc(base23, (len23 as usize) * 16, 4); - let l24 = i32::from(*((base + 40) as *const u8)); - let l25 = *((base + 48) as *const i64); - let l26 = *((base + 56) as *const i64); - - WorkerMetadata{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l4 as u64, - low_bits: l5 as u64, + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[constructor]get-workers"] + fn wit_import( + _: i64, + _: i64, + _: i32, + _: *mut u8, + _: usize, + _: i32, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: i32, _: *mut u8, _: usize, _: i32) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits1), + _rt::as_i64(low_bits1), + result14_0, + result14_1, + result14_2, + match &precise { + true => 1, + false => 0, }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes8), + ); + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + GetWorkers::from_handle(ret as u32) + } + } + } + impl GetWorkers { + #[allow(unused_unsafe, clippy::all)] + pub fn get_next(&self) -> Option<_rt::Vec> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "[method]get-workers.get-next"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let base27 = l2; + let len27 = l3; + let mut result27 = _rt::Vec::with_capacity(len27); + for i in 0..len27 { + let base = base27.add(i * 64); + let e27 = { + let l4 = *base.add(0).cast::(); + let l5 = *base.add(8).cast::(); + let l6 = *base.add(16).cast::<*mut u8>(); + let l7 = *base.add(20).cast::(); + let len8 = l7; + let bytes8 = + _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + let l9 = *base.add(24).cast::<*mut u8>(); + let l10 = *base.add(28).cast::(); + let base14 = l9; + let len14 = l10; + let mut result14 = _rt::Vec::with_capacity(len14); + for i in 0..len14 { + let base = base14.add(i * 8); + let e14 = { + let l11 = *base.add(0).cast::<*mut u8>(); + let l12 = *base.add(4).cast::(); + let len13 = l12; + let bytes13 = _rt::Vec::from_raw_parts( + l11.cast(), + len13, + len13, + ); + + _rt::string_lift(bytes13) + }; + result14.push(e14); + } + _rt::cabi_dealloc(base14, len14 * 8, 4); + let l15 = *base.add(32).cast::<*mut u8>(); + let l16 = *base.add(36).cast::(); + let base23 = l15; + let len23 = l16; + let mut result23 = _rt::Vec::with_capacity(len23); + for i in 0..len23 { + let base = base23.add(i * 16); + let e23 = { + let l17 = *base.add(0).cast::<*mut u8>(); + let l18 = *base.add(4).cast::(); + let len19 = l18; + let bytes19 = _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ); + let l20 = *base.add(8).cast::<*mut u8>(); + let l21 = *base.add(12).cast::(); + let len22 = l21; + let bytes22 = _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ); + + ( + _rt::string_lift(bytes19), + _rt::string_lift(bytes22), + ) + }; + result23.push(e23); + } + _rt::cabi_dealloc(base23, len23 * 16, 4); + let l24 = i32::from(*base.add(40).cast::()); + let l25 = *base.add(48).cast::(); + let l26 = *base.add(56).cast::(); + + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l4 as u64, + low_bits: l5 as u64, + }, + }, + worker_name: _rt::string_lift(bytes8), + }, + args: result14, + env: result23, + status: WorkerStatus::_lift(l24 as u8), + component_version: l25 as u64, + retry_count: l26 as u64, + } + }; + result27.push(e27); + } + _rt::cabi_dealloc(base27, len27 * 64, 8); + + result27 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Create a new promise + pub fn golem_create_promise() -> PromiseId { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-create-promise"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::<*mut u8>(); + let l4 = *ptr0.add(20).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *ptr0.add(24).cast::(); + PromiseId { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + }, + }, + worker_name: _rt::string_lift(bytes5), }, - args: result14, - env: result23, - status: WorkerStatus::_lift(l24 as u8), - component_version: l25 as u64, - retry_count: l26 as u64, - } + oplog_idx: l6 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + pub fn golem_await_promise(promise_id: &PromiseId) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let ptr5 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-await-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5, + ); + let l6 = *ptr5.add(0).cast::<*mut u8>(); + let l7 = *ptr5.add(4).cast::(); + let len8 = l7; + _rt::Vec::from_raw_parts(l6.cast(), len8, len8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + pub fn golem_complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = data; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-complete-promise"] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i64, + _: i64, + _: *mut u8, + _: usize, + _: i64, + _: *mut u8, + _: usize, + ) -> i32 { + unreachable!() + } + let ret = wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ptr5.cast_mut(), + len5, + ); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Deletes the given promise + pub fn golem_delete_promise(promise_id: &PromiseId) { + unsafe { + let PromiseId { + worker_id: worker_id0, + oplog_idx: oplog_idx0, + } = promise_id; + let WorkerId { + component_id: component_id1, + worker_name: worker_name1, + } = worker_id0; + let ComponentId { uuid: uuid2 } = component_id1; + let Uuid { + high_bits: high_bits3, + low_bits: low_bits3, + } = uuid2; + let vec4 = worker_name1; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "golem-delete-promise"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits3), + _rt::as_i64(low_bits3), + ptr4.cast_mut(), + len4, + _rt::as_i64(oplog_idx0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + pub fn get_self_uri(function_name: &str) -> Uri { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-self-uri"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + super::super::super::golem::rpc::types::Uri { + value: _rt::string_lift(bytes4), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Returns the current position in the persistent op log + pub fn get_oplog_index() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-index"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + pub fn set_oplog_index(oplog_idx: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-index"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(oplog_idx)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + pub fn oplog_commit(replicas: u8) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "oplog-commit"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(_rt::as_i32(&replicas)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + pub fn mark_begin_operation() -> OplogIndex { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-begin-operation"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64 { + unreachable!() + } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + pub fn mark_end_operation(begin: OplogIndex) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "mark-end-operation"] + fn wit_import(_: i64); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64) { + unreachable!() + } + wit_import(_rt::as_i64(begin)); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current retry policy associated with the worker + pub fn get_retry_policy() -> RetryPolicy { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-retry-policy"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + RetryPolicy { + max_attempts: l1 as u32, + min_delay: l2 as u64, + max_delay: l3 as u64, + multiplier: l4 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + pub fn set_retry_policy(new_retry_policy: RetryPolicy) { + unsafe { + let RetryPolicy { + max_attempts: max_attempts0, + min_delay: min_delay0, + max_delay: max_delay0, + multiplier: multiplier0, + } = new_retry_policy; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-retry-policy"] + fn wit_import(_: i32, _: i64, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i32(max_attempts0), + _rt::as_i64(min_delay0), + _rt::as_i64(max_delay0), + _rt::as_i32(multiplier0), + ); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the worker's current persistence level. + pub fn get_oplog_persistence_level() -> PersistenceLevel { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-oplog-persistence-level"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + let v0 = match ret { + 0 => PersistenceLevel::PersistNothing, + 1 => PersistenceLevel::PersistRemoteSideEffects, + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + PersistenceLevel::Smart + } }; - result27.push(e27); - } - wit_bindgen::rt::dealloc(base27, (len27 as usize) * 64, 8); - - result27 - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Create a new promise - pub fn golem_create_promise() -> PromiseId{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-create-promise"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i32); - let l4 = *((ptr0 + 20) as *const i32); - let len5 = l4 as usize; - let bytes5 = Vec::from_raw_parts(l3 as *mut _, len5, len5); - let l6 = *((ptr0 + 24) as *const i64); - PromiseId{ - worker_id: WorkerId{ - component_id: ComponentId{ - uuid: Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - }, - }, - worker_name: wit_bindgen::rt::string_lift(bytes5), - }, - oplog_idx: l6 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - pub fn golem_await_promise(promise_id: &PromiseId,) -> 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 PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let ptr5 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-await-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5); - let l6 = *((ptr5 + 0) as *const i32); - let l7 = *((ptr5 + 4) as *const i32); - let len8 = l7 as usize; - Vec::from_raw_parts(l6 as *mut _, len8, len8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - pub fn golem_complete_promise(promise_id: &PromiseId,data: &[u8],) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - let vec5 = data; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-complete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0), ptr5, len5); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Deletes the given promise - pub fn golem_delete_promise(promise_id: &PromiseId,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let PromiseId{ worker_id:worker_id0, oplog_idx:oplog_idx0, } = promise_id; - let WorkerId{ component_id:component_id1, worker_name:worker_name1, } = worker_id0; - let ComponentId{ uuid:uuid2, } = component_id1; - let Uuid{ high_bits:high_bits3, low_bits:low_bits3, } = uuid2; - let vec4 = worker_name1; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "golem-delete-promise"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits3), wit_bindgen::rt::as_i64(low_bits3), ptr4, len4, wit_bindgen::rt::as_i64(oplog_idx0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - pub fn get_self_uri(function_name: &str,) -> Uri{ - - #[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 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-self-uri"] - fn wit_import(_: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr0, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; - let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); - super::super::super::golem::rpc::types::Uri{ - value: wit_bindgen::rt::string_lift(bytes4), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the current position in the persistent op log - pub fn get_oplog_index() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-index"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - pub fn set_oplog_index(oplog_idx: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-index"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(oplog_idx)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - pub fn oplog_commit(replicas: u8,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "oplog-commit"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(replicas)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - pub fn mark_begin_operation() -> OplogIndex{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-begin-operation"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - pub fn mark_end_operation(begin: OplogIndex,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "mark-end-operation"] - fn wit_import(_: i64, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(begin)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current retry policy associated with the worker - pub fn get_retry_policy() -> RetryPolicy{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-retry-policy"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i32); - RetryPolicy{ - max_attempts: l1 as u32, - min_delay: l2 as u64, - max_delay: l3 as u64, - multiplier: l4 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - pub fn set_retry_policy(new_retry_policy: RetryPolicy,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RetryPolicy{ max_attempts:max_attempts0, min_delay:min_delay0, max_delay:max_delay0, multiplier:multiplier0, } = new_retry_policy; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-retry-policy"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i32(max_attempts0), wit_bindgen::rt::as_i64(min_delay0), wit_bindgen::rt::as_i64(max_delay0), wit_bindgen::rt::as_i32(multiplier0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the worker's current persistence level. - pub fn get_oplog_persistence_level() -> PersistenceLevel{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-oplog-persistence-level"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - let v0 = match ret { - 0 => { - PersistenceLevel::PersistNothing - } - 1 => { - PersistenceLevel::PersistRemoteSideEffects - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - PersistenceLevel::Smart - } - }; - v0 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let result0 = match new_persistence_level { - PersistenceLevel::PersistNothing=> { - 0i32 - } - PersistenceLevel::PersistRemoteSideEffects=> { - 1i32 - } - PersistenceLevel::Smart=> { - 2i32 - } - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-oplog-persistence-level"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(result0); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - pub fn get_idempotence_mode() -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "get-idempotence-mode"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - pub fn set_idempotence_mode(idempotent: bool,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "set-idempotence-mode"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(match idempotent { true => 1, false => 0 }); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - pub fn generate_idempotency_key() -> Uuid{ - - #[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; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "generate-idempotency-key"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - Uuid{ - high_bits: l1 as u64, - low_bits: l2 as u64, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - pub fn update_worker(worker_id: &WorkerId,target_version: ComponentVersion,mode: UpdateMode,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let WorkerId{ component_id:component_id0, worker_name:worker_name0, } = worker_id; - let ComponentId{ uuid:uuid1, } = component_id0; - let Uuid{ high_bits:high_bits2, low_bits:low_bits2, } = uuid1; - let vec3 = worker_name0; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:api/host@0.2.0")] - extern "C" { - #[link_name = "update-worker"] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i32, _: i32, _: i64, _: i32, ){ unreachable!() } - wit_import(wit_bindgen::rt::as_i64(high_bits2), wit_bindgen::rt::as_i64(low_bits2), ptr3, len3, wit_bindgen::rt::as_i64(target_version), mode.clone() as i32); + v0 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + pub fn set_oplog_persistence_level(new_persistence_level: PersistenceLevel) { + unsafe { + let result0 = match new_persistence_level { + PersistenceLevel::PersistNothing => 0i32, + PersistenceLevel::PersistRemoteSideEffects => 1i32, + PersistenceLevel::Smart => 2i32, + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-oplog-persistence-level"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(result0); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + pub fn get_idempotence_mode() -> bool { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-idempotence-mode"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32 { + unreachable!() + } + let ret = wit_import(); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + pub fn set_idempotence_mode(idempotent: bool) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "set-idempotence-mode"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import(match &idempotent { + true => 1, + false => 0, + }); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + pub fn generate_idempotency_key() -> Uuid { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "generate-idempotency-key"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8) { + unreachable!() + } + wit_import(ptr0); + let l1 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + pub fn update_worker( + worker_id: &WorkerId, + target_version: ComponentVersion, + mode: UpdateMode, + ) { + unsafe { + let WorkerId { + component_id: component_id0, + worker_name: worker_name0, + } = worker_id; + let ComponentId { uuid: uuid1 } = component_id0; + let Uuid { + high_bits: high_bits2, + low_bits: low_bits2, + } = uuid1; + let vec3 = worker_name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "update-worker"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: i32) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits2), + _rt::as_i64(low_bits2), + ptr3.cast_mut(), + len3, + _rt::as_i64(target_version), + mode.clone() as i32, + ); + } + } } - } - } - - } - pub mod rpc { - - #[allow(clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type NodeIndex = i32; - #[derive(Clone)] - pub enum WitNode{ - RecordValue(wit_bindgen::rt::vec::Vec::), - VariantValue((u32,Option,)), - EnumValue(u32), - FlagsValue(wit_bindgen::rt::vec::Vec::), - TupleValue(wit_bindgen::rt::vec::Vec::), - ListValue(wit_bindgen::rt::vec::Vec::), - OptionValue(Option), - ResultValue(Result,Option>), - PrimU8(u8), - PrimU16(u16), - PrimU32(u32), - PrimU64(u64), - PrimS8(i8), - PrimS16(i16), - PrimS32(i32), - PrimS64(i64), - PrimFloat32(f32), - PrimFloat64(f64), - PrimChar(char), - PrimBool(bool), - PrimString(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for WitNode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - WitNode::RecordValue(e) => { - f.debug_tuple("WitNode::RecordValue").field(e).finish() - } - WitNode::VariantValue(e) => { - f.debug_tuple("WitNode::VariantValue").field(e).finish() - } - WitNode::EnumValue(e) => { - f.debug_tuple("WitNode::EnumValue").field(e).finish() - } - WitNode::FlagsValue(e) => { - f.debug_tuple("WitNode::FlagsValue").field(e).finish() - } - WitNode::TupleValue(e) => { - f.debug_tuple("WitNode::TupleValue").field(e).finish() - } - WitNode::ListValue(e) => { - f.debug_tuple("WitNode::ListValue").field(e).finish() - } - WitNode::OptionValue(e) => { - f.debug_tuple("WitNode::OptionValue").field(e).finish() - } - WitNode::ResultValue(e) => { - f.debug_tuple("WitNode::ResultValue").field(e).finish() - } - WitNode::PrimU8(e) => { - f.debug_tuple("WitNode::PrimU8").field(e).finish() - } - WitNode::PrimU16(e) => { - f.debug_tuple("WitNode::PrimU16").field(e).finish() - } - WitNode::PrimU32(e) => { - f.debug_tuple("WitNode::PrimU32").field(e).finish() - } - WitNode::PrimU64(e) => { - f.debug_tuple("WitNode::PrimU64").field(e).finish() - } - WitNode::PrimS8(e) => { - f.debug_tuple("WitNode::PrimS8").field(e).finish() - } - WitNode::PrimS16(e) => { - f.debug_tuple("WitNode::PrimS16").field(e).finish() - } - WitNode::PrimS32(e) => { - f.debug_tuple("WitNode::PrimS32").field(e).finish() - } - WitNode::PrimS64(e) => { - f.debug_tuple("WitNode::PrimS64").field(e).finish() - } - WitNode::PrimFloat32(e) => { - f.debug_tuple("WitNode::PrimFloat32").field(e).finish() - } - WitNode::PrimFloat64(e) => { - f.debug_tuple("WitNode::PrimFloat64").field(e).finish() - } - WitNode::PrimChar(e) => { - f.debug_tuple("WitNode::PrimChar").field(e).finish() - } - WitNode::PrimBool(e) => { - f.debug_tuple("WitNode::PrimBool").field(e).finish() - } - WitNode::PrimString(e) => { - f.debug_tuple("WitNode::PrimString").field(e).finish() - } - } - } - } - #[derive(Clone)] - pub struct WitValue { - pub nodes: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for WitValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("WitValue").field("nodes", &self.nodes).finish() - } - } - #[derive(Clone)] - pub struct Uri { - pub value: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] - pub enum RpcError{ - ProtocolError(wit_bindgen::rt::string::String), - Denied(wit_bindgen::rt::string::String), - NotFound(wit_bindgen::rt::string::String), - RemoteInternalError(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - RpcError::ProtocolError(e) => { - f.debug_tuple("RpcError::ProtocolError").field(e).finish() - } - RpcError::Denied(e) => { - f.debug_tuple("RpcError::Denied").field(e).finish() - } - RpcError::NotFound(e) => { - f.debug_tuple("RpcError::NotFound").field(e).finish() - } - RpcError::RemoteInternalError(e) => { - f.debug_tuple("RpcError::RemoteInternalError").field(e).finish() - } - } - } - } - impl ::core::fmt::Display for RpcError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for RpcError {} - - #[derive(Debug)] - #[repr(transparent)] - pub struct WasmRpc{ - handle: wit_bindgen::rt::Resource, - } - - impl WasmRpc{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for WasmRpc{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]wasm-rpc"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn new(location: &Uri,) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let Uri{ value:value0, } = location; - let vec1 = value0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - + #[allow(dead_code)] + pub mod rpc { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[constructor]wasm-rpc"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1, len1); - WasmRpc::from_handle(ret as u32) - } - } - } - impl WasmRpc { - #[allow(unused_unsafe, clippy::all)] - pub fn invoke_and_await(&self,function_name: &str,function_params: &[WitValue],) -> Result{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let mut cleanup_list = Vec::new(); - - #[repr(align(4))] - struct RetArea([u8; 16]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec9 = function_params; - let len9 = vec9.len() as i32; - let layout9 = alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); - let result9 = if layout9.size() != 0 - { - let ptr = alloc::alloc(layout9); - if ptr.is_null() - { - alloc::handle_alloc_error(layout9); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9 as i32 + (i as i32) * 8; - { - let WitValue{ nodes:nodes1, } = e; - let vec8 = nodes1; - let len8 = vec8.len() as i32; - let layout8 = alloc::Layout::from_size_align_unchecked(vec8.len() * 24, 8); - let result8 = if layout8.size() != 0 - { - let ptr = alloc::alloc(layout8); - if ptr.is_null() - { - alloc::handle_alloc_error(layout8); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8 as i32 + (i as i32) * 24; - { - match e { - WitNode::RecordValue(e) => { - *((base + 0) as *mut u8) = (0i32) as u8; - let vec2 = e; - 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; - }, - WitNode::VariantValue(e) => { - *((base + 0) as *mut u8) = (1i32) as u8; - let (t3_0, t3_1, ) = e; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(t3_0); - match t3_1 { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };}, + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type NodeIndex = i32; + #[derive(Clone)] + pub enum WitNode { + RecordValue(_rt::Vec), + VariantValue((u32, Option)), + EnumValue(u32), + FlagsValue(_rt::Vec), + TupleValue(_rt::Vec), + ListValue(_rt::Vec), + OptionValue(Option), + ResultValue(Result, Option>), + PrimU8(u8), + PrimU16(u16), + PrimU32(u32), + PrimU64(u64), + PrimS8(i8), + PrimS16(i16), + PrimS32(i32), + PrimS64(i64), + PrimFloat32(f32), + PrimFloat64(f64), + PrimChar(char), + PrimBool(bool), + PrimString(_rt::String), + } + impl ::core::fmt::Debug for WitNode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + WitNode::RecordValue(e) => { + f.debug_tuple("WitNode::RecordValue").field(e).finish() + } + WitNode::VariantValue(e) => { + f.debug_tuple("WitNode::VariantValue").field(e).finish() + } WitNode::EnumValue(e) => { - *((base + 0) as *mut u8) = (2i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, + f.debug_tuple("WitNode::EnumValue").field(e).finish() + } WitNode::FlagsValue(e) => { - *((base + 0) as *mut u8) = (3i32) as u8; - let vec4 = e; - let len4 = vec4.len() as i32; - let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 1, 1); - let result4 = if layout4.size() != 0 - { - let ptr = alloc::alloc(layout4); - if ptr.is_null() - { - alloc::handle_alloc_error(layout4); + f.debug_tuple("WitNode::FlagsValue").field(e).finish() + } + WitNode::TupleValue(e) => { + f.debug_tuple("WitNode::TupleValue").field(e).finish() + } + WitNode::ListValue(e) => { + f.debug_tuple("WitNode::ListValue").field(e).finish() + } + WitNode::OptionValue(e) => { + f.debug_tuple("WitNode::OptionValue").field(e).finish() + } + WitNode::ResultValue(e) => { + f.debug_tuple("WitNode::ResultValue").field(e).finish() + } + WitNode::PrimU8(e) => f.debug_tuple("WitNode::PrimU8").field(e).finish(), + WitNode::PrimU16(e) => f.debug_tuple("WitNode::PrimU16").field(e).finish(), + WitNode::PrimU32(e) => f.debug_tuple("WitNode::PrimU32").field(e).finish(), + WitNode::PrimU64(e) => f.debug_tuple("WitNode::PrimU64").field(e).finish(), + WitNode::PrimS8(e) => f.debug_tuple("WitNode::PrimS8").field(e).finish(), + WitNode::PrimS16(e) => f.debug_tuple("WitNode::PrimS16").field(e).finish(), + WitNode::PrimS32(e) => f.debug_tuple("WitNode::PrimS32").field(e).finish(), + WitNode::PrimS64(e) => f.debug_tuple("WitNode::PrimS64").field(e).finish(), + WitNode::PrimFloat32(e) => { + f.debug_tuple("WitNode::PrimFloat32").field(e).finish() + } + WitNode::PrimFloat64(e) => { + f.debug_tuple("WitNode::PrimFloat64").field(e).finish() + } + WitNode::PrimChar(e) => { + f.debug_tuple("WitNode::PrimChar").field(e).finish() + } + WitNode::PrimBool(e) => { + f.debug_tuple("WitNode::PrimBool").field(e).finish() + } + WitNode::PrimString(e) => { + f.debug_tuple("WitNode::PrimString").field(e).finish() + } + } + } + } + #[derive(Clone)] + pub struct WitValue { + pub nodes: _rt::Vec, + } + impl ::core::fmt::Debug for WitValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WitValue") + .field("nodes", &self.nodes) + .finish() + } + } + #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, + } + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } + } + #[derive(Clone)] + pub enum RpcError { + ProtocolError(_rt::String), + Denied(_rt::String), + NotFound(_rt::String), + RemoteInternalError(_rt::String), + } + impl ::core::fmt::Debug for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + RpcError::ProtocolError(e) => { + f.debug_tuple("RpcError::ProtocolError").field(e).finish() + } + RpcError::Denied(e) => f.debug_tuple("RpcError::Denied").field(e).finish(), + RpcError::NotFound(e) => { + f.debug_tuple("RpcError::NotFound").field(e).finish() + } + RpcError::RemoteInternalError(e) => f + .debug_tuple("RpcError::RemoteInternalError") + .field(e) + .finish(), + } + } + } + impl ::core::fmt::Display for RpcError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for RpcError {} + + #[derive(Debug)] + #[repr(transparent)] + pub struct WasmRpc { + handle: _rt::Resource, + } + + impl WasmRpc { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for WasmRpc { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]wasm-rpc"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn new(location: &Uri) -> Self { + unsafe { + let Uri { value: value0 } = location; + let vec1 = value0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[constructor]wasm-rpc"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr1.cast_mut(), len1); + WasmRpc::from_handle(ret as u32) + } + } + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec9 = function_params; + let len9 = vec9.len(); + let layout9 = + _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); + let result9 = if layout9.size() != 0 { + let ptr = _rt::alloc::alloc(layout9).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout9); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec4.into_iter().enumerate() { - let base = result4 as i32 + (i as i32) * 1; + } else { { - *((base + 0) as *mut u8) = (match e { true => 1, false => 0 }) as u8; + ::core::ptr::null_mut() } - } - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = result4 as i32; - cleanup_list.extend_from_slice(&[(result4, layout4),]); - }, - WitNode::TupleValue(e) => { - *((base + 0) as *mut u8) = (4i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - *((base + 12) as *mut i32) = len5; - *((base + 8) as *mut i32) = ptr5; - }, - WitNode::ListValue(e) => { - *((base + 0) as *mut u8) = (5i32) as u8; - let vec6 = e; - let ptr6 = vec6.as_ptr() as i32; - let len6 = vec6.len() as i32; - *((base + 12) as *mut i32) = len6; - *((base + 8) as *mut i32) = ptr6; - }, - WitNode::OptionValue(e) => { - *((base + 0) as *mut u8) = (6i32) as u8; - match e { - Some(e) => { - *((base + 8) as *mut u8) = (1i32) as u8; - *((base + 12) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 8) as *mut u8) = (0i32) as u8; - } - }, - };}, - WitNode::ResultValue(e) => { - *((base + 0) as *mut u8) = (7i32) as u8; - match e { - Ok(e) => { { - *((base + 8) as *mut u8) = (0i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { + }; + for (i, e) in vec9.into_iter().enumerate() { + let base = result9.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec8 = nodes1; + let len8 = vec8.len(); + let layout8 = _rt::alloc::Layout::from_size_align_unchecked( + vec8.len() * 24, + 8, + ); + let result8 = if layout8.size() != 0 { + let ptr = _rt::alloc::alloc(layout8).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout8); + } + ptr + } else { { - *((base + 12) as *mut u8) = (0i32) as u8; + ::core::ptr::null_mut() } - }, - };} }, - Err(e) => { { - *((base + 8) as *mut u8) = (1i32) as u8; - match e { - Some(e) => { - *((base + 12) as *mut u8) = (1i32) as u8; - *((base + 16) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - None => { - { - *((base + 12) as *mut u8) = (0i32) as u8; - } - }, - };} }, - };}, - WitNode::PrimU8(e) => { - *((base + 0) as *mut u8) = (8i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimU16(e) => { - *((base + 0) as *mut u8) = (9i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimU32(e) => { - *((base + 0) as *mut u8) = (10i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimU64(e) => { - *((base + 0) as *mut u8) = (11i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimS8(e) => { - *((base + 0) as *mut u8) = (12i32) as u8; - *((base + 8) as *mut u8) = (wit_bindgen::rt::as_i32(e)) as u8; - }, - WitNode::PrimS16(e) => { - *((base + 0) as *mut u8) = (13i32) as u8; - *((base + 8) as *mut u16) = (wit_bindgen::rt::as_i32(e)) as u16; - }, - WitNode::PrimS32(e) => { - *((base + 0) as *mut u8) = (14i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimS64(e) => { - *((base + 0) as *mut u8) = (15i32) as u8; - *((base + 8) as *mut i64) = wit_bindgen::rt::as_i64(e); - }, - WitNode::PrimFloat32(e) => { - *((base + 0) as *mut u8) = (16i32) as u8; - *((base + 8) as *mut f32) = wit_bindgen::rt::as_f32(e); - }, - WitNode::PrimFloat64(e) => { - *((base + 0) as *mut u8) = (17i32) as u8; - *((base + 8) as *mut f64) = wit_bindgen::rt::as_f64(e); - }, - WitNode::PrimChar(e) => { - *((base + 0) as *mut u8) = (18i32) as u8; - *((base + 8) as *mut i32) = wit_bindgen::rt::as_i32(e); - }, - WitNode::PrimBool(e) => { - *((base + 0) as *mut u8) = (19i32) as u8; - *((base + 8) as *mut u8) = (match e { true => 1, false => 0 }) as u8; - }, - WitNode::PrimString(e) => { - *((base + 0) as *mut u8) = (20i32) as u8; - let vec7 = e; - let ptr7 = vec7.as_ptr() as i32; - let len7 = vec7.len() as i32; - *((base + 12) as *mut i32) = len7; - *((base + 8) as *mut i32) = ptr7; - }, - } - } - } - *((base + 4) as *mut i32) = len8; - *((base + 0) as *mut i32) = result8 as i32; - cleanup_list.extend_from_slice(&[(result8, layout8),]); - } - } - let ptr10 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "golem:rpc/types@0.1.0")] - extern "C" { - #[link_name = "[method]wasm-rpc.invoke-and-await"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0, len0, result9 as i32, len9, ptr10); - let l11 = i32::from(*((ptr10 + 0) as *const u8)); - if layout9.size() != 0 { - alloc::dealloc(result9, layout9); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - alloc::dealloc(ptr, layout); - - } - - } - match l11 { - 0 => { - let e = { - let l12 = *((ptr10 + 4) as *const i32); - let l13 = *((ptr10 + 8) as *const i32); - let base55 = l12; - let len55 = l13; - let mut result55 = Vec::with_capacity(len55 as usize); - for i in 0..len55 { - let base = base55 + i * 24; - let e55 = { - let l14 = i32::from(*((base + 0) as *const u8)); - let v54 = match l14 { - 0 => { - let e54 = { - let l15 = *((base + 8) as *const i32); - let l16 = *((base + 12) as *const i32); - let len17 = l16 as usize; - - Vec::from_raw_parts(l15 as *mut _, len17, len17) - }; - WitNode::RecordValue(e54) - } - 1 => { - let e54 = { - let l18 = *((base + 8) as *const i32); - let l19 = i32::from(*((base + 12) as *const u8)); - - (l18 as u32, match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *((base + 16) as *const i32); - - l20 - }; - Some(e) + }; + for (i, e) in vec8.into_iter().enumerate() { + let base = result8.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - }) - }; - WitNode::VariantValue(e54) - } - 2 => { - let e54 = { - let l21 = *((base + 8) as *const i32); - - l21 as u32 - }; - WitNode::EnumValue(e54) - } - 3 => { - let e54 = { - let l22 = *((base + 8) as *const i32); - let l23 = *((base + 12) as *const i32); - let base25 = l22; - let len25 = l23; - let mut result25 = Vec::with_capacity(len25 as usize); - for i in 0..len25 { - let base = base25 + i * 1; - let e25 = { - let l24 = i32::from(*((base + 0) as *const u8)); - - wit_bindgen::rt::bool_lift(l24 as u8) - }; - result25.push(e25); - } - wit_bindgen::rt::dealloc(base25, (len25 as usize) * 1, 1); - - result25 - }; - WitNode::FlagsValue(e54) - } - 4 => { - let e54 = { - let l26 = *((base + 8) as *const i32); - let l27 = *((base + 12) as *const i32); - let len28 = l27 as usize; - - Vec::from_raw_parts(l26 as *mut _, len28, len28) - }; - WitNode::TupleValue(e54) - } - 5 => { - let e54 = { - let l29 = *((base + 8) as *const i32); - let l30 = *((base + 12) as *const i32); - let len31 = l30 as usize; - - Vec::from_raw_parts(l29 as *mut _, len31, len31) - }; - WitNode::ListValue(e54) - } - 6 => { - let e54 = { - let l32 = i32::from(*((base + 8) as *const u8)); - - match l32 { + } + } + *base.add(4).cast::() = len8; + *base.add(0).cast::<*mut u8>() = result8; + cleanup_list.extend_from_slice(&[(result8, layout8)]); + } + } + let ptr10 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result9, + len9, + ptr10, + ); + let l11 = i32::from(*ptr10.add(0).cast::()); + if layout9.size() != 0 { + _rt::alloc::dealloc(result9.cast(), layout9); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l11 { + 0 => { + let e = { + let l12 = *ptr10.add(4).cast::<*mut u8>(); + let l13 = *ptr10.add(8).cast::(); + let base55 = l12; + let len55 = l13; + let mut result55 = _rt::Vec::with_capacity(len55); + for i in 0..len55 { + let base = base55.add(i * 24); + let e55 = { + let l14 = i32::from(*base.add(0).cast::()); + let v54 = match l14 { + 0 => { + let e54 = { + let l15 = *base.add(8).cast::<*mut u8>(); + let l16 = *base.add(12).cast::(); + let len17 = l16; + + _rt::Vec::from_raw_parts( + l15.cast(), + len17, + len17, + ) + }; + WitNode::RecordValue(e54) + } + 1 => { + let e54 = + { + let l18 = *base.add(8).cast::(); + let l19 = i32::from( + *base.add(12).cast::(), + ); + + (l18 as u32, match l19 { 0 => None, 1 => { let e = { - let l33 = *((base + 12) as *const i32); - - l33 + let l20 = *base.add(16).cast::(); + + l20 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::OptionValue(e54) - } - 7 => { - let e54 = { - let l34 = i32::from(*((base + 8) as *const u8)); - - match l34 { - 0 => { - let e = { - let l35 = i32::from(*((base + 12) as *const u8)); - - match l35 { + _ => _rt::invalid_enum_discriminant(), + }) + }; + WitNode::VariantValue(e54) + } + 2 => { + let e54 = { + let l21 = *base.add(8).cast::(); + + l21 as u32 + }; + WitNode::EnumValue(e54) + } + 3 => { + let e54 = { + let l22 = *base.add(8).cast::<*mut u8>(); + let l23 = *base.add(12).cast::(); + let base25 = l22; + let len25 = l23; + let mut result25 = + _rt::Vec::with_capacity(len25); + for i in 0..len25 { + let base = base25.add(i * 1); + let e25 = { + let l24 = i32::from( + *base.add(0).cast::(), + ); + + _rt::bool_lift(l24 as u8) + }; + result25.push(e25); + } + _rt::cabi_dealloc(base25, len25 * 1, 1); + + result25 + }; + WitNode::FlagsValue(e54) + } + 4 => { + let e54 = { + let l26 = *base.add(8).cast::<*mut u8>(); + let l27 = *base.add(12).cast::(); + let len28 = l27; + + _rt::Vec::from_raw_parts( + l26.cast(), + len28, + len28, + ) + }; + WitNode::TupleValue(e54) + } + 5 => { + let e54 = { + let l29 = *base.add(8).cast::<*mut u8>(); + let l30 = *base.add(12).cast::(); + let len31 = l30; + + _rt::Vec::from_raw_parts( + l29.cast(), + len31, + len31, + ) + }; + WitNode::ListValue(e54) + } + 6 => { + let e54 = { + let l32 = + i32::from(*base.add(8).cast::()); + + match l32 { + 0 => None, + 1 => { + let e = { + let l33 = + *base.add(12).cast::(); + + l33 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e54) + } + 7 => { + let e54 = { + let l34 = + i32::from(*base.add(8).cast::()); + + match l34 { + 0 => { + let e = { + let l35 = i32::from( + *base.add(12).cast::(), + ); + + match l35 { 0 => None, 1 => { let e = { - let l36 = *((base + 16) as *const i32); - + let l36 = *base.add(16).cast::(); + l36 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Ok(e) - } - 1 => { - let e = { - let l37 = i32::from(*((base + 12) as *const u8)); - - match l37 { + }; + Ok(e) + } + 1 => { + let e = { + let l37 = i32::from( + *base.add(12).cast::(), + ); + + match l37 { 0 => None, 1 => { let e = { - let l38 = *((base + 16) as *const i32); - + let l38 = *base.add(16).cast::(); + l38 }; Some(e) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + _ => _rt::invalid_enum_discriminant(), } - }; - Err(e) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e54) + } + 8 => { + let e54 = { + let l39 = + i32::from(*base.add(8).cast::()); + + l39 as u8 + }; + WitNode::PrimU8(e54) + } + 9 => { + let e54 = { + let l40 = + i32::from(*base.add(8).cast::()); + + l40 as u16 + }; + WitNode::PrimU16(e54) + } + 10 => { + let e54 = { + let l41 = *base.add(8).cast::(); + + l41 as u32 + }; + WitNode::PrimU32(e54) + } + 11 => { + let e54 = { + let l42 = *base.add(8).cast::(); + + l42 as u64 + }; + WitNode::PrimU64(e54) + } + 12 => { + let e54 = { + let l43 = + i32::from(*base.add(8).cast::()); + + l43 as i8 + }; + WitNode::PrimS8(e54) + } + 13 => { + let e54 = { + let l44 = + i32::from(*base.add(8).cast::()); + + l44 as i16 + }; + WitNode::PrimS16(e54) + } + 14 => { + let e54 = { + let l45 = *base.add(8).cast::(); + + l45 + }; + WitNode::PrimS32(e54) + } + 15 => { + let e54 = { + let l46 = *base.add(8).cast::(); + + l46 + }; + WitNode::PrimS64(e54) + } + 16 => { + let e54 = { + let l47 = *base.add(8).cast::(); + + l47 + }; + WitNode::PrimFloat32(e54) + } + 17 => { + let e54 = { + let l48 = *base.add(8).cast::(); + + l48 + }; + WitNode::PrimFloat64(e54) + } + 18 => { + let e54 = { + let l49 = *base.add(8).cast::(); + + _rt::char_lift(l49 as u32) + }; + WitNode::PrimChar(e54) + } + 19 => { + let e54 = { + let l50 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l50 as u8) + }; + WitNode::PrimBool(e54) + } + n => { + debug_assert_eq!( + n, 20, + "invalid enum discriminant" + ); + let e54 = { + let l51 = *base.add(8).cast::<*mut u8>(); + let l52 = *base.add(12).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts( + l51.cast(), + len53, + len53, + ); + + _rt::string_lift(bytes53) + }; + WitNode::PrimString(e54) + } + }; + + v54 + }; + result55.push(e55); + } + _rt::cabi_dealloc(base55, len55 * 24, 8); + + WitValue { nodes: result55 } + }; + Ok(e) + } + 1 => { + let e = { + let l56 = i32::from(*ptr10.add(4).cast::()); + let v69 = match l56 { + 0 => { + let e69 = { + let l57 = *ptr10.add(8).cast::<*mut u8>(); + let l58 = *ptr10.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + + _rt::string_lift(bytes59) + }; + RpcError::ProtocolError(e69) + } + 1 => { + let e69 = { + let l60 = *ptr10.add(8).cast::<*mut u8>(); + let l61 = *ptr10.add(12).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts( + l60.cast(), + len62, + len62, + ); + + _rt::string_lift(bytes62) + }; + RpcError::Denied(e69) + } + 2 => { + let e69 = { + let l63 = *ptr10.add(8).cast::<*mut u8>(); + let l64 = *ptr10.add(12).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts( + l63.cast(), + len65, + len65, + ); + + _rt::string_lift(bytes65) + }; + RpcError::NotFound(e69) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e69 = { + let l66 = *ptr10.add(8).cast::<*mut u8>(); + let l67 = *ptr10.add(12).cast::(); + let len68 = l67; + let bytes68 = _rt::Vec::from_raw_parts( + l66.cast(), + len68, + len68, + ); + + _rt::string_lift(bytes68) + }; + RpcError::RemoteInternalError(e69) } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - }; - WitNode::ResultValue(e54) - } - 8 => { - let e54 = { - let l39 = i32::from(*((base + 8) as *const u8)); - - l39 as u8 - }; - WitNode::PrimU8(e54) - } - 9 => { - let e54 = { - let l40 = i32::from(*((base + 8) as *const u16)); - - l40 as u16 - }; - WitNode::PrimU16(e54) - } - 10 => { - let e54 = { - let l41 = *((base + 8) as *const i32); - - l41 as u32 - }; - WitNode::PrimU32(e54) - } - 11 => { - let e54 = { - let l42 = *((base + 8) as *const i64); - - l42 as u64 - }; - WitNode::PrimU64(e54) - } - 12 => { - let e54 = { - let l43 = i32::from(*((base + 8) as *const i8)); - - l43 as i8 - }; - WitNode::PrimS8(e54) - } - 13 => { - let e54 = { - let l44 = i32::from(*((base + 8) as *const i16)); - - l44 as i16 - }; - WitNode::PrimS16(e54) - } - 14 => { - let e54 = { - let l45 = *((base + 8) as *const i32); - - l45 - }; - WitNode::PrimS32(e54) - } - 15 => { - let e54 = { - let l46 = *((base + 8) as *const i64); - - l46 - }; - WitNode::PrimS64(e54) - } - 16 => { - let e54 = { - let l47 = *((base + 8) as *const f32); - - l47 - }; - WitNode::PrimFloat32(e54) - } - 17 => { - let e54 = { - let l48 = *((base + 8) as *const f64); - - l48 - }; - WitNode::PrimFloat64(e54) - } - 18 => { - let e54 = { - let l49 = *((base + 8) as *const i32); - - wit_bindgen::rt::char_lift(l49 as u32) - }; - WitNode::PrimChar(e54) - } - 19 => { - let e54 = { - let l50 = i32::from(*((base + 8) as *const u8)); - - wit_bindgen::rt::bool_lift(l50 as u8) - }; - WitNode::PrimBool(e54) - } - n => { - debug_assert_eq!(n, 20, "invalid enum discriminant"); - let e54 = { - let l51 = *((base + 8) as *const i32); - let l52 = *((base + 12) as *const i32); - let len53 = l52 as usize; - let bytes53 = Vec::from_raw_parts(l51 as *mut _, len53, len53); - - wit_bindgen::rt::string_lift(bytes53) }; - WitNode::PrimString(e54) - } + + v69 }; - - v54 - }; - result55.push(e55); + Err(e) } - wit_bindgen::rt::dealloc(base55, (len55 as usize) * 24, 8); - - WitValue{ - nodes: result55, - } - }; - Ok(e) - } - 1 => { - let e = { - let l56 = i32::from(*((ptr10 + 4) as *const u8)); - let v69 = match l56 { - 0 => { - let e69 = { - let l57 = *((ptr10 + 8) as *const i32); - let l58 = *((ptr10 + 12) as *const i32); - let len59 = l58 as usize; - let bytes59 = Vec::from_raw_parts(l57 as *mut _, len59, len59); - - wit_bindgen::rt::string_lift(bytes59) - }; - RpcError::ProtocolError(e69) - } - 1 => { - let e69 = { - let l60 = *((ptr10 + 8) as *const i32); - let l61 = *((ptr10 + 12) as *const i32); - let len62 = l61 as usize; - let bytes62 = Vec::from_raw_parts(l60 as *mut _, len62, len62); - - wit_bindgen::rt::string_lift(bytes62) - }; - RpcError::Denied(e69) - } - 2 => { - let e69 = { - let l63 = *((ptr10 + 8) as *const i32); - let l64 = *((ptr10 + 12) as *const i32); - let len65 = l64 as usize; - let bytes65 = Vec::from_raw_parts(l63 as *mut _, len65, len65); - - wit_bindgen::rt::string_lift(bytes65) - }; - RpcError::NotFound(e69) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e69 = { - let l66 = *((ptr10 + 8) as *const i32); - let l67 = *((ptr10 + 12) as *const i32); - let len68 = l67 as usize; - let bytes68 = Vec::from_raw_parts(l66 as *mut _, len68, len68); - - wit_bindgen::rt::string_lift(bytes68) - }; - RpcError::RemoteInternalError(e69) - } - }; - - v69 - }; - Err(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), - } - } - } - } - - } - - } - } - pub mod wasi { - pub mod clocks { - - #[allow(clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Pollable = super::super::super::wasi::io::poll::Pollable; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + } + } +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; + #[link_name = "now"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; + #[link_name = "resolution"] + fn wit_import() -> i64; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } + fn wit_import() -> i64 { + unreachable!() + } let ret = wit_import(); ret as u64 - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the specified instant - /// occured. - pub fn subscribe_instant(when: Instant,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the specified instant + /// occured. + pub fn subscribe_instant(when: Instant) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-instant"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-instant"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. - pub fn subscribe_duration(when: Duration,) -> Pollable{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + } + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + pub fn subscribe_duration(when: Duration) -> Pollable { + unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] extern "C" { - #[link_name = "subscribe-duration"] - fn wit_import(_: i64, ) -> i32; + #[link_name = "subscribe-duration"] + fn wit_import(_: i64) -> i32; } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i64(when)); + fn wit_import(_: i64) -> i32 { + unreachable!() + } + let ret = wit_import(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) - } } - - } - } - pub mod io { - - #[allow(clippy::all)] - pub mod poll { - #[used] + } + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod poll { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// `pollable` epresents a single I/O event which may be ready, or not. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Pollable { + handle: _rt::Resource, + } + + impl Pollable { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// `pollable` epresents a single I/O event which may be ready, or not. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Pollable{ - handle: wit_bindgen::rt::Resource, - } - - impl Pollable{ - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { + pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: wit_bindgen::rt::Resource::from_handle(handle), - } - } - - #[doc(hidden)] - pub fn into_handle(self) -> u32 { - wit_bindgen::rt::Resource::into_handle(self.handle) - } - - #[doc(hidden)] - pub fn handle(&self) -> u32 { - wit_bindgen::rt::Resource::handle(&self.handle) - } - } - - - unsafe impl wit_bindgen::rt::WasmResource for Pollable{ - #[inline] - unsafe fn drop(_handle: u32) { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for Pollable { + #[inline] + unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - + #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]pollable"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// Return the readiness of a pollable. This function never blocks. - /// - /// Returns `true` when the pollable is ready, and `false` otherwise. - pub fn ready(&self,) -> bool{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.ready"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - } - impl Pollable { - #[allow(unused_unsafe, clippy::all)] - /// `block` returns immediately if the pollable is ready, and otherwise - /// blocks until ready. - /// - /// This function is equivalent to calling `poll.poll` on a list - /// containing only this pollable. - pub fn block(&self,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]pollable"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Pollable { + #[allow(unused_unsafe, clippy::all)] + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + pub fn ready(&self) -> bool { unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/poll@0.2.0")] - extern "C" { - #[link_name = "[method]pollable.block"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import((self).handle() as i32); - } - } + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.ready"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + _rt::bool_lift(ret as u8) + } } + } + impl Pollable { #[allow(unused_unsafe, clippy::all)] - /// Poll for completion on a set of pollables. - /// - /// This function takes a list of pollables, which identify I/O sources of - /// interest, and waits until one or more of the events is ready for I/O. - /// - /// The result `list` contains one or more indices of handles in the - /// argument list that is ready for I/O. - /// - /// If the list contains more elements than can be indexed with a `u32` - /// value, this function traps. - /// - /// A timeout can be implemented by adding a pollable from the - /// wasi-clocks API to the list. - /// - /// This function does not return a `result`; polling in itself does not - /// do any I/O so it doesn't fail. If any of the I/O sources identified by - /// the pollables has an error, it is indicated by marking the source as - /// being reaedy for I/O. - pub fn poll(in_: &[&Pollable],) -> wit_bindgen::rt::vec::Vec::{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + pub fn block(&self) { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/poll@0.2.0")] + extern "C" { + #[link_name = "[method]pollable.block"] + fn wit_import(_: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) { + unreachable!() + } + wit_import((self).handle() as i32); + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + pub fn poll(in_: &[&Pollable]) -> _rt::Vec { + unsafe { #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let vec0 = in_; - let len0 = vec0.len() as i32; - let layout0 = alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); - let result0 = if layout0.size() != 0 - { - let ptr = alloc::alloc(layout0); - if ptr.is_null() - { - alloc::handle_alloc_error(layout0); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; + let len0 = vec0.len(); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let result0 = if layout0.size() != 0 { + let ptr = _rt::alloc::alloc(layout0).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout0); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; for (i, e) in vec0.into_iter().enumerate() { - let base = result0 as i32 + (i as i32) * 4; - { - *((base + 0) as *mut i32) = (e).handle() as i32; - } + let base = result0.add(i * 4); + { + *base.add(0).cast::() = (e).handle() as i32; + } } - let ptr1 = ret_area.as_mut_ptr() as i32; + let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:io/poll@0.2.0")] extern "C" { - #[link_name = "poll"] - fn wit_import(_: i32, _: i32, _: i32, ); + #[link_name = "poll"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8); } - + #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(result0 as i32, len0, ptr1); - let l2 = *((ptr1 + 0) as *const i32); - let l3 = *((ptr1 + 4) as *const i32); - let len4 = l3 as usize; + fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import(result0, len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let len4 = l3; if layout0.size() != 0 { - alloc::dealloc(result0, layout0); - } - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } - } - - } - - } - } - pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - #[derive(Clone)] - pub struct ProductItem { - pub product_id: wit_bindgen::rt::string::String, - pub name: wit_bindgen::rt::string::String, + _rt::alloc::dealloc(result0.cast(), layout0); + } + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } + } + } + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[derive(Clone)] + pub struct ProductItem { + pub product_id: _rt::String, + pub name: _rt::String, pub price: f32, pub quantity: u32, - } - impl ::core::fmt::Debug for ProductItem { + } + impl ::core::fmt::Debug for ProductItem { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ProductItem").field("product-id", &self.product_id).field("name", &self.name).field("price", &self.price).field("quantity", &self.quantity).finish() - } - } - #[derive(Clone)] - pub struct OrderConfirmation { - pub order_id: wit_bindgen::rt::string::String, - } - impl ::core::fmt::Debug for OrderConfirmation { + f.debug_struct("ProductItem") + .field("product-id", &self.product_id) + .field("name", &self.name) + .field("price", &self.price) + .field("quantity", &self.quantity) + .finish() + } + } + #[derive(Clone)] + pub struct OrderConfirmation { + pub order_id: _rt::String, + } + impl ::core::fmt::Debug for OrderConfirmation { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("OrderConfirmation").field("order-id", &self.order_id).finish() + f.debug_struct("OrderConfirmation") + .field("order-id", &self.order_id) + .finish() } - } - #[derive(Clone)] - pub enum CheckoutResult{ - Error(wit_bindgen::rt::string::String), + } + #[derive(Clone)] + pub enum CheckoutResult { + Error(_rt::String), Success(OrderConfirmation), - } - impl ::core::fmt::Debug for CheckoutResult { + } + impl ::core::fmt::Debug for CheckoutResult { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - CheckoutResult::Error(e) => { - f.debug_tuple("CheckoutResult::Error").field(e).finish() + match self { + CheckoutResult::Error(e) => { + f.debug_tuple("CheckoutResult::Error").field(e).finish() + } + CheckoutResult::Success(e) => { + f.debug_tuple("CheckoutResult::Success").field(e).finish() + } } - CheckoutResult::Success(e) => { - f.debug_tuple("CheckoutResult::Success").field(e).finish() - } - } - } - } - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#initialize-cart"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_initialize_cart(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::initialize_cart(wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#add-item"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_add_item(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: f32,arg5: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - let len1 = arg3 as usize; - let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); - <_GuestImpl as Guest>::add_item(ProductItem{ - product_id: wit_bindgen::rt::string_lift(bytes0), - name: wit_bindgen::rt::string_lift(bytes1), + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_initialize_cart_cabi(arg0: *mut u8, arg1: usize) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::initialize_cart(_rt::string_lift(bytes0)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_add_item_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: f32, + arg5: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + T::add_item(ProductItem { + product_id: _rt::string_lift(bytes0), + name: _rt::string_lift(bytes1), price: arg4, quantity: arg5 as u32, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#remove-item"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_remove_item(arg0: i32,arg1: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::remove_item(wit_bindgen::rt::string_lift(bytes0)); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#update-item-quantity"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_update_item_quantity(arg0: i32,arg1: i32,arg2: i32,) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::update_item_quantity(wit_bindgen::rt::string_lift(bytes0), arg2 as u32); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#checkout"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_checkout() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::checkout(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { + }); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_remove_item_cabi(arg0: *mut u8, arg1: usize) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::remove_item(_rt::string_lift(bytes0)); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_update_item_quantity_cabi( + arg0: *mut u8, + arg1: usize, + arg2: i32, + ) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::update_item_quantity(_rt::string_lift(bytes0), arg2 as u32); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_checkout_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::checkout(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { CheckoutResult::Error(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 8) as *mut i32) = len2; - *((ptr1 + 4) as *mut i32) = ptr2; - }, + *ptr1.add(0).cast::() = (0i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(8).cast::() = len2; + *ptr1.add(4).cast::<*mut u8>() = ptr2.cast_mut(); + } CheckoutResult::Success(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let OrderConfirmation{ order_id:order_id3, } = e; - let vec4 = (order_id3.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((ptr1 + 8) as *mut i32) = len4; - *((ptr1 + 4) as *mut i32) = ptr4; - }, - } - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#checkout"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_checkout(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - _ => { - let l3 = *((arg0 + 4) as *const i32); - let l4 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l3, (l4) as usize, 1); - }, - } - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#get-cart-contents"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_cart_contents() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get_cart_contents(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec5 = result0; - let len5 = vec5.len() as i32; - let layout5 = alloc::Layout::from_size_align_unchecked(vec5.len() * 24, 4); - let result5 = if layout5.size() != 0 - { - let ptr = alloc::alloc(layout5); - if ptr.is_null() - { - alloc::handle_alloc_error(layout5); + *ptr1.add(0).cast::() = (1i32) as u8; + let OrderConfirmation { + order_id: order_id3, + } = e; + let vec4 = (order_id3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr1.add(8).cast::() = len4; + *ptr1.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_checkout(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + _ => { + let l3 = *arg0.add(4).cast::<*mut u8>(); + let l4 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_cart_contents_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get_cart_contents(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec5 = result0; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 24, 4); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); } ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5 as i32 + (i as i32) * 24; + } else { { - let ProductItem{ product_id:product_id2, name:name2, price:price2, quantity:quantity2, } = e; - let vec3 = (product_id2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; - let vec4 = (name2.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 12) as *mut i32) = len4; - *((base + 8) as *mut i32) = ptr4; - *((base + 16) as *mut f32) = wit_bindgen::rt::as_f32(price2); - *((base + 20) as *mut i32) = wit_bindgen::rt::as_i32(quantity2); - } - } - *((ptr1 + 4) as *mut i32) = len5; - *((ptr1 + 0) as *mut i32) = result5 as i32; - ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#get-cart-contents"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_cart_contents(arg0: i32,) { - let l4 = *((arg0 + 0) as *const i32); - let l5 = *((arg0 + 4) as *const i32); - let base6 = l4; - let len6 = l5; - for i in 0..len6 { - let base = base6 + i *24; - { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 8) as *const i32); - let l3 = *((base + 12) as *const i32); - wit_bindgen::rt::dealloc(l2, (l3) as usize, 1); - } - } - wit_bindgen::rt::dealloc(base6, (len6 as usize) * 24, 4); - } + ::core::ptr::null_mut() + } }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#not-durable"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_not_durable() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::not_durable(); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn initialize_cart(user_id: wit_bindgen::rt::string::String,); - fn add_item(item: ProductItem,); - fn remove_item(product_id: wit_bindgen::rt::string::String,); - fn update_item_quantity(product_id: wit_bindgen::rt::string::String,quantity: u32,); + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 24); + { + let ProductItem { + product_id: product_id2, + name: name2, + price: price2, + quantity: quantity2, + } = e; + let vec3 = (product_id2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + let vec4 = (name2.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = ptr4.cast_mut(); + *base.add(16).cast::() = _rt::as_f32(price2); + *base.add(20).cast::() = _rt::as_i32(quantity2); + } + } + *ptr1.add(4).cast::() = len5; + *ptr1.add(0).cast::<*mut u8>() = result5; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_cart_contents(arg0: *mut u8) { + let l4 = *arg0.add(0).cast::<*mut u8>(); + let l5 = *arg0.add(4).cast::(); + let base6 = l4; + let len6 = l5; + for i in 0..len6 { + let base = base6.add(i * 24); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(8).cast::<*mut u8>(); + let l3 = *base.add(12).cast::(); + _rt::cabi_dealloc(l2, l3, 1); + } + } + _rt::cabi_dealloc(base6, len6 * 24, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_not_durable_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::not_durable(); + } + pub trait Guest { + fn initialize_cart(user_id: _rt::String); + fn add_item(item: ProductItem); + fn remove_item(product_id: _rt::String); + fn update_item_quantity(product_id: _rt::String, quantity: u32); fn checkout() -> CheckoutResult; - fn get_cart_contents() -> wit_bindgen::rt::vec::Vec::; + fn get_cart_contents() -> _rt::Vec; fn not_durable(); - } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - - } - } - } - - #[cfg(target_arch = "wasm32")] - #[link_section = "component-type:shopping-cart"] - #[doc(hidden)] - pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4045] = [3, 0, 13, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 165, 3, 1, 65, 2, 1, 66, 23, 1, 114, 4, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 4, 110, 97, 109, 101, 115, 5, 112, 114, 105, 99, 101, 118, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 4, 0, 12, 112, 114, 111, 100, 117, 99, 116, 45, 105, 116, 101, 109, 3, 0, 0, 1, 112, 1, 1, 114, 4, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 5, 105, 116, 101, 109, 115, 2, 5, 116, 111, 116, 97, 108, 118, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 119, 4, 0, 5, 111, 114, 100, 101, 114, 3, 0, 3, 1, 114, 1, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 4, 0, 18, 111, 114, 100, 101, 114, 45, 99, 111, 110, 102, 105, 114, 109, 97, 116, 105, 111, 110, 3, 0, 5, 1, 113, 2, 5, 101, 114, 114, 111, 114, 1, 115, 0, 7, 115, 117, 99, 99, 101, 115, 115, 1, 6, 0, 4, 0, 15, 99, 104, 101, 99, 107, 111, 117, 116, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 1, 64, 1, 7, 117, 115, 101, 114, 45, 105, 100, 115, 1, 0, 4, 0, 15, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 45, 99, 97, 114, 116, 1, 9, 1, 64, 1, 4, 105, 116, 101, 109, 1, 1, 0, 4, 0, 8, 97, 100, 100, 45, 105, 116, 101, 109, 1, 10, 1, 64, 1, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 1, 0, 4, 0, 11, 114, 101, 109, 111, 118, 101, 45, 105, 116, 101, 109, 1, 11, 1, 64, 2, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 1, 0, 4, 0, 20, 117, 112, 100, 97, 116, 101, 45, 105, 116, 101, 109, 45, 113, 117, 97, 110, 116, 105, 116, 121, 1, 12, 1, 64, 0, 0, 8, 4, 0, 8, 99, 104, 101, 99, 107, 111, 117, 116, 1, 13, 1, 64, 0, 0, 2, 4, 0, 17, 103, 101, 116, 45, 99, 97, 114, 116, 45, 99, 111, 110, 116, 101, 110, 116, 115, 1, 14, 1, 64, 0, 1, 0, 4, 0, 11, 110, 111, 116, 45, 100, 117, 114, 97, 98, 108, 101, 1, 15, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 144, 27, 1, 65, 2, 1, 65, 13, 1, 66, 25, 1, 122, 4, 0, 10, 110, 111, 100, 101, 45, 105, 110, 100, 101, 120, 3, 0, 0, 1, 112, 1, 1, 107, 1, 1, 111, 2, 121, 3, 1, 112, 127, 1, 106, 1, 3, 1, 3, 1, 113, 21, 12, 114, 101, 99, 111, 114, 100, 45, 118, 97, 108, 117, 101, 1, 2, 0, 13, 118, 97, 114, 105, 97, 110, 116, 45, 118, 97, 108, 117, 101, 1, 4, 0, 10, 101, 110, 117, 109, 45, 118, 97, 108, 117, 101, 1, 121, 0, 11, 102, 108, 97, 103, 115, 45, 118, 97, 108, 117, 101, 1, 5, 0, 11, 116, 117, 112, 108, 101, 45, 118, 97, 108, 117, 101, 1, 2, 0, 10, 108, 105, 115, 116, 45, 118, 97, 108, 117, 101, 1, 2, 0, 12, 111, 112, 116, 105, 111, 110, 45, 118, 97, 108, 117, 101, 1, 3, 0, 12, 114, 101, 115, 117, 108, 116, 45, 118, 97, 108, 117, 101, 1, 6, 0, 7, 112, 114, 105, 109, 45, 117, 56, 1, 125, 0, 8, 112, 114, 105, 109, 45, 117, 49, 54, 1, 123, 0, 8, 112, 114, 105, 109, 45, 117, 51, 50, 1, 121, 0, 8, 112, 114, 105, 109, 45, 117, 54, 52, 1, 119, 0, 7, 112, 114, 105, 109, 45, 115, 56, 1, 126, 0, 8, 112, 114, 105, 109, 45, 115, 49, 54, 1, 124, 0, 8, 112, 114, 105, 109, 45, 115, 51, 50, 1, 122, 0, 8, 112, 114, 105, 109, 45, 115, 54, 52, 1, 120, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 51, 50, 1, 118, 0, 12, 112, 114, 105, 109, 45, 102, 108, 111, 97, 116, 54, 52, 1, 117, 0, 9, 112, 114, 105, 109, 45, 99, 104, 97, 114, 1, 116, 0, 9, 112, 114, 105, 109, 45, 98, 111, 111, 108, 1, 127, 0, 11, 112, 114, 105, 109, 45, 115, 116, 114, 105, 110, 103, 1, 115, 0, 4, 0, 8, 119, 105, 116, 45, 110, 111, 100, 101, 3, 0, 7, 1, 112, 8, 1, 114, 1, 5, 110, 111, 100, 101, 115, 9, 4, 0, 9, 119, 105, 116, 45, 118, 97, 108, 117, 101, 3, 0, 10, 1, 114, 1, 5, 118, 97, 108, 117, 101, 115, 4, 0, 3, 117, 114, 105, 3, 0, 12, 1, 113, 4, 14, 112, 114, 111, 116, 111, 99, 111, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 6, 100, 101, 110, 105, 101, 100, 1, 115, 0, 9, 110, 111, 116, 45, 102, 111, 117, 110, 100, 1, 115, 0, 21, 114, 101, 109, 111, 116, 101, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 101, 114, 114, 111, 114, 1, 115, 0, 4, 0, 9, 114, 112, 99, 45, 101, 114, 114, 111, 114, 3, 0, 14, 4, 0, 8, 119, 97, 115, 109, 45, 114, 112, 99, 3, 1, 1, 105, 16, 1, 64, 1, 8, 108, 111, 99, 97, 116, 105, 111, 110, 13, 0, 17, 4, 0, 21, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 119, 97, 115, 109, 45, 114, 112, 99, 1, 18, 1, 104, 16, 1, 112, 11, 1, 106, 1, 11, 1, 15, 1, 64, 3, 4, 115, 101, 108, 102, 19, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 15, 102, 117, 110, 99, 116, 105, 111, 110, 45, 112, 97, 114, 97, 109, 115, 20, 0, 21, 4, 0, 33, 91, 109, 101, 116, 104, 111, 100, 93, 119, 97, 115, 109, 45, 114, 112, 99, 46, 105, 110, 118, 111, 107, 101, 45, 97, 110, 100, 45, 97, 119, 97, 105, 116, 1, 22, 3, 1, 21, 103, 111, 108, 101, 109, 58, 114, 112, 99, 47, 116, 121, 112, 101, 115, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 10, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 1, 1, 104, 0, 1, 64, 1, 4, 115, 101, 108, 102, 1, 0, 127, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 114, 101, 97, 100, 121, 1, 2, 1, 64, 1, 4, 115, 101, 108, 102, 1, 1, 0, 4, 0, 22, 91, 109, 101, 116, 104, 111, 100, 93, 112, 111, 108, 108, 97, 98, 108, 101, 46, 98, 108, 111, 99, 107, 1, 3, 1, 112, 1, 1, 112, 121, 1, 64, 1, 2, 105, 110, 4, 0, 5, 4, 0, 4, 112, 111, 108, 108, 1, 6, 3, 1, 18, 119, 97, 115, 105, 58, 105, 111, 47, 112, 111, 108, 108, 64, 48, 46, 50, 46, 48, 5, 1, 2, 3, 0, 1, 8, 112, 111, 108, 108, 97, 98, 108, 101, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 8, 112, 111, 108, 108, 97, 98, 108, 101, 3, 0, 0, 1, 119, 4, 0, 7, 105, 110, 115, 116, 97, 110, 116, 3, 0, 2, 1, 119, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 4, 1, 64, 0, 0, 3, 4, 0, 3, 110, 111, 119, 1, 6, 1, 64, 0, 0, 5, 4, 0, 10, 114, 101, 115, 111, 108, 117, 116, 105, 111, 110, 1, 7, 1, 105, 1, 1, 64, 1, 4, 119, 104, 101, 110, 3, 0, 8, 4, 0, 17, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 105, 110, 115, 116, 97, 110, 116, 1, 9, 1, 64, 1, 4, 119, 104, 101, 110, 5, 0, 8, 4, 0, 18, 115, 117, 98, 115, 99, 114, 105, 98, 101, 45, 100, 117, 114, 97, 116, 105, 111, 110, 1, 10, 3, 1, 33, 119, 97, 115, 105, 58, 99, 108, 111, 99, 107, 115, 47, 109, 111, 110, 111, 116, 111, 110, 105, 99, 45, 99, 108, 111, 99, 107, 64, 48, 46, 50, 46, 48, 5, 3, 2, 3, 0, 0, 3, 117, 114, 105, 2, 3, 0, 2, 8, 100, 117, 114, 97, 116, 105, 111, 110, 1, 66, 97, 2, 3, 2, 1, 4, 4, 0, 3, 117, 114, 105, 3, 0, 0, 2, 3, 2, 1, 5, 4, 0, 8, 100, 117, 114, 97, 116, 105, 111, 110, 3, 0, 2, 1, 119, 4, 0, 11, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 3, 0, 4, 1, 119, 4, 0, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 3, 0, 6, 1, 114, 2, 9, 104, 105, 103, 104, 45, 98, 105, 116, 115, 119, 8, 108, 111, 119, 45, 98, 105, 116, 115, 119, 4, 0, 4, 117, 117, 105, 100, 3, 0, 8, 1, 114, 1, 4, 117, 117, 105, 100, 9, 4, 0, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 3, 0, 10, 1, 114, 2, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 11, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 115, 4, 0, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 3, 0, 12, 1, 114, 2, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 4, 0, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 3, 0, 14, 1, 114, 4, 12, 109, 97, 120, 45, 97, 116, 116, 101, 109, 112, 116, 115, 121, 9, 109, 105, 110, 45, 100, 101, 108, 97, 121, 3, 9, 109, 97, 120, 45, 100, 101, 108, 97, 121, 3, 10, 109, 117, 108, 116, 105, 112, 108, 105, 101, 114, 121, 4, 0, 12, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 3, 0, 16, 1, 113, 3, 15, 112, 101, 114, 115, 105, 115, 116, 45, 110, 111, 116, 104, 105, 110, 103, 0, 0, 27, 112, 101, 114, 115, 105, 115, 116, 45, 114, 101, 109, 111, 116, 101, 45, 115, 105, 100, 101, 45, 101, 102, 102, 101, 99, 116, 115, 0, 0, 5, 115, 109, 97, 114, 116, 0, 0, 4, 0, 17, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 3, 0, 18, 1, 109, 2, 9, 97, 117, 116, 111, 109, 97, 116, 105, 99, 14, 115, 110, 97, 112, 115, 104, 111, 116, 45, 98, 97, 115, 101, 100, 4, 0, 11, 117, 112, 100, 97, 116, 101, 45, 109, 111, 100, 101, 3, 0, 20, 1, 109, 6, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 13, 103, 114, 101, 97, 116, 101, 114, 45, 101, 113, 117, 97, 108, 7, 103, 114, 101, 97, 116, 101, 114, 10, 108, 101, 115, 115, 45, 101, 113, 117, 97, 108, 4, 108, 101, 115, 115, 4, 0, 17, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 22, 1, 109, 4, 5, 101, 113, 117, 97, 108, 9, 110, 111, 116, 45, 101, 113, 117, 97, 108, 4, 108, 105, 107, 101, 8, 110, 111, 116, 45, 108, 105, 107, 101, 4, 0, 24, 115, 116, 114, 105, 110, 103, 45, 102, 105, 108, 116, 101, 114, 45, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 3, 0, 24, 1, 109, 7, 7, 114, 117, 110, 110, 105, 110, 103, 4, 105, 100, 108, 101, 9, 115, 117, 115, 112, 101, 110, 100, 101, 100, 11, 105, 110, 116, 101, 114, 114, 117, 112, 116, 101, 100, 8, 114, 101, 116, 114, 121, 105, 110, 103, 6, 102, 97, 105, 108, 101, 100, 6, 101, 120, 105, 116, 101, 100, 4, 0, 13, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 3, 0, 26, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 18, 119, 111, 114, 107, 101, 114, 45, 110, 97, 109, 101, 45, 102, 105, 108, 116, 101, 114, 3, 0, 28, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 27, 4, 0, 20, 119, 111, 114, 107, 101, 114, 45, 115, 116, 97, 116, 117, 115, 45, 102, 105, 108, 116, 101, 114, 3, 0, 30, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 21, 119, 111, 114, 107, 101, 114, 45, 118, 101, 114, 115, 105, 111, 110, 45, 102, 105, 108, 116, 101, 114, 3, 0, 32, 1, 114, 2, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 23, 5, 118, 97, 108, 117, 101, 119, 4, 0, 24, 119, 111, 114, 107, 101, 114, 45, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 45, 102, 105, 108, 116, 101, 114, 3, 0, 34, 1, 114, 3, 4, 110, 97, 109, 101, 115, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 25, 5, 118, 97, 108, 117, 101, 115, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 101, 110, 118, 45, 102, 105, 108, 116, 101, 114, 3, 0, 36, 1, 113, 5, 4, 110, 97, 109, 101, 1, 29, 0, 6, 115, 116, 97, 116, 117, 115, 1, 31, 0, 7, 118, 101, 114, 115, 105, 111, 110, 1, 33, 0, 10, 99, 114, 101, 97, 116, 101, 100, 45, 97, 116, 1, 35, 0, 3, 101, 110, 118, 1, 37, 0, 4, 0, 22, 119, 111, 114, 107, 101, 114, 45, 112, 114, 111, 112, 101, 114, 116, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 38, 1, 112, 39, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 40, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 108, 108, 45, 102, 105, 108, 116, 101, 114, 3, 0, 41, 1, 112, 42, 1, 114, 1, 7, 102, 105, 108, 116, 101, 114, 115, 43, 4, 0, 17, 119, 111, 114, 107, 101, 114, 45, 97, 110, 121, 45, 102, 105, 108, 116, 101, 114, 3, 0, 44, 1, 112, 115, 1, 111, 2, 115, 115, 1, 112, 47, 1, 114, 6, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 4, 97, 114, 103, 115, 46, 3, 101, 110, 118, 48, 6, 115, 116, 97, 116, 117, 115, 27, 17, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 118, 101, 114, 115, 105, 111, 110, 119, 11, 114, 101, 116, 114, 121, 45, 99, 111, 117, 110, 116, 119, 4, 0, 15, 119, 111, 114, 107, 101, 114, 45, 109, 101, 116, 97, 100, 97, 116, 97, 3, 0, 49, 4, 0, 11, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 3, 1, 1, 107, 45, 1, 105, 51, 1, 64, 3, 12, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 100, 11, 6, 102, 105, 108, 116, 101, 114, 52, 7, 112, 114, 101, 99, 105, 115, 101, 127, 0, 53, 4, 0, 24, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 1, 54, 1, 104, 51, 1, 112, 50, 1, 107, 56, 1, 64, 1, 4, 115, 101, 108, 102, 55, 0, 57, 4, 0, 28, 91, 109, 101, 116, 104, 111, 100, 93, 103, 101, 116, 45, 119, 111, 114, 107, 101, 114, 115, 46, 103, 101, 116, 45, 110, 101, 120, 116, 1, 58, 1, 64, 0, 0, 15, 4, 0, 20, 103, 111, 108, 101, 109, 45, 99, 114, 101, 97, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 59, 1, 112, 125, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 0, 60, 4, 0, 19, 103, 111, 108, 101, 109, 45, 97, 119, 97, 105, 116, 45, 112, 114, 111, 109, 105, 115, 101, 1, 61, 1, 64, 2, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 4, 100, 97, 116, 97, 60, 0, 127, 4, 0, 22, 103, 111, 108, 101, 109, 45, 99, 111, 109, 112, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 62, 1, 64, 1, 10, 112, 114, 111, 109, 105, 115, 101, 45, 105, 100, 15, 1, 0, 4, 0, 20, 103, 111, 108, 101, 109, 45, 100, 101, 108, 101, 116, 101, 45, 112, 114, 111, 109, 105, 115, 101, 1, 63, 1, 64, 1, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 1, 4, 0, 12, 103, 101, 116, 45, 115, 101, 108, 102, 45, 117, 114, 105, 1, 64, 1, 64, 0, 0, 5, 4, 0, 15, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 65, 1, 64, 1, 9, 111, 112, 108, 111, 103, 45, 105, 100, 120, 5, 1, 0, 4, 0, 15, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 105, 110, 100, 101, 120, 1, 66, 1, 64, 1, 8, 114, 101, 112, 108, 105, 99, 97, 115, 125, 1, 0, 4, 0, 12, 111, 112, 108, 111, 103, 45, 99, 111, 109, 109, 105, 116, 1, 67, 4, 0, 20, 109, 97, 114, 107, 45, 98, 101, 103, 105, 110, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 65, 1, 64, 1, 5, 98, 101, 103, 105, 110, 5, 1, 0, 4, 0, 18, 109, 97, 114, 107, 45, 101, 110, 100, 45, 111, 112, 101, 114, 97, 116, 105, 111, 110, 1, 68, 1, 64, 0, 0, 17, 4, 0, 16, 103, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 69, 1, 64, 1, 16, 110, 101, 119, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 17, 1, 0, 4, 0, 16, 115, 101, 116, 45, 114, 101, 116, 114, 121, 45, 112, 111, 108, 105, 99, 121, 1, 70, 1, 64, 0, 0, 19, 4, 0, 27, 103, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 71, 1, 64, 1, 21, 110, 101, 119, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 19, 1, 0, 4, 0, 27, 115, 101, 116, 45, 111, 112, 108, 111, 103, 45, 112, 101, 114, 115, 105, 115, 116, 101, 110, 99, 101, 45, 108, 101, 118, 101, 108, 1, 72, 1, 64, 0, 0, 127, 4, 0, 20, 103, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 73, 1, 64, 1, 10, 105, 100, 101, 109, 112, 111, 116, 101, 110, 116, 127, 1, 0, 4, 0, 20, 115, 101, 116, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 101, 45, 109, 111, 100, 101, 1, 74, 1, 64, 0, 0, 9, 4, 0, 24, 103, 101, 110, 101, 114, 97, 116, 101, 45, 105, 100, 101, 109, 112, 111, 116, 101, 110, 99, 121, 45, 107, 101, 121, 1, 75, 1, 64, 3, 9, 119, 111, 114, 107, 101, 114, 45, 105, 100, 13, 14, 116, 97, 114, 103, 101, 116, 45, 118, 101, 114, 115, 105, 111, 110, 7, 4, 109, 111, 100, 101, 21, 1, 0, 4, 0, 13, 117, 112, 100, 97, 116, 101, 45, 119, 111, 114, 107, 101, 114, 1, 76, 3, 1, 20, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 104, 111, 115, 116, 64, 48, 46, 50, 46, 48, 5, 6, 1, 66, 23, 1, 114, 4, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 4, 110, 97, 109, 101, 115, 5, 112, 114, 105, 99, 101, 118, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 4, 0, 12, 112, 114, 111, 100, 117, 99, 116, 45, 105, 116, 101, 109, 3, 0, 0, 1, 112, 1, 1, 114, 4, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 5, 105, 116, 101, 109, 115, 2, 5, 116, 111, 116, 97, 108, 118, 9, 116, 105, 109, 101, 115, 116, 97, 109, 112, 119, 4, 0, 5, 111, 114, 100, 101, 114, 3, 0, 3, 1, 114, 1, 8, 111, 114, 100, 101, 114, 45, 105, 100, 115, 4, 0, 18, 111, 114, 100, 101, 114, 45, 99, 111, 110, 102, 105, 114, 109, 97, 116, 105, 111, 110, 3, 0, 5, 1, 113, 2, 5, 101, 114, 114, 111, 114, 1, 115, 0, 7, 115, 117, 99, 99, 101, 115, 115, 1, 6, 0, 4, 0, 15, 99, 104, 101, 99, 107, 111, 117, 116, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 1, 64, 1, 7, 117, 115, 101, 114, 45, 105, 100, 115, 1, 0, 4, 0, 15, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 45, 99, 97, 114, 116, 1, 9, 1, 64, 1, 4, 105, 116, 101, 109, 1, 1, 0, 4, 0, 8, 97, 100, 100, 45, 105, 116, 101, 109, 1, 10, 1, 64, 1, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 1, 0, 4, 0, 11, 114, 101, 109, 111, 118, 101, 45, 105, 116, 101, 109, 1, 11, 1, 64, 2, 10, 112, 114, 111, 100, 117, 99, 116, 45, 105, 100, 115, 8, 113, 117, 97, 110, 116, 105, 116, 121, 121, 1, 0, 4, 0, 20, 117, 112, 100, 97, 116, 101, 45, 105, 116, 101, 109, 45, 113, 117, 97, 110, 116, 105, 116, 121, 1, 12, 1, 64, 0, 0, 8, 4, 0, 8, 99, 104, 101, 99, 107, 111, 117, 116, 1, 13, 1, 64, 0, 0, 2, 4, 0, 17, 103, 101, 116, 45, 99, 97, 114, 116, 45, 99, 111, 110, 116, 101, 110, 116, 115, 1, 14, 1, 64, 0, 1, 0, 4, 0, 11, 110, 111, 116, 45, 100, 117, 114, 97, 98, 108, 101, 1, 15, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 7, 4, 1, 22, 103, 111, 108, 101, 109, 58, 105, 116, 47, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 4, 0, 11, 19, 1, 0, 13, 115, 104, 111, 112, 112, 105, 110, 103, 45, 99, 97, 114, 116, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - - #[inline(never)] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - pub fn __link_section() {} - \ No newline at end of file + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#initialize-cart"] + unsafe extern "C" fn export_initialize_cart(arg0: *mut u8,arg1: usize,) { + $($path_to_types)*::_export_initialize_cart_cabi::<$ty>(arg0, arg1) + } + #[export_name = "golem:it/api#add-item"] + unsafe extern "C" fn export_add_item(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: f32,arg5: i32,) { + $($path_to_types)*::_export_add_item_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5) + } + #[export_name = "golem:it/api#remove-item"] + unsafe extern "C" fn export_remove_item(arg0: *mut u8,arg1: usize,) { + $($path_to_types)*::_export_remove_item_cabi::<$ty>(arg0, arg1) + } + #[export_name = "golem:it/api#update-item-quantity"] + unsafe extern "C" fn export_update_item_quantity(arg0: *mut u8,arg1: usize,arg2: i32,) { + $($path_to_types)*::_export_update_item_quantity_cabi::<$ty>(arg0, arg1, arg2) + } + #[export_name = "golem:it/api#checkout"] + unsafe extern "C" fn export_checkout() -> *mut u8 { + $($path_to_types)*::_export_checkout_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#checkout"] + unsafe extern "C" fn _post_return_checkout(arg0: *mut u8,) { + $($path_to_types)*::__post_return_checkout::<$ty>(arg0) + } + #[export_name = "golem:it/api#get-cart-contents"] + unsafe extern "C" fn export_get_cart_contents() -> *mut u8 { + $($path_to_types)*::_export_get_cart_contents_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:it/api#get-cart-contents"] + unsafe extern "C" fn _post_return_get_cart_contents(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_cart_contents::<$ty>(arg0) + } + #[export_name = "golem:it/api#not-durable"] + unsafe extern "C" fn export_not_durable() { + $($path_to_types)*::_export_not_durable_cabi::<$ty>() + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); + } + } + } +} +mod _rt { + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + pub use alloc_crate::alloc; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_f32(t: T) -> f32 { + t.as_f32() + } + + pub trait AsF32 { + fn as_f32(self) -> f32; + } + + impl<'a, T: Copy + AsF32> AsF32 for &'a T { + fn as_f32(self) -> f32 { + (*self).as_f32() + } + } + + impl AsF32 for f32 { + #[inline] + fn as_f32(self) -> f32 { + self as f32 + } + } + + pub fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn char_lift(val: u32) -> char { + if cfg!(debug_assertions) { + core::char::from_u32(val).unwrap() + } else { + core::char::from_u32_unchecked(val) + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_shopping_cart_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_shopping_cart_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.25.0:shopping-cart:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3604] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x90\x1b\x01A\x02\x01\ +A\x0d\x01B\x19\x01z\x04\0\x0anode-index\x03\0\0\x01p\x01\x01k\x01\x01o\x02y\x03\x01\ +p\x7f\x01j\x01\x03\x01\x03\x01q\x15\x0crecord-value\x01\x02\0\x0dvariant-value\x01\ +\x04\0\x0aenum-value\x01y\0\x0bflags-value\x01\x05\0\x0btuple-value\x01\x02\0\x0a\ +list-value\x01\x02\0\x0coption-value\x01\x03\0\x0cresult-value\x01\x06\0\x07prim\ +-u8\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01\ +~\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01\ +v\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-st\ +ring\x01s\0\x04\0\x08wit-node\x03\0\x07\x01p\x08\x01r\x01\x05nodes\x09\x04\0\x09\ +wit-value\x03\0\x0a\x01r\x01\x05values\x04\0\x03uri\x03\0\x0c\x01q\x04\x0eprotoc\ +ol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\x15remote-internal-error\x01\ +s\0\x04\0\x09rpc-error\x03\0\x0e\x04\0\x08wasm-rpc\x03\x01\x01i\x10\x01@\x01\x08\ +location\x0d\0\x11\x04\0\x15[constructor]wasm-rpc\x01\x12\x01h\x10\x01p\x0b\x01j\ +\x01\x0b\x01\x0f\x01@\x03\x04self\x13\x0dfunction-names\x0ffunction-params\x14\0\ +\x15\x04\0![method]wasm-rpc.invoke-and-await\x01\x16\x03\x01\x15golem:rpc/types@\ +0.1.0\x05\0\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\ +\x04\0\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[me\ +thod]pollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04pol\ +l\x01\x06\x03\x01\x12wasi:io/poll@0.2.0\x05\x01\x02\x03\0\x01\x08pollable\x01B\x0f\ +\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01\ +w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\ +\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-\ +instant\x01\x09\x01@\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\ +\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x03\x02\x03\0\0\x03uri\x02\x03\0\x02\x08\ +duration\x01Ba\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\ +\x08duration\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11compone\ +nt-version\x03\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\ +\x01r\x01\x04uuid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\ +\x0bworker-names\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog\ +-idx\x05\x04\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\ +\x09max-delay\x03\x0amultipliery\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fper\ +sist-nothing\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persis\ +tence-level\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mo\ +de\x03\0\x14\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-\ +equal\x04less\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equa\ +l\x04like\x08not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07ru\ +nning\x04idle\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0d\ +worker-status\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-nam\ +e-filter\x03\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-statu\ +s-filter\x03\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-\ +filter\x03\0\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at\ +-filter\x03\0\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-en\ +v-filter\x03\0$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\ +\x0acreated-at\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\ +\x01r\x01\x07filters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filter\ +s+\x04\0\x11worker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-i\ +d\x0d\x04args.\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\ +\x0fworker-metadata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0c\ +component-id\x0b\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x01\ +6\x01h3\x01p2\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01\ +:\x01@\0\0\x0f\x04\0\x14golem-create-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\ +\0<\x04\0\x13golem-await-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\ +\0\x16golem-complete-promise\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x14gole\ +m-delete-promise\x01?\x01@\x01\x0dfunction-names\0\x01\x04\0\x0cget-self-uri\x01\ +@\x01@\0\0\x05\x04\0\x0fget-oplog-index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\ +\0\x0fset-oplog-index\x01B\x01@\x01\x08replicas}\x01\0\x04\0\x0coplog-commit\x01\ +C\x04\0\x14mark-begin-operation\x01A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-e\ +nd-operation\x01D\x01@\0\0\x11\x04\0\x10get-retry-policy\x01E\x01@\x01\x10new-re\ +try-policy\x11\x01\0\x04\0\x10set-retry-policy\x01F\x01@\0\0\x13\x04\0\x1bget-op\ +log-persistence-level\x01G\x01@\x01\x15new-persistence-level\x13\x01\0\x04\0\x1b\ +set-oplog-persistence-level\x01H\x01@\0\0\x7f\x04\0\x14get-idempotence-mode\x01I\ +\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\x14set-idempotence-mode\x01J\x01@\0\0\x09\ +\x04\0\x18generate-idempotency-key\x01K\x01@\x03\x09worker-id\x0d\x0etarget-vers\ +ion\x07\x04mode\x15\x01\0\x04\0\x0dupdate-worker\x01L\x03\x01\x14golem:api/host@\ +0.2.0\x05\x06\x01B\x17\x01r\x04\x0aproduct-ids\x04names\x05pricev\x08quantityy\x04\ +\0\x0cproduct-item\x03\0\0\x01p\x01\x01r\x04\x08order-ids\x05items\x02\x05totalv\ +\x09timestampw\x04\0\x05order\x03\0\x03\x01r\x01\x08order-ids\x04\0\x12order-con\ +firmation\x03\0\x05\x01q\x02\x05error\x01s\0\x07success\x01\x06\0\x04\0\x0fcheck\ +out-result\x03\0\x07\x01@\x01\x07user-ids\x01\0\x04\0\x0finitialize-cart\x01\x09\ +\x01@\x01\x04item\x01\x01\0\x04\0\x08add-item\x01\x0a\x01@\x01\x0aproduct-ids\x01\ +\0\x04\0\x0bremove-item\x01\x0b\x01@\x02\x0aproduct-ids\x08quantityy\x01\0\x04\0\ +\x14update-item-quantity\x01\x0c\x01@\0\0\x08\x04\0\x08checkout\x01\x0d\x01@\0\0\ +\x02\x04\0\x11get-cart-contents\x01\x0e\x01@\0\x01\0\x04\0\x0bnot-durable\x01\x0f\ +\x04\x01\x0cgolem:it/api\x05\x07\x04\x01\x16golem:it/shopping-cart\x04\0\x0b\x13\ +\x01\0\x0dshopping-cart\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-c\ +omponent\x070.208.1\x10wit-bindgen-rust\x060.25.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/shopping-cart/src/lib.rs b/test-components/shopping-cart/src/lib.rs index b62d2d9c7e..b7f340b314 100644 --- a/test-components/shopping-cart/src/lib.rs +++ b/test-components/shopping-cart/src/lib.rs @@ -162,3 +162,5 @@ impl Guest for Component { }) } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/stdio-cc.wasm b/test-components/stdio-cc.wasm index 9469cb9a92..ab29f489ff 100755 Binary files a/test-components/stdio-cc.wasm and b/test-components/stdio-cc.wasm differ diff --git a/test-components/stdio-cc/Cargo.lock b/test-components/stdio-cc/Cargo.lock index ed7aa7fec0..f9ed4a0423 100644 --- a/test-components/stdio-cc/Cargo.lock +++ b/test-components/stdio-cc/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-stdio-cc" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/stdio-cc/Cargo.toml b/test-components/stdio-cc/Cargo.toml index ad892a67bd..fe544d2a6a 100644 --- a/test-components/stdio-cc/Cargo.toml +++ b/test-components/stdio-cc/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/stdio-cc/src/bindings.rs b/test-components/stdio-cc/src/bindings.rs index 4ed9b9bbe3..e924cbfcce 100644 --- a/test-components/stdio-cc/src/bindings.rs +++ b/test-components/stdio-cc/src/bindings.rs @@ -1,41 +1,76 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::run(); - } -}; -use super::Component as _GuestImpl; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::run(); +} pub trait Guest { - fn run(); + fn run(); +} +#[doc(hidden)] + +macro_rules! __export_world_stdio_cc_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "run"] + unsafe extern "C" fn export_run() { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_stdio_cc_cabi; +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } } +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_stdio_cc_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_stdio_cc_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_stdio_cc_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:stdio-cc"] +#[link_section = "component-type:wit-bindgen:0.25.0:stdio-cc:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 168] = [3, 0, 8, 115, 116, 100, 105, 111, 45, 99, 99, 0, 97, 115, 109, 13, 0, 1, 0, 7, 41, 1, 65, 2, 1, 65, 2, 1, 64, 0, 1, 0, 4, 0, 3, 114, 117, 110, 1, 0, 4, 1, 17, 103, 111, 108, 101, 109, 58, 105, 116, 47, 115, 116, 100, 105, 111, 45, 99, 99, 4, 0, 11, 14, 1, 0, 8, 115, 116, 100, 105, 111, 45, 99, 99, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 167] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07)\x01A\x02\x01A\x02\x01\ +@\0\x01\0\x04\0\x03run\x01\0\x04\x01\x11golem:it/stdio-cc\x04\0\x0b\x0e\x01\0\x08\ +stdio-cc\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.2\ +08.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/stdio-cc/src/lib.rs b/test-components/stdio-cc/src/lib.rs index a9b140c2ea..6a17eb74b6 100644 --- a/test-components/stdio-cc/src/lib.rs +++ b/test-components/stdio-cc/src/lib.rs @@ -20,3 +20,5 @@ impl Guest for Component { println!("{}", result); } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/swift-1.wasm b/test-components/swift-1.wasm index 0ba6b2094e..01486b81ba 100644 Binary files a/test-components/swift-1.wasm and b/test-components/swift-1.wasm differ diff --git a/test-components/tinygo-wasi-http.wasm b/test-components/tinygo-wasi-http.wasm index 1544bc5468..88691e86f3 100644 Binary files a/test-components/tinygo-wasi-http.wasm and b/test-components/tinygo-wasi-http.wasm differ diff --git a/test-components/tinygo-wasi-http/wit/deps/cli/imports.wit b/test-components/tinygo-wasi-http/wit/deps/cli/imports.wit new file mode 100644 index 0000000000..083b84a036 --- /dev/null +++ b/test-components/tinygo-wasi-http/wit/deps/cli/imports.wit @@ -0,0 +1,20 @@ +package wasi:cli@0.2.0; + +world imports { + include wasi:clocks/imports@0.2.0; + include wasi:filesystem/imports@0.2.0; + include wasi:sockets/imports@0.2.0; + include wasi:random/imports@0.2.0; + include wasi:io/imports@0.2.0; + + import environment; + import exit; + import stdin; + import stdout; + import stderr; + import terminal-input; + import terminal-output; + import terminal-stdin; + import terminal-stdout; + import terminal-stderr; +} diff --git a/test-components/tinygo-wasi-http/wit/deps/golem/golem-host.wit b/test-components/tinygo-wasi-http/wit/deps/golem/golem-host.wit index 7acda93328..a2b4c588fd 100644 --- a/test-components/tinygo-wasi-http/wit/deps/golem/golem-host.wit +++ b/test-components/tinygo-wasi-http/wit/deps/golem/golem-host.wit @@ -3,249 +3,249 @@ package golem:api@0.2.0; /// The Golem host API provides low level access to Golem specific features such as promises and control over /// the durability and transactional guarantees the executor provides. interface host { - use golem:rpc/types@0.1.0.{uri}; - use wasi:clocks/monotonic-clock@0.2.0.{duration}; - - /// An index into the persistent log storing all performed operations of a worker - type oplog-index = u64; - - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - record promise-id { - worker-id: worker-id, - oplog-idx: oplog-index, - } - - /// Represents a Golem worker - record worker-id { - component-id: component-id, - worker-name: string - } - - - /// Represents a Golem component - record component-id { - uuid: uuid, - } - - /// Represents a Golem component's version - type component-version = u64; - - /// UUID - record uuid { - high-bits: u64, - low-bits: u64 - } - - /// Configures how the executor retries failures - record retry-policy { - /// The maximum number of retries before the worker becomes permanently failed - max-attempts: u32, - /// The minimum delay between retries (applied to the first retry) - min-delay: duration, - /// The maximum delay between retries - max-delay: duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - multiplier: u32 - } - - /// Configurable persistence level for workers - variant persistence-level { - persist-nothing, - persist-remote-side-effects, - smart - } - - /// Describes how to update a worker to a different component version - enum update-mode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - automatic, - - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - snapshot-based - } - - enum filter-comparator { - equal, - not-equal, - greater-equal, - greater, - less-equal, - less - } - - enum string-filter-comparator { - equal, - not-equal, - like, - not-like - } - - enum worker-status { - /// The worker is running an invoked function - running, - /// The worker is ready to run an invoked function - idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - suspended, - /// The last invocation was interrupted but will be resumed - interrupted, - /// The last invocation failed and a retry was scheduled - retrying, - /// The last invocation failed and the worker can no longer be used - failed, - /// The worker exited after a successful invocation and can no longer be invoked - exited, - } - - record worker-name-filter { - comparator: string-filter-comparator, - value: string - } - - record worker-status-filter { - comparator: filter-comparator, - value: worker-status - } - - record worker-version-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-created-at-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-env-filter { - name: string, - comparator: string-filter-comparator, - value: string - } - - variant worker-property-filter { - name(worker-name-filter), - status(worker-status-filter), - version(worker-version-filter), - created-at(worker-created-at-filter), - env(worker-env-filter) - } - - record worker-all-filter { - filters: list - } - - record worker-any-filter { - filters: list - } - - record worker-metadata { - worker-id: worker-id, - args: list, - env: list>, - status: worker-status, - component-version: u64, - retry-count: u64 - } - - resource get-workers { -constructor(component-id: component-id, filter: option, precise: bool); - - get-next: func() -> option>; - } - - /// Create a new promise - golem-create-promise: func() -> promise-id; - - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - golem-await-promise: func(promise-id: promise-id) -> list; - - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - golem-complete-promise: func(promise-id: promise-id, data: list) -> bool; - - /// Deletes the given promise - golem-delete-promise: func(promise-id: promise-id) -> (); - - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - get-self-uri: func(function-name: string) -> uri; - - /// Returns the current position in the persistent op log - get-oplog-index: func() -> oplog-index; - - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - set-oplog-index: func(oplog-idx: oplog-index) -> (); - - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - oplog-commit: func(replicas: u8) -> (); - - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - mark-begin-operation: func() -> oplog-index; - - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - mark-end-operation: func(begin: oplog-index) -> (); - - /// Gets the current retry policy associated with the worker - get-retry-policy: func() -> retry-policy; - - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - set-retry-policy: func(new-retry-policy: retry-policy) -> (); - - /// Gets the worker's current persistence level. - get-oplog-persistence-level: func() -> persistence-level; - - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); - - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - get-idempotence-mode: func() -> bool; - - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - set-idempotence-mode: func(idempotent: bool) -> (); - - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - generate-idempotency-key: func() -> uuid; - - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); + use golem:rpc/types@0.1.0.{uri}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; + + /// An index into the persistent log storing all performed operations of a worker + type oplog-index = u64; + + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + record promise-id { + worker-id: worker-id, + oplog-idx: oplog-index, + } + + /// Represents a Golem worker + record worker-id { + component-id: component-id, + worker-name: string + } + + + /// Represents a Golem component + record component-id { + uuid: uuid, + } + + /// Represents a Golem component's version + type component-version = u64; + + /// UUID + record uuid { + high-bits: u64, + low-bits: u64 + } + + /// Configures how the executor retries failures + record retry-policy { + /// The maximum number of retries before the worker becomes permanently failed + max-attempts: u32, + /// The minimum delay between retries (applied to the first retry) + min-delay: duration, + /// The maximum delay between retries + max-delay: duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + multiplier: u32 + } + + /// Configurable persistence level for workers + variant persistence-level { + persist-nothing, + persist-remote-side-effects, + smart + } + + /// Describes how to update a worker to a different component version + enum update-mode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + automatic, + + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + snapshot-based + } + + enum filter-comparator { + equal, + not-equal, + greater-equal, + greater, + less-equal, + less + } + + enum string-filter-comparator { + equal, + not-equal, + like, + not-like + } + + enum worker-status { + /// The worker is running an invoked function + running, + /// The worker is ready to run an invoked function + idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + suspended, + /// The last invocation was interrupted but will be resumed + interrupted, + /// The last invocation failed and a retry was scheduled + retrying, + /// The last invocation failed and the worker can no longer be used + failed, + /// The worker exited after a successful invocation and can no longer be invoked + exited, + } + + record worker-name-filter { + comparator: string-filter-comparator, + value: string + } + + record worker-status-filter { + comparator: filter-comparator, + value: worker-status + } + + record worker-version-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-created-at-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-env-filter { + name: string, + comparator: string-filter-comparator, + value: string + } + + variant worker-property-filter { + name(worker-name-filter), + status(worker-status-filter), + version(worker-version-filter), + created-at(worker-created-at-filter), + env(worker-env-filter) + } + + record worker-all-filter { + filters: list + } + + record worker-any-filter { + filters: list + } + + record worker-metadata { + worker-id: worker-id, + args: list, + env: list>, + status: worker-status, + component-version: u64, + retry-count: u64 + } + + resource get-workers { + constructor(component-id: component-id, filter: option, precise: bool); + + get-next: func() -> option>; + } + + /// Create a new promise + golem-create-promise: func() -> promise-id; + + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + golem-await-promise: func(promise-id: promise-id) -> list; + + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + golem-complete-promise: func(promise-id: promise-id, data: list) -> bool; + + /// Deletes the given promise + golem-delete-promise: func(promise-id: promise-id) -> (); + + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + get-self-uri: func(function-name: string) -> uri; + + /// Returns the current position in the persistent op log + get-oplog-index: func() -> oplog-index; + + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + set-oplog-index: func(oplog-idx: oplog-index) -> (); + + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + oplog-commit: func(replicas: u8) -> (); + + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + mark-begin-operation: func() -> oplog-index; + + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + mark-end-operation: func(begin: oplog-index) -> (); + + /// Gets the current retry policy associated with the worker + get-retry-policy: func() -> retry-policy; + + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + set-retry-policy: func(new-retry-policy: retry-policy) -> (); + + /// Gets the worker's current persistence level. + get-oplog-persistence-level: func() -> persistence-level; + + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); + + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + get-idempotence-mode: func() -> bool; + + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + set-idempotence-mode: func(idempotent: bool) -> (); + + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + generate-idempotency-key: func() -> uuid; + + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface save-snapshot { - /// Saves the component's state into a user-defined snapshot - save: func() -> list; + /// Saves the component's state into a user-defined snapshot + save: func() -> list; } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface load-snapshot { - /// Tries to load a user-defined snapshot, setting up the worker's state based on it. - /// The function can return with a failure to indicate that the update is not possible. - load: func(bytes: list) -> result<_, string>; + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + load: func(bytes: list) -> result<_, string>; } world golem-host { - import host; - import save-snapshot; - import load-snapshot; + import host; + import save-snapshot; + import load-snapshot; } \ No newline at end of file diff --git a/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual-batch.wit b/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual-batch.wit new file mode 100644 index 0000000000..080999eeaa --- /dev/null +++ b/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual-batch.wit @@ -0,0 +1,81 @@ +/// A keyvalue interface that provides eventually consistent batch operations. +/// +/// A batch operation is an operation that operates on multiple keys at once. +/// +/// Batch operations are useful for reducing network round-trip time. For example, +/// if you want to get the values associated with 100 keys, you can either do 100 get +/// operations or you can do 1 batch get operation. The batch operation is +/// faster because it only needs to make 1 network call instead of 100. +/// +/// A batch operation does not guarantee atomicity, meaning that if the batch +/// operation fails, some of the keys may have been modified and some may not. +/// Transactional operations are being worked on and will be added in the future to +/// provide atomicity. +/// +/// Data consistency in a key value store refers to the gaurantee that once a +/// write operation completes, all subsequent read operations will return the +/// value that was written. +/// +/// The level of consistency in batch operations is **eventual consistency**, the same +/// with the readwrite interface. This interface does not guarantee strong consistency, +/// meaning that if a write operation completes, subsequent read operations may not return +/// the value that was written. +interface eventual-batch { + /// A keyvalue interface that provides batch get operations. + use types.{bucket, error, key, incoming-value, outgoing-value}; + + /// Get the values associated with the keys in the bucket. It returns a list of + /// incoming-value that can be consumed to get the value associated with the key. + /// + /// If any of the keys do not exist in the bucket, it returns a `none` value for + /// that key in the list. + /// + /// Note that the key-value pairs are guaranteed to be returned in the same order + /// + /// MAY show an out-of-date value if there are concurrent writes to the bucket. + /// + /// If any other error occurs, it returns an `Err(error)`. + get-many: func(bucket: borrow, keys: list) -> result>, error>; + + /// Get all the keys in the bucket. It returns a list of keys. + /// + /// Note that the keys are not guaranteed to be returned in any particular order. + /// + /// If the bucket is empty, it returns an empty list. + /// + /// MAY show an out-of-date list of keys if there are concurrent writes to the bucket. + /// + /// If any error occurs, it returns an `Err(error)`. + keys: func(bucket: borrow) -> result, error>; + + /// Set the values associated with the keys in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// Note that the key-value pairs are not guaranteed to be set in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already set. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// set while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + set-many: func(bucket: borrow, key-values: list>>) -> result<_, error>; + + /// Delete the key-value pairs associated with the keys in the bucket. + /// + /// Note that the key-value pairs are not guaranteed to be deleted in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it skips the key. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already deleted. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// deleted while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + delete-many: func(bucket: borrow, keys: list) -> result<_, error>; +} \ No newline at end of file diff --git a/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual.wit b/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual.wit new file mode 100644 index 0000000000..e6e33cfe74 --- /dev/null +++ b/test-components/tinygo-wasi-http/wit/deps/keyvalue/eventual.wit @@ -0,0 +1,56 @@ +/// A keyvalue interface that provides eventually consistent CRUD operations. +/// +/// A CRUD operation is an operation that acts on a single key-value pair. +/// +/// The value in the key-value pair is defined as a `u8` byte array and the intention +/// is that it is the common denominator for all data types defined by different +/// key-value stores to handle data, ensuring compatibility between different +/// key-value stores. Note: the clients will be expecting serialization/deserialization overhead +/// to be handled by the key-value store. The value could be a serialized object from +/// JSON, HTML or vendor-specific data types like AWS S3 objects. +/// +/// Data consistency in a key value store refers to the gaurantee that once a +/// write operation completes, all subsequent read operations will return the +/// value that was written. +/// +/// The level of consistency in readwrite interfaces is **eventual consistency**, +/// which means that if a write operation completes successfully, all subsequent +/// read operations will eventually return the value that was written. In other words, +/// if we pause the updates to the system, the system eventually will return +/// the last updated value for read. +interface eventual { + /// A keyvalue interface that provides simple read and write operations. + use types.{bucket, error, incoming-value, key, outgoing-value}; + + /// Get the value associated with the key in the bucket. + /// + /// The value is returned as an option. If the key-value pair exists in the + /// bucket, it returns `Ok(value)`. If the key does not exist in the + /// bucket, it returns `Ok(none)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + get: func(bucket: borrow, key: key) -> result, error>; + + /// Set the value associated with the key in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// If the key does not exist in the bucket, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. + set: func(bucket: borrow, key: key, outgoing-value: borrow) -> result<_, error>; + + /// Delete the key-value pair associated with the key in the bucket. + /// + /// If the key does not exist in the bucket, it does nothing. + /// + /// If any other error occurs, it returns an `Err(error)`. + delete: func(bucket: borrow, key: key) -> result<_, error>; + + /// Check if the key exists in the bucket. + /// + /// If the key exists in the bucket, it returns `Ok(true)`. If the key does + /// not exist in the bucket, it returns `Ok(false)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + exists: func(bucket: borrow, key: key) -> result; +} \ No newline at end of file diff --git a/test-components/tinygo-wasi-http/wit/deps/wasm-rpc/wasm-rpc.wit b/test-components/tinygo-wasi-http/wit/deps/wasm-rpc/wasm-rpc.wit new file mode 100644 index 0000000000..8e31847bed --- /dev/null +++ b/test-components/tinygo-wasi-http/wit/deps/wasm-rpc/wasm-rpc.wit @@ -0,0 +1,56 @@ +package golem:rpc@0.1.0; + +interface types { + type node-index = s32; + + record wit-value { + nodes: list, + } + + variant wit-node { + record-value(list), + variant-value(tuple>), + enum-value(u32), + flags-value(list), + tuple-value(list), + list-value(list), + option-value(option), + result-value(result, option>), + prim-u8(u8), + prim-u16(u16), + prim-u32(u32), + prim-u64(u64), + prim-s8(s8), + prim-s16(s16), + prim-s32(s32), + prim-s64(s64), + prim-float32(float32), + prim-float64(float64), + prim-char(char), + prim-bool(bool), + prim-string(string), + handle(tuple) + } + + record uri { + value: string, + } + + variant rpc-error { + protocol-error(string), + denied(string), + not-found(string), + remote-internal-error(string) + } + + resource wasm-rpc { + constructor(location: uri); + + invoke-and-await: func(function-name: string, function-params: list) -> result; + invoke: func(function-name: string, function-params: list) -> result<_, rpc-error>; + } +} + +world wit-value { + import types; +} diff --git a/test-components/tinygo-wasi.wasm b/test-components/tinygo-wasi.wasm index 390638d812..f2863106f6 100644 Binary files a/test-components/tinygo-wasi.wasm and b/test-components/tinygo-wasi.wasm differ diff --git a/test-components/tinygo-wasi/wit/deps/cli/imports.wit b/test-components/tinygo-wasi/wit/deps/cli/imports.wit new file mode 100644 index 0000000000..083b84a036 --- /dev/null +++ b/test-components/tinygo-wasi/wit/deps/cli/imports.wit @@ -0,0 +1,20 @@ +package wasi:cli@0.2.0; + +world imports { + include wasi:clocks/imports@0.2.0; + include wasi:filesystem/imports@0.2.0; + include wasi:sockets/imports@0.2.0; + include wasi:random/imports@0.2.0; + include wasi:io/imports@0.2.0; + + import environment; + import exit; + import stdin; + import stdout; + import stderr; + import terminal-input; + import terminal-output; + import terminal-stdin; + import terminal-stdout; + import terminal-stderr; +} diff --git a/test-components/tinygo-wasi/wit/deps/golem/golem-host.wit b/test-components/tinygo-wasi/wit/deps/golem/golem-host.wit index 7acda93328..a2b4c588fd 100644 --- a/test-components/tinygo-wasi/wit/deps/golem/golem-host.wit +++ b/test-components/tinygo-wasi/wit/deps/golem/golem-host.wit @@ -3,249 +3,249 @@ package golem:api@0.2.0; /// The Golem host API provides low level access to Golem specific features such as promises and control over /// the durability and transactional guarantees the executor provides. interface host { - use golem:rpc/types@0.1.0.{uri}; - use wasi:clocks/monotonic-clock@0.2.0.{duration}; - - /// An index into the persistent log storing all performed operations of a worker - type oplog-index = u64; - - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - record promise-id { - worker-id: worker-id, - oplog-idx: oplog-index, - } - - /// Represents a Golem worker - record worker-id { - component-id: component-id, - worker-name: string - } - - - /// Represents a Golem component - record component-id { - uuid: uuid, - } - - /// Represents a Golem component's version - type component-version = u64; - - /// UUID - record uuid { - high-bits: u64, - low-bits: u64 - } - - /// Configures how the executor retries failures - record retry-policy { - /// The maximum number of retries before the worker becomes permanently failed - max-attempts: u32, - /// The minimum delay between retries (applied to the first retry) - min-delay: duration, - /// The maximum delay between retries - max-delay: duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - multiplier: u32 - } - - /// Configurable persistence level for workers - variant persistence-level { - persist-nothing, - persist-remote-side-effects, - smart - } - - /// Describes how to update a worker to a different component version - enum update-mode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - automatic, - - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - snapshot-based - } - - enum filter-comparator { - equal, - not-equal, - greater-equal, - greater, - less-equal, - less - } - - enum string-filter-comparator { - equal, - not-equal, - like, - not-like - } - - enum worker-status { - /// The worker is running an invoked function - running, - /// The worker is ready to run an invoked function - idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - suspended, - /// The last invocation was interrupted but will be resumed - interrupted, - /// The last invocation failed and a retry was scheduled - retrying, - /// The last invocation failed and the worker can no longer be used - failed, - /// The worker exited after a successful invocation and can no longer be invoked - exited, - } - - record worker-name-filter { - comparator: string-filter-comparator, - value: string - } - - record worker-status-filter { - comparator: filter-comparator, - value: worker-status - } - - record worker-version-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-created-at-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-env-filter { - name: string, - comparator: string-filter-comparator, - value: string - } - - variant worker-property-filter { - name(worker-name-filter), - status(worker-status-filter), - version(worker-version-filter), - created-at(worker-created-at-filter), - env(worker-env-filter) - } - - record worker-all-filter { - filters: list - } - - record worker-any-filter { - filters: list - } - - record worker-metadata { - worker-id: worker-id, - args: list, - env: list>, - status: worker-status, - component-version: u64, - retry-count: u64 - } - - resource get-workers { -constructor(component-id: component-id, filter: option, precise: bool); - - get-next: func() -> option>; - } - - /// Create a new promise - golem-create-promise: func() -> promise-id; - - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - golem-await-promise: func(promise-id: promise-id) -> list; - - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - golem-complete-promise: func(promise-id: promise-id, data: list) -> bool; - - /// Deletes the given promise - golem-delete-promise: func(promise-id: promise-id) -> (); - - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - get-self-uri: func(function-name: string) -> uri; - - /// Returns the current position in the persistent op log - get-oplog-index: func() -> oplog-index; - - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - set-oplog-index: func(oplog-idx: oplog-index) -> (); - - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - oplog-commit: func(replicas: u8) -> (); - - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - mark-begin-operation: func() -> oplog-index; - - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - mark-end-operation: func(begin: oplog-index) -> (); - - /// Gets the current retry policy associated with the worker - get-retry-policy: func() -> retry-policy; - - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - set-retry-policy: func(new-retry-policy: retry-policy) -> (); - - /// Gets the worker's current persistence level. - get-oplog-persistence-level: func() -> persistence-level; - - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); - - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - get-idempotence-mode: func() -> bool; - - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - set-idempotence-mode: func(idempotent: bool) -> (); - - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - generate-idempotency-key: func() -> uuid; - - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); + use golem:rpc/types@0.1.0.{uri}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; + + /// An index into the persistent log storing all performed operations of a worker + type oplog-index = u64; + + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + record promise-id { + worker-id: worker-id, + oplog-idx: oplog-index, + } + + /// Represents a Golem worker + record worker-id { + component-id: component-id, + worker-name: string + } + + + /// Represents a Golem component + record component-id { + uuid: uuid, + } + + /// Represents a Golem component's version + type component-version = u64; + + /// UUID + record uuid { + high-bits: u64, + low-bits: u64 + } + + /// Configures how the executor retries failures + record retry-policy { + /// The maximum number of retries before the worker becomes permanently failed + max-attempts: u32, + /// The minimum delay between retries (applied to the first retry) + min-delay: duration, + /// The maximum delay between retries + max-delay: duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + multiplier: u32 + } + + /// Configurable persistence level for workers + variant persistence-level { + persist-nothing, + persist-remote-side-effects, + smart + } + + /// Describes how to update a worker to a different component version + enum update-mode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + automatic, + + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + snapshot-based + } + + enum filter-comparator { + equal, + not-equal, + greater-equal, + greater, + less-equal, + less + } + + enum string-filter-comparator { + equal, + not-equal, + like, + not-like + } + + enum worker-status { + /// The worker is running an invoked function + running, + /// The worker is ready to run an invoked function + idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + suspended, + /// The last invocation was interrupted but will be resumed + interrupted, + /// The last invocation failed and a retry was scheduled + retrying, + /// The last invocation failed and the worker can no longer be used + failed, + /// The worker exited after a successful invocation and can no longer be invoked + exited, + } + + record worker-name-filter { + comparator: string-filter-comparator, + value: string + } + + record worker-status-filter { + comparator: filter-comparator, + value: worker-status + } + + record worker-version-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-created-at-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-env-filter { + name: string, + comparator: string-filter-comparator, + value: string + } + + variant worker-property-filter { + name(worker-name-filter), + status(worker-status-filter), + version(worker-version-filter), + created-at(worker-created-at-filter), + env(worker-env-filter) + } + + record worker-all-filter { + filters: list + } + + record worker-any-filter { + filters: list + } + + record worker-metadata { + worker-id: worker-id, + args: list, + env: list>, + status: worker-status, + component-version: u64, + retry-count: u64 + } + + resource get-workers { + constructor(component-id: component-id, filter: option, precise: bool); + + get-next: func() -> option>; + } + + /// Create a new promise + golem-create-promise: func() -> promise-id; + + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + golem-await-promise: func(promise-id: promise-id) -> list; + + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + golem-complete-promise: func(promise-id: promise-id, data: list) -> bool; + + /// Deletes the given promise + golem-delete-promise: func(promise-id: promise-id) -> (); + + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + get-self-uri: func(function-name: string) -> uri; + + /// Returns the current position in the persistent op log + get-oplog-index: func() -> oplog-index; + + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + set-oplog-index: func(oplog-idx: oplog-index) -> (); + + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + oplog-commit: func(replicas: u8) -> (); + + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + mark-begin-operation: func() -> oplog-index; + + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + mark-end-operation: func(begin: oplog-index) -> (); + + /// Gets the current retry policy associated with the worker + get-retry-policy: func() -> retry-policy; + + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + set-retry-policy: func(new-retry-policy: retry-policy) -> (); + + /// Gets the worker's current persistence level. + get-oplog-persistence-level: func() -> persistence-level; + + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); + + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + get-idempotence-mode: func() -> bool; + + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + set-idempotence-mode: func(idempotent: bool) -> (); + + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + generate-idempotency-key: func() -> uuid; + + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface save-snapshot { - /// Saves the component's state into a user-defined snapshot - save: func() -> list; + /// Saves the component's state into a user-defined snapshot + save: func() -> list; } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface load-snapshot { - /// Tries to load a user-defined snapshot, setting up the worker's state based on it. - /// The function can return with a failure to indicate that the update is not possible. - load: func(bytes: list) -> result<_, string>; + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + load: func(bytes: list) -> result<_, string>; } world golem-host { - import host; - import save-snapshot; - import load-snapshot; + import host; + import save-snapshot; + import load-snapshot; } \ No newline at end of file diff --git a/test-components/tinygo-wasi/wit/deps/keyvalue/eventual-batch.wit b/test-components/tinygo-wasi/wit/deps/keyvalue/eventual-batch.wit new file mode 100644 index 0000000000..080999eeaa --- /dev/null +++ b/test-components/tinygo-wasi/wit/deps/keyvalue/eventual-batch.wit @@ -0,0 +1,81 @@ +/// A keyvalue interface that provides eventually consistent batch operations. +/// +/// A batch operation is an operation that operates on multiple keys at once. +/// +/// Batch operations are useful for reducing network round-trip time. For example, +/// if you want to get the values associated with 100 keys, you can either do 100 get +/// operations or you can do 1 batch get operation. The batch operation is +/// faster because it only needs to make 1 network call instead of 100. +/// +/// A batch operation does not guarantee atomicity, meaning that if the batch +/// operation fails, some of the keys may have been modified and some may not. +/// Transactional operations are being worked on and will be added in the future to +/// provide atomicity. +/// +/// Data consistency in a key value store refers to the gaurantee that once a +/// write operation completes, all subsequent read operations will return the +/// value that was written. +/// +/// The level of consistency in batch operations is **eventual consistency**, the same +/// with the readwrite interface. This interface does not guarantee strong consistency, +/// meaning that if a write operation completes, subsequent read operations may not return +/// the value that was written. +interface eventual-batch { + /// A keyvalue interface that provides batch get operations. + use types.{bucket, error, key, incoming-value, outgoing-value}; + + /// Get the values associated with the keys in the bucket. It returns a list of + /// incoming-value that can be consumed to get the value associated with the key. + /// + /// If any of the keys do not exist in the bucket, it returns a `none` value for + /// that key in the list. + /// + /// Note that the key-value pairs are guaranteed to be returned in the same order + /// + /// MAY show an out-of-date value if there are concurrent writes to the bucket. + /// + /// If any other error occurs, it returns an `Err(error)`. + get-many: func(bucket: borrow, keys: list) -> result>, error>; + + /// Get all the keys in the bucket. It returns a list of keys. + /// + /// Note that the keys are not guaranteed to be returned in any particular order. + /// + /// If the bucket is empty, it returns an empty list. + /// + /// MAY show an out-of-date list of keys if there are concurrent writes to the bucket. + /// + /// If any error occurs, it returns an `Err(error)`. + keys: func(bucket: borrow) -> result, error>; + + /// Set the values associated with the keys in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// Note that the key-value pairs are not guaranteed to be set in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already set. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// set while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + set-many: func(bucket: borrow, key-values: list>>) -> result<_, error>; + + /// Delete the key-value pairs associated with the keys in the bucket. + /// + /// Note that the key-value pairs are not guaranteed to be deleted in the order + /// they are provided. + /// + /// If any of the keys do not exist in the bucket, it skips the key. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it + /// does not rollback the key-value pairs that were already deleted. Thus, this batch operation + /// does not guarantee atomicity, implying that some key-value pairs could be + /// deleted while others might fail. + /// + /// Other concurrent operations may also be able to see the partial results. + delete-many: func(bucket: borrow, keys: list) -> result<_, error>; +} \ No newline at end of file diff --git a/test-components/tinygo-wasi/wit/deps/keyvalue/eventual.wit b/test-components/tinygo-wasi/wit/deps/keyvalue/eventual.wit new file mode 100644 index 0000000000..e6e33cfe74 --- /dev/null +++ b/test-components/tinygo-wasi/wit/deps/keyvalue/eventual.wit @@ -0,0 +1,56 @@ +/// A keyvalue interface that provides eventually consistent CRUD operations. +/// +/// A CRUD operation is an operation that acts on a single key-value pair. +/// +/// The value in the key-value pair is defined as a `u8` byte array and the intention +/// is that it is the common denominator for all data types defined by different +/// key-value stores to handle data, ensuring compatibility between different +/// key-value stores. Note: the clients will be expecting serialization/deserialization overhead +/// to be handled by the key-value store. The value could be a serialized object from +/// JSON, HTML or vendor-specific data types like AWS S3 objects. +/// +/// Data consistency in a key value store refers to the gaurantee that once a +/// write operation completes, all subsequent read operations will return the +/// value that was written. +/// +/// The level of consistency in readwrite interfaces is **eventual consistency**, +/// which means that if a write operation completes successfully, all subsequent +/// read operations will eventually return the value that was written. In other words, +/// if we pause the updates to the system, the system eventually will return +/// the last updated value for read. +interface eventual { + /// A keyvalue interface that provides simple read and write operations. + use types.{bucket, error, incoming-value, key, outgoing-value}; + + /// Get the value associated with the key in the bucket. + /// + /// The value is returned as an option. If the key-value pair exists in the + /// bucket, it returns `Ok(value)`. If the key does not exist in the + /// bucket, it returns `Ok(none)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + get: func(bucket: borrow, key: key) -> result, error>; + + /// Set the value associated with the key in the bucket. If the key already + /// exists in the bucket, it overwrites the value. + /// + /// If the key does not exist in the bucket, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. + set: func(bucket: borrow, key: key, outgoing-value: borrow) -> result<_, error>; + + /// Delete the key-value pair associated with the key in the bucket. + /// + /// If the key does not exist in the bucket, it does nothing. + /// + /// If any other error occurs, it returns an `Err(error)`. + delete: func(bucket: borrow, key: key) -> result<_, error>; + + /// Check if the key exists in the bucket. + /// + /// If the key exists in the bucket, it returns `Ok(true)`. If the key does + /// not exist in the bucket, it returns `Ok(false)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + exists: func(bucket: borrow, key: key) -> result; +} \ No newline at end of file diff --git a/test-components/tinygo-wasi/wit/deps/wasm-rpc/wasm-rpc.wit b/test-components/tinygo-wasi/wit/deps/wasm-rpc/wasm-rpc.wit new file mode 100644 index 0000000000..8e31847bed --- /dev/null +++ b/test-components/tinygo-wasi/wit/deps/wasm-rpc/wasm-rpc.wit @@ -0,0 +1,56 @@ +package golem:rpc@0.1.0; + +interface types { + type node-index = s32; + + record wit-value { + nodes: list, + } + + variant wit-node { + record-value(list), + variant-value(tuple>), + enum-value(u32), + flags-value(list), + tuple-value(list), + list-value(list), + option-value(option), + result-value(result, option>), + prim-u8(u8), + prim-u16(u16), + prim-u32(u32), + prim-u64(u64), + prim-s8(s8), + prim-s16(s16), + prim-s32(s32), + prim-s64(s64), + prim-float32(float32), + prim-float64(float64), + prim-char(char), + prim-bool(bool), + prim-string(string), + handle(tuple) + } + + record uri { + value: string, + } + + variant rpc-error { + protocol-error(string), + denied(string), + not-found(string), + remote-internal-error(string) + } + + resource wasm-rpc { + constructor(location: uri); + + invoke-and-await: func(function-name: string, function-params: list) -> result; + invoke: func(function-name: string, function-params: list) -> result<_, rpc-error>; + } +} + +world wit-value { + import types; +} diff --git a/test-components/update-test-v1.wasm b/test-components/update-test-v1.wasm index d4269c2c86..63f736b051 100755 Binary files a/test-components/update-test-v1.wasm and b/test-components/update-test-v1.wasm differ diff --git a/test-components/update-test-v1/Cargo.lock b/test-components/update-test-v1/Cargo.lock index 013596ed92..d65702ea8d 100644 --- a/test-components/update-test-v1/Cargo.lock +++ b/test-components/update-test-v1/Cargo.lock @@ -72,7 +72,7 @@ name = "update-test-v1" version = "0.0.1" dependencies = [ "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -82,10 +82,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/update-test-v1/Cargo.toml b/test-components/update-test-v1/Cargo.toml index a786779639..11e3a89f1e 100644 --- a/test-components/update-test-v1/Cargo.toml +++ b/test-components/update-test-v1/Cargo.toml @@ -14,7 +14,7 @@ strip = true [dependencies] rand = "0.8.5" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/update-test-v1/src/bindings.rs b/test-components/update-test-v1/src/bindings.rs index 1c56a3a2fe..2f7775b57f 100644 --- a/test-components/update-test-v1/src/bindings.rs +++ b/test-components/update-test-v1/src/bindings.rs @@ -1,114 +1,150 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod component { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f1"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f1(arg0: i64,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f1(arg0 as u64); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f2"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f2() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f2(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f3"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f3() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f3(); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn f1(speed_ms: u64,) -> u64; - fn f2() -> u64; - fn f3() -> u64; - } - + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod component { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f1_cabi(arg0: i64) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f1(arg0 as u64); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f2_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f2(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f3_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f3(); + _rt::as_i64(result0) + } + pub trait Guest { + fn f1(speed_ms: u64) -> u64; + fn f2() -> u64; + fn f3() -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_component_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:component/api#f1"] + unsafe extern "C" fn export_f1(arg0: i64,) -> i64 { + $($path_to_types)*::_export_f1_cabi::<$ty>(arg0) } - - } + #[export_name = "golem:component/api#f2"] + unsafe extern "C" fn export_f2() -> i64 { + $($path_to_types)*::_export_f2_cabi::<$ty>() + } + #[export_name = "golem:component/api#f3"] + unsafe extern "C" fn export_f3() -> i64 { + $($path_to_types)*::_export_f3_cabi::<$ty>() + } + };); } + #[doc(hidden)] + pub(crate) use __export_golem_component_api_cabi; + } + } + } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_update_test_v1_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::component::api::__export_golem_component_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::component::api); + ) +} +#[doc(inline)] +pub(crate) use __export_update_test_v1_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:update-test-v1"] +#[link_section = "component-type:wit-bindgen:0.25.0:update-test-v1:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 332] = [3, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 49, 0, 97, 115, 109, 13, 0, 1, 0, 7, 71, 1, 65, 2, 1, 66, 5, 1, 64, 1, 8, 115, 112, 101, 101, 100, 45, 109, 115, 119, 0, 119, 4, 0, 2, 102, 49, 1, 0, 1, 64, 0, 0, 119, 4, 0, 2, 102, 50, 1, 1, 4, 0, 2, 102, 51, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 109, 1, 65, 2, 1, 65, 2, 1, 66, 5, 1, 64, 1, 8, 115, 112, 101, 101, 100, 45, 109, 115, 119, 0, 119, 4, 0, 2, 102, 49, 1, 0, 1, 64, 0, 0, 119, 4, 0, 2, 102, 50, 1, 1, 4, 0, 2, 102, 51, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 4, 1, 30, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 49, 4, 0, 11, 20, 1, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 49, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 241] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07m\x01A\x02\x01A\x02\x01\ +B\x05\x01@\x01\x08speed-msw\0w\x04\0\x02f1\x01\0\x01@\0\0w\x04\0\x02f2\x01\x01\x04\ +\0\x02f3\x01\x01\x04\x01\x13golem:component/api\x05\0\x04\x01\x1egolem:component\ +/update-test-v1\x04\0\x0b\x14\x01\0\x0eupdate-test-v1\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/update-test-v1/src/lib.rs b/test-components/update-test-v1/src/lib.rs index e34cbd96e7..71d5c4721d 100644 --- a/test-components/update-test-v1/src/lib.rs +++ b/test-components/update-test-v1/src/lib.rs @@ -43,3 +43,5 @@ impl Guest for Component { std::env::vars().collect::>().len() as u64 } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/update-test-v2.wasm b/test-components/update-test-v2.wasm index 84fa6b1655..c1fb7c813f 100755 Binary files a/test-components/update-test-v2.wasm and b/test-components/update-test-v2.wasm differ diff --git a/test-components/update-test-v2/Cargo.lock b/test-components/update-test-v2/Cargo.lock index db52851edf..3444ca6c45 100644 --- a/test-components/update-test-v2/Cargo.lock +++ b/test-components/update-test-v2/Cargo.lock @@ -19,14 +19,14 @@ name = "update-test-v2" version = "0.0.1" dependencies = [ "bytes", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/update-test-v2/Cargo.toml b/test-components/update-test-v2/Cargo.toml index 2fdffeb40c..accd0e0612 100644 --- a/test-components/update-test-v2/Cargo.toml +++ b/test-components/update-test-v2/Cargo.toml @@ -14,7 +14,7 @@ strip = true [dependencies] bytes = "1.6.0" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/update-test-v2/src/bindings.rs b/test-components/update-test-v2/src/bindings.rs index 7bbbadbf2f..498a8eadd0 100644 --- a/test-components/update-test-v2/src/bindings.rs +++ b/test-components/update-test-v2/src/bindings.rs @@ -1,213 +1,236 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod save_snapshot { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod save_snapshot { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_save_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::save(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_save(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 1, 1); + } + pub trait Guest { + /// Saves the component's state into a user-defined snapshot + fn save() -> _rt::Vec; + } + #[doc(hidden)] + + macro_rules! __export_golem_api_save_snapshot_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "golem:api/save-snapshot@0.2.0#save"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_save() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::save(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 + unsafe extern "C" fn export_save() -> *mut u8 { + $($path_to_types)*::_export_save_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:api/save-snapshot@0.2.0#save"] + unsafe extern "C" fn _post_return_save(arg0: *mut u8,) { + $($path_to_types)*::__post_return_save::<$ty>(arg0) } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:api/save-snapshot@0.2.0#save"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_save(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - let base2 = l0; - let len2 = l1; - wit_bindgen::rt::dealloc(base2, (len2 as usize) * 1, 1); + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_api_save_snapshot_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - /// Saves the component's state into a user-defined snapshot - fn save() -> wit_bindgen::rt::vec::Vec::; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - + #[allow(dead_code)] + pub mod component { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f1_cabi(arg0: i64) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f1(arg0 as u64); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f2_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f2(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f3_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f3(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_f4_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::f4(); + _rt::as_i64(result0) + } + pub trait Guest { + fn f1(speed_ms: u64) -> u64; + fn f2() -> u64; + fn f3() -> u64; + fn f4() -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_component_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:component/api#f1"] + unsafe extern "C" fn export_f1(arg0: i64,) -> i64 { + $($path_to_types)*::_export_f1_cabi::<$ty>(arg0) } - pub mod component { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f1"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f1(arg0: i64,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f1(arg0 as u64); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f2"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f2() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f2(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f3"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f3() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f3(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#f4"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_f4() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::f4(); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn f1(speed_ms: u64,) -> u64; - fn f2() -> u64; - fn f3() -> u64; - fn f4() -> u64; + #[export_name = "golem:component/api#f2"] + unsafe extern "C" fn export_f2() -> i64 { + $($path_to_types)*::_export_f2_cabi::<$ty>() + } + #[export_name = "golem:component/api#f3"] + unsafe extern "C" fn export_f3() -> i64 { + $($path_to_types)*::_export_f3_cabi::<$ty>() + } + #[export_name = "golem:component/api#f4"] + unsafe extern "C" fn export_f4() -> i64 { + $($path_to_types)*::_export_f4_cabi::<$ty>() + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_component_api_cabi; + } } - - } - } - } +} +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::alloc; + pub use alloc_crate::vec::Vec; + extern crate alloc as alloc_crate; } +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_update_test_v2_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::component::api::__export_golem_component_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::component::api); + $($path_to_types_root)*::exports::golem::api::save_snapshot::__export_golem_api_save_snapshot_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::api::save_snapshot); + ) +} +#[doc(inline)] +pub(crate) use __export_update_test_v2_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:update-test-v2"] +#[link_section = "component-type:wit-bindgen:0.25.0:update-test-v2:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 550] = [3, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 50, 0, 97, 115, 109, 13, 0, 1, 0, 7, 78, 1, 65, 2, 1, 66, 6, 1, 64, 1, 8, 115, 112, 101, 101, 100, 45, 109, 115, 119, 0, 119, 4, 0, 2, 102, 49, 1, 0, 1, 64, 0, 0, 119, 4, 0, 2, 102, 50, 1, 1, 4, 0, 2, 102, 51, 1, 1, 4, 0, 2, 102, 52, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 170, 1, 1, 65, 2, 1, 65, 4, 1, 66, 6, 1, 64, 1, 8, 115, 112, 101, 101, 100, 45, 109, 115, 119, 0, 119, 4, 0, 2, 102, 49, 1, 0, 1, 64, 0, 0, 119, 4, 0, 2, 102, 50, 1, 1, 4, 0, 2, 102, 51, 1, 1, 4, 0, 2, 102, 52, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 1, 66, 3, 1, 112, 125, 1, 64, 0, 0, 0, 4, 0, 4, 115, 97, 118, 101, 1, 1, 4, 1, 29, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 115, 97, 118, 101, 45, 115, 110, 97, 112, 115, 104, 111, 116, 64, 48, 46, 50, 46, 48, 5, 1, 4, 1, 30, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 50, 4, 0, 11, 20, 1, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 50, 3, 2, 0, 0, 164, 1, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 105, 110, 116, 101, 114, 102, 97, 99, 101, 115, 34, 58, 123, 34, 97, 112, 105, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 83, 101, 101, 32, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 87, 101, 98, 65, 115, 115, 101, 109, 98, 108, 121, 47, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 109, 111, 100, 101, 108, 47, 98, 108, 111, 98, 47, 109, 97, 105, 110, 47, 100, 101, 115, 105, 103, 110, 47, 109, 118, 112, 47, 87, 73, 84, 46, 109, 100, 32, 102, 111, 114, 32, 109, 111, 114, 101, 32, 100, 101, 116, 97, 105, 108, 115, 32, 97, 98, 111, 117, 116, 32, 116, 104, 101, 32, 87, 73, 84, 32, 115, 121, 110, 116, 97, 120, 34, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 303] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xaa\x01\x01A\x02\x01\ +A\x04\x01B\x06\x01@\x01\x08speed-msw\0w\x04\0\x02f1\x01\0\x01@\0\0w\x04\0\x02f2\x01\ +\x01\x04\0\x02f3\x01\x01\x04\0\x02f4\x01\x01\x04\x01\x13golem:component/api\x05\0\ +\x01B\x03\x01p}\x01@\0\0\0\x04\0\x04save\x01\x01\x04\x01\x1dgolem:api/save-snaps\ +hot@0.2.0\x05\x01\x04\x01\x1egolem:component/update-test-v2\x04\0\x0b\x14\x01\0\x0e\ +update-test-v2\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x07\ +0.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/update-test-v2/src/lib.rs b/test-components/update-test-v2/src/lib.rs index d60bdfe2e8..4933b10eeb 100644 --- a/test-components/update-test-v2/src/lib.rs +++ b/test-components/update-test-v2/src/lib.rs @@ -60,4 +60,6 @@ impl save_snapshot::Guest for Component { result.put_u64(Component::f2()); result } -} \ No newline at end of file +} + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/update-test-v3.wasm b/test-components/update-test-v3.wasm index 14e51f270c..8dd4133747 100755 Binary files a/test-components/update-test-v3.wasm and b/test-components/update-test-v3.wasm differ diff --git a/test-components/update-test-v3/Cargo.lock b/test-components/update-test-v3/Cargo.lock index 554878efed..7f4aef4f91 100644 --- a/test-components/update-test-v3/Cargo.lock +++ b/test-components/update-test-v3/Cargo.lock @@ -19,14 +19,14 @@ name = "update-test-v3" version = "0.0.1" dependencies = [ "bytes", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/update-test-v3/Cargo.toml b/test-components/update-test-v3/Cargo.toml index 3067d64a6e..17b04de77d 100644 --- a/test-components/update-test-v3/Cargo.toml +++ b/test-components/update-test-v3/Cargo.toml @@ -14,7 +14,7 @@ strip = true [dependencies] bytes = "1.6.0" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/update-test-v3/src/bindings.rs b/test-components/update-test-v3/src/bindings.rs index 0b5e9c7b13..442fa813eb 100644 --- a/test-components/update-test-v3/src/bindings.rs +++ b/test-components/update-test-v3/src/bindings.rs @@ -1,239 +1,285 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod save_snapshot { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod save_snapshot { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_save_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::save(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_save(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 1, 1); + } + pub trait Guest { + /// Saves the component's state into a user-defined snapshot + fn save() -> _rt::Vec; + } + #[doc(hidden)] + + macro_rules! __export_golem_api_save_snapshot_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "golem:api/save-snapshot@0.2.0#save"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_save() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::save(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - let vec2 = (result0).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 4) as *mut i32) = len2; - *((ptr1 + 0) as *mut i32) = ptr2; - ptr1 + unsafe extern "C" fn export_save() -> *mut u8 { + $($path_to_types)*::_export_save_cabi::<$ty>() + } + #[export_name = "cabi_post_golem:api/save-snapshot@0.2.0#save"] + unsafe extern "C" fn _post_return_save(arg0: *mut u8,) { + $($path_to_types)*::__post_return_save::<$ty>(arg0) } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:api/save-snapshot@0.2.0#save"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_save(arg0: i32,) { - let l0 = *((arg0 + 0) as *const i32); - let l1 = *((arg0 + 4) as *const i32); - let base2 = l0; - let len2 = l1; - wit_bindgen::rt::dealloc(base2, (len2 as usize) * 1, 1); + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_api_save_snapshot_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - /// Saves the component's state into a user-defined snapshot - fn save() -> wit_bindgen::rt::vec::Vec::; + + #[allow(dead_code, clippy::all)] + pub mod load_snapshot { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_load_cabi(arg0: *mut u8, arg1: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let result1 = T::load(_rt::Vec::from_raw_parts(arg0.cast(), len0, len0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_load(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + fn load(bytes: _rt::Vec) -> Result<(), _rt::String>; + } + #[doc(hidden)] + + macro_rules! __export_golem_api_load_snapshot_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:api/load-snapshot@0.2.0#load"] + unsafe extern "C" fn export_load(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_load_cabi::<$ty>(arg0, arg1) } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 8]); - static mut _RET_AREA: _RetArea = _RetArea([0; 8]); - - } - - - #[allow(clippy::all)] - pub mod load_snapshot { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:api/load-snapshot@0.2.0#load"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_load(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let result1 = <_GuestImpl as Guest>::load(Vec::from_raw_parts(arg0 as *mut _, len0, len0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:api/load-snapshot@0.2.0#load"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_load(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + #[export_name = "cabi_post_golem:api/load-snapshot@0.2.0#load"] + unsafe extern "C" fn _post_return_load(arg0: *mut u8,) { + $($path_to_types)*::__post_return_load::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_api_load_snapshot_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - /// Tries to load a user-defined snapshot, setting up the worker's state based on it. - /// The function can return with a failure to indicate that the update is not possible. - fn load(bytes: wit_bindgen::rt::vec::Vec::,) -> Result<(),wit_bindgen::rt::string::String>; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - + #[allow(dead_code)] + pub mod component { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_cabi() -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::get(); + _rt::as_i64(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_set_cabi(arg0: i64) -> i64 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::set(arg0 as u64); + _rt::as_i64(result0) + } + pub trait Guest { + fn get() -> u64; + fn set(value: u64) -> u64; + } + #[doc(hidden)] + + macro_rules! __export_golem_component_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:component/api#get"] + unsafe extern "C" fn export_get() -> i64 { + $($path_to_types)*::_export_get_cabi::<$ty>() } - pub mod component { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get() -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::get(); - wit_bindgen::rt::as_i64(result0) - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:component/api#set"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_set(arg0: i64,) -> i64 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::set(arg0 as u64); - wit_bindgen::rt::as_i64(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn get() -> u64; - fn set(value: u64,) -> u64; + #[export_name = "golem:component/api#set"] + unsafe extern "C" fn export_set(arg0: i64,) -> i64 { + $($path_to_types)*::_export_set_cabi::<$ty>(arg0) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_golem_component_api_cabi; + } } - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + pub use alloc_crate::alloc; + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_update_test_v3_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::api::save_snapshot::__export_golem_api_save_snapshot_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::api::save_snapshot); + $($path_to_types_root)*::exports::golem::api::load_snapshot::__export_golem_api_load_snapshot_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::api::load_snapshot); + $($path_to_types_root)*::exports::golem::component::api::__export_golem_component_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::component::api); + ) +} +#[doc(inline)] +pub(crate) use __export_update_test_v3_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:update-test-v3"] +#[link_section = "component-type:wit-bindgen:0.25.0:update-test-v3:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 437] = [3, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 51, 0, 97, 115, 109, 13, 0, 1, 0, 7, 63, 1, 65, 2, 1, 66, 4, 1, 64, 0, 0, 119, 4, 0, 3, 103, 101, 116, 1, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 0, 119, 4, 0, 3, 115, 101, 116, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 221, 1, 1, 65, 2, 1, 65, 6, 1, 66, 3, 1, 112, 125, 1, 64, 0, 0, 0, 4, 0, 4, 115, 97, 118, 101, 1, 1, 4, 1, 29, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 115, 97, 118, 101, 45, 115, 110, 97, 112, 115, 104, 111, 116, 64, 48, 46, 50, 46, 48, 5, 0, 1, 66, 4, 1, 112, 125, 1, 106, 0, 1, 115, 1, 64, 1, 5, 98, 121, 116, 101, 115, 0, 0, 1, 4, 0, 4, 108, 111, 97, 100, 1, 2, 4, 1, 29, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 108, 111, 97, 100, 45, 115, 110, 97, 112, 115, 104, 111, 116, 64, 48, 46, 50, 46, 48, 5, 1, 1, 66, 4, 1, 64, 0, 0, 119, 4, 0, 3, 103, 101, 116, 1, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 119, 0, 119, 4, 0, 3, 115, 101, 116, 1, 1, 4, 1, 19, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 97, 112, 105, 5, 2, 4, 1, 30, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 51, 4, 0, 11, 20, 1, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 51, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 354] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdd\x01\x01A\x02\x01\ +A\x06\x01B\x03\x01p}\x01@\0\0\0\x04\0\x04save\x01\x01\x04\x01\x1dgolem:api/save-\ +snapshot@0.2.0\x05\0\x01B\x04\x01p}\x01j\0\x01s\x01@\x01\x05bytes\0\0\x01\x04\0\x04\ +load\x01\x02\x04\x01\x1dgolem:api/load-snapshot@0.2.0\x05\x01\x01B\x04\x01@\0\0w\ +\x04\0\x03get\x01\0\x01@\x01\x05valuew\0w\x04\0\x03set\x01\x01\x04\x01\x13golem:\ +component/api\x05\x02\x04\x01\x1egolem:component/update-test-v3\x04\0\x0b\x14\x01\ +\0\x0eupdate-test-v3\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-comp\ +onent\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/update-test-v3/src/lib.rs b/test-components/update-test-v3/src/lib.rs index f49991c8fb..f0ace91370 100644 --- a/test-components/update-test-v3/src/lib.rs +++ b/test-components/update-test-v3/src/lib.rs @@ -45,4 +45,6 @@ impl load_snapshot::Guest for Component { Err("Invalid snapshot - not enough bytes to read u64".to_string()) } } -} \ No newline at end of file +} + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/update-test-v4.wasm b/test-components/update-test-v4.wasm index 378767b9b6..0755cb8cb1 100755 Binary files a/test-components/update-test-v4.wasm and b/test-components/update-test-v4.wasm differ diff --git a/test-components/update-test-v4/Cargo.lock b/test-components/update-test-v4/Cargo.lock index db7a3d6131..5888b14920 100644 --- a/test-components/update-test-v4/Cargo.lock +++ b/test-components/update-test-v4/Cargo.lock @@ -12,14 +12,14 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" name = "update-test-v4" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/update-test-v4/Cargo.toml b/test-components/update-test-v4/Cargo.toml index 03f29599a6..7829d432d0 100644 --- a/test-components/update-test-v4/Cargo.toml +++ b/test-components/update-test-v4/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/update-test-v4/src/bindings.rs b/test-components/update-test-v4/src/bindings.rs index 3e0e95e5e7..88e9af63e5 100644 --- a/test-components/update-test-v4/src/bindings.rs +++ b/test-components/update-test-v4/src/bindings.rs @@ -1,99 +1,145 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod api { - - #[allow(clippy::all)] - pub mod load_snapshot { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod api { + #[allow(dead_code, clippy::all)] + pub mod load_snapshot { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_load_cabi(arg0: *mut u8, arg1: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let result1 = T::load(_rt::Vec::from_raw_parts(arg0.cast(), len0, len0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(_) => { + *ptr2.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_load(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + fn load(bytes: _rt::Vec) -> Result<(), _rt::String>; + } + #[doc(hidden)] + + macro_rules! __export_golem_api_load_snapshot_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + #[export_name = "golem:api/load-snapshot@0.2.0#load"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_load(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let len0 = arg1 as usize; - let result1 = <_GuestImpl as Guest>::load(Vec::from_raw_parts(arg0 as *mut _, len0, len0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - match result1 { - Ok(_) => { { - *((ptr2 + 0) as *mut u8) = (0i32) as u8; - } }, - Err(e) => { { - *((ptr2 + 0) as *mut u8) = (1i32) as u8; - let vec3 = (e.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - ::core::mem::forget(vec3); - *((ptr2 + 8) as *mut i32) = len3; - *((ptr2 + 4) as *mut i32) = ptr3; - } }, - };ptr2 + unsafe extern "C" fn export_load(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_load_cabi::<$ty>(arg0, arg1) } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:api/load-snapshot@0.2.0#load"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_load(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + #[export_name = "cabi_post_golem:api/load-snapshot@0.2.0#load"] + unsafe extern "C" fn _post_return_load(arg0: *mut u8,) { + $($path_to_types)*::__post_return_load::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_api_load_snapshot_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - /// Tries to load a user-defined snapshot, setting up the worker's state based on it. - /// The function can return with a failure to indicate that the update is not possible. - fn load(bytes: wit_bindgen::rt::vec::Vec::,) -> Result<(),wit_bindgen::rt::string::String>; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub use alloc_crate::vec::Vec; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub use alloc_crate::string::String; + extern crate alloc as alloc_crate; + pub use alloc_crate::alloc; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_update_test_v4_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::api::load_snapshot::__export_golem_api_load_snapshot_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::api::load_snapshot); + ) +} +#[doc(inline)] +pub(crate) use __export_update_test_v4_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:update-test-v4"] +#[link_section = "component-type:wit-bindgen:0.25.0:update-test-v4:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 246] = [3, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 52, 0, 97, 115, 109, 13, 0, 1, 0, 7, 107, 1, 65, 2, 1, 65, 2, 1, 66, 4, 1, 112, 125, 1, 106, 0, 1, 115, 1, 64, 1, 5, 98, 121, 116, 101, 115, 0, 0, 1, 4, 0, 4, 108, 111, 97, 100, 1, 2, 4, 1, 29, 103, 111, 108, 101, 109, 58, 97, 112, 105, 47, 108, 111, 97, 100, 45, 115, 110, 97, 112, 115, 104, 111, 116, 64, 48, 46, 50, 46, 48, 5, 0, 4, 1, 30, 103, 111, 108, 101, 109, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 52, 4, 0, 11, 20, 1, 0, 14, 117, 112, 100, 97, 116, 101, 45, 116, 101, 115, 116, 45, 118, 52, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 239] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07k\x01A\x02\x01A\x02\x01\ +B\x04\x01p}\x01j\0\x01s\x01@\x01\x05bytes\0\0\x01\x04\0\x04load\x01\x02\x04\x01\x1d\ +golem:api/load-snapshot@0.2.0\x05\0\x04\x01\x1egolem:component/update-test-v4\x04\ +\0\x0b\x14\x01\0\x0eupdate-test-v4\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/update-test-v4/src/lib.rs b/test-components/update-test-v4/src/lib.rs index 5cf6e6c4b8..b95f94b7ff 100644 --- a/test-components/update-test-v4/src/lib.rs +++ b/test-components/update-test-v4/src/lib.rs @@ -8,4 +8,6 @@ impl load_snapshot::Guest for Component { fn load(_bytes: Vec) -> Result<(), String> { Err("Invalid snapshot - simulating failure".to_string()) } -} \ No newline at end of file +} + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/variant-service.wasm b/test-components/variant-service.wasm index 6367d5fc37..6182ebae39 100755 Binary files a/test-components/variant-service.wasm and b/test-components/variant-service.wasm differ diff --git a/test-components/variant-service/Cargo.lock b/test-components/variant-service/Cargo.lock index 836ce95889..e706e03ad1 100644 --- a/test-components/variant-service/Cargo.lock +++ b/test-components/variant-service/Cargo.lock @@ -79,7 +79,7 @@ version = "0.0.1" dependencies = [ "once_cell", "rand", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wit-bindgen" -version = "0.16.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b76f1d099678b4f69402a421e888bbe71bf20320c2f3f3565d0e7484dbe5bc20" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/variant-service/cargo.toml b/test-components/variant-service/cargo.toml index 90b721a702..756d970071 100644 --- a/test-components/variant-service/cargo.toml +++ b/test-components/variant-service/cargo.toml @@ -15,7 +15,7 @@ strip = true [dependencies] once_cell = "1.17.1" rand = "0.8.5" -wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/variant-service/src/bindings.rs b/test-components/variant-service/src/bindings.rs index 77f3630aa6..9e9128e7b9 100644 --- a/test-components/variant-service/src/bindings.rs +++ b/test-components/variant-service/src/bindings.rs @@ -1,116 +1,156 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] pub mod exports { - pub mod golem { - pub mod it { - - #[allow(clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - #[derive(Clone)] - pub enum BidResult{ - Success, - Failure(wit_bindgen::rt::string::String), - } - impl ::core::fmt::Debug for BidResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - BidResult::Success => { - f.debug_tuple("BidResult::Success").finish() - } - BidResult::Failure(e) => { - f.debug_tuple("BidResult::Failure").field(e).finish() - } - } - } - } - const _: () = { - - #[doc(hidden)] - #[export_name = "golem:it/api#bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_bid() -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::bid(); - let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; - match result0 { - BidResult::Success=> { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; + #[allow(dead_code)] + pub mod golem { + #[allow(dead_code)] + pub mod it { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[derive(Clone)] + pub enum BidResult { + Success, + Failure(_rt::String), } - } - BidResult::Failure(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let vec2 = (e.into_bytes()).into_boxed_slice(); - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - ::core::mem::forget(vec2); - *((ptr1 + 8) as *mut i32) = len2; - *((ptr1 + 4) as *mut i32) = ptr2; - }, - } - ptr1 + impl ::core::fmt::Debug for BidResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + BidResult::Success => f.debug_tuple("BidResult::Success").finish(), + BidResult::Failure(e) => { + f.debug_tuple("BidResult::Failure").field(e).finish() + } + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_bid_cabi() -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::bid(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + BidResult::Success => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + BidResult::Failure(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(8).cast::() = len2; + *ptr1.add(4).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_bid(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + pub trait Guest { + fn bid() -> BidResult; + } + #[doc(hidden)] + + macro_rules! __export_golem_it_api_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "golem:it/api#bid"] + unsafe extern "C" fn export_bid() -> *mut u8 { + $($path_to_types)*::_export_bid_cabi::<$ty>() } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_golem:it/api#bid"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_bid(arg0: i32,) { - let l0 = i32::from(*((arg0 + 0) as *const u8)); - match l0 { - 0 => (), - _ => { - let l1 = *((arg0 + 4) as *const i32); - let l2 = *((arg0 + 8) as *const i32); - wit_bindgen::rt::dealloc(l1, (l2) as usize, 1); - }, - } + #[export_name = "cabi_post_golem:it/api#bid"] + unsafe extern "C" fn _post_return_bid(arg0: *mut u8,) { + $($path_to_types)*::__post_return_bid::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_golem_it_api_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - }; - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn bid() -> BidResult; } - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - #[repr(align(4))] - struct _RetArea([u8; 12]); - static mut _RET_AREA: _RetArea = _RetArea([0; 12]); - - } - } - } } +mod _rt { + pub use alloc_crate::string::String; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + extern crate alloc as alloc_crate; + pub use alloc_crate::alloc; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_variant_service_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::golem::it::api::__export_golem_it_api_cabi!($ty with_types_in $($path_to_types_root)*::exports::golem::it::api); + ) +} +#[doc(inline)] +pub(crate) use __export_variant_service_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:variant-service"] +#[link_section = "component-type:wit-bindgen:0.25.0:variant-service:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 338] = [3, 0, 15, 118, 97, 114, 105, 97, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 76, 1, 65, 2, 1, 66, 4, 1, 113, 2, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 7, 102, 97, 105, 108, 117, 114, 101, 1, 115, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 0, 1, 64, 0, 0, 1, 4, 0, 3, 98, 105, 100, 1, 2, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 11, 9, 1, 0, 3, 97, 112, 105, 3, 0, 0, 7, 108, 1, 65, 2, 1, 65, 2, 1, 66, 4, 1, 113, 2, 7, 115, 117, 99, 99, 101, 115, 115, 0, 0, 7, 102, 97, 105, 108, 117, 114, 101, 1, 115, 0, 4, 0, 10, 98, 105, 100, 45, 114, 101, 115, 117, 108, 116, 3, 0, 0, 1, 64, 0, 0, 1, 4, 0, 3, 98, 105, 100, 1, 2, 4, 1, 12, 103, 111, 108, 101, 109, 58, 105, 116, 47, 97, 112, 105, 5, 0, 4, 1, 24, 103, 111, 108, 101, 109, 58, 105, 116, 47, 118, 97, 114, 105, 97, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 4, 0, 11, 21, 1, 0, 15, 118, 97, 114, 105, 97, 110, 116, 45, 115, 101, 114, 118, 105, 99, 101, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 241] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07l\x01A\x02\x01A\x02\x01\ +B\x04\x01q\x02\x07success\0\0\x07failure\x01s\0\x04\0\x0abid-result\x03\0\0\x01@\ +\0\0\x01\x04\0\x03bid\x01\x02\x04\x01\x0cgolem:it/api\x05\0\x04\x01\x18golem:it/\ +variant-service\x04\0\x0b\x15\x01\0\x0fvariant-service\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/variant-service/src/lib.rs b/test-components/variant-service/src/lib.rs index 8d79a0bb41..a3ee448cf5 100644 --- a/test-components/variant-service/src/lib.rs +++ b/test-components/variant-service/src/lib.rs @@ -9,3 +9,5 @@ impl Guest for Component { BidResult::Success } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/write-stderr.wasm b/test-components/write-stderr.wasm index cdb17f92de..b0c6bb3eda 100755 Binary files a/test-components/write-stderr.wasm and b/test-components/write-stderr.wasm differ diff --git a/test-components/write-stderr/Cargo.lock b/test-components/write-stderr/Cargo.lock index c2cf31647a..1a7e1ad6c2 100644 --- a/test-components/write-stderr/Cargo.lock +++ b/test-components/write-stderr/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-write-stderr" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/write-stderr/Cargo.toml b/test-components/write-stderr/Cargo.toml index 663804d6e2..1f257bcaad 100644 --- a/test-components/write-stderr/Cargo.toml +++ b/test-components/write-stderr/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/write-stderr/src/bindings.rs b/test-components/write-stderr/src/bindings.rs index b09a4d0a72..b38c0a6d77 100644 --- a/test-components/write-stderr/src/bindings.rs +++ b/test-components/write-stderr/src/bindings.rs @@ -1,41 +1,76 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::run(); - } -}; -use super::Component as _GuestImpl; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::run(); +} pub trait Guest { - fn run(); + fn run(); +} +#[doc(hidden)] + +macro_rules! __export_world_write_stderr_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "run"] + unsafe extern "C" fn export_run() { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_write_stderr_cabi; +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } } +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_write_stderr_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_write_stderr_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_write_stderr_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:write-stderr"] +#[link_section = "component-type:wit-bindgen:0.25.0:write-stderr:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 180] = [3, 0, 12, 119, 114, 105, 116, 101, 45, 115, 116, 100, 101, 114, 114, 0, 97, 115, 109, 13, 0, 1, 0, 7, 45, 1, 65, 2, 1, 65, 2, 1, 64, 0, 1, 0, 4, 0, 3, 114, 117, 110, 1, 0, 4, 1, 21, 103, 111, 108, 101, 109, 58, 105, 116, 47, 119, 114, 105, 116, 101, 45, 115, 116, 100, 101, 114, 114, 4, 0, 11, 18, 1, 0, 12, 119, 114, 105, 116, 101, 45, 115, 116, 100, 101, 114, 114, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 175] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07-\x01A\x02\x01A\x02\x01\ +@\0\x01\0\x04\0\x03run\x01\0\x04\x01\x15golem:it/write-stderr\x04\0\x0b\x12\x01\0\ +\x0cwrite-stderr\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-componen\ +t\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/write-stderr/src/lib.rs b/test-components/write-stderr/src/lib.rs index d2bea02908..90a7221c68 100644 --- a/test-components/write-stderr/src/lib.rs +++ b/test-components/write-stderr/src/lib.rs @@ -9,3 +9,5 @@ impl Guest for Component { eprintln!("Sample text written to the error output"); } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/write-stdout.wasm b/test-components/write-stdout.wasm index 5e3eaa1970..018ffaaa97 100644 Binary files a/test-components/write-stdout.wasm and b/test-components/write-stdout.wasm differ diff --git a/test-components/write-stdout/Cargo.lock b/test-components/write-stdout/Cargo.lock index c9c1ec83e6..bd701fc023 100644 --- a/test-components/write-stdout/Cargo.lock +++ b/test-components/write-stdout/Cargo.lock @@ -12,14 +12,14 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" name = "golem-it-write-stdout" version = "0.0.1" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" dependencies = [ "bitflags", ] diff --git a/test-components/write-stdout/Cargo.toml b/test-components/write-stdout/Cargo.toml index a482fe6475..1dcd101135 100644 --- a/test-components/write-stdout/Cargo.toml +++ b/test-components/write-stdout/Cargo.toml @@ -13,7 +13,7 @@ opt-level = 's' strip = true [dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [package.metadata.component.target] path = "wit" diff --git a/test-components/write-stdout/src/bindings.rs b/test-components/write-stdout/src/bindings.rs index 26624f4d5e..1acec90216 100644 --- a/test-components/write-stdout/src/bindings.rs +++ b/test-components/write-stdout/src/bindings.rs @@ -1,41 +1,76 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "run"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_run() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::run(); - } -}; -use super::Component as _GuestImpl; +// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! +// Options used: +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn _export_run_cabi() { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::run(); +} pub trait Guest { - fn run(); + fn run(); +} +#[doc(hidden)] + +macro_rules! __export_world_write_stdout_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "run"] + unsafe extern "C" fn export_run() { + $($path_to_types)*::_export_run_cabi::<$ty>() + } + };); +} +#[doc(hidden)] +pub(crate) use __export_world_write_stdout_cabi; +mod _rt { + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen_rt::run_ctors_once(); + } } +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_write_stdout_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::__export_world_write_stdout_cabi!($ty with_types_in $($path_to_types_root)*); + ) +} +#[doc(inline)] +pub(crate) use __export_write_stdout_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:write-stdout"] +#[link_section = "component-type:wit-bindgen:0.25.0:write-stdout:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 180] = [3, 0, 12, 119, 114, 105, 116, 101, 45, 115, 116, 100, 111, 117, 116, 0, 97, 115, 109, 13, 0, 1, 0, 7, 45, 1, 65, 2, 1, 65, 2, 1, 64, 0, 1, 0, 4, 0, 3, 114, 117, 110, 1, 0, 4, 1, 21, 103, 111, 108, 101, 109, 58, 105, 116, 47, 119, 114, 105, 116, 101, 45, 115, 116, 100, 111, 117, 116, 4, 0, 11, 18, 1, 0, 12, 119, 114, 105, 116, 101, 45, 115, 116, 100, 111, 117, 116, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 175] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07-\x01A\x02\x01A\x02\x01\ +@\0\x01\0\x04\0\x03run\x01\0\x04\x01\x15golem:it/write-stdout\x04\0\x0b\x12\x01\0\ +\x0cwrite-stdout\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-componen\ +t\x070.208.1\x10wit-bindgen-rust\x060.25.0"; #[inline(never)] #[doc(hidden)] #[cfg(target_arch = "wasm32")] -pub fn __link_section() {} +pub fn __link_custom_section_describing_imports() { + wit_bindgen_rt::maybe_link_cabi_realloc(); +} diff --git a/test-components/write-stdout/src/lib.rs b/test-components/write-stdout/src/lib.rs index 0b46c27f60..bb246a72eb 100644 --- a/test-components/write-stdout/src/lib.rs +++ b/test-components/write-stdout/src/lib.rs @@ -9,3 +9,5 @@ impl Guest for Component { println!("Sample text written to the output"); } } + +bindings::export!(Component with_types_in bindings); diff --git a/test-components/zig-1.wasm b/test-components/zig-1.wasm index 56a22eec49..c3659cb463 100644 Binary files a/test-components/zig-1.wasm and b/test-components/zig-1.wasm differ diff --git a/test-components/zig-1/src/bindings/zig1.c b/test-components/zig-1/src/bindings/zig1.c index 04725e190f..0ff52f8821 100644 --- a/test-components/zig-1/src/bindings/zig1.c +++ b/test-components/zig-1/src/bindings/zig1.c @@ -1,6 +1,11 @@ -// Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! #include "zig1.h" +#include +// Exported Functions from `zig1` + + +// Canonical ABI intrinsics __attribute__((__weak__, __export_name__("cabi_realloc"))) void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { @@ -18,6 +23,8 @@ void __wasm_export_zig1_run(void) { zig1_run(); } +// Ensure that the *_component_type.o object is linked in + extern void __component_type_object_force_link_zig1(void); void __component_type_object_force_link_zig1_public_use_in_this_compilation_unit(void) { __component_type_object_force_link_zig1(); diff --git a/test-components/zig-1/src/bindings/zig1.h b/test-components/zig-1/src/bindings/zig1.h index 5492c1c9f9..dbc75fcdf9 100644 --- a/test-components/zig-1/src/bindings/zig1.h +++ b/test-components/zig-1/src/bindings/zig1.h @@ -1,11 +1,10 @@ -// Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! #ifndef __BINDINGS_ZIG1_H #define __BINDINGS_ZIG1_H #ifdef __cplusplus extern "C" { #endif -#include #include #include diff --git a/test-components/zig-1/src/bindings/zig1_component_type.o b/test-components/zig-1/src/bindings/zig1_component_type.o index 798fd1a286..bace158c52 100644 Binary files a/test-components/zig-1/src/bindings/zig1_component_type.o and b/test-components/zig-1/src/bindings/zig1_component_type.o differ diff --git a/test-components/zig-3.wasm b/test-components/zig-3.wasm index d19600f143..21d2754417 100644 Binary files a/test-components/zig-3.wasm and b/test-components/zig-3.wasm differ diff --git a/test-components/zig-3/src/bindings/zig3.c b/test-components/zig-3/src/bindings/zig3.c index a1ddd6619a..12a61ae554 100644 --- a/test-components/zig-3/src/bindings/zig3.c +++ b/test-components/zig-3/src/bindings/zig3.c @@ -1,6 +1,12 @@ -// Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! #include "zig3.h" +#include +// Exported Functions from `golem:it/api` + + + +// Canonical ABI intrinsics __attribute__((__weak__, __export_name__("cabi_realloc"))) void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { @@ -24,6 +30,8 @@ int64_t __wasm_export_exports_golem_it_api_get(void) { return (int64_t) (ret); } +// Ensure that the *_component_type.o object is linked in + extern void __component_type_object_force_link_zig3(void); void __component_type_object_force_link_zig3_public_use_in_this_compilation_unit(void) { __component_type_object_force_link_zig3(); diff --git a/test-components/zig-3/src/bindings/zig3.h b/test-components/zig-3/src/bindings/zig3.h index b702a5f9de..5b12b3b2d0 100644 --- a/test-components/zig-3/src/bindings/zig3.h +++ b/test-components/zig-3/src/bindings/zig3.h @@ -1,11 +1,10 @@ -// Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! #ifndef __BINDINGS_ZIG3_H #define __BINDINGS_ZIG3_H #ifdef __cplusplus extern "C" { #endif -#include #include #include diff --git a/test-components/zig-3/src/bindings/zig3_component_type.o b/test-components/zig-3/src/bindings/zig3_component_type.o index 04c11ded4a..71ca8698dc 100644 Binary files a/test-components/zig-3/src/bindings/zig3_component_type.o and b/test-components/zig-3/src/bindings/zig3_component_type.o differ