From bc28b25c8ecce8cbce61a6600c6d2c4346be6360 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Sun, 22 Mar 2026 12:03:03 +0100 Subject: [PATCH] Fix wasm32 --- Dockerfile | 2 +- gui/src/io.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index efc1be7..41591fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ################## ### BASE STAGE ### ################## -FROM rust:1.92.0 AS base +FROM rust:1.94.0 AS base RUN rustup target add wasm32-unknown-unknown RUN rustup target add x86_64-unknown-linux-musl diff --git a/gui/src/io.rs b/gui/src/io.rs index 363235c..92a3f84 100644 --- a/gui/src/io.rs +++ b/gui/src/io.rs @@ -40,6 +40,7 @@ impl Io { /// Spawn a fallible async function. /// /// Update the `ConnectionStatus` in the GUI depending on whether the result is an error. + #[cfg(not(target_arch = "wasm32"))] pub fn spawn(&self, f: impl FnOnce() -> Fut + Send + 'static) where Fut: Future>, @@ -64,4 +65,34 @@ impl Io { .await; }); } + + /// Spawn a fallible async function. + /// + /// Update the `ConnectionStatus` in the GUI depending on whether the result is an error. + // FIXME: this function is duplicated from the one above, but without the `Send` requirement on the future. + #[cfg(target_arch = "wasm32")] + pub fn spawn(&self, f: impl FnOnce() -> Fut + Send + 'static) + where + Fut: Future>, + Fut: 'static, + { + let io = self.clone(); + spawn(async move { + let _ = io.state.status.send(ui::ConnectionStatus::Syncing).await; + let result = f().await; + let was_error = result.is_err(); + if let Err(e) = result { + eprintln!("{e:?}"); + } + let _ = io + .state + .status + .send(if was_error { + ui::ConnectionStatus::Error + } else { + ui::ConnectionStatus::Idle + }) + .await; + }); + } }