mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
chore(tool manager): Added ToolDownloadAgent
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -5,7 +5,6 @@ use super::{
|
||||
};
|
||||
|
||||
pub trait Downloadable: Send + Sync {
|
||||
fn get_progress_object(&self) -> Arc<ProgressObject>;
|
||||
fn version(&self) -> String;
|
||||
fn id(&self) -> String;
|
||||
fn download(&mut self) -> Result<(), ApplicationDownloadError>;
|
||||
|
||||
@ -296,10 +296,6 @@ impl GameDownloadAgent {
|
||||
}
|
||||
|
||||
impl Downloadable for GameDownloadAgent {
|
||||
fn get_progress_object(&self) -> Arc<ProgressObject> {
|
||||
self.progress.clone()
|
||||
}
|
||||
|
||||
fn id(&self) -> String {
|
||||
self.id.clone()
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
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>;
|
||||
}
|
||||
@ -1,4 +1,3 @@
|
||||
mod external_component;
|
||||
mod prefix;
|
||||
mod registry;
|
||||
mod tool;
|
||||
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::external_component::ExternalComponent;
|
||||
use crate::download_manager::downloadable::Downloadable;
|
||||
|
||||
pub struct Registry<T: ExternalComponent> {
|
||||
pub struct Registry<T: Downloadable> {
|
||||
tools: HashMap<String, T>
|
||||
}
|
||||
|
||||
@ -1,26 +1,36 @@
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::external_component::ExternalComponent;
|
||||
use crate::download_manager::{download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable, progress_object::ProgressObject};
|
||||
|
||||
pub struct Tool {
|
||||
name: String,
|
||||
pub struct ToolDownloadAgent {
|
||||
id: String,
|
||||
version: String,
|
||||
location: Option<PathBuf>,
|
||||
location: String,
|
||||
control_flag: DownloadThreadControl,
|
||||
progress: Arc<ProgressObject>,
|
||||
}
|
||||
impl ExternalComponent for Tool {
|
||||
fn download(&mut self) {
|
||||
impl Downloadable for ToolDownloadAgent {
|
||||
fn id(&self) -> String {
|
||||
self.id.clone()
|
||||
}
|
||||
|
||||
fn progress(&self) -> Arc<ProgressObject> {
|
||||
self.progress.clone()
|
||||
}
|
||||
|
||||
fn control_flag(&self) -> DownloadThreadControl {
|
||||
self.control_flag.clone()
|
||||
}
|
||||
|
||||
fn install_dir(&self) -> String {
|
||||
self.location.clone()
|
||||
}
|
||||
|
||||
fn version(&self) -> String {
|
||||
self.version.clone()
|
||||
}
|
||||
|
||||
fn download(&mut self) -> Result<(), crate::download_manager::application_download_error::ApplicationDownloadError> {
|
||||
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