From eca2ab88796dfe98c89808085d201dd27e944152 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Sat, 28 Mar 2026 17:46:00 +0100 Subject: [PATCH] fix: P3 source uses cfg for async (WASM) vs sync (host) P3 components generate async trait on WASM and sync on host. Use #[cfg(target_arch = "wasm32")] to provide both implementations in the same source file. Co-Authored-By: Claude Opus 4.6 (1M context) --- test/p3/src_p3/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/p3/src_p3/lib.rs b/test/p3/src_p3/lib.rs index b2b122bf..65156ca6 100644 --- a/test/p3/src_p3/lib.rs +++ b/test/p3/src_p3/lib.rs @@ -1,12 +1,18 @@ -// P3 test component — async interface +// P3 test component — async on WASM, sync on host use hello_p3_bindings::exports::hello::interfaces::greeting::Guest; struct Component; impl Guest for Component { + #[cfg(target_arch = "wasm32")] async fn greet(name: String) -> String { format!("Hello, {}! (P3 async)", name) } + + #[cfg(not(target_arch = "wasm32"))] + fn greet(name: String) -> String { + format!("Hello, {}! (P3 host)", name) + } } hello_p3_bindings::export!(Component with_types_in hello_p3_bindings);