bytehaul
A Rust async HTTP download library with resume, multi-connection, write-back cache, rate limiting, and checksum verification.
Documentation
Features
-
Single & multi-connection downloads — automatic Range probing and fallback
-
Resume / breakpoint continuation — control file persistence with atomic save
-
Write-back cache — piece-based aggregation to reduce random I/O
-
Memory budget & backpressure — semaphore-based flow control
-
Retry with exponential backoff — configurable max retries, respects
Retry-After -
Rate limiting — shared token-bucket across all workers
-
SHA-256 checksum verification — post-download integrity check
-
Cancellation — cooperative cancel via watch channel
-
Progress reporting — real-time speed, downloaded bytes, state
-
Shared network configuration - proxy, custom DNS servers, and IPv6 toggle on the downloader client
Quick Start
use ;
async
Configuration
use Duration;
use ;
let mut spec = new;
spec.max_connections = 8; // parallel workers
spec.piece_size = 2 * 1024 * 1024; // 2 MiB pieces
spec.min_split_size = 10 * 1024 * 1024; // split only if > 10 MiB
spec.file_allocation = Prealloc;
spec.resume = true; // enable breakpoint resume
spec.max_retries = 5;
spec.retry_base_delay = from_secs;
spec.max_download_speed = 1024 * 1024; // 1 MB/s limit
spec.checksum = Some;
Network stack settings live on the shared downloader client:
use SocketAddr;
use Downloader;
let downloader = builder
.all_proxy
.dns_servers
.enable_ipv6
.build?;
DownloadSpec::connect_timeout is still supported. If a task overrides it, bytehaul builds an equivalent client just for that download.
Progress Monitoring
use ;
async
Cancellation
let handle = downloader.download;
// Cancel from another task or after a timeout
handle.cancel;
let result = handle.wait.await; // returns Err(DownloadError::Cancelled)
Architecture
DownloadManager
└─ DownloadSession
├─ Scheduler (piece assignment, segment reclamation)
├─ HttpWorker ×N (Range requests, retry)
│ └─ channel ─→ Writer (WriteBackCache → FileWriter)
└─ ControlStore (atomic save/load/delete)
License
MIT. See LICENSE.