Add AsyncHandler for wrapping task spawning
This commit is contained in:
14
src-tauri/src/process/async_handler.rs
Normal file
14
src-tauri/src/process/async_handler.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use std::future::Future;
|
||||
use tauri::{async_runtime, async_runtime::JoinHandle};
|
||||
|
||||
pub struct AsyncHandler;
|
||||
|
||||
impl AsyncHandler {
|
||||
pub fn spawn<F, Fut>(f: F) -> JoinHandle<()>
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: Future<Output = ()> + Send + 'static,
|
||||
{
|
||||
async_runtime::spawn(f())
|
||||
}
|
||||
}
|
||||
2
src-tauri/src/process/mod.rs
Normal file
2
src-tauri/src/process/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod async_handler;
|
||||
pub use async_handler::AsyncHandler;
|
||||
Reference in New Issue
Block a user