mirror of
https://github.com/hulthe/inkopslista.git
synced 2026-08-03 23:11:28 +02:00
Fix wasm32
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user