diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 22:34:51 +0100 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 22:34:51 +0100 |
commit | 1970eb80f84ffdae7d5940fde3ff0d400e951c3c (patch) | |
tree | f2490b10f02864dc2ee24e11f614092d72e13c90 /src-tauri | |
parent | 3f315cfd36cb6d1bdbdd102c0bcfb2f9a0ce0fb9 (diff) | |
download | FlightCore-1970eb80f84ffdae7d5940fde3ff0d400e951c3c.tar.gz FlightCore-1970eb80f84ffdae7d5940fde3ff0d400e951c3c.zip |
refactor: Use custom object to expose results
Allows for expandability in the future
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/bindings/ParsedLogResults.ts | 3 | ||||
-rw-r--r-- | src-tauri/src/repair_and_verify/log_handling.rs | 16 |
2 files changed, 17 insertions, 2 deletions
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<string>, }
\ 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<String>, +} /// Parse logs for installed mods #[tauri::command] pub async fn parse_given_log_text_for_installed_mods( log_text: String, -) -> Result<Vec<String>, String> { +) -> Result<ParsedLogResults, String> { // 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); } |