Skip to content

Commit

Permalink
feat(config): add config for grassator
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Jul 12, 2024
1 parent 9c2af45 commit b19a68e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
mod models;
mod state;
mod utils;

#[tauri::command]
fn get_config(config: tauri::State<state::Config>) -> Result<state::Config, ()> {
Ok(config.inner().clone())
}

#[tauri::command]
async fn get_file_size(url: &str) -> Result<models::FileSize, ()> {
match utils::get_file_size(url).await {
Expand All @@ -15,8 +21,9 @@ async fn get_file_size(url: &str) -> Result<models::FileSize, ()> {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.manage(state::Config::default())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![get_file_size])
.invoke_handler(tauri::generate_handler![get_config, get_file_size])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
16 changes: 16 additions & 0 deletions src-tauri/src/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct Config {
pub(crate) preset_file: String,
pub(crate) threads_count: u32,
}

impl Default for Config {
fn default() -> Self {
Self {
preset_file: String::from("presets/default.json"),
threads_count: 1,
}
}
}

0 comments on commit b19a68e

Please sign in to comment.