1
0
Fork 0

improved types

- moved types  to types.rs
- added custom serialization logic
This commit is contained in:
Kim, Jimin 2022-01-27 17:52:52 +09:00
parent bbe2bdf72d
commit a0795c8041
2 changed files with 77 additions and 37 deletions

View file

@ -1,50 +1,16 @@
// [Sync]: must be synced with `src/pages/Install/types.ts`
use tauri::Window;
use crate::constants;
use crate::util;
mod types;
mod install_bepinex;
mod install_mod;
mod launch_game;
mod launch_options;
// [Sync]
#[derive(Clone, serde::Serialize)]
pub enum InstallSteps {
DownloadBepInEx,
InstallBepInEx,
LaunchOption,
LaunchGame,
DownloadWbmZip,
InstallWbm,
Done,
}
// [Sync]
#[derive(serde::Serialize, PartialEq)]
pub enum InstallResult {
NoErr,
SetLaunchOption,
LaunchGame,
Skip, // only used for subcommands
}
// [Sync]
#[derive(serde::Serialize)]
pub enum InstallErr {
FailedToGetGamePath,
UnsupportedOS,
BepInExDownloadFailed,
BepInExUnzipFailed,
WBMDownloadFailed,
WBMRemoveFailed,
WBMDirectoryCreationFailed,
WBMUnzipFailed,
}
#[derive(Clone, serde::Serialize)]
struct InstallPayload(i64);
use types::{InstallErr, InstallResult, InstallSteps};
// todo: show current step in the frontend

View file

@ -0,0 +1,74 @@
/// must be synced with `src/pages/Install/types.ts`
//
//
//
#[derive(Clone, Copy)]
pub enum InstallSteps {
DownloadBepInEx,
InstallBepInEx,
LaunchOption,
LaunchGame,
DownloadWbmZip,
InstallWbm,
Done,
}
impl serde::Serialize for InstallSteps {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_i64(*self as i64)
}
}
//
//
//
#[derive(Clone, Copy, PartialEq)]
pub enum InstallResult {
NoErr,
SetLaunchOption,
LaunchGame,
Skip, // only used for subcommands
}
impl serde::Serialize for InstallResult {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_i64(*self as i64)
}
}
//
//
//
#[derive(Clone, Copy)]
pub enum InstallErr {
FailedToGetGamePath,
UnsupportedOS,
BepInExDownloadFailed,
BepInExUnzipFailed,
WBMDownloadFailed,
WBMRemoveFailed,
WBMDirectoryCreationFailed,
WBMUnzipFailed,
}
impl serde::Serialize for InstallErr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_i64(*self as i64)
}
}
// #[derive(Clone, serde::Serialize)]
// struct InstallPayload(i64);