mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
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 <git@quexeky.dev>
This commit is contained in:
@ -9,6 +9,7 @@ mod debug;
|
||||
mod process;
|
||||
mod remote;
|
||||
mod state;
|
||||
mod tools;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
|
||||
0
src-tauri/src/tools/compatibility_layer.rs
Normal file
0
src-tauri/src/tools/compatibility_layer.rs
Normal file
8
src-tauri/src/tools/external_component.rs
Normal file
8
src-tauri/src/tools/external_component.rs
Normal file
@ -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<PathBuf>;
|
||||
}
|
||||
4
src-tauri/src/tools/mod.rs
Normal file
4
src-tauri/src/tools/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
mod external_component;
|
||||
mod prefix;
|
||||
mod registry;
|
||||
mod tool;
|
||||
0
src-tauri/src/tools/prefix.rs
Normal file
0
src-tauri/src/tools/prefix.rs
Normal file
7
src-tauri/src/tools/registry.rs
Normal file
7
src-tauri/src/tools/registry.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::external_component::ExternalComponent;
|
||||
|
||||
pub struct Registry<T: ExternalComponent> {
|
||||
tools: HashMap<String, T>
|
||||
}
|
||||
26
src-tauri/src/tools/tool.rs
Normal file
26
src-tauri/src/tools/tool.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::external_component::ExternalComponent;
|
||||
|
||||
pub struct Tool {
|
||||
name: String,
|
||||
version: String,
|
||||
location: Option<PathBuf>,
|
||||
}
|
||||
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<PathBuf> {
|
||||
&self.location
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user