feat(game): game uninstalling & partial compat

This commit is contained in:
DecDuck
2024-12-26 11:59:26 +11:00
parent 9ea2aa4997
commit dd7f5675d8
26 changed files with 469 additions and 96 deletions

View File

@ -2,6 +2,7 @@ use std::{
any::Any,
collections::VecDeque,
fmt::Debug,
io,
sync::{
mpsc::{SendError, Sender},
Arc, Mutex, MutexGuard,
@ -41,8 +42,12 @@ pub enum DownloadManagerSignal {
Error(GameDownloadError),
/// Pushes UI update
Update,
/// Uninstall game
/// Takes game ID
Uninstall(String),
}
#[derive(Debug, Clone)]
pub enum DownloadManagerStatus {
Downloading,
Paused,
@ -51,6 +56,15 @@ pub enum DownloadManagerStatus {
Finished,
}
impl Serialize for DownloadManagerStatus {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&format!["{:?}", self])
}
}
#[derive(Serialize, Clone)]
pub enum GameDownloadStatus {
Queued,
@ -191,6 +205,11 @@ impl DownloadManager {
.unwrap();
self.terminator.join()
}
pub fn uninstall_game(&self, game_id: String) {
self.command_sender
.send(DownloadManagerSignal::Uninstall(game_id))
.unwrap();
}
}
/// Takes in the locked value from .edit() and attempts to