From 1970eb80f84ffdae7d5940fde3ff0d400e951c3c Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Sun, 5 Feb 2023 22:34:51 +0100 Subject: refactor: Use custom object to expose results Allows for expandability in the future --- src-tauri/bindings/ParsedLogResults.ts | 3 +++ src-tauri/src/repair_and_verify/log_handling.rs | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src-tauri/bindings/ParsedLogResults.ts (limited to 'src-tauri') diff --git a/src-tauri/bindings/ParsedLogResults.ts b/src-tauri/bindings/ParsedLogResults.ts new file mode 100644 index 00000000..9d9d5c63 --- /dev/null +++ b/src-tauri/bindings/ParsedLogResults.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface ParsedLogResults { installed_mods: Array, } \ No newline at end of file diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs index 3b87f632..6bb6528e 100644 --- a/src-tauri/src/repair_and_verify/log_handling.rs +++ b/src-tauri/src/repair_and_verify/log_handling.rs @@ -1,10 +1,18 @@ use regex::Regex; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +#[derive(Serialize, Deserialize, Debug, Clone, TS)] +#[ts(export)] +pub struct ParsedLogResults { + installed_mods: Vec, +} /// Parse logs for installed mods #[tauri::command] pub async fn parse_given_log_text_for_installed_mods( log_text: String, -) -> Result, String> { +) -> Result { // Regex to capture mod loading let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n").unwrap(); @@ -22,6 +30,10 @@ 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); + return Ok(parsed_log_results); } -- cgit v1.2.3