From 68b783dec1192730cb4a2dc257764672c4aa9f89 Mon Sep 17 00:00:00 2001 From: Andrzej Ressel Date: Tue, 5 Mar 2024 01:52:28 +0100 Subject: [PATCH] Save --- .github/workflows/rust.yml | 4 +- Cargo.lock | 282 +++--- Cargo.toml | 7 +- pulumi_rust/Cargo.toml | 1 - pulumi_rust/src/pulumi.rs | 12 +- pulumi_rust_wasm/Cargo.toml | 3 +- pulumi_rust_wasm/src/bindings.rs | 534 ++++++----- pulumi_rust_wasm/src/lib.rs | 2 + pulumi_wasm/Cargo.toml | 3 +- pulumi_wasm/src/bindings.rs | 1421 ++++++++++++++++------------ pulumi_wasm/src/lib.rs | 25 +- pulumi_wasm/tests/test.rs | 12 +- pulumi_wasm_main/Cargo.toml | 3 +- pulumi_wasm_main/src/bindings.rs | 770 +++++++++------ pulumi_wasm_main/src/lib.rs | 2 + pulumi_wasm_main/src/random.rs | 4 +- pulumi_wasm_random/Cargo.toml | 3 +- pulumi_wasm_random/src/bindings.rs | 985 +++++++++++-------- pulumi_wasm_random/src/lib.rs | 3 +- 19 files changed, 2343 insertions(+), 1733 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8298c32f7..6710a4a18 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,11 +34,11 @@ jobs: version: "25.3" - name: Build run: | - cargo install cargo-component@0.8.0 --locked || which cargo-component + cargo install cargo-component@0.9.0 --locked || which cargo-component cargo build --verbose cargo component build -p pulumi_wasm --verbose cargo component build -p pulumi_wasm_random --verbose cargo component build -p pulumi_rust_wasm --verbose cargo component build -p pulumi_wasm_main --verbose - name: Run tests - run: cargo test --verbose + run: cargo test --all --verbose diff --git a/Cargo.lock b/Cargo.lock index 19b7b7dc8..27ce527ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,9 +241,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -437,18 +437,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7c0d51205b863591dd1e7aaa0fb69c2ea7bed48ffa63d6c4a848b07a35a732" +checksum = "9515fcc42b6cb5137f76b84c1a6f819782d0cf12473d145d3bc5cd67eedc8bc2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ffb467cbc25543e4c20d2ad669bf8275598047b03c89652ad5fe2a0f47fc0e1" +checksum = "1ad827c6071bfe6d22de1bc331296a29f9ddc506ff926d8415b435ec6a6efce0" dependencies = [ "bumpalo", "cranelift-bforest", @@ -467,33 +467,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7e74aed5c2b91e38d090653506afbd2cd3be1ff70593e2aa6bb82b3c6b77ff" +checksum = "10e6b36237a9ca2ce2fb4cc7741d418a080afa1327402138412ef85d5367bef1" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff2dd24cce0775566da85770cb48aa58fef901cf2bff30275b42e7dbe62cbd5" +checksum = "c36bf4bfb86898a94ccfa773a1f86e8a5346b1983ff72059bdd2db4600325251" [[package]] name = "cranelift-control" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8bcf4d5c73bbca309edf3af2839b5218e5c74cfbf22b0ac492af8a1d11120d9" +checksum = "7cbf36560e7a6bd1409ca91e7b43b2cc7ed8429f343d7605eadf9046e8fac0d0" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "286754159b1a685475d6a0b4710832f950d6f4846a817002e2c23ff001321a65" +checksum = "a71e11061a75b1184c09bea97c026a88f08b59ade96a7bb1f259d4ea0df2e942" dependencies = [ "serde", "serde_derive", @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67150a1fef9857caba710f8c0c8223d640f02c0e5d1ebbfc75ed62912599cb6b" +checksum = "af5d4da63143ee3485c7bcedde0a818727d737d1083484a0ceedb8950c89e495" dependencies = [ "cranelift-codegen", "log", @@ -513,15 +513,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb7ceea70d3e0d7f69df7657f99de902e32016731c5a8d2788c1df0215f00952" +checksum = "457a9832b089e26f5eea70dcf49bed8ec6edafed630ce7c83161f24d46ab8085" [[package]] name = "cranelift-native" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707e5d9384ce4fa3c40af1abf4c3ec49857745cced5187593385f4a2c0b95445" +checksum = "9b490d579df1ce365e1ea359e24ed86d82289fa785153327c2f6a69a59a731e4" dependencies = [ "cranelift-codegen", "libc", @@ -530,9 +530,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.104.1" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d957e3ff2a14c2f974a66c22bfcedcd2bd0272af8dce4236869c3942f5a471" +checksum = "8cd747ed7f9a461dda9c388415392f6bb95d1a6ef3b7694d17e0817eb74b7798" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -540,7 +540,7 @@ dependencies = [ "itertools 0.10.5", "log", "smallvec", - "wasmparser 0.118.1", + "wasmparser", "wasmtime-types", ] @@ -859,7 +859,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "debugid", "fxhash", "serde", @@ -1206,7 +1206,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall", ] @@ -1538,7 +1538,6 @@ dependencies = [ "uuid", "wasmtime", "wasmtime-wasi", - "wit-bindgen", ] [[package]] @@ -1546,13 +1545,14 @@ name = "pulumi_rust_wasm" version = "0.1.0" dependencies = [ "anyhow", + "bitflags 2.4.2", "futures", "lazy_static", "rmp-serde", "serde", "serde_json", "uuid", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -1560,6 +1560,7 @@ name = "pulumi_wasm" version = "0.1.0" dependencies = [ "anyhow", + "bitflags 2.4.2", "futures", "lazy_static", "once_cell", @@ -1575,7 +1576,7 @@ dependencies = [ "uuid", "wasmtime", "wasmtime-wasi", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -1583,6 +1584,7 @@ name = "pulumi_wasm_main" version = "0.1.0" dependencies = [ "anyhow", + "bitflags 2.4.2", "futures", "lazy_static", "once_cell", @@ -1598,7 +1600,7 @@ dependencies = [ "uuid", "wasmtime", "wasmtime-wasi", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -1606,6 +1608,7 @@ name = "pulumi_wasm_random" version = "0.1.0" dependencies = [ "anyhow", + "bitflags 2.4.2", "futures", "lazy_static", "once_cell", @@ -1620,7 +1623,7 @@ dependencies = [ "uuid", "wasmtime", "wasmtime-wasi", - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] @@ -1794,7 +1797,7 @@ version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "itoa", "libc", @@ -1981,7 +1984,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cap-fs-ext", "cap-std", "fd-lock", @@ -2213,7 +2216,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "futures-core", "futures-util", @@ -2243,7 +2246,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2405,13 +2407,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasi-cap-std-sync" -version = "17.0.1" +name = "wasi-common" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025e842ba390587e523785ff58bd54fbbf1781b8d3072bc9aba4dc0b809f69da" +checksum = "880c1461417b2bf90262591bf8a5f04358fb86dac8a585a49b87024971296763" dependencies = [ "anyhow", - "async-trait", + "bitflags 2.4.2", "cap-fs-ext", "cap-rand", "cap-std", @@ -2419,27 +2421,10 @@ dependencies = [ "fs-set-times", "io-extras", "io-lifetimes", + "log", "once_cell", "rustix", "system-interface", - "tracing", - "wasi-common", - "windows-sys 0.52.0", -] - -[[package]] -name = "wasi-common" -version = "17.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4d4023cc65b3615590d38db0afb79234de09b3bb89cb0d8f83bdee9f5c28a8" -dependencies = [ - "anyhow", - "bitflags 2.4.1", - "cap-rand", - "cap-std", - "io-extras", - "log", - "rustix", "thiserror", "tracing", "wasmtime", @@ -2501,15 +2486,6 @@ version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" -[[package]] -name = "wasm-encoder" -version = "0.38.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.41.0" @@ -2519,23 +2495,13 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasmparser" -version = "0.118.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" -dependencies = [ - "indexmap 2.1.0", - "semver", -] - [[package]] name = "wasmparser" version = "0.121.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953cf6a7606ab31382cb1caa5ae403e77ba70c7f8e12eeda167e7040d42bfda8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "indexmap 2.1.0", "semver", ] @@ -2547,15 +2513,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e32c13c59fdc64d3f6998a1d52eb1d362b6904a88b754190ccb85661ad577a" dependencies = [ "anyhow", - "wasmparser 0.121.0", + "wasmparser", ] [[package]] name = "wasmtime" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb6aa966be38f613954c3debe7ba6c7a02ffd0537432be438da0b038955cdf" +checksum = "4c843b8bc4dd4f3a76173ba93405c71111d570af0d90ea5f6299c705d0c2add2" dependencies = [ + "addr2line", "anyhow", "async-trait", "bincode", @@ -2563,26 +2530,30 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", + "gimli", "indexmap 2.1.0", + "ittapi", "libc", "log", "object", "once_cell", "paste", "rayon", + "rustix", "serde", "serde_derive", "serde_json", "target-lexicon", - "wasm-encoder 0.38.1", - "wasmparser 0.118.1", + "wasm-encoder", + "wasmparser", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", - "wasmtime-jit", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", "wasmtime-runtime", "wasmtime-winch", "wat", @@ -2591,18 +2562,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1495ef4d46aec14f967b672e946e391dd8a14a443cda3d5e0779ff67fb6e28d" +checksum = "86b9d329c718b3a18412a6a017c912b539baa8fe1210d21b651f6b4dbafed743" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2de1b065bdbaca3df9e7e9f70eb129e326a99d971b16d666acd798d98d47635" +checksum = "6fb4fc2bbf9c790a57875eba65588fa97acf57a7d784dc86d057e648d9a1ed91" dependencies = [ "anyhow", "base64", @@ -2620,9 +2591,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f19bcff82f81ba0273c0b68f3909977b0dd54489bc86c630d8aad43dca92f3f" +checksum = "d8d55ddfd02898885c39638eae9631cd430c83a368f5996ed0f7bfb181d02157" dependencies = [ "anyhow", "proc-macro2", @@ -2635,15 +2606,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af072b7ad5ac5583e1f9e4737ebf88923de564fb5d4ace0ca9b4b720bdf95a1" +checksum = "1d6d69c430cddc70ec42159506962c66983ce0192ebde4eb125b7aabc49cff88" [[package]] name = "wasmtime-cranelift" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df08a8bd9a68732577bee05ac685e4c247238b5e79ad9c062e2dfb4d04dca132" +checksum = "31ca62f519225492bd555d0ec85a2dacb0c10315db3418c8b9aeb3824bf54a24" dependencies = [ "anyhow", "cfg-if", @@ -2658,7 +2629,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.118.1", + "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -2666,9 +2637,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "404201c9e669083f189f01337b3ed0aa0eb081157fb4e170bbfe193df9497771" +checksum = "fd5f2071f42e61490bf7cb95b9acdbe6a29dd577a398019304a960585f28b844" dependencies = [ "anyhow", "cranelift-codegen", @@ -2682,22 +2653,25 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e696b4911c9a69c3c2892ec05eb41bb15436d1a46d8830a755c40f5df47546a" +checksum = "82bf1a47f384610da19f58b0fd392ca6a3b720974315c08afb0392c0f3951fed" dependencies = [ "anyhow", + "bincode", + "cpp_demangle", "cranelift-entity", "gimli", "indexmap 2.1.0", "log", "object", + "rustc-demangle", "serde", "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder 0.38.1", - "wasmparser 0.118.1", + "wasm-encoder", + "wasmparser", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2705,9 +2679,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a39681c1f6f54d1bf7efe5dc829f8d7fc0e2ca12c346fd7a3efbf726e9681d2" +checksum = "0e31aecada2831e067ebfe93faa3001cc153d506f8af40bbea58aa1d20fe4820" dependencies = [ "anyhow", "cc", @@ -2718,38 +2692,11 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "wasmtime-jit" -version = "17.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c56519882d936c680bd191d58ac04cff071a470eca2dcc664adcd60f986a731" -dependencies = [ - "addr2line", - "anyhow", - "bincode", - "cfg-if", - "cpp_demangle", - "gimli", - "ittapi", - "log", - "object", - "rustc-demangle", - "rustix", - "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.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "babc65e64ab0dd4e1ce65624db64e24ed0fbdebb16148729173fa0da9f70e53c" +checksum = "833dae95bc7a4f9177bf93f9497419763535b74e37eb8c37be53937d3281e287" dependencies = [ "object", "once_cell", @@ -2759,9 +2706,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ec5b11c12d9acb09612e7ce04c4c8aea3e8dc79b2591ffdead986a5ce8ec49" +checksum = "33f4121cb29dda08139b2824a734dd095d83ce843f2d613a84eb580b9cfc17ac" dependencies = [ "cfg-if", "libc", @@ -2770,9 +2717,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28e1c31bbdf67cb86f149bcead5193749f23f77c93c5244ec9ac8d192f90966c" +checksum = "4e517f2b996bb3b0e34a82a2bce194f850d9bcfc25c08328ef5fb71b071066b8" dependencies = [ "anyhow", "cc", @@ -2788,7 +2735,7 @@ dependencies = [ "psm", "rustix", "sptr", - "wasm-encoder 0.38.1", + "wasm-encoder", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", @@ -2800,22 +2747,22 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e799cff634d30fd042db96b417d515e54f903b95f8c1e0ec60e8f604479485" +checksum = "54a327d7a0ef57bd52a507d28b4561a74126c7a8535a2fc6f2025716bc6a52e8" dependencies = [ "cranelift-entity", "serde", "serde_derive", "thiserror", - "wasmparser 0.118.1", + "wasmparser", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10fe166d4e4c95d5d80c5b47e1e12256af2099ac525ddb9a19b1aeb8896e5e1" +checksum = "8ef32eea9fc7035a55159a679d1e89b43ece5ae45d24eed4808e6a92c99a0da4" dependencies = [ "proc-macro2", "quote", @@ -2824,13 +2771,13 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494f99111a165dcddc69aaa5fa23604f49dcfab479a869edd84581abd6ac569b" +checksum = "d04d2fb2257245aa05ff799ded40520ae4d8cd31b0d14972afac89061f12fe12" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "cap-fs-ext", "cap-net-ext", @@ -2841,7 +2788,6 @@ dependencies = [ "futures", "io-extras", "io-lifetimes", - "libc", "log", "once_cell", "rustix", @@ -2850,7 +2796,6 @@ dependencies = [ "tokio", "tracing", "url", - "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", @@ -2859,16 +2804,16 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f5d76d399cb4423e6f178bc154a0e1c314711e28dabaa6e757e56628a083ec" +checksum = "db3378c0e808a744b5d4df2a9a9d2746a53b151811926731f04fc401707f7d54" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.118.1", + "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2876,9 +2821,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb3bc92c031cf4961135bffe055a69c1bd67c253dca20631478189bb05ec27b" +checksum = "ca677c36869e45602617b25a9968ec0d895ad9a0aee3756d9dee1ddd89456f91" dependencies = [ "anyhow", "heck", @@ -2888,9 +2833,9 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da08ab734954e16f57be38423b90c25a0b13420e51cbd0a2e37b86a468a988c" +checksum = "7f4cbfb052d66f03603a9b77f18171ea245c7805714caad370a549a6344bf86b" [[package]] name = "wast" @@ -2911,7 +2856,7 @@ dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.41.0", + "wasm-encoder", ] [[package]] @@ -2937,13 +2882,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd5b200b5dd3d5d7cc4093166f4f916d2d2839296cf1b1757b9726635f6425c3" +checksum = "b69812e493f8a43d8551abfaaf9539e1aff0cf56a58cdd276845fc4af035d0cd" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.1", + "bitflags 2.4.2", "thiserror", "tracing", "wasmtime", @@ -2952,9 +2897,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4dc34a2bc1091599de005e9b854cd1a9ea35b16ca51cac2797274c1a2666e06" +checksum = "0446357a5a7af0172848b6eca7b2aa1ab7d90065cd2ab02b633a322e1a52f636" dependencies = [ "anyhow", "heck", @@ -2967,9 +2912,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "17.0.1" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ba3b37f402a7513b9ed7973a6e907074987b3afdcede98d3d79939b3e76f1b" +checksum = "9498ef53a12cf25dc6de9baef6ccd8b58d159202c412a19f4d72b218393086c5" dependencies = [ "proc-macro2", "quote", @@ -3001,9 +2946,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d921185084e134e897e0e202e129a422306d0f1391954ecf4928d36defa897d" +checksum = "8197ed4a2ebf612f0624ddda10de71f8cd2d3a4ecf8ffac0586a264599708d63" dependencies = [ "anyhow", "cranelift-codegen", @@ -3011,7 +2956,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.118.1", + "wasmparser", "wasmtime-environ", ] @@ -3162,18 +3107,15 @@ version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "windows-sys 0.52.0", ] [[package]] -name = "wit-bindgen" -version = "0.17.0" +name = "wit-bindgen-rt" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" -dependencies = [ - "bitflags 2.4.1", -] +checksum = "026d24a27f6712541fa534f2954bd9e0eb66172f033c2157c0f31d106255c497" [[package]] name = "wit-parser" diff --git a/Cargo.toml b/Cargo.toml index 88f310ac7..0ea6c29f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,15 +34,16 @@ uuid = { version = "1.7.0", features = ["v4", "v7"] } futures = "0.3.30" lazy_static = "1.4.0" once_cell = "1.19.0" -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } +bitflags = "2.4.2" +wit-bindgen-rt = "0.21.0" rmp = "0.8.12" rmp-serde = "1.1.2" rmpv = "1.0.1" serde = "1.0.196" tonic = { version = "0.11.0", default-features = false } serde_json = "1.0.113" -wasmtime = "17.0.1" -wasmtime-wasi = "17.0.1" +wasmtime = "18.0.2" +wasmtime-wasi = "18.0.2" tonic-build = "0.11.0" async-trait = "0.1.77" tonic-web = "0.11.0" diff --git a/pulumi_rust/Cargo.toml b/pulumi_rust/Cargo.toml index d2eedd2b3..6b483a32b 100644 --- a/pulumi_rust/Cargo.toml +++ b/pulumi_rust/Cargo.toml @@ -13,7 +13,6 @@ tonic.workspace = true log.workspace = true uuid.workspace = true tracing-subscriber.workspace = true -wit-bindgen.workspace = true wasmtime.workspace = true wasmtime-wasi.workspace = true anyhow.workspace = true diff --git a/pulumi_rust/src/pulumi.rs b/pulumi_rust/src/pulumi.rs index 4ee7cd14f..4e0037278 100644 --- a/pulumi_rust/src/pulumi.rs +++ b/pulumi_rust/src/pulumi.rs @@ -76,19 +76,11 @@ impl MyState { } impl WasiView for SimplePluginCtx { - fn table(&self) -> &ResourceTable { - &self.table - } - - fn table_mut(&mut self) -> &mut ResourceTable { + fn table(&mut self) -> &mut ResourceTable { &mut self.table } - fn ctx(&self) -> &WasiCtx { - &self.context - } - - fn ctx_mut(&mut self) -> &mut WasiCtx { + fn ctx(&mut self) -> &mut WasiCtx { &mut self.context } } diff --git a/pulumi_rust_wasm/Cargo.toml b/pulumi_rust_wasm/Cargo.toml index 88e12f2e1..1fbd2cc8c 100644 --- a/pulumi_rust_wasm/Cargo.toml +++ b/pulumi_rust_wasm/Cargo.toml @@ -10,7 +10,8 @@ crate-type = ["rlib", "cdylib"] [dependencies] uuid.workspace = true -wit-bindgen.workspace = true +bitflags.workspace = true +wit-bindgen-rt.workspace = true anyhow.workspace = true serde.workspace = true rmp-serde.workspace = true diff --git a/pulumi_rust_wasm/src/bindings.rs b/pulumi_rust_wasm/src/bindings.rs index 84796e333..b7d319560 100644 --- a/pulumi_rust_wasm/src/bindings.rs +++ b/pulumi_rust_wasm/src/bindings.rs @@ -1,232 +1,344 @@ -// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT! +// Options used: pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod output_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Output{ - handle: wit_bindgen::rt::Resource, - } - - impl Output{ + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod output_interface { + #[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(Debug)] + #[repr(transparent)] + pub struct Output { + handle: _rt::Resource, + } + + impl Output { + #[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 Output { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]output"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[allow(unused_unsafe, clippy::all)] + pub fn create_struct(fields: &[(_rt::String, &Output)]) -> Output { + unsafe { + let vec2 = fields; + 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() + } + }; + 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; + } + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "create-struct"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(result2, len2); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + Output::from_handle(ret as u32) + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn new(value: &[u8]) -> Self { + unsafe { + let vec0 = value; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[constructor]output"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr0.cast_mut(), len0); + Output::from_handle(ret as u32) + } + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn map(&self, function_name: &str) -> Output { + unsafe { + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.map"] + 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); + Output::from_handle(ret as u32) + } + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self) -> Output { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } + } + } + } +} +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. + 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 Output{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]output"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - pub fn create_struct(fields: &[(wit_bindgen::rt::string::String,&Output,)],) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec2 = fields; - 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; - } - } - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "create-struct"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(result2 as i32, len2); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - Output::from_handle(ret as u32) - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn new(value: &[u8],) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = value; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[constructor]output"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr0, len0); - Output::from_handle(ret as u32) - } + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn map(&self,function_name: &str,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.map"] - 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); - Output::from_handle(ret as u32) - } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.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 = *((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) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + } + + 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 Output { - #[allow(unused_unsafe, clippy::all)] - pub fn duplicate(&self,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.duplicate"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Output::from_handle(ret as u32) - } + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() } - } - } - - } + extern crate alloc as alloc_crate; } #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:pulumi-rust"] +#[link_section = "component-type:wit-bindgen:0.20.0:pulumi-rust:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 452] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 195, 2, 1, 65, 2, 1, 65, 2, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 3, 0, 0, 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, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 453] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc3\x02\x01A\x02\x01\ +A\x02\x01B\x11\x04\0\x06output\x03\x01\x01p}\x01i\0\x01@\x01\x05value\x01\0\x02\x04\ +\0\x13[constructor]output\x01\x03\x01h\0\x01@\x02\x04self\x04\x0dfunction-names\0\ +\x02\x04\0\x12[method]output.map\x01\x05\x01k\x01\x01@\x01\x04self\x04\0\x06\x04\ +\0\x12[method]output.get\x01\x07\x01@\x01\x04self\x04\0\x02\x04\0\x18[method]out\ +put.duplicate\x01\x08\x01o\x02s\x04\x01p\x09\x01@\x01\x06fields\x0a\0\x02\x04\0\x0d\ +create-struct\x01\x0b\x03\x01,component:pulumi-wasm/output-interface@0.1.0\x05\0\ +\x04\x01'component:pulumi-wasm/pulumi-rust@0.1.0\x04\0\x0b\x11\x01\0\x0bpulumi-r\ +ust\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.201.0\x10\ +wit-bindgen-rust\x060.20.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/pulumi_rust_wasm/src/lib.rs b/pulumi_rust_wasm/src/lib.rs index d65b3e0ec..06bc62ad4 100644 --- a/pulumi_rust_wasm/src/lib.rs +++ b/pulumi_rust_wasm/src/lib.rs @@ -4,6 +4,8 @@ use lazy_static::lazy_static; // use crate::bindings::exports::component::pulumi_wasm::function_holder::Guest; pub(crate) mod bindings; +// bindings::export!(Component with_types_in bindings); + pub mod output; // pub mod pulumi; diff --git a/pulumi_wasm/Cargo.toml b/pulumi_wasm/Cargo.toml index fcfc8f1f2..bfe791b59 100644 --- a/pulumi_wasm/Cargo.toml +++ b/pulumi_wasm/Cargo.toml @@ -16,7 +16,8 @@ uuid.workspace = true futures.workspace = true lazy_static.workspace = true once_cell.workspace = true -wit-bindgen.workspace = true +bitflags.workspace = true +wit-bindgen-rt.workspace = true rmp.workspace = true rmp-serde.workspace = true rmpv.workspace = true diff --git a/pulumi_wasm/src/bindings.rs b/pulumi_wasm/src/bindings.rs index 7c6a556d8..4b28d04ed 100644 --- a/pulumi_wasm/src/bindings.rs +++ b/pulumi_wasm/src/bindings.rs @@ -1,623 +1,856 @@ -// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT! +// Options used: pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod external_world { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - #[allow(unused_unsafe, clippy::all)] - pub fn register_resource(request: &[u8],) -> 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 = request; - 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 = "component:pulumi-wasm/external-world@0.1.0")] - extern "C" { - #[link_name = "register-resource"] - 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; - Vec::from_raw_parts(l2 as *mut _, len4, len4) - } - } - - } - - } -} -pub mod exports { - pub mod component { pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod output_interface { - #[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::Output as Output; - const _: () = { - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[dtor]output"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: usize) { - wit_bindgen::rt::Resource::::dtor(rep) - } - }; - unsafe impl wit_bindgen::rt::RustResource for Output{ - unsafe fn new(_rep: usize) -> u32 { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-new]output"] - fn new(_: usize) -> u32; - } - new(_rep) - } - } - - unsafe fn rep(_handle: u32) -> usize { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - + + #[allow(clippy::all)] + pub mod external_world { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-rep]output"] - fn rep(_: u32) -> usize; - } - rep(_handle) + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[allow(unused_unsafe, clippy::all)] + pub fn register_resource(request: &[u8]) -> _rt::Vec { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = request; + 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 = "component:pulumi-wasm/external-world@0.1.0")] + extern "C" { + #[link_name = "register-resource"] + 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; + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + } } - } } - pub type OwnOutput = wit_bindgen::rt::Resource; - - - unsafe impl wit_bindgen::rt::WasmResource for Output{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]output"] - fn drop(_: u32); - } - - drop(_handle); + } +} +pub mod exports { + pub mod component { + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod output_interface { + #[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 Output { + handle: _rt::Resource, + } + + type _OutputRep = Option; + + impl Output { + /// 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 `Output`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _OutputRep = Some(val); + let ptr: *mut _OutputRep = _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 `GuestOutput` 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), + } + } + } + + fn as_ptr(&self) -> *mut _OutputRep { + Output::type_guard::(); + unsafe { T::_resource_rep(self.handle()).cast() } + } + } + + /// A borrowed version of [`Output`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Output>, + } + + impl<'a> OutputBorrow<'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 _OutputRep { + Output::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Output { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0" + )] + extern "C" { + #[link_name = "[resource-drop]output"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_struct_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + let base4 = arg0; + let len4 = arg1; + let mut result4 = _rt::Vec::with_capacity(len4); + for i in 0..len4 { + let base = base4.add(i * 12); + let e4 = { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + let len2 = l1; + let bytes2 = _rt::Vec::from_raw_parts(l0.cast(), len2, len2); + let l3 = *base.add(8).cast::(); + + ( + _rt::string_lift(bytes2), + OutputBorrow::lift(l3 as u32 as usize), + ) + }; + result4.push(e4); + } + _rt::cabi_dealloc(base4, len4 * 12, 4); + let result5 = T::create_struct(result4); + (result5).take_handle() as i32 + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_constructor_output_cabi( + arg0: *mut u8, + arg1: usize, + ) -> i32 { + let len0 = arg1; + let result1 = + Output::new(T::new(_rt::Vec::from_raw_parts(arg0.cast(), len0, len0))); + (result1).take_handle() as i32 + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_output_map_cabi( + arg0: i32, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + let len0 = arg2; + let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); + let result1 = T::map( + OutputBorrow::lift(arg0 as u32 as usize).get(), + _rt::string_lift(bytes0), + ); + (result1).take_handle() as i32 + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_output_get_cabi(arg0: i32) -> *mut u8 { + let result0 = T::get(OutputBorrow::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 vec2 = (e).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(); + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_output_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_method_output_duplicate_cabi( + arg0: i32, + ) -> i32 { + let result0 = T::duplicate(OutputBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + pub trait Guest { + type Output: GuestOutput; + fn create_struct(fields: _rt::Vec<(_rt::String, OutputBorrow<'_>)>) -> Output; + } + pub trait GuestOutput: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0" + )] + extern "C" { + #[link_name = "[resource-new]output"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link( + wasm_import_module = "[export]component:pulumi-wasm/output-interface@0.1.0" + )] + extern "C" { + #[link_name = "[resource-rep]output"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn new(value: _rt::Vec) -> Self; + fn map(&self, function_name: _rt::String) -> Output; + fn get(&self) -> Option<_rt::Vec>; + fn duplicate(&self) -> Output; + } + #[doc(hidden)] + + macro_rules! __export_component_pulumi_wasm_output_interface_0_1_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#create-struct"] + unsafe extern "C" fn export_create_struct(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_create_struct_cabi::<$ty>(arg0, arg1) + } + + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[constructor]output"] + unsafe extern "C" fn export_constructor_output(arg0: *mut u8,arg1: usize,) -> i32 { + $($path_to_types)*::_export_constructor_output_cabi::<<$ty as $($path_to_types)*::Guest>::Output>(arg0, arg1) + } + + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.map"] + unsafe extern "C" fn export_method_output_map(arg0: i32,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_output_map_cabi::<<$ty as $($path_to_types)*::Guest>::Output>(arg0, arg1, arg2) + } + + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.get"] + unsafe extern "C" fn export_method_output_get(arg0: i32,) -> *mut u8 { + $($path_to_types)*::_export_method_output_get_cabi::<<$ty as $($path_to_types)*::Guest>::Output>(arg0) + } + + #[export_name = "cabi_post_component:pulumi-wasm/output-interface@0.1.0#[method]output.get"] + unsafe extern "C" fn _post_return_method_output_get(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_output_get::<<$ty as $($path_to_types)*::Guest>::Output>(arg0) + } + + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.duplicate"] + unsafe extern "C" fn export_method_output_duplicate(arg0: i32,) -> i32 { + $($path_to_types)*::_export_method_output_duplicate_cabi::<<$ty as $($path_to_types)*::Guest>::Output>(arg0) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_component_pulumi_wasm_output_interface_0_1_0_cabi; + + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 12]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); } - } - } - - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/output-interface@0.1.0#create-struct"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_struct(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 base4 = arg0; - let len4 = arg1; - let mut result4 = Vec::with_capacity(len4 as usize); - for i in 0..len4 { - let base = base4 + i * 12; - let e4 = { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - let len2 = l1 as usize; - let bytes2 = Vec::from_raw_parts(l0 as *mut _, len2, len2); - let l3 = *((base + 8) as *const i32); - - (wit_bindgen::rt::string_lift(bytes2), wit_bindgen::rt::Resource::::lift_borrow(l3 as u32 as usize)) - }; - result4.push(e4); + + #[allow(clippy::all)] + pub mod register_interface { + #[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 Output = super::super::super::super::exports::component::pulumi_wasm::output_interface::Output; + pub type OutputBorrow<'a> = super::super::super::super::exports::component::pulumi_wasm::output_interface::OutputBorrow<'a>; + pub struct ObjectField<'a> { + /// name: list, //FIXME: String does not work + pub object: OutputBorrow<'a>, + } + impl<'a> ::core::fmt::Debug for ObjectField<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectField") + .field("object", &self.object) + .finish() + } + } + pub struct RegisterResourceRequest<'a> { + pub type_: _rt::String, + pub name: _rt::String, + pub object_names: _rt::Vec<_rt::String>, + pub object: _rt::Vec>, + } + impl<'a> ::core::fmt::Debug for RegisterResourceRequest<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RegisterResourceRequest") + .field("type", &self.type_) + .field("name", &self.name) + .field("object-names", &self.object_names) + .field("object", &self.object) + .finish() + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_register_cabi( + arg0: *mut u8, + arg1: usize, + arg2: *mut u8, + arg3: usize, + arg4: *mut u8, + arg5: usize, + arg6: *mut u8, + arg7: usize, + ) { + 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 base5 = arg4; + let len5 = arg5; + let mut result5 = _rt::Vec::with_capacity(len5); + for i in 0..len5 { + let base = base5.add(i * 8); + let e5 = { + let l2 = *base.add(0).cast::<*mut u8>(); + let l3 = *base.add(4).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + result5.push(e5); + } + _rt::cabi_dealloc(base5, len5 * 8, 4); + let base7 = arg6; + let len7 = arg7; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 4); + let e7 = { + let l6 = *base.add(0).cast::(); + + ObjectField { + object: OutputBorrow::lift(l6 as u32 as usize), + } + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 4, 4); + T::register(RegisterResourceRequest { + type_: _rt::string_lift(bytes0), + name: _rt::string_lift(bytes1), + object_names: result5, + object: result7, + }); + } + pub trait Guest { + fn register(request: RegisterResourceRequest<'_>); + } + #[doc(hidden)] + + macro_rules! __export_component_pulumi_wasm_register_interface_0_1_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + + #[export_name = "component:pulumi-wasm/register-interface@0.1.0#register"] + unsafe extern "C" fn export_register(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,) { + $($path_to_types)*::_export_register_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_component_pulumi_wasm_register_interface_0_1_0_cabi; } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 12, 4); - let result5 = <_GuestImpl as Guest>::create_struct(result4); - wit_bindgen::rt::Resource::into_handle(result5) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[constructor]output"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_constructor_output(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 = OwnOutput::new(<_OutputImpl as GuestOutput>::new(Vec::from_raw_parts(arg0 as *mut _, len0, len0))); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.map"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_output_map(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 = arg2 as usize; - let bytes0 = Vec::from_raw_parts(arg1 as *mut _, len0, len0); - let result1 = <_OutputImpl as GuestOutput>::map(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize), wit_bindgen::rt::string_lift(bytes0)); - wit_bindgen::rt::Resource::into_handle(result1) as i32 - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_output_get(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 = <_OutputImpl as GuestOutput>::get(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 vec2 = (e).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; - }, - None => { - { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; + + #[allow(clippy::all)] + pub mod function_reverse_callback { + #[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 Output = super::super::super::super::exports::component::pulumi_wasm::output_interface::Output; + pub type OutputBorrow<'a> = super::super::super::super::exports::component::pulumi_wasm::output_interface::OutputBorrow<'a>; + pub struct FunctionInvocationRequest { + pub id: Output, + pub function_id: _rt::String, + pub value: _rt::Vec, } - }, - };ptr1 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_component:pulumi-wasm/output-interface@0.1.0#[method]output.get"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_method_output_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); - }, - } + impl ::core::fmt::Debug for FunctionInvocationRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FunctionInvocationRequest") + .field("id", &self.id) + .field("function-id", &self.function_id) + .field("value", &self.value) + .finish() + } + } + pub struct FunctionInvocationResult<'a> { + pub id: OutputBorrow<'a>, + pub value: _rt::Vec, + } + impl<'a> ::core::fmt::Debug for FunctionInvocationResult<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FunctionInvocationResult") + .field("id", &self.id) + .field("value", &self.value) + .finish() + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_get_functions_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::get_functions(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec6 = result1; + let len6 = vec6.len(); + let layout6 = _rt::alloc::Layout::from_size_align_unchecked(vec6.len() * 20, 4); + let result6 = if layout6.size() != 0 { + let ptr = _rt::alloc::alloc(layout6).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout6); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6.add(i * 20); + { + let FunctionInvocationRequest { + id: id3, + function_id: function_id3, + value: value3, + } = e; + *base.add(0).cast::() = (id3).take_handle() as i32; + let vec4 = (function_id3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(8).cast::() = len4; + *base.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + let vec5 = (value3).into_boxed_slice(); + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + ::core::mem::forget(vec5); + *base.add(16).cast::() = len5; + *base.add(12).cast::<*mut u8>() = ptr5.cast_mut(); + } + } + *ptr2.add(4).cast::() = len6; + *ptr2.add(0).cast::<*mut u8>() = result6; + ptr2 + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_get_functions(arg0: *mut u8) { + let l5 = *arg0.add(0).cast::<*mut u8>(); + let l6 = *arg0.add(4).cast::(); + let base7 = l5; + let len7 = l6; + for i in 0..len7 { + let base = base7.add(i * 20); + { + let l0 = *base.add(4).cast::<*mut u8>(); + let l1 = *base.add(8).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(12).cast::<*mut u8>(); + let l3 = *base.add(16).cast::(); + let base4 = l2; + let len4 = l3; + _rt::cabi_dealloc(base4, len4 * 1, 1); + } + } + _rt::cabi_dealloc(base7, len7 * 20, 4); + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_set_functions_cabi(arg0: *mut u8, arg1: usize) { + let base4 = arg0; + let len4 = arg1; + let mut result4 = _rt::Vec::with_capacity(len4); + for i in 0..len4 { + let base = base4.add(i * 12); + let e4 = { + let l0 = *base.add(0).cast::(); + let l1 = *base.add(4).cast::<*mut u8>(); + let l2 = *base.add(8).cast::(); + let len3 = l2; + + FunctionInvocationResult { + id: OutputBorrow::lift(l0 as u32 as usize), + value: _rt::Vec::from_raw_parts(l1.cast(), len3, len3), + } + }; + result4.push(e4); + } + _rt::cabi_dealloc(base4, len4 * 12, 4); + T::set_functions(result4); + } + pub trait Guest { + fn get_functions(source: _rt::String) -> _rt::Vec; + fn set_functions(results: _rt::Vec>); + } + #[doc(hidden)] + + macro_rules! __export_component_pulumi_wasm_function_reverse_callback_0_1_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + + #[export_name = "component:pulumi-wasm/function-reverse-callback@0.1.0#get-functions"] + unsafe extern "C" fn export_get_functions(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_get_functions_cabi::<$ty>(arg0, arg1) + } + + #[export_name = "cabi_post_component:pulumi-wasm/function-reverse-callback@0.1.0#get-functions"] + unsafe extern "C" fn _post_return_get_functions(arg0: *mut u8,) { + $($path_to_types)*::__post_return_get_functions::<$ty>(arg0) + } + + #[export_name = "component:pulumi-wasm/function-reverse-callback@0.1.0#set-functions"] + unsafe extern "C" fn export_set_functions(arg0: *mut u8,arg1: usize,) { + $($path_to_types)*::_export_set_functions_cabi::<$ty>(arg0, arg1) + } + };); +} + #[doc(hidden)] + pub(crate) use __export_component_pulumi_wasm_function_reverse_callback_0_1_0_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 = "component:pulumi-wasm/output-interface@0.1.0#[method]output.duplicate"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_method_output_duplicate(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 = <_OutputImpl as GuestOutput>::duplicate(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); - wit_bindgen::rt::Resource::into_handle(result0) as i32 - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn create_struct(fields: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,&Output,)>,) -> OwnOutput; } - use super::super::super::super::super::Output as _OutputImpl; - pub trait GuestOutput { - fn new(value: wit_bindgen::rt::vec::Vec::,) -> Self; - fn map(&self,function_name: wit_bindgen::rt::string::String,) -> OwnOutput; - fn get(&self,) -> Option>; - fn duplicate(&self,) -> OwnOutput; - } - - #[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(clippy::all)] - pub mod register_interface { - #[used] + } +} +mod _rt { + 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. + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type OwnOutput = super::super::super::super::exports::component::pulumi_wasm::output_interface::OwnOutput; - pub type Output = super::super::super::super::exports::component::pulumi_wasm::output_interface::Output; - pub struct ObjectField<'a,> { - /// name: list, //FIXME: String does not work - pub object: &'a Output, - } - impl<'a,> ::core::fmt::Debug for ObjectField<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ObjectField").field("object", &self.object).finish() - } - } - pub struct RegisterResourceRequest<'a,> { - pub type_: wit_bindgen::rt::string::String, - pub name: wit_bindgen::rt::string::String, - pub object_names: wit_bindgen::rt::vec::Vec::, - pub object: wit_bindgen::rt::vec::Vec::>, - } - impl<'a,> ::core::fmt::Debug for RegisterResourceRequest<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object-names", &self.object_names).field("object", &self.object).finish() - } - } - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/register-interface@0.1.0#register"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_register(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: 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 base5 = arg4; - let len5 = arg5; - let mut result5 = Vec::with_capacity(len5 as usize); - for i in 0..len5 { - let base = base5 + i * 8; - let e5 = { - let l2 = *((base + 0) as *const i32); - let l3 = *((base + 4) 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) - }; - result5.push(e5); - } - wit_bindgen::rt::dealloc(base5, (len5 as usize) * 8, 4); - let base7 = arg6; - let len7 = arg7; - let mut result7 = Vec::with_capacity(len7 as usize); - for i in 0..len7 { - let base = base7 + i * 4; - let e7 = { - let l6 = *((base + 0) as *const i32); - - ObjectField{ - object: wit_bindgen::rt::Resource::::lift_borrow(l6 as u32 as usize), - } - }; - result7.push(e7); + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 4, 4); - <_GuestImpl as Guest>::register(RegisterResourceRequest{ - type_: wit_bindgen::rt::string_lift(bytes0), - name: wit_bindgen::rt::string_lift(bytes1), - object_names: result5, - object: result7, - }); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn register(request: RegisterResourceRequest,); } - - } - - - #[allow(clippy::all)] - pub mod function_reverse_callback { - #[used] + + /// 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)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type OwnOutput = super::super::super::super::exports::component::pulumi_wasm::output_interface::OwnOutput; - pub type Output = super::super::super::super::exports::component::pulumi_wasm::output_interface::Output; - pub struct FunctionInvocationRequest { - pub id: OwnOutput, - pub function_id: wit_bindgen::rt::string::String, - pub value: wit_bindgen::rt::vec::Vec::, - } - impl ::core::fmt::Debug for FunctionInvocationRequest { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FunctionInvocationRequest").field("id", &self.id).field("function-id", &self.function_id).field("value", &self.value).finish() - } + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) } - pub struct FunctionInvocationResult<'a,> { - pub id: &'a Output, - pub value: wit_bindgen::rt::vec::Vec::, + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) } - impl<'a,> ::core::fmt::Debug for FunctionInvocationResult<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FunctionInvocationResult").field("id", &self.id).field("value", &self.value).finish() - } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() } - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/function-reverse-callback@0.1.0#get-functions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_get_functions(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_functions(wit_bindgen::rt::string_lift(bytes0)); - let ptr2 = _RET_AREA.0.as_mut_ptr() as i32; - let vec6 = result1; - let len6 = vec6.len() as i32; - let layout6 = alloc::Layout::from_size_align_unchecked(vec6.len() * 20, 4); - let result6 = if layout6.size() != 0 - { - let ptr = alloc::alloc(layout6); - if ptr.is_null() - { - alloc::handle_alloc_error(layout6); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec6.into_iter().enumerate() { - let base = result6 as i32 + (i as i32) * 20; - { - let FunctionInvocationRequest{ id:id3, function_id:function_id3, value:value3, } = e; - *((base + 0) as *mut i32) = wit_bindgen::rt::Resource::into_handle(id3) as i32; - let vec4 = (function_id3.into_bytes()).into_boxed_slice(); - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - ::core::mem::forget(vec4); - *((base + 8) as *mut i32) = len4; - *((base + 4) as *mut i32) = ptr4; - let vec5 = (value3).into_boxed_slice(); - let ptr5 = vec5.as_ptr() as i32; - let len5 = vec5.len() as i32; - ::core::mem::forget(vec5); - *((base + 16) as *mut i32) = len5; - *((base + 12) as *mut i32) = ptr5; - } - } - *((ptr2 + 4) as *mut i32) = len6; - *((ptr2 + 0) as *mut i32) = result6 as i32; - ptr2 - } - - const _: () = { - #[doc(hidden)] - #[export_name = "cabi_post_component:pulumi-wasm/function-reverse-callback@0.1.0#get-functions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __post_return_get_functions(arg0: i32,) { - let l5 = *((arg0 + 0) as *const i32); - let l6 = *((arg0 + 4) as *const i32); - let base7 = l5; - let len7 = l6; - for i in 0..len7 { - let base = base7 + i *20; - { - let l0 = *((base + 4) as *const i32); - let l1 = *((base + 8) as *const i32); - wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); - let l2 = *((base + 12) as *const i32); - let l3 = *((base + 16) as *const i32); - let base4 = l2; - let len4 = l3; - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 1, 1); - } - } - wit_bindgen::rt::dealloc(base7, (len7 as usize) * 20, 4); - } - }; - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/function-reverse-callback@0.1.0#set-functions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_set_functions(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 base4 = arg0; - let len4 = arg1; - let mut result4 = Vec::with_capacity(len4 as usize); - for i in 0..len4 { - let base = base4 + i * 12; - let e4 = { - let l0 = *((base + 0) as *const i32); - let l1 = *((base + 4) as *const i32); - let l2 = *((base + 8) as *const i32); - let len3 = l2 as usize; - - FunctionInvocationResult{ - id: wit_bindgen::rt::Resource::::lift_borrow(l0 as u32 as usize), - value: Vec::from_raw_parts(l1 as *mut _, len3, len3), + } + + 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), } - }; - result4.push(e4); } - wit_bindgen::rt::dealloc(base4, (len4 as usize) * 12, 4); - <_GuestImpl as Guest>::set_functions(result4); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn get_functions(source: wit_bindgen::rt::string::String,) -> wit_bindgen::rt::vec::Vec::; - fn set_functions(results: 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]); - - } - } - } + pub use alloc_crate::boxed::Box; + 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; + 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_pulumi_wasm_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::component::pulumi_wasm::output_interface::__export_component_pulumi_wasm_output_interface_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::pulumi_wasm::output_interface); + $($path_to_types_root)*::exports::component::pulumi_wasm::register_interface::__export_component_pulumi_wasm_register_interface_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::pulumi_wasm::register_interface); + $($path_to_types_root)*::exports::component::pulumi_wasm::function_reverse_callback::__export_component_pulumi_wasm_function_reverse_callback_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::pulumi_wasm::function_reverse_callback); + ) +} +#[doc(inline)] +pub(crate) use __export_pulumi_wasm_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:pulumi-wasm"] +#[link_section = "component-type:wit-bindgen:0.20.0:pulumi-wasm:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1018] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 249, 6, 1, 65, 2, 1, 65, 9, 1, 66, 3, 1, 112, 125, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 0, 0, 0, 4, 0, 17, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 1, 1, 3, 1, 42, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 101, 120, 116, 101, 114, 110, 97, 108, 45, 119, 111, 114, 108, 100, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 4, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 1, 2, 3, 0, 1, 6, 111, 117, 116, 112, 117, 116, 1, 66, 11, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 1, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 12, 111, 98, 106, 101, 99, 116, 45, 102, 105, 101, 108, 100, 3, 0, 3, 1, 112, 115, 1, 112, 4, 1, 114, 4, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 12, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 5, 6, 111, 98, 106, 101, 99, 116, 6, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 7, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 8, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 9, 4, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 105, 1, 1, 112, 125, 1, 114, 3, 2, 105, 100, 2, 11, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 100, 115, 5, 118, 97, 108, 117, 101, 3, 4, 0, 27, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 4, 1, 104, 1, 1, 114, 2, 2, 105, 100, 6, 5, 118, 97, 108, 117, 101, 3, 4, 0, 26, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 1, 112, 5, 1, 64, 1, 6, 115, 111, 117, 114, 99, 101, 115, 0, 9, 4, 0, 13, 103, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 10, 1, 112, 8, 1, 64, 1, 7, 114, 101, 115, 117, 108, 116, 115, 11, 1, 0, 4, 0, 13, 115, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 12, 4, 1, 53, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 102, 117, 110, 99, 116, 105, 111, 110, 45, 114, 101, 118, 101, 114, 115, 101, 45, 99, 97, 108, 108, 98, 97, 99, 107, 64, 48, 46, 49, 46, 48, 5, 4, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 3, 0, 0, 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, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1019] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf9\x06\x01A\x02\x01\ +A\x09\x01B\x03\x01p}\x01@\x01\x07request\0\0\0\x04\0\x11register-resource\x01\x01\ +\x03\x01*component:pulumi-wasm/external-world@0.1.0\x05\0\x01B\x11\x04\0\x06outp\ +ut\x03\x01\x01p}\x01i\0\x01@\x01\x05value\x01\0\x02\x04\0\x13[constructor]output\ +\x01\x03\x01h\0\x01@\x02\x04self\x04\x0dfunction-names\0\x02\x04\0\x12[method]ou\ +tput.map\x01\x05\x01k\x01\x01@\x01\x04self\x04\0\x06\x04\0\x12[method]output.get\ +\x01\x07\x01@\x01\x04self\x04\0\x02\x04\0\x18[method]output.duplicate\x01\x08\x01\ +o\x02s\x04\x01p\x09\x01@\x01\x06fields\x0a\0\x02\x04\0\x0dcreate-struct\x01\x0b\x04\ +\x01,component:pulumi-wasm/output-interface@0.1.0\x05\x01\x02\x03\0\x01\x06outpu\ +t\x01B\x0b\x02\x03\x02\x01\x02\x04\0\x06output\x03\0\0\x01h\x01\x01r\x01\x06obje\ +ct\x02\x04\0\x0cobject-field\x03\0\x03\x01ps\x01p\x04\x01r\x04\x04types\x04names\ +\x0cobject-names\x05\x06object\x06\x04\0\x19register-resource-request\x03\0\x07\x01\ +@\x01\x07request\x08\x01\0\x04\0\x08register\x01\x09\x04\x01.component:pulumi-wa\ +sm/register-interface@0.1.0\x05\x03\x01B\x0f\x02\x03\x02\x01\x02\x04\0\x06output\ +\x03\0\0\x01i\x01\x01p}\x01r\x03\x02id\x02\x0bfunction-ids\x05value\x03\x04\0\x1b\ +function-invocation-request\x03\0\x04\x01h\x01\x01r\x02\x02id\x06\x05value\x03\x04\ +\0\x1afunction-invocation-result\x03\0\x07\x01p\x05\x01@\x01\x06sources\0\x09\x04\ +\0\x0dget-functions\x01\x0a\x01p\x08\x01@\x01\x07results\x0b\x01\0\x04\0\x0dset-\ +functions\x01\x0c\x04\x015component:pulumi-wasm/function-reverse-callback@0.1.0\x05\ +\x04\x04\x01'component:pulumi-wasm/pulumi-wasm@0.1.0\x04\0\x0b\x11\x01\0\x0bpulu\ +mi-wasm\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.20\ +1.0\x10wit-bindgen-rust\x060.20.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/pulumi_wasm/src/lib.rs b/pulumi_wasm/src/lib.rs index 7e9983f09..cdfb16982 100644 --- a/pulumi_wasm/src/lib.rs +++ b/pulumi_wasm/src/lib.rs @@ -9,12 +9,13 @@ use bindings::component::pulumi_wasm::external_world; use crate::bindings::exports::component::pulumi_wasm::function_reverse_callback::{ FunctionInvocationRequest, FunctionInvocationResult, }; -use crate::bindings::exports::component::pulumi_wasm::output_interface::{GuestOutput, OwnOutput}; +use crate::bindings::exports::component::pulumi_wasm::output_interface::{GuestOutput}; use crate::bindings::exports::component::pulumi_wasm::register_interface::{ObjectField, RegisterResourceRequest}; use crate::bindings::exports::component::pulumi_wasm::{ function_reverse_callback, output_interface, register_interface, }; use crate::output::{access_map, FunctionId, FunctionSource, OutputContent}; +bindings::export!(Component with_types_in bindings); mod bindings; mod grpc; @@ -23,10 +24,12 @@ mod output; struct Component; impl output_interface::Guest for Component { - fn create_struct(_fields: Vec<(String, &Output)>) -> OwnOutput { + type Output = Output; + + fn create_struct(_fields: Vec<(String, output_interface::OutputBorrow<'_>)>) -> output_interface::Output { //FIXME let cell = output::create_nothing(); - OwnOutput::new(Output { output: cell, tags: vec![] }) + output_interface::Output::new(Output { output: cell, tags: vec![] }) // todo!() // let mut field_names = vec![]; // let mut field_values = vec![]; @@ -89,11 +92,11 @@ impl GuestOutput for Output { Output { output: cell, tags: vec![] } } - fn map(&self, function_name: String) -> OwnOutput { + fn map(&self, function_name: String) -> output_interface::Output { let function_id = FunctionId::from_string(&function_name); let function_source = FunctionSource::from_str("source"); let output = output::map_external(function_id, function_source, self.output.clone()); - OwnOutput::new(Output { output, tags: vec![] }) + output_interface::Output::new(Output { output, tags: vec![] }) } fn get(&self) -> Option> { @@ -112,8 +115,8 @@ impl GuestOutput for Output { } } - fn duplicate(&self) -> OwnOutput { - OwnOutput::new(Output { + fn duplicate(&self) -> output_interface::Output { + output_interface::Output::new(Output { output: self.output.clone(), tags: self.tags.clone(), }) @@ -187,7 +190,7 @@ impl function_reverse_callback::Guest for Component { let mut vec = vec![]; rmpv::encode::write_value(&mut vec, v).unwrap(); Some(FunctionInvocationRequest { - id: OwnOutput::new(Output { output: f.clone(), tags: vec![] }), + id: output_interface::Output::new(Output { output: f.clone(), tags: vec![] }), function_id: id.get(), value: vec, }) @@ -209,7 +212,7 @@ impl function_reverse_callback::Guest for Component { fn set_functions(results: Vec) { for x in results { let value = rmpv::decode::read_value(&mut x.value.as_slice()).unwrap(); - let borrowed = &x.id.output; + let borrowed = &x.id.get::().output; borrowed.replace(OutputContent::Done(value)); } } @@ -233,8 +236,8 @@ impl register_interface::Guest for Component { let s: String = "length".to_string(); // let s: String = String::from_utf8(name.clone()).unwrap(); - let v = match &*object.object.output.borrow() { - OutputContent::Done(vec) => messagepack_to_protoc(vec), + let v = match &*object.object.get::().output.borrow() { + OutputContent::Done(vec) => messagepack_to_protoc(&vec), OutputContent::Mapped(_, _, _) => todo!(), OutputContent::Func(_, _) => todo!(), OutputContent::Nothing => todo!() diff --git a/pulumi_wasm/tests/test.rs b/pulumi_wasm/tests/test.rs index f17c723d9..1dd94f324 100644 --- a/pulumi_wasm/tests/test.rs +++ b/pulumi_wasm/tests/test.rs @@ -48,19 +48,11 @@ impl server::component::pulumi_wasm::external_world::Host for MyState { } impl WasiView for SimplePluginCtx { - fn table(&self) -> &ResourceTable { - &self.table - } - - fn table_mut(&mut self) -> &mut ResourceTable { + fn table(&mut self) -> &mut ResourceTable { &mut self.table } - fn ctx(&self) -> &WasiCtx { - &self.context - } - - fn ctx_mut(&mut self) -> &mut WasiCtx { + fn ctx(&mut self) -> &mut WasiCtx { &mut self.context } } diff --git a/pulumi_wasm_main/Cargo.toml b/pulumi_wasm_main/Cargo.toml index c231194ea..91ad797fd 100644 --- a/pulumi_wasm_main/Cargo.toml +++ b/pulumi_wasm_main/Cargo.toml @@ -16,7 +16,8 @@ uuid.workspace = true futures.workspace = true lazy_static.workspace = true once_cell.workspace = true -wit-bindgen.workspace = true +bitflags.workspace = true +wit-bindgen-rt.workspace = true rmp.workspace = true rmp-serde.workspace = true rmpv.workspace = true diff --git a/pulumi_wasm_main/src/bindings.rs b/pulumi_wasm_main/src/bindings.rs index cfd298b73..2f5e86147 100644 --- a/pulumi_wasm_main/src/bindings.rs +++ b/pulumi_wasm_main/src/bindings.rs @@ -1,341 +1,487 @@ -// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT! +// Options used: pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod output_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Output{ - handle: wit_bindgen::rt::Resource, - } - - impl Output{ - #[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 Output{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]output"] - fn drop(_: u32); + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod output_interface { + #[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(Debug)] + #[repr(transparent)] + pub struct Output { + handle: _rt::Resource, } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - pub fn create_struct(fields: &[(wit_bindgen::rt::string::String,&Output,)],) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec2 = fields; - 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); + + impl Output { + #[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) + } } - 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; + + unsafe impl _rt::WasmResource for Output { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]output"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - } - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "create-struct"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(result2 as i32, len2); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - Output::from_handle(ret as u32) - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn new(value: &[u8],) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = value; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[constructor]output"] - fn wit_import(_: i32, _: i32, ) -> i32; + + #[allow(unused_unsafe, clippy::all)] + pub fn create_struct(fields: &[(_rt::String, &Output)]) -> Output { + unsafe { + let vec2 = fields; + 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() + } + }; + 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; + } + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "create-struct"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(result2, len2); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + Output::from_handle(ret as u32) + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr0, len0); - Output::from_handle(ret as u32) - } - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn map(&self,function_name: &str,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.map"] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32; + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn new(value: &[u8]) -> Self { + unsafe { + let vec0 = value; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[constructor]output"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr0.cast_mut(), len0); + Output::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0, len0); - Output::from_handle(ret as u32) - } - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.get"] - fn wit_import(_: i32, _: i32, ); + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn map(&self, function_name: &str) -> Output { + unsafe { + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.map"] + 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); + Output::from_handle(ret as u32) + } + } } - - #[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; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self) -> Output { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } } - } } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn duplicate(&self,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(clippy::all)] + pub mod pulumi_provider_random_interface { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.duplicate"] - fn wit_import(_: i32, ) -> i32; + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output; + pub struct RandomStringArgs<'a> { + pub name: _rt::String, + pub length: &'a Output, + } + impl<'a> ::core::fmt::Debug for RandomStringArgs<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RandomStringArgs") + .field("name", &self.name) + .field("length", &self.length) + .finish() + } + } + #[allow(unused_unsafe, clippy::all)] + /// create-random-string: func(args: random-string-args) -> random-string-result; + pub fn create_random_string(args: &RandomStringArgs<'_>) { + unsafe { + let RandomStringArgs { + name: name0, + length: length0, + } = args; + let vec1 = name0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0" + )] + extern "C" { + #[link_name = "create-random-string"] + fn wit_import(_: *mut u8, _: usize, _: i32); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32) { + unreachable!() + } + wit_import(ptr1.cast_mut(), len1, (length0).handle() as i32); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn handle_functions() { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link( + wasm_import_module = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0" + )] + extern "C" { + #[link_name = "handle-functions"] + fn wit_import(); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() { + unreachable!() + } + wit_import(); + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Output::from_handle(ret as u32) - } } - } - } - - - #[allow(clippy::all)] - pub mod pulumi_provider_random_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output; - pub struct RandomStringArgs<'a,> { - pub name: wit_bindgen::rt::string::String, - pub length: &'a Output, - } - impl<'a,> ::core::fmt::Debug for RandomStringArgs<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RandomStringArgs").field("name", &self.name).field("length", &self.length).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - /// create-random-string: func(args: random-string-args) -> random-string-result; - pub fn create_random_string(args: RandomStringArgs<'_,>,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RandomStringArgs{ name:name0, length:length0, } = args; - let vec1 = name0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0")] - extern "C" { - #[link_name = "create-random-string"] - fn wit_import(_: i32, _: i32, _: i32, ); +} +pub mod exports { + pub mod component { + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod pulumi_main { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_main_cabi() { + T::main(); + } + pub trait Guest { + fn main(); + } + #[doc(hidden)] + + macro_rules! __export_component_pulumi_wasm_pulumi_main_0_1_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + + #[export_name = "component:pulumi-wasm/pulumi-main@0.1.0#main"] + unsafe extern "C" fn export_main() { + $($path_to_types)*::_export_main_cabi::<$ty>() } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr1, len1, (length0).handle() as i32); - } + };); } - #[allow(unused_unsafe, clippy::all)] - pub fn handle_functions(){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0")] - extern "C" { - #[link_name = "handle-functions"] - fn wit_import(); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(){ unreachable!() } - wit_import(); + #[doc(hidden)] + pub(crate) use __export_component_pulumi_wasm_pulumi_main_0_1_0_cabi; + } } - } - } - - } } -pub mod exports { - pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod pulumi_main { - #[used] +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. + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/pulumi-main@0.1.0#main"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_main() { - #[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>::main(); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn main(); + 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::alloc; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + 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_new_main_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::component::pulumi_wasm::pulumi_main::__export_component_pulumi_wasm_pulumi_main_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::pulumi_wasm::pulumi_main); + ) } +#[doc(inline)] +pub(crate) use __export_new_main_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:new-main"] +#[link_section = "component-type:wit-bindgen:0.20.0:new-main:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 797] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 159, 5, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 16, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 3, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 7, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 9, 6, 114, 101, 115, 117, 108, 116, 9, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 1, 64, 1, 4, 97, 114, 103, 115, 8, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 12, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 13, 3, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 2, 1, 64, 0, 1, 0, 4, 0, 4, 109, 97, 105, 110, 1, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 36, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 110, 101, 119, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 4, 0, 11, 14, 1, 0, 8, 110, 101, 119, 45, 109, 97, 105, 110, 3, 0, 0, 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, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 798] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x9f\x05\x01A\x02\x01\ +A\x07\x01B\x11\x04\0\x06output\x03\x01\x01p}\x01i\0\x01@\x01\x05value\x01\0\x02\x04\ +\0\x13[constructor]output\x01\x03\x01h\0\x01@\x02\x04self\x04\x0dfunction-names\0\ +\x02\x04\0\x12[method]output.map\x01\x05\x01k\x01\x01@\x01\x04self\x04\0\x06\x04\ +\0\x12[method]output.get\x01\x07\x01@\x01\x04self\x04\0\x02\x04\0\x18[method]out\ +put.duplicate\x01\x08\x01o\x02s\x04\x01p\x09\x01@\x01\x06fields\x0a\0\x02\x04\0\x0d\ +create-struct\x01\x0b\x03\x01,component:pulumi-wasm/output-interface@0.1.0\x05\0\ +\x02\x03\0\0\x06output\x01B\x10\x02\x03\x02\x01\x01\x04\0\x06output\x03\0\0\x01k\ +y\x01h\x01\x01k\x03\x01q\x02\x07literal\x01\x02\0\x03res\x01\x04\0\x04\0\x0aeith\ +er-u32\x03\0\x05\x01r\x02\x04names\x06length\x03\x04\0\x12random-string-args\x03\ +\0\x07\x01i\x01\x01r\x02\x03url\x09\x06result\x09\x04\0\x14random-string-result\x03\ +\0\x0a\x01@\x01\x04args\x08\x01\0\x04\0\x14create-random-string\x01\x0c\x01@\0\x01\ +\0\x04\0\x10handle-functions\x01\x0d\x03\x01(output: Output) -> output_interface::Output { unsafe { let inner = output.get_inner(); let cloned = inner.duplicate(); - pulumi_provider_random_interface::Output::from_handle(cloned.into_handle()) + pulumi_provider_random_interface::Output::from_handle(cloned.take_handle()) } } \ No newline at end of file diff --git a/pulumi_wasm_random/Cargo.toml b/pulumi_wasm_random/Cargo.toml index fb7b323ec..be13b650c 100644 --- a/pulumi_wasm_random/Cargo.toml +++ b/pulumi_wasm_random/Cargo.toml @@ -16,7 +16,8 @@ uuid.workspace = true futures.workspace = true lazy_static.workspace = true once_cell.workspace = true -wit-bindgen.workspace = true +bitflags.workspace = true +wit-bindgen-rt.workspace = true rmp.workspace = true rmp-serde.workspace = true rmpv.workspace = true diff --git a/pulumi_wasm_random/src/bindings.rs b/pulumi_wasm_random/src/bindings.rs index 1ed0b842f..3ea4e8994 100644 --- a/pulumi_wasm_random/src/bindings.rs +++ b/pulumi_wasm_random/src/bindings.rs @@ -1,434 +1,615 @@ -// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT! +// Options used: pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod output_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Output{ - handle: wit_bindgen::rt::Resource, - } - - impl Output{ - #[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 Output{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[resource-drop]output"] - fn drop(_: u32); + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod output_interface { + #[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(Debug)] + #[repr(transparent)] + pub struct Output { + handle: _rt::Resource, } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - pub fn create_struct(fields: &[(wit_bindgen::rt::string::String,&Output,)],) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec2 = fields; - 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); + + impl Output { + #[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) + } } - 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; + + unsafe impl _rt::WasmResource for Output { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]output"] + fn drop(_: u32); + } + + drop(_handle); + } + } } - } - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "create-struct"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(result2 as i32, len2); - if layout2.size() != 0 { - alloc::dealloc(result2, layout2); - } - Output::from_handle(ret as u32) - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn new(value: &[u8],) -> Self{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = value; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[constructor]output"] - fn wit_import(_: i32, _: i32, ) -> i32; + + #[allow(unused_unsafe, clippy::all)] + pub fn create_struct(fields: &[(_rt::String, &Output)]) -> Output { + unsafe { + let vec2 = fields; + 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() + } + }; + 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; + } + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "create-struct"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(result2, len2); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + Output::from_handle(ret as u32) + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr0, len0); - Output::from_handle(ret as u32) - } - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn map(&self,function_name: &str,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let vec0 = function_name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.map"] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32; + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn new(value: &[u8]) -> Self { + unsafe { + let vec0 = value; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[constructor]output"] + fn wit_import(_: *mut u8, _: usize) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import(ptr0.cast_mut(), len0); + Output::from_handle(ret as u32) + } + } } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0, len0); - Output::from_handle(ret as u32) - } - } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.get"] - fn wit_import(_: i32, _: i32, ); + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn map(&self, function_name: &str) -> Output { + unsafe { + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.map"] + 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); + Output::from_handle(ret as u32) + } + } } - - #[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; - - Vec::from_raw_parts(l2 as *mut _, len4, len4) - }; - Some(e) - } - _ => wit_bindgen::rt::invalid_enum_discriminant(), + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn get(&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 = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self) -> Output { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } } - } } - } - impl Output { - #[allow(unused_unsafe, clippy::all)] - pub fn duplicate(&self,) -> Output{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - + + #[allow(clippy::all)] + pub mod register_interface { + #[used] + #[doc(hidden)] #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] - extern "C" { - #[link_name = "[method]output.duplicate"] - fn wit_import(_: i32, ) -> i32; + static __FORCE_SECTION_REF: fn() = + super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output; + pub struct ObjectField<'a> { + /// name: list, //FIXME: String does not work + pub object: &'a Output, } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Output::from_handle(ret as u32) - } - } - } - - } - - - #[allow(clippy::all)] - pub mod register_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output; - pub struct ObjectField<'a,> { - /// name: list, //FIXME: String does not work - pub object: &'a Output, - } - impl<'a,> ::core::fmt::Debug for ObjectField<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ObjectField").field("object", &self.object).finish() - } - } - pub struct RegisterResourceRequest<'a,> { - pub type_: wit_bindgen::rt::string::String, - pub name: wit_bindgen::rt::string::String, - pub object_names: wit_bindgen::rt::vec::Vec::, - pub object: wit_bindgen::rt::vec::Vec::>, - } - impl<'a,> ::core::fmt::Debug for RegisterResourceRequest<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object-names", &self.object_names).field("object", &self.object).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn register(request: RegisterResourceRequest<'_,>,){ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - let RegisterResourceRequest{ type_:type_0, name:name0, object_names:object_names0, object:object0, } = request; - let vec1 = type_0; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - let vec2 = name0; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - let vec4 = object_names0; - 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); + impl<'a> ::core::fmt::Debug for ObjectField<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectField") + .field("object", &self.object) + .finish() + } } - 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; - let ptr3 = vec3.as_ptr() as i32; - let len3 = vec3.len() as i32; - *((base + 4) as *mut i32) = len3; - *((base + 0) as *mut i32) = ptr3; + pub struct RegisterResourceRequest<'a> { + pub type_: _rt::String, + pub name: _rt::String, + pub object_names: _rt::Vec<_rt::String>, + pub object: _rt::Vec>, } - } - let vec6 = object0; - let len6 = vec6.len() as i32; - let layout6 = alloc::Layout::from_size_align_unchecked(vec6.len() * 4, 4); - let result6 = if layout6.size() != 0 - { - let ptr = alloc::alloc(layout6); - if ptr.is_null() - { - alloc::handle_alloc_error(layout6); + impl<'a> ::core::fmt::Debug for RegisterResourceRequest<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RegisterResourceRequest") + .field("type", &self.type_) + .field("name", &self.name) + .field("object-names", &self.object_names) + .field("object", &self.object) + .finish() + } } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec6.into_iter().enumerate() { - let base = result6 as i32 + (i as i32) * 4; - { - let ObjectField{ object:object5, } = e; - *((base + 0) as *mut i32) = (object5).handle() as i32; + #[allow(unused_unsafe, clippy::all)] + pub fn register(request: &RegisterResourceRequest<'_>) { + unsafe { + let RegisterResourceRequest { + type_: type_0, + name: name0, + object_names: object_names0, + object: object0, + } = request; + let vec1 = type_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = name0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let vec4 = object_names0; + 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; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + *base.add(4).cast::() = len3; + *base.add(0).cast::<*mut u8>() = ptr3.cast_mut(); + } + } + let vec6 = object0; + let len6 = vec6.len(); + let layout6 = _rt::alloc::Layout::from_size_align_unchecked(vec6.len() * 4, 4); + let result6 = if layout6.size() != 0 { + let ptr = _rt::alloc::alloc(layout6).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout6); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6.add(i * 4); + { + let ObjectField { object: object5 } = e; + *base.add(0).cast::() = (object5).handle() as i32; + } + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/register-interface@0.1.0")] + extern "C" { + #[link_name = "register"] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + ) { + unreachable!() + } + wit_import( + ptr1.cast_mut(), + len1, + ptr2.cast_mut(), + len2, + result4, + len4, + result6, + len6, + ); + if layout4.size() != 0 { + _rt::alloc::dealloc(result4.cast(), layout4); + } + if layout6.size() != 0 { + _rt::alloc::dealloc(result6.cast(), layout6); + } + } } - } - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "component:pulumi-wasm/register-interface@0.1.0")] - extern "C" { - #[link_name = "register"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr1, len1, ptr2, len2, result4 as i32, len4, result6 as i32, len6); - if layout4.size() != 0 { - alloc::dealloc(result4, layout4); - } - if layout6.size() != 0 { - alloc::dealloc(result6, layout6); - } } - } - } - - } } pub mod exports { - pub mod component { - pub mod pulumi_wasm { - - #[allow(clippy::all)] - pub mod pulumi_provider_random_interface { - #[used] + pub mod component { + pub mod pulumi_wasm { + + #[allow(clippy::all)] + pub mod pulumi_provider_random_interface { + #[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 Output = + super::super::super::super::component::pulumi_wasm::output_interface::Output; + pub struct RandomStringArgs<'a> { + pub name: _rt::String, + pub length: &'a Output, + } + impl<'a> ::core::fmt::Debug for RandomStringArgs<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RandomStringArgs") + .field("name", &self.name) + .field("length", &self.length) + .finish() + } + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_random_string_cabi( + arg0: *mut u8, + arg1: usize, + arg2: i32, + ) { + let handle1; + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + T::create_random_string(RandomStringArgs { + name: _rt::string_lift(bytes0), + length: { + handle1 = super::super::super::super::component::pulumi_wasm::output_interface::Output::from_handle(arg2 as u32); + &handle1 + }, + }); + } + + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_handle_functions_cabi() { + T::handle_functions(); + } + pub trait Guest { + /// create-random-string: func(args: random-string-args) -> random-string-result; + fn create_random_string(args: RandomStringArgs<'_>); + fn handle_functions(); + } + #[doc(hidden)] + + macro_rules! __export_component_pulumi_wasm_pulumi_provider_random_interface_0_1_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + + #[export_name = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0#create-random-string"] + unsafe extern "C" fn export_create_random_string(arg0: *mut u8,arg1: usize,arg2: i32,) { + $($path_to_types)*::_export_create_random_string_cabi::<$ty>(arg0, arg1, arg2) + } + + #[export_name = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0#handle-functions"] + unsafe extern "C" fn export_handle_functions() { + $($path_to_types)*::_export_handle_functions_cabi::<$ty>() + } + };); + } + #[doc(hidden)] + pub(crate) use __export_component_pulumi_wasm_pulumi_provider_random_interface_0_1_0_cabi; + } + } + } +} +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. + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - pub type Output = super::super::super::super::component::pulumi_wasm::output_interface::Output; - pub struct RandomStringArgs<'a,> { - pub name: wit_bindgen::rt::string::String, - pub length: &'a Output, + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } } - impl<'a,> ::core::fmt::Debug for RandomStringArgs<'a,> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RandomStringArgs").field("name", &self.name).field("length", &self.length).finish() - } + + /// 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 = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0#create-random-string"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_create_random_string(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 handle1; - let len0 = arg1 as usize; - let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); - <_GuestImpl as Guest>::create_random_string(RandomStringArgs{ - name: wit_bindgen::rt::string_lift(bytes0), - length: { - - handle1 = super::super::super::super::component::pulumi_wasm::output_interface::Output::from_handle(arg2 as u32); - &handle1 - }, - }); - } - }; - const _: () = { - - #[doc(hidden)] - #[export_name = "component:pulumi-wasm/pulumi-provider-random-interface@0.1.0#handle-functions"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_handle_functions() { - #[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>::handle_functions(); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - /// create-random-string: func(args: random-string-args) -> random-string-result; - fn create_random_string(args: RandomStringArgs,); - fn handle_functions(); + + #[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::alloc; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + 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_pulumi_provider_random_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::component::pulumi_wasm::pulumi_provider_random_interface::__export_component_pulumi_wasm_pulumi_provider_random_interface_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::pulumi_wasm::pulumi_provider_random_interface); + ) +} +#[doc(inline)] +pub(crate) use __export_pulumi_provider_random_impl as export; + #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:pulumi-provider-random"] +#[link_section = "component-type:wit-bindgen:0.20.0:pulumi-provider-random:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 968] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 188, 6, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 11, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 1, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 12, 111, 98, 106, 101, 99, 116, 45, 102, 105, 101, 108, 100, 3, 0, 3, 1, 112, 115, 1, 112, 4, 1, 114, 4, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 12, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 5, 6, 111, 98, 106, 101, 99, 116, 6, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 7, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 8, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 9, 3, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 16, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 3, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 7, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 9, 6, 114, 101, 115, 117, 108, 116, 9, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 1, 64, 1, 4, 97, 114, 103, 115, 8, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 12, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 13, 4, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 50, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 28, 1, 0, 22, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 3, 0, 0, 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, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 969] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbc\x06\x01A\x02\x01\ +A\x07\x01B\x11\x04\0\x06output\x03\x01\x01p}\x01i\0\x01@\x01\x05value\x01\0\x02\x04\ +\0\x13[constructor]output\x01\x03\x01h\0\x01@\x02\x04self\x04\x0dfunction-names\0\ +\x02\x04\0\x12[method]output.map\x01\x05\x01k\x01\x01@\x01\x04self\x04\0\x06\x04\ +\0\x12[method]output.get\x01\x07\x01@\x01\x04self\x04\0\x02\x04\0\x18[method]out\ +put.duplicate\x01\x08\x01o\x02s\x04\x01p\x09\x01@\x01\x06fields\x0a\0\x02\x04\0\x0d\ +create-struct\x01\x0b\x03\x01,component:pulumi-wasm/output-interface@0.1.0\x05\0\ +\x02\x03\0\0\x06output\x01B\x0b\x02\x03\x02\x01\x01\x04\0\x06output\x03\0\0\x01h\ +\x01\x01r\x01\x06object\x02\x04\0\x0cobject-field\x03\0\x03\x01ps\x01p\x04\x01r\x04\ +\x04types\x04names\x0cobject-names\x05\x06object\x06\x04\0\x19register-resource-\ +request\x03\0\x07\x01@\x01\x07request\x08\x01\0\x04\0\x08register\x01\x09\x03\x01\ +.component:pulumi-wasm/register-interface@0.1.0\x05\x02\x01B\x10\x02\x03\x02\x01\ +\x01\x04\0\x06output\x03\0\0\x01ky\x01h\x01\x01k\x03\x01q\x02\x07literal\x01\x02\ +\0\x03res\x01\x04\0\x04\0\x0aeither-u32\x03\0\x05\x01r\x02\x04names\x06length\x03\ +\x04\0\x12random-string-args\x03\0\x07\x01i\x01\x01r\x02\x03url\x09\x06result\x09\ +\x04\0\x14random-string-result\x03\0\x0a\x01@\x01\x04args\x08\x01\0\x04\0\x14cre\ +ate-random-string\x01\x0c\x01@\0\x01\0\x04\0\x10handle-functions\x01\x0d\x04\x01\ +