pub struct DownloadEngine { /* private fields */ }Implementations§
Source§impl DownloadEngine
impl DownloadEngine
pub fn new(tick_interval_ms: u64) -> Self
pub fn with_retry_policy(tick_interval_ms: u64, policy: RetryPolicy) -> Self
pub fn set_global_rate_limiter(&mut self, config: RateLimiterConfig)
pub fn global_rate_limiter(&self) -> Option<&RateLimiter>
pub fn take_global_rate_limiter(&mut self) -> Option<RateLimiter>
Sourcepub fn spawn_progress_aggregator(
group: Arc<RwLock<RequestGroup>>,
receiver: UnboundedReceiver<ProgressUpdate>,
) -> JoinHandle<()>
pub fn spawn_progress_aggregator( group: Arc<RwLock<RequestGroup>>, receiver: UnboundedReceiver<ProgressUpdate>, ) -> JoinHandle<()>
Spawn a progress aggregator task that receives ProgressUpdates from
download commands and applies them to the shared RequestGroup.
This eliminates per-chunk write-lock contention on the download hot
path: each DownloadCommand performs a cheap lock-free
mpsc::UnboundedSender::send and this single aggregator task is the
only writer of the progress fields.
The aggregator deduplicates consecutive updates with identical
completed_bytes values and only refreshes the speed fields when the
sender provides a non-zero download_speed sample (0 means “no fresh
sample this tick”).
The task exits cleanly when all senders are dropped (the receiver
returns None).
This is intentionally an associated function (not &self): it is
called automatically by
DownloadCommand::spawn_progress_aggregator
during execute(), since every DownloadCommand now auto-creates a
progress channel in its constructor. External callers rarely need to
invoke this directly.
pub fn set_save_session( &mut self, path: PathBuf, interval: Option<Duration>, man: Arc<RwLock<RequestGroupMan>>, )
pub fn mark_session_dirty(&self)
pub fn save_session_path(&self) -> Option<&PathBuf>
pub fn add_command(&self, command: Box<dyn Command>) -> Result<()>
pub fn retry_stats(&self) -> &RetryStats
pub fn retry_policy(&self) -> &RetryPolicy
Sourcepub fn ftp_pool(&self) -> &Arc<FtpConnectionPool> ⓘ
pub fn ftp_pool(&self) -> &Arc<FtpConnectionPool> ⓘ
Get a reference to the FTP connection pool for dependency injection.
Sourcepub fn dns_cache(&self) -> &Arc<Mutex<DnsCache>> ⓘ
pub fn dns_cache(&self) -> &Arc<Mutex<DnsCache>> ⓘ
Get a reference to the DNS cache for dependency injection.
Sourcepub fn set_keep_alive(&mut self, v: bool)
pub fn set_keep_alive(&mut self, v: bool)
Enable/disable keep-alive mode. When true, the engine stays alive even with no pending/running commands (used for RPC listen mode). The loop only exits on shutdown signal.
Sourcepub fn command_sender(&self) -> UnboundedSender<Box<dyn Command>>
pub fn command_sender(&self) -> UnboundedSender<Box<dyn Command>>
Clone the command sender so external callers (e.g., RPC) can submit download commands to the engine loop.
Sourcepub fn take_shutdown_sender(&mut self) -> Option<Sender<()>>
pub fn take_shutdown_sender(&mut self) -> Option<Sender<()>>
Take the shutdown sender so an external task (e.g., Ctrl+C handler) can
signal the engine to stop. Must be called before run().