Skip to main content

Module advanced_download

Module advanced_download 

Source
Expand description

Advanced parallel download functionality with resume support.

The AdvancedDownloader provides high-performance downloads using:

  • Parallel connections: Split files into chunks downloaded simultaneously
  • Resume support: Continue interrupted downloads from where they left off
  • Progress callbacks: Real-time progress and status updates
  • Cancellation: Graceful download cancellation via atomic tokens

§Example

use kget::{AdvancedDownloader, ProxyConfig, Optimizer};
use std::sync::Arc;

let mut downloader = AdvancedDownloader::new(
    "https://releases.ubuntu.com/22.04/ubuntu-22.04-desktop-amd64.iso".to_string(),
    "ubuntu.iso".to_string(),
    false,
    ProxyConfig::default(),
    Optimizer::new(),
);

// Set progress callback (0.0 to 1.0)
downloader.set_progress_callback(Arc::new(|progress| {
    println!("Progress: {:.1}%", progress * 100.0);
}));

// Set status callback for messages
downloader.set_status_callback(Arc::new(|msg| {
    println!("Status: {}", msg);
}));

// Start download
downloader.download().unwrap();

§Parallel Downloads

The downloader automatically determines the optimal number of connections based on the Optimizer configuration. For large files, this can provide significant speed improvements.

Structs§

AdvancedDownloader
High-performance downloader with parallel connections and resume support.