Expand description
§aria2-core
Core library for the aria2-rust download utility — a high-performance, multi-protocol download manager rewritten in Rust.
§Supported Protocols & Features
| Protocol / Feature | Status | Notes |
|---|---|---|
| HTTP / HTTPS | ✅ Full | Range requests, redirects, cookies, gzip/bzip2/chunked decoding |
| FTP / SFTP | ✅ Full | Passive/active mode, REST resume, LIST/MLSD parsing |
| BitTorrent | ✅ Full | Piece picker, choke algorithm, DHT, tracker (HTTP/UDP), seeding |
| Metalink | ✅ Full | v3/v4 parsing, multi-source, checksum verification, signature |
| Auth: Basic (RFC 7617) | ✅ | Base64 credential encoding, HTTPS-only enforcement |
| Auth: Digest (RFC 7616) | ✅ | MD5/SHA256/SHA512 HA1→HA2→Response chain, nonce/qop/stale |
| LPD (BEP 14) | ✅ | UDP multicast peer discovery on 239.192.152.143:6771 |
| MSE (BEP 10) | ✅ | X25519 DH key exchange, RC4 encryption, plaintext fallback |
| Stream Filters | ✅ | Composable GZip/BZip2/Chunked decoder pipeline |
| Post-Download Hooks | ✅ | Move/Rename/Touch/Exec hook chain with env injection |
| BT Progress Persistence | ✅ | Atomic .aria2 file save/load, C++ format compatible |
§Module Overview
-
config— Configuration system with ~95 core options, multi-source merging (defaults → env → file → CLI),ConfigManagerruntime manager, NetRC authentication parser, and URI list file parser. -
engine— Download engine with event-loop architecture (DownloadEngine), command queue, timer system, tick-based scheduling. IncludesBtDownloadCommandwith pluggable progress/LPD/hook managers. -
request— Request management layer:RequestGroupMan(global task manager),RequestGroup(per-task lifecycle: Waiting → Active → Paused → Complete/Error/Removed), segment tracking, and bitfield management. -
auth— HTTP authentication:BasicAuthProvider,DigestAuthProvider, thread-safeCredentialStorewith automatic secret zeroing. -
http— HTTP client with connection pooling, redirect following (iterative with loop detection), stream filters (GzDecoder,ChunkedDecoder), cookie jar, and auth header builders. -
ftp— FTP/SFTP protocol handler with passive/active modes, fast-path LIST parser, REST resume support, and control file management. -
filesystem— Disk I/O abstraction:DiskAdaptor,DiskWriter, file pre-allocation strategies, write cache (LRU eviction), and checksum verification. -
ui— Console UI components:ProgressBar,MultiProgress(multi-task summary),StatusPanel, and formatting utilities (format_size,format_speed,format_duration).
§Quick Start
use aria2_core::config::ConfigManager;
use aria2_core::request::request_group_man::RequestGroupMan;
use aria2_core::request::request_group::DownloadOptions;
use aria2_core::config::OptionValue;
#[tokio::main]
async fn main() {
let mut config = ConfigManager::new();
config.set_global_option("dir", OptionValue::Str("./downloads".into())).await.unwrap();
config.set_global_option("split", OptionValue::Int(4)).await.unwrap();
let man = RequestGroupMan::new();
let opts = DownloadOptions {
split: Some(4),
..Default::default()
};
match man.add_group(vec!["http://example.com/file.zip".into()], opts).await {
Ok(gid) => println!("Started: #{}", gid.value()),
Err(e) => eprintln!("Error: {}", e),
}
}Re-exports§
pub use engine::multi_file_layout::TorrentFileEntry;pub use request::request_group::DownloadStatus;pub use request::request_group::RUNTIME_CHANGEABLE_OPTIONS;
Modules§
- auth
- HTTP Authentication module
- checksum
- colorized_
stream - config
- constants
- dns
- engine
- error
- filesystem
- ftp
- FTP 协议客户端模块
- http
- log
- option
- Option handling module.
- rate_
limiter - request
- retry
- segment
- selector
- session
- ui
- util
- validation
Macros§
- scoped_
perf_ timer - Helper macro for creating a scoped timer
Functions§
- init_
logging - Initialize the logging subsystem with optional file output.