Fix wasm32

This commit is contained in:
2026-03-22 12:03:03 +01:00
parent bada5982c8
commit bc28b25c8e
2 changed files with 32 additions and 1 deletions
+1 -1
View File
@@ -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
+31
View File
@@ -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<Fut>(&self, f: impl FnOnce() -> Fut + Send + 'static)
where
Fut: Future<Output = anyhow::Result<()>>,
@@ -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<Fut>(&self, f: impl FnOnce() -> Fut + Send + 'static)
where
Fut: Future<Output = anyhow::Result<()>>,
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;
});
}
}