pub struct Config {Show 18 fields
pub threads: usize,
pub proxy: Proxy<String>,
pub headers: HashMap<String, String>,
pub min_chunk_size: u64,
pub sync_all: bool,
pub write_buffer_size: usize,
pub cache_high_watermark: usize,
pub cache_low_watermark: usize,
pub write_queue_cap: usize,
pub retry_gap: Duration,
pub pull_timeout: Duration,
pub accept_invalid_certs: bool,
pub accept_invalid_hostnames: bool,
pub retry_times: usize,
pub local_address: Vec<IpAddr>,
pub max_speculative: usize,
pub downloaded_chunk: Arc<Mutex<Vec<ProgressEntry>>>,
pub chunk_window: u64,
}Fields§
§threads: usizeNumber of threads. Recommended: 32 / 16 / 8. More threads does not always mean faster.
proxy: Proxy<String>Proxy setting. Supports https, http, and socks5 proxies.
headers: HashMap<String, String>Custom request headers.
min_chunk_size: u64Minimum chunk size in bytes. Recommended: 8 * 1024 * 1024
- Chunks that are too small may cause heavy contention.
- When chunking is no longer possible, speculative mode is used.
sync_all: boolWhether to ensure data is fully flushed to disk. Recommended: false
Set to true only if you need to power off immediately after download.
write_buffer_size: usizeWrite buffer size in bytes. Recommended: 16 * 1024 * 1024
- Only effective for
WriteMethod::Std. Helps convert random writes into sequential writes. - Not used for
WriteMethod::Mmap, as the buffer is managed by the OS.
cache_high_watermark: usizeCache high watermark in bytes. Recommended: 16 * 1024 * 1024
When the byte merge buffer reaches this size, a merge flush is triggered
to reduce the buffer to cache_low_watermark or below.
- Only effective for
WriteMethod::Std. - Not used for
WriteMethod::Mmap.
cache_low_watermark: usizeCache low watermark in bytes. Recommended: 8 * 1024 * 1024
After a merge flush, the byte merge buffer size is reduced to this level or below.
- Only effective for
WriteMethod::Std. - Not used for
WriteMethod::Mmap.
write_queue_cap: usizeWrite queue capacity. Recommended: 10240
If download threads fill the write queue, backpressure is applied to slow down downloads and prevent excessive memory usage.
retry_gap: DurationDefault retry interval after a request failure. Recommended: 500ms
If the server returns a Retry-After header, that value takes precedence.
pull_timeout: DurationPull timeout. Recommended: 5000ms
If no bytes are received within pull_timeout after sending the request,
the connection is dropped and re-established. This helps TCP detect
congestion and can improve download speed.
accept_invalid_certs: boolWhether to accept invalid certificates (dangerous). Recommended: false
accept_invalid_hostnames: boolWhether to accept invalid hostnames (dangerous). Recommended: false
retry_times: usizeNumber of retries for fetching metadata. Recommended: 10. Note: this is not
the retry count during download.
local_address: Vec<IpAddr>Local IP addresses to bind for outgoing requests. Recommended: Vec::new()
If you have multiple network interfaces, you can provide their IP addresses; requests will be rotated among them. This may not always improve speed.
max_speculative: usizeMaximum number of speculative workers. Recommended: 3
When the remaining chunk is smaller than min_chunk_size and cannot be split,
speculative mode is used. Up to max_speculative workers compete on the same
chunk to prevent the download from stalling near 99%.
downloaded_chunk: Arc<Mutex<Vec<ProgressEntry>>>Already downloaded chunks. Pass Vec::new() to download the entire file.
chunk_window: u64Smoothing window for downloaded chunks in bytes. Recommended: 8 * 1024
Filters out small gaps in downloaded_chunk that are smaller than
chunk_window to reduce the number of HTTP requests.