diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 23:02:41 +0100 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 23:02:41 +0100 |
commit | 252c2ca40d805e8190b70e5599e44ee632a99778 (patch) | |
tree | c9f81cf8adcfb9c775bdcf48e9b49101831f715f /src-tauri | |
parent | b2904f389dfa230b5b790ca6856be51c40647c6d (diff) | |
download | FlightCore-252c2ca40d805e8190b70e5599e44ee632a99778.tar.gz FlightCore-252c2ca40d805e8190b70e5599e44ee632a99778.zip |
refactor: Use wrapper function
that calls into dedicated parser functions and then assemble object
inside the wrapper function
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/main.rs | 4 | ||||
-rw-r--r-- | src-tauri/src/repair_and_verify/log_handling.rs | 20 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 06adf784..015ac925 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,7 +37,7 @@ use tauri::Manager; use tauri_plugin_store::PluginBuilder; use tokio::time::sleep; -use crate::repair_and_verify::log_handling::parse_given_log_text_for_installed_mods; +use crate::repair_and_verify::log_handling::parse_given_log_text; #[derive(Default)] struct Counter(Arc<Mutex<i32>>); @@ -112,7 +112,7 @@ fn main() { delete_northstar_mod, get_server_player_count, delete_thunderstore_mod, - parse_given_log_text_for_installed_mods, + parse_given_log_text, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs index 6bb6528e..2b394a23 100644 --- a/src-tauri/src/repair_and_verify/log_handling.rs +++ b/src-tauri/src/repair_and_verify/log_handling.rs @@ -9,10 +9,7 @@ pub struct ParsedLogResults { } /// Parse logs for installed mods -#[tauri::command] -pub async fn parse_given_log_text_for_installed_mods( - log_text: String, -) -> Result<ParsedLogResults, String> { +fn parse_given_log_text_for_installed_mods(log_text: String) -> Result<Vec<String>, String> { // Regex to capture mod loading let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n").unwrap(); @@ -30,10 +27,17 @@ pub async fn parse_given_log_text_for_installed_mods( }; } - let parsed_log_results = ParsedLogResults { - installed_mods: mods, - }; - // Return the captured mod names + return Ok(mods); +} + +/// Parse logs for installed mods +#[tauri::command] +pub async fn parse_given_log_text(log_text: String) -> Result<ParsedLogResults, String> { + let installed_mods = parse_given_log_text_for_installed_mods(log_text)?; + + let parsed_log_results = ParsedLogResults { installed_mods }; + + // Return the parsed results return Ok(parsed_log_results); } |