forked from akanyan/STARTLINER
refactor: move logic away from tauri commands
This commit is contained in:
33
rust/src/profile.rs
Normal file
33
rust/src/profile.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::fs;
|
||||
use crate::{model::misc, util};
|
||||
|
||||
// {game}-profile-{name}.json
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Profile {
|
||||
pub game: misc::Game,
|
||||
pub path: PathBuf,
|
||||
pub name: String,
|
||||
pub mods: Vec<String>,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
pub fn new(path: PathBuf) -> Profile {
|
||||
Profile {
|
||||
game: misc::Game::Ongeki,
|
||||
path: path,
|
||||
name: "ongeki-default".to_owned(),
|
||||
mods: [].to_vec()
|
||||
}
|
||||
}
|
||||
pub async fn save(&self) {
|
||||
let path = util::get_dirs().config_dir().join("profile-ongeki-default.json");
|
||||
let s = serde_json::to_string_pretty(self).unwrap();
|
||||
fs::write(&path, s).await.unwrap();
|
||||
log::info!("Written to {}", path.to_string_lossy());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user