From bb1ef3e8ef48e3b73c1b7b8aa97bc70bf4e17a97 Mon Sep 17 00:00:00 2001 From: Rohan Krishnaswamy <47869999+rkrishn7@users.noreply.github.com> Date: Tue, 5 Mar 2024 00:07:15 -0800 Subject: [PATCH] chore: bump wit-bindgen to v0.21.0 (#88) --- Cargo.lock | 147 ++++++++++++++++++++------ examples/authenticate-http/Cargo.lock | 51 +++++---- examples/intercept-simple/Cargo.lock | 50 +++++---- src/kiwi-sdk/Cargo.toml | 2 +- src/kiwi-sdk/macro/src/lib.rs | 70 ++++++------ src/kiwi-sdk/src/lib.rs | 2 + 6 files changed, 207 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8ea0a2..e59f8f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,7 +484,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser", + "wasmparser 0.121.0", "wasmtime-types", ] @@ -1146,7 +1146,7 @@ dependencies = [ "wasmtime-wasi", "wasmtime-wasi-http", "wat", - "wit-component", + "wit-component 0.20.1", ] [[package]] @@ -2344,6 +2344,15 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-metadata" version = "0.10.17" @@ -2356,8 +2365,24 @@ dependencies = [ "serde_derive", "serde_json", "spdx", - "wasm-encoder", - "wasmparser", + "wasm-encoder 0.41.0", + "wasmparser 0.121.0", +] + +[[package]] +name = "wasm-metadata" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", ] [[package]] @@ -2371,6 +2396,17 @@ dependencies = [ "semver", ] +[[package]] +name = "wasmparser" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +dependencies = [ + "bitflags 2.4.1", + "indexmap", + "semver", +] + [[package]] name = "wasmprinter" version = "0.2.78" @@ -2378,7 +2414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e32c13c59fdc64d3f6998a1d52eb1d362b6904a88b754190ccb85661ad577a" dependencies = [ "anyhow", - "wasmparser", + "wasmparser 0.121.0", ] [[package]] @@ -2409,8 +2445,8 @@ dependencies = [ "serde_derive", "serde_json", "target-lexicon", - "wasm-encoder", - "wasmparser", + "wasm-encoder 0.41.0", + "wasmparser 0.121.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -2466,7 +2502,7 @@ dependencies = [ "syn 2.0.48", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser", + "wit-parser 0.13.1", ] [[package]] @@ -2494,7 +2530,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser", + "wasmparser 0.121.0", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -2535,8 +2571,8 @@ dependencies = [ "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder", - "wasmparser", + "wasm-encoder 0.41.0", + "wasmparser 0.121.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2600,7 +2636,7 @@ dependencies = [ "psm", "rustix", "sptr", - "wasm-encoder", + "wasm-encoder 0.41.0", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", @@ -2620,7 +2656,7 @@ dependencies = [ "serde", "serde_derive", "thiserror", - "wasmparser", + "wasmparser 0.121.0", ] [[package]] @@ -2701,7 +2737,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser", + "wasmparser 0.121.0", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2716,7 +2752,7 @@ dependencies = [ "anyhow", "heck", "indexmap", - "wit-parser", + "wit-parser 0.13.1", ] [[package]] @@ -2744,7 +2780,7 @@ dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder", + "wasm-encoder 0.41.0", ] [[package]] @@ -2847,7 +2883,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser", + "wasmparser 0.121.0", "wasmtime-environ", ] @@ -3004,43 +3040,50 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "dbdedb8dd38c89c2cfa71e7450515f1c17f94cc2853881652d005b10f3f2559c" dependencies = [ "bitflags 2.4.1", + "wit-bindgen-rt", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d22547a645a7d3e4311b977a34f12e1d47df48125dc06e11e45984c99282ed" +checksum = "4ebcbf07363368a9e6e8b89c18bff176c4f35ed2dd2f2f5f9c473bb56813369b" dependencies = [ "anyhow", - "wit-component", - "wit-parser", + "wit-parser 0.201.0", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "026d24a27f6712541fa534f2954bd9e0eb66172f033c2157c0f31d106255c497" + [[package]] name = "wit-bindgen-rust" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a691b95d07cc4e7f7aa259b480f7f0208c4ded49406fd4f8bfd5a5a61c5db1" +checksum = "a2a4d36bf13b5ef534599d24dae792b1ae2b40fe1248c2754fd3f7343fb2ca70" dependencies = [ "anyhow", "heck", - "wasm-metadata", + "indexmap", + "wasm-metadata 0.201.0", "wit-bindgen-core", - "wit-component", + "wit-component 0.201.0", ] [[package]] name = "wit-bindgen-rust-macro" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763cc6195d4ede622e5388051e381d397930016c8dc2f1199d3b48eb26781b6a" +checksum = "bf4bf1b15b5227d1ca9ba7fc6a7850c72f9df0fbac3c46a0855763cc454ff11a" dependencies = [ "anyhow", "proc-macro2", @@ -3048,7 +3091,6 @@ dependencies = [ "syn 2.0.48", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component", ] [[package]] @@ -3064,10 +3106,29 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", + "wasm-encoder 0.41.0", + "wasm-metadata 0.10.17", + "wasmparser 0.121.0", + "wit-parser 0.13.1", +] + +[[package]] +name = "wit-component" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" +dependencies = [ + "anyhow", + "bitflags 2.4.1", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder 0.201.0", + "wasm-metadata 0.201.0", + "wasmparser 0.201.0", + "wit-parser 0.201.0", ] [[package]] @@ -3087,6 +3148,24 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "wit-parser" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser 0.201.0", +] + [[package]] name = "witx" version = "0.9.1" diff --git a/examples/authenticate-http/Cargo.lock b/examples/authenticate-http/Cargo.lock index a100fcf..38fcf22 100644 --- a/examples/authenticate-http/Cargo.lock +++ b/examples/authenticate-http/Cargo.lock @@ -92,7 +92,7 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "kiwi-macro" -version = "0.1.1-alpha.6" +version = "0.1.1-alpha.7" dependencies = [ "proc-macro2", "quote", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "kiwi-sdk" -version = "0.1.1-alpha.6" +version = "0.1.1-alpha.7" dependencies = [ "anyhow", "http", @@ -239,18 +239,18 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "wasm-encoder" -version = "0.41.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09bca7d6388637d27fb5edbeab11f56bfabcef8743c55ae34370e1e5030a071" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.10.17" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c853d3809fc9fccf3bc0ad63f4f51d8eefad0bacf88f957aa991c1d9b88b016e" +checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" dependencies = [ "anyhow", "indexmap", @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.121.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953cf6a7606ab31382cb1caa5ae403e77ba70c7f8e12eeda167e7040d42bfda8" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ "bitflags", "indexmap", @@ -275,33 +275,40 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" +checksum = "dbdedb8dd38c89c2cfa71e7450515f1c17f94cc2853881652d005b10f3f2559c" dependencies = [ "bitflags", + "wit-bindgen-rt", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d22547a645a7d3e4311b977a34f12e1d47df48125dc06e11e45984c99282ed" +checksum = "4ebcbf07363368a9e6e8b89c18bff176c4f35ed2dd2f2f5f9c473bb56813369b" dependencies = [ "anyhow", - "wit-component", "wit-parser", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "026d24a27f6712541fa534f2954bd9e0eb66172f033c2157c0f31d106255c497" + [[package]] name = "wit-bindgen-rust" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a691b95d07cc4e7f7aa259b480f7f0208c4ded49406fd4f8bfd5a5a61c5db1" +checksum = "a2a4d36bf13b5ef534599d24dae792b1ae2b40fe1248c2754fd3f7343fb2ca70" dependencies = [ "anyhow", "heck", + "indexmap", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -309,9 +316,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.17.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763cc6195d4ede622e5388051e381d397930016c8dc2f1199d3b48eb26781b6a" +checksum = "bf4bf1b15b5227d1ca9ba7fc6a7850c72f9df0fbac3c46a0855763cc454ff11a" dependencies = [ "anyhow", "proc-macro2", @@ -319,14 +326,13 @@ dependencies = [ "syn 2.0.48", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component", ] [[package]] name = "wit-component" -version = "0.20.1" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "331de496d439010797c17637d8002712b9b69110f1669164c09dfa226ad277bb" +checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" dependencies = [ "anyhow", "bitflags", @@ -343,9 +349,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.13.1" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df4913a2219096373fd6512adead1fb77ecdaa59d7fc517972a7d30b12f625be" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" dependencies = [ "anyhow", "id-arena", @@ -356,4 +362,5 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", + "wasmparser", ] diff --git a/examples/intercept-simple/Cargo.lock b/examples/intercept-simple/Cargo.lock index 8fc33a9..4946459 100644 --- a/examples/intercept-simple/Cargo.lock +++ b/examples/intercept-simple/Cargo.lock @@ -90,7 +90,7 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "kiwi-macro" -version = "0.1.1-alpha.6" +version = "0.1.1-alpha.7" dependencies = [ "proc-macro2", "quote", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "kiwi-sdk" -version = "0.1.1-alpha.6" +version = "0.1.1-alpha.7" dependencies = [ "anyhow", "http", @@ -237,18 +237,18 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "wasm-encoder" -version = "0.41.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.10.20" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18ebaa7bd0f9e7a5e5dd29b9a998acf21c4abed74265524dd7e85934597bfb10" +checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" dependencies = [ "anyhow", "indexmap", @@ -262,9 +262,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.121.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ "bitflags", "indexmap", @@ -273,33 +273,40 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.17.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78a762c4fbc1bc0dedf4aaa280ac5ea87e0d3a7ec83487b7b25999a55ec4b73" +checksum = "dbdedb8dd38c89c2cfa71e7450515f1c17f94cc2853881652d005b10f3f2559c" dependencies = [ "bitflags", + "wit-bindgen-rt", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.17.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43cc97e83ffaabab15791f6fe7d7f8c4e1dc670243e460765c2830463d53bcdf" +checksum = "4ebcbf07363368a9e6e8b89c18bff176c4f35ed2dd2f2f5f9c473bb56813369b" dependencies = [ "anyhow", - "wit-component", "wit-parser", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "026d24a27f6712541fa534f2954bd9e0eb66172f033c2157c0f31d106255c497" + [[package]] name = "wit-bindgen-rust" -version = "0.17.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67b2ee0578e3e8be67f1d863b86e5d649bb16d56c85752eef5228967db103e2" +checksum = "a2a4d36bf13b5ef534599d24dae792b1ae2b40fe1248c2754fd3f7343fb2ca70" dependencies = [ "anyhow", "heck", + "indexmap", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -307,9 +314,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.17.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345a07e6740bc71c7da6e95e9547d89c54895b8a93fad9d192b67c1ec8358e32" +checksum = "bf4bf1b15b5227d1ca9ba7fc6a7850c72f9df0fbac3c46a0855763cc454ff11a" dependencies = [ "anyhow", "proc-macro2", @@ -317,14 +324,13 @@ dependencies = [ "syn 2.0.48", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component", ] [[package]] name = "wit-component" -version = "0.21.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be60cd1b2ff7919305301d0c27528d4867bd793afe890ba3837743da9655d91b" +checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" dependencies = [ "anyhow", "bitflags", @@ -341,9 +347,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.14.0" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee4ad7310367bf272507c0c8e0c74a80b4ed586b833f7c7ca0b7588f686f11a" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" dependencies = [ "anyhow", "id-arena", diff --git a/src/kiwi-sdk/Cargo.toml b/src/kiwi-sdk/Cargo.toml index ac99e5e..5e98c10 100644 --- a/src/kiwi-sdk/Cargo.toml +++ b/src/kiwi-sdk/Cargo.toml @@ -11,5 +11,5 @@ description = "The Kiwi SDK allows you to write pluggable modules that hook into [dependencies] anyhow = "1.0.79" kiwi-macro = { version = "~0.1.1-alpha.7", path = "./macro" } -wit-bindgen = "0.17.0" +wit-bindgen = "0.21.0" http = "1.0.0" diff --git a/src/kiwi-sdk/macro/src/lib.rs b/src/kiwi-sdk/macro/src/lib.rs index 135d8a3..22df4ff 100644 --- a/src/kiwi-sdk/macro/src/lib.rs +++ b/src/kiwi-sdk/macro/src/lib.rs @@ -26,28 +26,25 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { quote!( #func mod __kiwi_intercept { - mod preamble { + mod bindings { #![allow(missing_docs)] ::kiwi_sdk::wit_bindgen::generate!({ path: #WIT_PATH, world: "intercept-hook", runtime_path: "::kiwi_sdk::wit_bindgen::rt", - exports: { - world: Kiwi, - } }); - - pub struct Kiwi; } - impl preamble::Guest for preamble::Kiwi { - fn intercept(ctx: self::preamble::kiwi::kiwi::intercept_types::Context) -> self::preamble::kiwi::kiwi::intercept_types::Action { + struct Kiwi; + + impl bindings::Guest for Kiwi { + fn intercept(ctx: self::bindings::kiwi::kiwi::intercept_types::Context) -> self::bindings::kiwi::kiwi::intercept_types::Action { super::#func_name(ctx.into()).into() } } - impl From for ::kiwi_sdk::hook::intercept::Context { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::Context) -> Self { + impl From for ::kiwi_sdk::hook::intercept::Context { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::Context) -> Self { Self { auth: value.auth.map(|raw| { ::kiwi_sdk::hook::intercept::AuthCtx { @@ -60,17 +57,17 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { } } - impl From for ::kiwi_sdk::hook::intercept::EventCtx { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::EventCtx) -> Self { + impl From for ::kiwi_sdk::hook::intercept::EventCtx { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::EventCtx) -> Self { match value { - self::preamble::kiwi::kiwi::intercept_types::EventCtx::Kafka(ctx) => Self::Kafka(ctx.into()), - self::preamble::kiwi::kiwi::intercept_types::EventCtx::Counter(ctx) => Self::Counter(ctx.into()), + self::bindings::kiwi::kiwi::intercept_types::EventCtx::Kafka(ctx) => Self::Kafka(ctx.into()), + self::bindings::kiwi::kiwi::intercept_types::EventCtx::Counter(ctx) => Self::Counter(ctx.into()), } } } - impl From for ::kiwi_sdk::hook::intercept::CounterEventCtx { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::CounterEventCtx) -> Self { + impl From for ::kiwi_sdk::hook::intercept::CounterEventCtx { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::CounterEventCtx) -> Self { Self { source_id: value.source_id, count: value.count, @@ -78,8 +75,8 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { } } - impl From for ::kiwi_sdk::hook::intercept::KafkaEventCtx { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::KafkaEventCtx) -> Self { + impl From for ::kiwi_sdk::hook::intercept::KafkaEventCtx { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::KafkaEventCtx) -> Self { let timestamp: Option = value.timestamp.map(|t| t.try_into().expect("timestamp conversion must not fail")); let partition: i32 = value.partition.try_into().expect("partition conversion must not fail"); let offset: i64 = value.offset.try_into().expect("offset conversion must not fail"); @@ -94,23 +91,23 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { } } - impl From for ::kiwi_sdk::hook::intercept::ConnectionCtx { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::ConnectionCtx) -> Self { + impl From for ::kiwi_sdk::hook::intercept::ConnectionCtx { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::ConnectionCtx) -> Self { match value { - self::preamble::kiwi::kiwi::intercept_types::ConnectionCtx::Websocket(ctx) => Self::WebSocket(ctx.into()), + self::bindings::kiwi::kiwi::intercept_types::ConnectionCtx::Websocket(ctx) => Self::WebSocket(ctx.into()), } } } - impl From for ::kiwi_sdk::hook::intercept::WebSocketConnectionCtx { - fn from(value: self::preamble::kiwi::kiwi::intercept_types::Websocket) -> Self { + impl From for ::kiwi_sdk::hook::intercept::WebSocketConnectionCtx { + fn from(value: self::bindings::kiwi::kiwi::intercept_types::Websocket) -> Self { Self { addr: value.addr, } } } - impl From<::kiwi_sdk::hook::intercept::Action> for self::preamble::kiwi::kiwi::intercept_types::Action { + impl From<::kiwi_sdk::hook::intercept::Action> for self::bindings::kiwi::kiwi::intercept_types::Action { fn from(value: ::kiwi_sdk::hook::intercept::Action) -> Self { match value { ::kiwi_sdk::hook::intercept::Action::Forward => Self::Forward, @@ -120,7 +117,7 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { } } - impl From<::kiwi_sdk::hook::intercept::TransformedPayload> for self::preamble::kiwi::kiwi::intercept_types::TransformedPayload { + impl From<::kiwi_sdk::hook::intercept::TransformedPayload> for self::bindings::kiwi::kiwi::intercept_types::TransformedPayload { fn from(value: ::kiwi_sdk::hook::intercept::TransformedPayload) -> Self { match value { ::kiwi_sdk::hook::intercept::TransformedPayload::Kafka(payload) => Self::Kafka(payload), @@ -128,6 +125,8 @@ pub fn intercept(_attr: TokenStream, item: TokenStream) -> TokenStream { } } } + + bindings::export!(Kiwi with_types_in bindings); } ) .into() @@ -144,15 +143,12 @@ pub fn authenticate(_attr: TokenStream, item: TokenStream) -> TokenStream { quote!( #func mod __kiwi_authenticate { - mod preamble { + mod bindings { #![allow(missing_docs)] ::kiwi_sdk::wit_bindgen::generate!({ path: #WIT_PATH, world: "authenticate-hook", runtime_path: "::kiwi_sdk::wit_bindgen::rt", - exports: { - world: Kiwi, - }, with: { "wasi:http/outgoing-handler@0.2.0": ::kiwi_sdk::wit::wasi::http::outgoing_handler, "wasi:http/types@0.2.0": ::kiwi_sdk::wit::wasi::http::types, @@ -162,17 +158,17 @@ pub fn authenticate(_attr: TokenStream, item: TokenStream) -> TokenStream { "wasi:io/error@0.2.0": ::kiwi_sdk::wit::wasi::io::error, }, }); - - pub struct Kiwi; } - impl preamble::Guest for preamble::Kiwi { - fn authenticate(incoming: self::preamble::kiwi::kiwi::authenticate_types::HttpRequest) -> self::preamble::kiwi::kiwi::authenticate_types::Outcome { + struct Kiwi; + + impl bindings::Guest for Kiwi { + fn authenticate(incoming: self::bindings::kiwi::kiwi::authenticate_types::HttpRequest) -> self::bindings::kiwi::kiwi::authenticate_types::Outcome { super::#func_name(incoming.into()).into() } } - impl From<::kiwi_sdk::hook::authenticate::Outcome> for self::preamble::kiwi::kiwi::authenticate_types::Outcome { + impl From<::kiwi_sdk::hook::authenticate::Outcome> for self::bindings::kiwi::kiwi::authenticate_types::Outcome { fn from(value: ::kiwi_sdk::hook::authenticate::Outcome) -> Self { match value { ::kiwi_sdk::hook::authenticate::Outcome::Authenticate => Self::Authenticate, @@ -182,8 +178,8 @@ pub fn authenticate(_attr: TokenStream, item: TokenStream) -> TokenStream { } } - impl From for ::kiwi_sdk::http::Request<()> { - fn from(value: self::preamble::kiwi::kiwi::authenticate_types::HttpRequest) -> Self { + impl From for ::kiwi_sdk::http::Request<()> { + fn from(value: self::bindings::kiwi::kiwi::authenticate_types::HttpRequest) -> Self { let mut uri_builder = ::kiwi_sdk::http::Uri::builder(); if let Some(scheme) = value.scheme { @@ -230,6 +226,8 @@ pub fn authenticate(_attr: TokenStream, item: TokenStream) -> TokenStream { request_builder.body(()).expect("failed to build request") } } + + bindings::export!(Kiwi with_types_in bindings); } ) .into() diff --git a/src/kiwi-sdk/src/lib.rs b/src/kiwi-sdk/src/lib.rs index 22c86d7..10eebcd 100644 --- a/src/kiwi-sdk/src/lib.rs +++ b/src/kiwi-sdk/src/lib.rs @@ -53,6 +53,8 @@ pub mod hook; #[doc(hidden)] pub mod wit { #![allow(missing_docs)] + #![allow(clippy::missing_safety_doc)] + #![allow(clippy::transmute_int_to_bool)] wit_bindgen::generate!({ path: "./wit",