mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-01-30 19:15:17 +01:00
* fix: Add lint and remove all unwraps from lib.rs Signed-off-by: quexeky <git@quexeky.dev> * chore: Remove all unwraps from util.rs and add state_lock macro Signed-off-by: quexeky <git@quexeky.dev> * chore: Add CacheError and remove unwraps from fetch_object Signed-off-by: quexeky <git@quexeky.dev> * chore: Remove unwraps from fetch_object and server_proto Signed-off-by: quexeky <git@quexeky.dev> * chore: Remove unwraps from auth.rs Signed-off-by: quexeky <git@quexeky.dev> * chore: Remove unwraps from process_handlers Signed-off-by: quexeky <git@quexeky.dev> * chore: Clippy unwrap linting Signed-off-by: quexeky <git@quexeky.dev> * chore: Remove lint Because not everything is actually resolved yet: will be resolved with a restructure of the library Signed-off-by: quexeky <git@quexeky.dev> * chore: Make the rest of clippy happy Signed-off-by: quexeky <git@quexeky.dev> * fix: Send download signal instead of triggering self.on_error Signed-off-by: quexeky <git@quexeky.dev> * fix: Corrupted state should panic Signed-off-by: quexeky <git@quexeky.dev> * fix: Use debug instead of display for specific errors Signed-off-by: quexeky <git@quexeky.dev> * fix: Settings now log error instead of panicking Signed-off-by: quexeky <git@quexeky.dev> --------- Signed-off-by: quexeky <git@quexeky.dev>
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use std::sync::Mutex;
|
|
|
|
use crate::{error::process_error::ProcessError, lock, AppState};
|
|
|
|
#[tauri::command]
|
|
pub fn launch_game(
|
|
id: String,
|
|
state: tauri::State<'_, Mutex<AppState>>,
|
|
) -> Result<(), ProcessError> {
|
|
let state_lock = lock!(state);
|
|
let mut process_manager_lock = lock!(state_lock.process_manager);
|
|
|
|
//let meta = DownloadableMetadata {
|
|
// id,
|
|
// version: Some(version),
|
|
// download_type: DownloadType::Game,
|
|
//};
|
|
|
|
match process_manager_lock.launch_process(id, &state_lock) {
|
|
Ok(()) => {}
|
|
Err(e) => return Err(e),
|
|
}
|
|
|
|
drop(process_manager_lock);
|
|
drop(state_lock);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn kill_game(
|
|
game_id: String,
|
|
state: tauri::State<'_, Mutex<AppState>>,
|
|
) -> Result<(), ProcessError> {
|
|
let state_lock = lock!(state);
|
|
let mut process_manager_lock = lock!(state_lock.process_manager);
|
|
process_manager_lock
|
|
.kill_game(game_id)
|
|
.map_err(ProcessError::IOError)
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn open_process_logs(
|
|
game_id: String,
|
|
state: tauri::State<'_, Mutex<AppState>>,
|
|
) -> Result<(), ProcessError> {
|
|
let state_lock = lock!(state);
|
|
let mut process_manager_lock = lock!(state_lock.process_manager);
|
|
process_manager_lock.open_process_logs(game_id)
|
|
}
|