From 20f726632e112cf8bd258bb44b447f5346fdaea2 Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 30 Dec 2024 17:09:31 +1100 Subject: [PATCH] chore(tool manager): Progress on adding tools Going to try changing around the download manager to take a generic trait rather than specifically for game downloads Signed-off-by: quexeky --- desktop/src-tauri/src/lib.rs | 1 + .../src/tools/compatibility_layer.rs | 0 .../src-tauri/src/tools/external_component.rs | 8 ++++++ desktop/src-tauri/src/tools/mod.rs | 4 +++ desktop/src-tauri/src/tools/prefix.rs | 0 desktop/src-tauri/src/tools/registry.rs | 7 +++++ desktop/src-tauri/src/tools/tool.rs | 26 +++++++++++++++++++ 7 files changed, 46 insertions(+) create mode 100644 desktop/src-tauri/src/tools/compatibility_layer.rs create mode 100644 desktop/src-tauri/src/tools/external_component.rs create mode 100644 desktop/src-tauri/src/tools/mod.rs create mode 100644 desktop/src-tauri/src/tools/prefix.rs create mode 100644 desktop/src-tauri/src/tools/registry.rs create mode 100644 desktop/src-tauri/src/tools/tool.rs diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index b7abcfe0..c68eefef 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -9,6 +9,7 @@ mod debug; mod process; mod remote; mod state; +mod tools; #[cfg(test)] mod tests; diff --git a/desktop/src-tauri/src/tools/compatibility_layer.rs b/desktop/src-tauri/src/tools/compatibility_layer.rs new file mode 100644 index 00000000..e69de29b diff --git a/desktop/src-tauri/src/tools/external_component.rs b/desktop/src-tauri/src/tools/external_component.rs new file mode 100644 index 00000000..2aec4b7c --- /dev/null +++ b/desktop/src-tauri/src/tools/external_component.rs @@ -0,0 +1,8 @@ +use std::path::PathBuf; + +pub trait ExternalComponent { + fn download(&mut self); + fn version(&self) -> &String; + fn is_installed(&self) -> bool; + fn location(&self) -> &Option; +} \ No newline at end of file diff --git a/desktop/src-tauri/src/tools/mod.rs b/desktop/src-tauri/src/tools/mod.rs new file mode 100644 index 00000000..6b8f4133 --- /dev/null +++ b/desktop/src-tauri/src/tools/mod.rs @@ -0,0 +1,4 @@ +mod external_component; +mod prefix; +mod registry; +mod tool; \ No newline at end of file diff --git a/desktop/src-tauri/src/tools/prefix.rs b/desktop/src-tauri/src/tools/prefix.rs new file mode 100644 index 00000000..e69de29b diff --git a/desktop/src-tauri/src/tools/registry.rs b/desktop/src-tauri/src/tools/registry.rs new file mode 100644 index 00000000..c1b000fb --- /dev/null +++ b/desktop/src-tauri/src/tools/registry.rs @@ -0,0 +1,7 @@ +use std::collections::HashMap; + +use super::external_component::ExternalComponent; + +pub struct Registry { + tools: HashMap +} diff --git a/desktop/src-tauri/src/tools/tool.rs b/desktop/src-tauri/src/tools/tool.rs new file mode 100644 index 00000000..6fab0251 --- /dev/null +++ b/desktop/src-tauri/src/tools/tool.rs @@ -0,0 +1,26 @@ +use std::path::PathBuf; + +use super::external_component::ExternalComponent; + +pub struct Tool { + name: String, + version: String, + location: Option, +} +impl ExternalComponent for Tool { + fn download(&mut self) { + todo!() + } + + fn version(&self) -> &String { + &self.version + } + + fn is_installed(&self) -> bool { + self.location.is_some() + } + + fn location(&self) -> &Option { + &self.location + } +} \ No newline at end of file