use std::future::Future; use tauri::{async_runtime, async_runtime::JoinHandle}; pub struct AsyncHandler; impl AsyncHandler { pub fn spawn(f: F) -> JoinHandle<()> where F: FnOnce() -> Fut + Send + 'static, Fut: Future + Send + 'static, { async_runtime::spawn(f()) } pub fn spawn_blocking(f: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { async_runtime::spawn_blocking(f) } pub fn block_on(f: F) -> R where F: FnOnce() -> Fut, Fut: Future, { async_runtime::block_on(f()) } }