2023-04-05 10:07:59 -07:00
|
|
|
use crate::api::Result;
|
|
|
|
|
use theseus::prelude::*;
|
2024-08-16 23:20:11 -07:00
|
|
|
use uuid::Uuid;
|
2023-04-05 10:07:59 -07:00
|
|
|
|
2023-06-28 09:58:58 -07:00
|
|
|
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
|
|
|
|
tauri::plugin::Builder::new("process")
|
|
|
|
|
.invoke_handler(tauri::generate_handler![
|
2024-07-24 11:03:19 -07:00
|
|
|
process_get_all,
|
|
|
|
|
process_get_by_profile_path,
|
|
|
|
|
process_kill,
|
|
|
|
|
process_wait_for,
|
2023-06-28 09:58:58 -07:00
|
|
|
])
|
|
|
|
|
.build()
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-05 10:07:59 -07:00
|
|
|
#[tauri::command]
|
2024-08-16 23:20:11 -07:00
|
|
|
pub async fn process_get_all() -> Result<Vec<ProcessMetadata>> {
|
2024-07-24 11:03:19 -07:00
|
|
|
Ok(process::get_all().await?)
|
2023-04-05 10:07:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2024-08-16 23:20:11 -07:00
|
|
|
pub async fn process_get_by_profile_path(
|
|
|
|
|
path: &str,
|
|
|
|
|
) -> Result<Vec<ProcessMetadata>> {
|
2024-07-24 11:03:19 -07:00
|
|
|
Ok(process::get_by_profile_path(path).await?)
|
2023-04-05 10:07:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2024-08-16 23:20:11 -07:00
|
|
|
pub async fn process_kill(uuid: Uuid) -> Result<()> {
|
|
|
|
|
Ok(process::kill(uuid).await?)
|
2023-04-05 10:07:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
2024-08-16 23:20:11 -07:00
|
|
|
pub async fn process_wait_for(uuid: Uuid) -> Result<()> {
|
|
|
|
|
Ok(process::wait_for(uuid).await?)
|
2023-04-05 10:07:59 -07:00
|
|
|
}
|