Skip to main content

dw_rs/
config.rs

1use std::time::Duration;
2
3/// Tunables for the download engine.
4///
5/// Defaults are chosen to be fast and safe on a typical broadband link while
6/// keeping peak memory bounded (roughly `2 * max_connections * write_buffer`).
7#[derive(Clone, Debug)]
8pub struct DownloadConfig {
9    pub max_connections: usize,
10
11    pub min_chunk_size: u64,
12    
13    pub piece_size: u64,
14
15    pub write_buffer: usize,
16
17    pub max_retries: u32,
18
19    pub piece_timeout: Duration,
20
21    pub connect_timeout: Duration,
22
23    pub quiet: bool,
24}
25
26impl Default for DownloadConfig {
27    fn default() -> Self {
28        Self {
29            max_connections: 8,
30            min_chunk_size: 1024 * 1024,
31            piece_size: 4 * 1024 * 1024,
32            write_buffer: 4 * 1024 * 1024,
33            max_retries: 5,
34            piece_timeout: Duration::from_secs(60),
35            connect_timeout: Duration::from_secs(15),
36            quiet: false,
37        }
38    }
39}