From d9e3323cfa0dc0059b40c0e8ab372a09d07d0ebd Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Mon, 29 Jan 2024 19:44:46 -0500 Subject: [PATCH] chore: update to wasmtime 17, move off cargo-component-bindings: https://github.com/bytecodealliance/cargo-component/commit/5cf73a6e8fee84c12f6f0c13bf74ebe938fa9514 --- Cargo.lock | 158 +++++------ corpus/00-component-instr-command/Cargo.lock | 40 +-- corpus/00-component-instr-command/Cargo.toml | 2 +- .../src/bindings.rs | 210 ++++++++++++++ corpus/00-component-instr-command/src/main.rs | 3 +- .../01-component-instr-component/Cargo.lock | 40 +-- .../01-component-instr-component/Cargo.toml | 2 +- .../src/bindings.rs | 266 ++++++++++++++++++ .../01-component-instr-component/src/lib.rs | 2 +- corpus/02-component-instr-combined/Cargo.lock | 58 +--- corpus/02-component-instr-combined/Cargo.toml | 2 +- .../src/bindings.rs | 49 ++++ .../02-component-instr-combined/src/main.rs | 2 +- rust/Cargo.toml | 4 +- rust/examples/otel-stdout-components.rs | 10 +- 15 files changed, 626 insertions(+), 222 deletions(-) create mode 100644 corpus/00-component-instr-command/src/bindings.rs create mode 100644 corpus/01-component-instr-component/src/bindings.rs create mode 100644 corpus/02-component-instr-combined/src/bindings.rs diff --git a/Cargo.lock b/Cargo.lock index 53b63de..01f4c13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,18 +261,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c22542c0b95bd3302f7ed6839869c561f2324bac2fd5e7e99f5cfa65fdc8b92" +checksum = "d819feeda4c420a18f1e28236ca0ce1177b22bf7c8a44ddee92dfe40de15bcf0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3db903ef2e9c8a4de2ea6db5db052c7857282952f9df604aa55d169e6000d8" +checksum = "e9b8d03d5bdbca7e5f72b0e0a0f69933ed1f09e24be6c075aa6fe3f802b0cc0c" dependencies = [ "bumpalo", "cranelift-bforest", @@ -291,33 +291,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6590feb5a1d6438f974bf6a5ac4dddf69fca14e1f07f3265d880f69e61a94463" +checksum = "a3fd3664e38e51649b17dc30cfdd561273fe2f590dcd013fb75d9eabc6272dfb" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7239038c56fafe77fddc8788fc8533dd6c474dc5bdc5637216404f41ba807330" +checksum = "4b031ec5e605828975952622b5a77d49126f20ffe88d33719a0af66b23a0fc36" [[package]] name = "cranelift-control" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7dc9c595341404d381d27a3d950160856b35b402275f0c3990cd1ad683c8053" +checksum = "fada054d017cf2ed8f7ed2336e0517fc1b19e6825be1790de9eb00c94788362b" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e3ee532fc4776c69bcedf7e62f9632cbb3f35776fa9a525cdade3195baa3f7" +checksum = "177b6f94ae8de6348eb45bf977c79ab9e3c40fc3ac8cb7ed8109560ea39bee7d" dependencies = [ "serde", "serde_derive", @@ -325,9 +325,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a612c94d09e653662ec37681dc2d6fd2b9856e6df7147be0afc9aabb0abf19df" +checksum = "ebebd23a69a23e3ddea78e98ff3a2de222e88c8e045d81ef4a72f042e0d79dbd" dependencies = [ "cranelift-codegen", "log", @@ -337,15 +337,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85db9830abeb1170b7d29b536ffd55af1d4d26ac8a77570b5d1aca003bf225cc" +checksum = "1571bfc14df8966d12c6121b5325026591a4b4009e22fea0fe3765ab7cd33b96" [[package]] name = "cranelift-native" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301ef0edafeaeda5771a5d2db64ac53e1818ae3111220a185677025fe91db4a1" +checksum = "35a69c37e0c10b46fe5527f2397ac821046efbf5f7ec112c8b84df25712f465b" dependencies = [ "cranelift-codegen", "libc", @@ -354,9 +354,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.103.0" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380f0abe8264e4570ac615fc31cef32a3b90a77f7eb97b08331f9dd357b1f500" +checksum = "9b3fef8bbceb8cb56d3f1778b0418d75c5cf12ec571a35fc01eb41abb0227a25" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1786,9 +1786,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "154528979a211aa28d969846e883df75705809ed9bcc70aba61460683ea7355b" +checksum = "db014d2ced91f17d1f1a8f2b76d6ea8d731bc1dbc8c2bbaec689d6a242568e5d" dependencies = [ "anyhow", "async-trait", @@ -1804,14 +1804,14 @@ dependencies = [ "system-interface", "tracing", "wasi-common", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasi-common" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d888b611fee7d273dd057dc009d2dd3132736f36710ffd65657ac83628d1e3b" +checksum = "449d17849e3c83a931374442fe2deee4d6bd1ebf469719ef44192e9e82e19c89" dependencies = [ "anyhow", "bitflags 2.4.2", @@ -1824,7 +1824,7 @@ dependencies = [ "tracing", "wasmtime", "wiggle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1942,9 +1942,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e539fded2495422ea3c4dfa7beeddba45904eece182cf315294009e1a323bf" +checksum = "910fabce77e660f0e0e41cfd5f69fc8bf020a025f059718846e918db7177f469" dependencies = [ "anyhow", "async-trait", @@ -1976,23 +1976,23 @@ dependencies = [ "wasmtime-runtime", "wasmtime-winch", "wat", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-asm-macros" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "660ba9143e15a2acd921820df221b73aee256bd3ca2d208d73d8adc9587ccbb9" +checksum = "37288142e9b4a61655a3bcbdc7316c2e4bb9e776b10ce3dd758f8186b4469572" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ce373743892002f9391c6741ef0cb0335b55ec899d874f311222b7e36f4594" +checksum = "45cbd74a636f09d2108f9405c79857f061e19323e4abeed22e837cfe7b08a22b" dependencies = [ "anyhow", "base64", @@ -2004,15 +2004,15 @@ dependencies = [ "serde_derive", "sha2", "toml", - "windows-sys 0.48.0", + "windows-sys 0.52.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ef32643324e564e1c359e9044daa06cbf90d7e2d6c99a738d17a12959f01a5" +checksum = "ad63de18eb42e586386b6091f787c82707cbd5ac5e9343216dba1976190cd03a" dependencies = [ "anyhow", "proc-macro2", @@ -2025,15 +2025,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c87d06c18d21a4818f354c00a85f4ebc62b2270961cd022968452b0e4dbed9d" +checksum = "7e0a160c0c44369aa4bee6d311a8e4366943bab1651040cc8b0fcec2c9eb8906" [[package]] name = "wasmtime-cranelift" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d648c8b4064a7911093b02237cd5569f71ca171d3a0a486bf80600b19e1cba2" +checksum = "3734cc01b7cd37bc62fdbcd9529ca9547440052d4b3886cfdec3b8081a5d3647" dependencies = [ "anyhow", "cfg-if", @@ -2056,9 +2056,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290a89027688782da8ff60b12bb95695494b1874e0d0ba2ba387d23dace6d70c" +checksum = "e0eb33cd30c47844aa228d4d0030587e65c1108343f311fe9f7248b5bd9cb65c" dependencies = [ "anyhow", "cranelift-codegen", @@ -2072,9 +2072,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61eb64fb3e0da883e2df4a13a81d6282e072336e6cb6295021d0f7ab2e352754" +checksum = "9a3a056b041fdea604f0972e2fae97958e7748d629a55180228348baefdfc217" dependencies = [ "anyhow", "cranelift-entity", @@ -2095,9 +2095,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecf1d3a838b0956b71ad3f8cb80069a228339775bf02dd35d86a5a68bbe443" +checksum = "43987d0977c07f15c3608c2f255870c127ffd19e35eeedb1ac1dccedf9932a42" dependencies = [ "anyhow", "cc", @@ -2105,14 +2105,14 @@ dependencies = [ "rustix 0.38.30", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-jit" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f485336add49267d8859e8f8084d2d4b9a4b1564496b6f30ba5b168d50c10ceb" +checksum = "9b3e48395ac672b386ed588d97a9612aa13a345008f26466f0dfb2a91628aa9f" dependencies = [ "addr2line", "anyhow", @@ -2132,14 +2132,14 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-jit-debug" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e119affec40edb2fab9044f188759a00c2df9c3017278d047012a2de1efb4f" +checksum = "dd21fd0f5ca68681d3d5b636eea00f182d0f9d764144469e9257fd7e3f55ae0e" dependencies = [ "object", "once_cell", @@ -2149,20 +2149,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b6d197fcc34ad32ed440e1f9552fd57d1f377d9699d31dee1b5b457322c1f8a" +checksum = "bdc26415bb89e9ccd3bdc498fef63aabf665c4c0dd710c107691deb9694955da" dependencies = [ "cfg-if", "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-runtime" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794b2bb19b99ef8322ff0dd9fe1ba7e19c41036dfb260b3f99ecce128c42ff92" +checksum = "0abddaf17912aabaf39be0802d5eba9a002e956e902d1ebd438a2fe1c88769a2" dependencies = [ "anyhow", "cc", @@ -2185,14 +2185,14 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-versioned-export-macros", "wasmtime-wmemcheck", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-types" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d995db8bb56f2cd8d2dc0ed5ffab94ffb435283b0fe6747f80f7aab40b2d06a1" +checksum = "b35a95cdc1433729085beab42c0a5c742b431f25b17c40d7718e46df63d5ffc7" dependencies = [ "cranelift-entity", "serde", @@ -2203,9 +2203,9 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c5565959287c21dd0f4277ae3518dd2ae62679f655ee2dbc4396e19d210db" +checksum = "fad322733fe67e45743784d8b1df452bcb54f581572a4f1a646a4332deecbcc2" dependencies = [ "proc-macro2", "quote", @@ -2214,9 +2214,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd8370078149d49a3a47e93741553fd79b700421464b6a27ca32718192ab130" +checksum = "902cc299b73655c36679b77efdfce4bb5971992f1a4a8a436dd3809a6848ff0e" dependencies = [ "anyhow", "async-trait", @@ -2244,14 +2244,14 @@ dependencies = [ "wasi-common", "wasmtime", "wiggle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-winch" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6f945ff9bad96e0a69973d74f193c19f627c8adbf250e7cb73ae7564b6cc8a" +checksum = "9e63aeca929f84560eec52c5af43bf5d623b92683b0195d9fb06da8ed860e092" dependencies = [ "anyhow", "cranelift-codegen", @@ -2266,9 +2266,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f328b2d4a690270324756e886ed5be3a4da4c00be0eea48253f4595ad068062b" +checksum = "41e5675998fdc74495afdd90ad2bd221206a258075b23048af0535a969b07893" dependencies = [ "anyhow", "heck", @@ -2278,9 +2278,9 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67761d8f8c0b3c13a5d34356274b10a40baba67fe9cfabbfc379a8b414e45de2" +checksum = "b20a19e10d8cb50b45412fb21192982b7ce85c0122dc33bb71f1813e25dc6e52" [[package]] name = "wast" @@ -2344,9 +2344,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0afb26cd3269289bb314a361ff0a6685e5ce793b62181a9fe3f81ace15051697" +checksum = "737728db69a7657a5f6a7bac445c02d8564d603d62c46c95edf928554e67d072" dependencies = [ "anyhow", "async-trait", @@ -2359,9 +2359,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef2868fed7584d2b552fa317104858ded80021d23b073b2d682d3c932a027bd" +checksum = "2460c7163b79ffefd9a564eaeab0a5b0e84bb91afdfeeb84d36f304ddbe08982" dependencies = [ "anyhow", "heck", @@ -2374,9 +2374,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "16.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ae1ec11a17ea481539ee9a5719a278c9790d974060fbf71db4b2c05378780b" +checksum = "fa8d8412375ba8325d61fbae56dead51dabfaec85d620ce36427922fb9cece83" dependencies = [ "proc-macro2", "quote", @@ -2417,9 +2417,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e58c236a6abdd9ab454552b4f29e16cfa837a86897c1503313b2e62e7609ec" +checksum = "9d2b346bad5397b219b4ff0a8fa7230936061ff07c61f05d589d8d81e06fb7b2" dependencies = [ "anyhow", "cranelift-codegen", diff --git a/corpus/00-component-instr-command/Cargo.lock b/corpus/00-component-instr-command/Cargo.lock index cb56540..6f97c91 100644 --- a/corpus/00-component-instr-command/Cargo.lock +++ b/corpus/00-component-instr-command/Cargo.lock @@ -4,38 +4,17 @@ version = 3 [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "cargo-component-bindings" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545e48ba821e07f93c97aea897bee6d407de4d58947f914160131f3d78b2c704" -dependencies = [ - "cargo-component-macro", - "wit-bindgen", -] - -[[package]] -name = "cargo-component-macro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e198ee0b668e902b43b5e7d2e9620a3891d2632429b3ba66e1ceea455053cbf5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "component-instr-command" version = "0.1.0" dependencies = [ - "cargo-component-bindings", "log", "observe_api", + "wit-bindgen", ] [[package]] @@ -58,7 +37,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -90,17 +69,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "unicode-ident" version = "1.0.12" diff --git a/corpus/00-component-instr-command/Cargo.toml b/corpus/00-component-instr-command/Cargo.toml index a6ad2d7..77e13d9 100644 --- a/corpus/00-component-instr-command/Cargo.toml +++ b/corpus/00-component-instr-command/Cargo.toml @@ -12,6 +12,6 @@ package = "example:component-instr-command" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cargo-component-bindings = "0.6.0" log = "0.4.20" +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} observe_api = { path = "../../observe-api/rust" } diff --git a/corpus/00-component-instr-command/src/bindings.rs b/corpus/00-component-instr-command/src/bindings.rs new file mode 100644 index 0000000..b4052d7 --- /dev/null +++ b/corpus/00-component-instr-command/src/bindings.rs @@ -0,0 +1,210 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +pub mod dylibso { + pub mod observe { + + #[allow(clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum LogLevel { + Error, + Warn, + Info, + Debug, + Trace, + } + impl ::core::fmt::Debug for LogLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + LogLevel::Error => { + f.debug_tuple("LogLevel::Error").finish() + } + LogLevel::Warn => { + f.debug_tuple("LogLevel::Warn").finish() + } + LogLevel::Info => { + f.debug_tuple("LogLevel::Info").finish() + } + LogLevel::Debug => { + f.debug_tuple("LogLevel::Debug").finish() + } + LogLevel::Trace => { + f.debug_tuple("LogLevel::Trace").finish() + } + } + } + } + + impl LogLevel{ + pub(crate) unsafe fn _lift(val: u8) -> LogLevel{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => LogLevel::Error, + 1 => LogLevel::Warn, + 2 => LogLevel::Info, + 3 => LogLevel::Debug, + 4 => LogLevel::Trace, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum MetricFormat { + Statsd, + } + impl ::core::fmt::Debug for MetricFormat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + MetricFormat::Statsd => { + f.debug_tuple("MetricFormat::Statsd").finish() + } + } + } + } + + impl MetricFormat{ + pub(crate) unsafe fn _lift(val: u8) -> MetricFormat{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => MetricFormat::Statsd, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + pub fn metric(format: MetricFormat,name: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "metric"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(format.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn log(level: LogLevel,msg: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = msg; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "log"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(level.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_enter(name: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-enter"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_tags(tags: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = tags; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-tags"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_exit(){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-exit"] + fn wit_import(); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(){ unreachable!() } + wit_import(); + } + } + + } + + } +} + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:component-instr-command"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 454] = [3, 0, 23, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 0, 97, 115, 109, 13, 0, 1, 0, 7, 168, 2, 1, 65, 2, 1, 65, 2, 1, 66, 15, 1, 109, 5, 5, 101, 114, 114, 111, 114, 4, 119, 97, 114, 110, 4, 105, 110, 102, 111, 5, 100, 101, 98, 117, 103, 5, 116, 114, 97, 99, 101, 4, 0, 9, 108, 111, 103, 45, 108, 101, 118, 101, 108, 3, 0, 0, 1, 109, 1, 6, 115, 116, 97, 116, 115, 100, 4, 0, 13, 109, 101, 116, 114, 105, 99, 45, 102, 111, 114, 109, 97, 116, 3, 0, 2, 1, 112, 125, 1, 64, 2, 6, 102, 111, 114, 109, 97, 116, 3, 4, 110, 97, 109, 101, 4, 1, 0, 4, 0, 6, 109, 101, 116, 114, 105, 99, 1, 5, 1, 64, 2, 5, 108, 101, 118, 101, 108, 1, 3, 109, 115, 103, 4, 1, 0, 4, 0, 3, 108, 111, 103, 1, 6, 1, 64, 1, 4, 110, 97, 109, 101, 115, 1, 0, 4, 0, 10, 115, 112, 97, 110, 45, 101, 110, 116, 101, 114, 1, 7, 1, 64, 1, 4, 116, 97, 103, 115, 115, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 116, 97, 103, 115, 1, 8, 1, 64, 0, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 101, 120, 105, 116, 1, 9, 3, 1, 19, 100, 121, 108, 105, 98, 115, 111, 58, 111, 98, 115, 101, 114, 118, 101, 47, 97, 112, 105, 5, 0, 4, 1, 55, 101, 120, 97, 109, 112, 108, 101, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 47, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 4, 0, 11, 29, 1, 0, 23, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/00-component-instr-command/src/main.rs b/corpus/00-component-instr-command/src/main.rs index d4fe238..bc1d43b 100644 --- a/corpus/00-component-instr-command/src/main.rs +++ b/corpus/00-component-instr-command/src/main.rs @@ -1,5 +1,4 @@ -cargo_component_bindings::generate!(); - +mod bindings; use observe_api::*; fn main() { diff --git a/corpus/01-component-instr-component/Cargo.lock b/corpus/01-component-instr-component/Cargo.lock index 57a1369..8810d14 100644 --- a/corpus/01-component-instr-component/Cargo.lock +++ b/corpus/01-component-instr-component/Cargo.lock @@ -4,38 +4,17 @@ version = 3 [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "cargo-component-bindings" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545e48ba821e07f93c97aea897bee6d407de4d58947f914160131f3d78b2c704" -dependencies = [ - "cargo-component-macro", - "wit-bindgen", -] - -[[package]] -name = "cargo-component-macro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e198ee0b668e902b43b5e7d2e9620a3891d2632429b3ba66e1ceea455053cbf5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "component-instr-component" version = "0.1.0" dependencies = [ - "cargo-component-bindings", "log", "observe_api", + "wit-bindgen", ] [[package]] @@ -58,7 +37,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -90,17 +69,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "unicode-ident" version = "1.0.12" diff --git a/corpus/01-component-instr-component/Cargo.toml b/corpus/01-component-instr-component/Cargo.toml index 69a0307..30ab317 100644 --- a/corpus/01-component-instr-component/Cargo.toml +++ b/corpus/01-component-instr-component/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cargo-component-bindings = "0.6.0" log = "0.4.20" +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} observe_api = { path = "../../observe-api/rust" } [lib] diff --git a/corpus/01-component-instr-component/src/bindings.rs b/corpus/01-component-instr-component/src/bindings.rs new file mode 100644 index 0000000..a7ae603 --- /dev/null +++ b/corpus/01-component-instr-component/src/bindings.rs @@ -0,0 +1,266 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +const _: () = { + + #[doc(hidden)] + #[export_name = "hello-world"] + #[allow(non_snake_case)] + unsafe extern "C" fn __export_hello_world() -> i32 { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + + // Before executing any other code, use this function to run all static + // constructors, if they have not yet been run. This is a hack required + // to work around wasi-libc ctors calling import functions to initialize + // the environment. + // + // This functionality will be removed once rust 1.69.0 is stable, at which + // point wasi-libc will no longer have this behavior. + // + // See + // https://github.com/bytecodealliance/preview2-prototyping/issues/99 + // for more details. + #[cfg(target_arch="wasm32")] + wit_bindgen::rt::run_ctors_once(); + + let result0 = <_GuestImpl as Guest>::hello_world(); + let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + ::core::mem::forget(vec2); + *((ptr1 + 4) as *mut i32) = len2; + *((ptr1 + 0) as *mut i32) = ptr2; + ptr1 + } + + const _: () = { + #[doc(hidden)] + #[export_name = "cabi_post_hello-world"] + #[allow(non_snake_case)] + unsafe extern "C" fn __post_return_hello_world(arg0: i32,) { + let l0 = *((arg0 + 0) as *const i32); + let l1 = *((arg0 + 4) as *const i32); + wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + } + }; +}; +use super::Component as _GuestImpl; +pub trait Guest { + fn hello_world() -> wit_bindgen::rt::string::String; +} + +#[allow(unused_imports)] +use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + +#[repr(align(4))] +struct _RetArea([u8; 8]); +static mut _RET_AREA: _RetArea = _RetArea([0; 8]); +pub mod dylibso { + pub mod observe { + + #[allow(clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum LogLevel { + Error, + Warn, + Info, + Debug, + Trace, + } + impl ::core::fmt::Debug for LogLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + LogLevel::Error => { + f.debug_tuple("LogLevel::Error").finish() + } + LogLevel::Warn => { + f.debug_tuple("LogLevel::Warn").finish() + } + LogLevel::Info => { + f.debug_tuple("LogLevel::Info").finish() + } + LogLevel::Debug => { + f.debug_tuple("LogLevel::Debug").finish() + } + LogLevel::Trace => { + f.debug_tuple("LogLevel::Trace").finish() + } + } + } + } + + impl LogLevel{ + pub(crate) unsafe fn _lift(val: u8) -> LogLevel{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => LogLevel::Error, + 1 => LogLevel::Warn, + 2 => LogLevel::Info, + 3 => LogLevel::Debug, + 4 => LogLevel::Trace, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum MetricFormat { + Statsd, + } + impl ::core::fmt::Debug for MetricFormat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + MetricFormat::Statsd => { + f.debug_tuple("MetricFormat::Statsd").finish() + } + } + } + } + + impl MetricFormat{ + pub(crate) unsafe fn _lift(val: u8) -> MetricFormat{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => MetricFormat::Statsd, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + pub fn metric(format: MetricFormat,name: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "metric"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(format.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn log(level: LogLevel,msg: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = msg; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "log"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(level.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_enter(name: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-enter"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_tags(tags: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = tags; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-tags"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_exit(){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-exit"] + fn wit_import(); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(){ unreachable!() } + wit_import(); + } + } + + } + + } +} + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:example"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 508] = [3, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 177, 2, 1, 65, 2, 1, 65, 4, 1, 66, 15, 1, 109, 5, 5, 101, 114, 114, 111, 114, 4, 119, 97, 114, 110, 4, 105, 110, 102, 111, 5, 100, 101, 98, 117, 103, 5, 116, 114, 97, 99, 101, 4, 0, 9, 108, 111, 103, 45, 108, 101, 118, 101, 108, 3, 0, 0, 1, 109, 1, 6, 115, 116, 97, 116, 115, 100, 4, 0, 13, 109, 101, 116, 114, 105, 99, 45, 102, 111, 114, 109, 97, 116, 3, 0, 2, 1, 112, 125, 1, 64, 2, 6, 102, 111, 114, 109, 97, 116, 3, 4, 110, 97, 109, 101, 4, 1, 0, 4, 0, 6, 109, 101, 116, 114, 105, 99, 1, 5, 1, 64, 2, 5, 108, 101, 118, 101, 108, 1, 3, 109, 115, 103, 4, 1, 0, 4, 0, 3, 108, 111, 103, 1, 6, 1, 64, 1, 4, 110, 97, 109, 101, 115, 1, 0, 4, 0, 10, 115, 112, 97, 110, 45, 101, 110, 116, 101, 114, 1, 7, 1, 64, 1, 4, 116, 97, 103, 115, 115, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 116, 97, 103, 115, 1, 8, 1, 64, 0, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 101, 120, 105, 116, 1, 9, 3, 1, 19, 100, 121, 108, 105, 98, 115, 111, 58, 111, 98, 115, 101, 114, 118, 101, 47, 97, 112, 105, 5, 0, 1, 64, 0, 0, 115, 4, 0, 11, 104, 101, 108, 108, 111, 45, 119, 111, 114, 108, 100, 1, 1, 4, 1, 43, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 93, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 119, 111, 114, 108, 100, 115, 34, 58, 123, 34, 101, 120, 97, 109, 112, 108, 101, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 65, 110, 32, 101, 120, 97, 109, 112, 108, 101, 32, 119, 111, 114, 108, 100, 32, 102, 111, 114, 32, 116, 104, 101, 32, 99, 111, 109, 112, 111, 110, 101, 110, 116, 32, 116, 111, 32, 116, 97, 114, 103, 101, 116, 46, 34, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/01-component-instr-component/src/lib.rs b/corpus/01-component-instr-component/src/lib.rs index 3c0df0e..c92ef62 100644 --- a/corpus/01-component-instr-component/src/lib.rs +++ b/corpus/01-component-instr-component/src/lib.rs @@ -1,4 +1,4 @@ -cargo_component_bindings::generate!(); +mod bindings; use observe_api::*; diff --git a/corpus/02-component-instr-combined/Cargo.lock b/corpus/02-component-instr-combined/Cargo.lock index 4268f40..b06a795 100644 --- a/corpus/02-component-instr-combined/Cargo.lock +++ b/corpus/02-component-instr-combined/Cargo.lock @@ -8,69 +8,13 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" -[[package]] -name = "cargo-component-bindings" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545e48ba821e07f93c97aea897bee6d407de4d58947f914160131f3d78b2c704" -dependencies = [ - "cargo-component-macro", - "wit-bindgen", -] - -[[package]] -name = "cargo-component-macro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e198ee0b668e902b43b5e7d2e9620a3891d2632429b3ba66e1ceea455053cbf5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "combined" version = "0.1.0" dependencies = [ - "cargo-component-bindings", -] - -[[package]] -name = "proc-macro2" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "wit-bindgen", ] -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - [[package]] name = "wit-bindgen" version = "0.16.0" diff --git a/corpus/02-component-instr-combined/Cargo.toml b/corpus/02-component-instr-combined/Cargo.toml index 145b1d7..575d0dd 100644 --- a/corpus/02-component-instr-combined/Cargo.toml +++ b/corpus/02-component-instr-combined/Cargo.toml @@ -12,4 +12,4 @@ package = "component:combined" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cargo-component-bindings = "0.6.0" +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} \ No newline at end of file diff --git a/corpus/02-component-instr-combined/src/bindings.rs b/corpus/02-component-instr-combined/src/bindings.rs new file mode 100644 index 0000000..7ad2b17 --- /dev/null +++ b/corpus/02-component-instr-combined/src/bindings.rs @@ -0,0 +1,49 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! + +#[allow(clippy::all)] +pub mod component_instr_component { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::__link_section; + #[allow(unused_unsafe, clippy::all)] + pub fn hello_world() -> wit_bindgen::rt::string::String{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component-instr-component")] + extern "C" { + #[link_name = "hello-world"] + fn wit_import(_: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ){ unreachable!() } + wit_import(ptr0); + let l1 = *((ptr0 + 0) as *const i32); + let l2 = *((ptr0 + 4) as *const i32); + let len3 = l2 as usize; + let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); + wit_bindgen::rt::string_lift(bytes3) + } + } + +} + + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:combined"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 219] = [3, 0, 8, 99, 111, 109, 98, 105, 110, 101, 100, 0, 97, 115, 109, 13, 0, 1, 0, 7, 92, 1, 65, 2, 1, 65, 2, 1, 66, 2, 1, 64, 0, 0, 115, 4, 0, 11, 104, 101, 108, 108, 111, 45, 119, 111, 114, 108, 100, 1, 0, 3, 0, 25, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 0, 4, 1, 27, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 99, 111, 109, 98, 105, 110, 101, 100, 47, 99, 111, 109, 98, 105, 110, 101, 100, 4, 0, 11, 14, 1, 0, 8, 99, 111, 109, 98, 105, 110, 101, 100, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/02-component-instr-combined/src/main.rs b/corpus/02-component-instr-combined/src/main.rs index 26b81b0..b9e007a 100644 --- a/corpus/02-component-instr-combined/src/main.rs +++ b/corpus/02-component-instr-combined/src/main.rs @@ -1,4 +1,4 @@ -cargo_component_bindings::generate!(); +mod bindings; use bindings::component_instr_component::hello_world; diff --git a/rust/Cargo.toml b/rust/Cargo.toml index cb0ebfd..adc4bfe 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -12,8 +12,8 @@ doctest = false [dependencies] anyhow = "1" -wasmtime = ">= 16.0.0, < 17.0.0" -wasmtime-wasi = ">= 16.0.0, < 17.0.0" +wasmtime = ">= 17.0.0, < 18.0.0" +wasmtime-wasi = ">= 17.0.0, < 18.0.0" tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] } rand = "0" modsurfer-demangle = { git = "https://github.com/dylibso/modsurfer" } diff --git a/rust/examples/otel-stdout-components.rs b/rust/examples/otel-stdout-components.rs index d3af12b..679fae2 100644 --- a/rust/examples/otel-stdout-components.rs +++ b/rust/examples/otel-stdout-components.rs @@ -3,20 +3,20 @@ use dylibso_observe_sdk::{ context::component::{ObserveSdk, ObserveSdkView}, }; -use wasmtime_wasi::preview2::{Table, WasiCtx, WasiView}; +use wasmtime_wasi::preview2::{ResourceTable, WasiCtx, WasiView}; struct State { - table: Table, + table: ResourceTable, wasi_ctx: WasiCtx, observe_sdk: ObserveSdk, } impl WasiView for State { - fn table(&self) -> &Table { + fn table(&self) -> &ResourceTable { &self.table } - fn table_mut(&mut self) -> &mut Table { + fn table_mut(&mut self) -> &mut ResourceTable { &mut self.table } @@ -48,7 +48,7 @@ pub async fn main() -> anyhow::Result<()> { let engine = wasmtime::Engine::new(&config)?; let component = wasmtime::component::Component::new(&engine, &data)?; - let table = Table::new(); + let table = ResourceTable::new(); // Setup WASI let wasi_ctx = wasmtime_wasi::preview2::WasiCtxBuilder::new()