blob: 4294d33e3ba7b78b9b1b8773dee757ba6d015350 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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) {
}
}
|