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
37
38
39
40
41
42
43
44
45
46
47
/// Configurations for the state machine
#[derive(Debug)]
pub struct Config {
/// allows to provide a runtime to run tasks like download, unzip, delete on
/// If None is provided it uses the default tokio runtime
pub runtime_handle: Option<tokio::runtime::Handle>,
/// Limits the number of parallel deletions and unzips, reduce this in case
/// you want to reduce the load on the filesystem.
/// E.g. to prevent a spike of filesystem access.
pub max_parallel_filesystem: usize,
pub max_parallel_downloads: usize,
/// For efficient fetching we need to assume the size of the LocalHeader.
///
/// When enabled, we just calculate the size of the LocalHeader using
/// knowledge from the CentralDirectory. Only enable this setting if you
/// know that this calculation is always correct — if it isn't, the file
/// download may fail.
///
/// When disabled, we fetch a bit more data, and probably discard some of it
/// again.
pub assume_cd_contains_lh_content: bool,
/// Sometimes there are 2 files in a zip that need to be downloaded, A and
/// C, with some unnecessary data B in between. Often it's faster to
/// just download the unnecessary data instead of splitting the files into
/// separate batches.
///
/// This setting specifies the maximum distance between 2 files for them to
/// be combined into one batch. Set it to 0 if you want to download each
/// file in a separate request. Set it to u64::MAX if you want to
/// combine all files into a single batch, even if that means
/// downloading a lot of unnecessary data.
///
/// The optimal value for this depends on bandwidth and latency.
pub max_junk_bytes_before_next_batch: u64,
}
impl Default for Config {
fn default() -> Self {
Self {
runtime_handle: None,
max_parallel_filesystem: 100,
max_parallel_downloads: 8,
assume_cd_contains_lh_content: false,
max_junk_bytes_before_next_batch: 8000,
}
}
}