aria2-core 0.3.14

aria2-rust core download engine: multi-protocol segmented downloads, rate limiting, configuration, session persistence, and BitTorrent seeding
Documentation
//! Runtime option policy shared by every external adapter.
//!
//! The option names in this module define one compatibility policy shared by
//! every external adapter. Keeping this metadata in core prevents JSON-RPC,
//! XML-RPC, the C API, and future adapters from drifting into different
//! interpretations of the same wire contract.

/// Options accepted by aria2's `changeGlobalOption` method.
///
/// This is the original aria2 `setChangeGlobalOption(true)` set. Unknown
/// names and known names outside this set must be ignored by RPC adapters.
pub const RUNTIME_GLOBAL_CHANGEABLE_OPTIONS: &[&str] = &[
    // General
    "allow-overwrite",
    "allow-piece-length-change",
    "always-resume",
    "async-dns",
    "auto-file-renaming",
    "check-integrity",
    "conditional-get",
    "continue",
    "dir",
    "disk-cache",
    "download-result",
    "enable-mmap",
    "file-allocation",
    "force-save",
    "save-not-found",
    "hash-check-only",
    "keep-unfinished-download-result",
    "log",
    "log-level",
    "max-concurrent-downloads",
    "max-connection-per-server",
    "max-download-limit",
    "max-http2-sessions-per-server",
    "max-http2-streams-per-session",
    "max-download-result",
    "max-mmap-limit",
    "max-overall-download-limit",
    "max-resume-failure-tries",
    "min-http-range-size",
    "min-split-size",
    "no-file-allocation-limit",
    "parameterized-uri",
    "pause-metadata",
    "realtime-chunk-checksum",
    "remove-control-file",
    "save-session",
    "rpc-save-upload-metadata",
    // HTTP/FTP
    "connect-timeout",
    "dry-run",
    "lowest-speed-limit",
    "max-file-not-found",
    "max-tries",
    "http-version",
    "http-adaptive-enabled",
    "http-adaptive-reduction-percent",
    "http-adaptive-backoff-base",
    "http-adaptive-backoff-max",
    "no-netrc",
    "piece-length",
    "remote-time",
    "retry-wait",
    "reuse-uri",
    "server-stat-of",
    "split",
    "stream-piece-selector",
    "timeout",
    "uri-selector",
    "content-disposition-default-utf8",
    "enable-http-keep-alive",
    "enable-http-pipelining",
    "header",
    "http-accept-gzip",
    "http-auth-challenge",
    "http-no-cache",
    "http-passwd",
    "http-user",
    "metalink-location",
    "referer",
    "save-cookies",
    "use-head",
    "no-want-digest-header",
    "user-agent",
    "ftp-passwd",
    "ftp-pasv",
    "ftp-reuse-connection",
    "ftp-type",
    "ftp-user",
    "ssh-host-key-md",
    "sftp-connect-timeout",
    "sftp-read-timeout",
    "sftp-compression",
    "sftp-keepalive-interval",
    "sftp-preferred-ciphers",
    "http-proxy",
    "http-proxy-passwd",
    "http-proxy-user",
    "https-proxy",
    "https-proxy-passwd",
    "https-proxy-user",
    "ftp-proxy",
    "ftp-proxy-passwd",
    "ftp-proxy-user",
    "all-proxy",
    "all-proxy-passwd",
    "all-proxy-user",
    "no-proxy",
    "proxy-method",
    // BitTorrent
    "bt-enable-hook-after-hash-check",
    "bt-enable-lpd",
    "bt-exclude-tracker",
    "bt-external-ip",
    "bt-force-encryption",
    "bt-hash-check-seed",
    "bt-load-saved-metadata",
    "bt-max-open-files",
    "bt-piece-selection-strategy",
    "bt-endgame-threshold",
    "dht-max-peer-info-hashes",
    "dht-max-peers-per-info-hash",
    "dht-max-items",
    "bt-max-peers",
    "bt-metadata-only",
    "bt-min-crypto-level",
    "bt-prioritize-piece",
    "bt-remove-unselected-file",
    "bt-request-peer-speed-limit",
    "bt-require-crypto",
    "bt-seed-unverified",
    "bt-save-metadata",
    "bt-stop-timeout",
    "bt-tracker",
    #[cfg(feature = "bittorrent")]
    "bt-incoming-peer-handshake-timeout",
    #[cfg(feature = "bittorrent")]
    "bt-utp-max-connections",
    #[cfg(feature = "bittorrent")]
    "bt-utp-connect-timeout",
    #[cfg(feature = "bittorrent")]
    "bt-utp-idle-timeout",
    #[cfg(feature = "bittorrent")]
    "bt-utp-keepalive-interval",
    #[cfg(feature = "bittorrent")]
    "enable-public-trackers",
    #[cfg(feature = "bittorrent")]
    "bt-tracker-source",
    #[cfg(feature = "bittorrent")]
    "bt-tracker-update-interval",
    #[cfg(feature = "bittorrent")]
    "bt-tracker-source-timeout",
    #[cfg(feature = "bittorrent")]
    "bt-tracker-source-concurrency",
    "bt-tracker-connect-timeout",
    "bt-tracker-interval",
    "bt-tracker-timeout",
    "bt-tracker-stopped-timeout",
    "enable-peer-exchange",
    "follow-torrent",
    "max-overall-upload-limit",
    "max-upload-limit",
    "seed-time",
    "seed-ratio",
    // Metalink
    "follow-metalink",
    "metalink-base-uri",
    "metalink-enable-unique-protocol",
    "metalink-language",
    "metalink-os",
    "metalink-preferred-protocol",
    "metalink-version",
];

/// Options copied into a request group when aria2 creates a download.
///
/// This includes aria2's `setInitialOption(true)` set from
/// `OptionHandlerFactory.cc` and supported Rust task extensions.
/// `aria2.getOption` serializes only these values from a group's option state;
/// RPC listener, authentication, logging, and other process-wide settings must
/// never become task options.
pub const INITIAL_REQUEST_OPTIONS: &[&str] = &[
    "allow-overwrite",
    "allow-piece-length-change",
    "all-proxy",
    "all-proxy-passwd",
    "all-proxy-user",
    "always-resume",
    "async-dns",
    "auto-file-renaming",
    "bt-enable-hook-after-hash-check",
    "bt-enable-lpd",
    "bt-exclude-tracker",
    "bt-external-ip",
    "bt-force-encryption",
    "bt-hash-check-seed",
    "bt-load-saved-metadata",
    "bt-max-peers",
    "bt-piece-selection-strategy",
    "bt-endgame-threshold",
    "bt-max-upload-slots",
    "bt-optimistic-unchoke-interval",
    "bt-snubbed-timeout",
    "bt-metadata-only",
    "bt-min-crypto-level",
    "bt-prioritize-piece",
    "bt-remove-unselected-file",
    "bt-request-peer-speed-limit",
    "bt-require-crypto",
    "bt-save-metadata",
    "bt-seed-unverified",
    "bt-stop-timeout",
    "bt-tracker",
    "enable-utp",
    "utp-listen-port",
    "bt-tracker-connect-timeout",
    "bt-tracker-interval",
    "bt-tracker-timeout",
    "bt-tracker-stopped-timeout",
    "enable-dht",
    "enable-dht6",
    "dht-listen-port",
    "dht-listen-addr",
    "dht-listen-addr6",
    "dht-entry-point",
    "dht-entry-point-host",
    "dht-entry-point-port",
    "dht-entry-point6",
    "dht-entry-point-host6",
    "dht-entry-point-port6",
    "dht-file-path",
    "dht-file-path6",
    "dht-message-timeout",
    "dht-refresh-check-interval",
    "dht-token-rotation-interval",
    "dht-node-contact-interval",
    "dht-cleanup-interval",
    "dht-save-interval",
    "dht-bootstrap-timeout",
    "dht-max-concurrent-lookups",
    "dht-persistence-max-age",
    "check-integrity",
    "checksum",
    "conditional-get",
    "connect-timeout",
    "content-disposition-default-utf8",
    "continue",
    "dir",
    "disk-cache",
    "dry-run",
    "enable-http-keep-alive",
    "enable-http-pipelining",
    "enable-mmap",
    "enable-peer-exchange",
    "file-allocation",
    "follow-metalink",
    "follow-torrent",
    "force-save",
    "ftp-passwd",
    "ftp-pasv",
    "ftp-proxy",
    "ftp-proxy-passwd",
    "ftp-proxy-user",
    "ftp-reuse-connection",
    "ftp-type",
    "ftp-user",
    "gid",
    "hash-check-only",
    "header",
    "http-accept-gzip",
    "http-auth-challenge",
    "http-no-cache",
    "http-passwd",
    "http-proxy",
    "http-proxy-passwd",
    "http-proxy-user",
    "http-user",
    "https-proxy",
    "https-proxy-passwd",
    "https-proxy-user",
    "index-out",
    "lowest-speed-limit",
    "max-connection-per-server",
    "max-download-limit",
    "max-file-not-found",
    "max-http2-sessions-per-server",
    "max-http2-streams-per-session",
    "http-version",
    "http-adaptive-enabled",
    "http-adaptive-reduction-percent",
    "http-adaptive-backoff-base",
    "http-adaptive-backoff-max",
    "max-mmap-limit",
    "max-resume-failure-tries",
    "max-tries",
    "max-upload-limit",
    "metalink-base-uri",
    "metalink-enable-unique-protocol",
    "metalink-language",
    "metalink-location",
    "metalink-os",
    "metalink-preferred-protocol",
    "metalink-version",
    "min-http-range-size",
    "min-split-size",
    "no-file-allocation-limit",
    "no-netrc",
    "no-proxy",
    "no-want-digest-header",
    "out",
    "parameterized-uri",
    "pause",
    "pause-metadata",
    "piece-length",
    "proxy-method",
    "realtime-chunk-checksum",
    "referer",
    "remote-time",
    "remove-control-file",
    "retry-wait",
    "reuse-uri",
    "rpc-save-upload-metadata",
    "save-not-found",
    "seed-ratio",
    "seed-time",
    "select-file",
    "split",
    "ssh-host-key-md",
    "sftp-connect-timeout",
    "sftp-read-timeout",
    "sftp-compression",
    "sftp-keepalive-interval",
    "sftp-preferred-ciphers",
    "stream-piece-selector",
    "timeout",
    "uri-selector",
    "use-head",
    "user-agent",
];

/// Initial options whose typed execution representation must not replace the
/// original wire spelling when a session entry is written.
pub const INITIAL_SNAPSHOT_WIRE_OPTIONS: &[&str] = &[
    "http-adaptive-reduction-percent",
    "http-adaptive-backoff-base",
    "http-adaptive-backoff-max",
    "min-http-range-size",
    "min-split-size",
];

/// Initial options consumed by task creation rather than download behavior.
///
/// `gid` is an identity allocator input and must never be serialized as a
/// normal per-download behavior option.
pub const INITIAL_IDENTITY_OPTIONS: &[&str] = &["gid"];

mod policy;
pub use policy::{
    RUNTIME_CHANGEABLE_FOR_RESERVED_OPTIONS, RUNTIME_CHANGEABLE_OPTIONS,
    is_global_option_changeable, is_initial_option, is_option_available, is_option_changeable,
    project_initial_options,
};

/// The application mode for a task-level runtime option update.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChangeableKind {
    /// Option takes effect immediately.
    Immediate,
    /// Option is stored as pending and applied on the next restart.
    Pending,
    /// Option cannot be changed through `aria2.changeOption`.
    NotChangeable,
}

#[cfg(test)]
mod tests;