summaryrefslogtreecommitdiffstats
path: root/src/launcher/download.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/launcher/download.rs')
-rw-r--r--src/launcher/download.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/launcher/download.rs b/src/launcher/download.rs
new file mode 100644
index 0000000..4294d33
--- /dev/null
+++ b/src/launcher/download.rs
@@ -0,0 +1,36 @@
+use std::path::{Path, PathBuf};
+use sha1_smol::Digest;
+
+pub trait Download {
+ fn get_url(&self) -> &str;
+ fn get_path(&self) -> &Path;
+ fn get_expect_digest(&self) -> Option<Digest>;
+ fn get_expect_size(&self) -> Option<usize>;
+
+ fn always_redownload(&self) -> bool;
+}
+
+pub type DownloadJob = dyn Download + Sync + Send;
+
+pub struct MultiDownloader<'j, 'js> {
+ jobs: &'js [&'j DownloadJob],
+ nhandles: usize
+}
+
+impl<'j, 'js> MultiDownloader<'j, 'js> {
+ pub fn new(jobs: &'js [&'j DownloadJob]) -> MultiDownloader<'j, 'js> {
+ Self::with_handles(jobs, 8)
+ }
+
+ pub fn with_handles(jobs: &'js [&'j DownloadJob], nhandles: usize) -> MultiDownloader<'j, 'js> {
+ assert!(nhandles > 0);
+
+ MultiDownloader {
+ jobs, nhandles
+ }
+ }
+
+ fn do_it(&self) {
+
+ }
+} \ No newline at end of file