pub fn download(
target: &str,
proxy: ProxyConfig,
_optimizer: Optimizer,
options: DownloadOptions,
status_callback: Option<&(dyn Fn(String) + Send + Sync)>,
) -> Result<(), Box<dyn Error + Send + Sync>>Expand description
Download a file from a URL with automatic retry and progress tracking.
This is the simple download function for basic use cases. For parallel
connections and resume support, use AdvancedDownloader.
§Arguments
target- URL to downloadproxy- Proxy configuration (useProxyConfig::default()for no proxy)_optimizer- Optimizer instance (reserved for future use)options- Download options (quiet mode, output path, ISO verification)status_callback- Optional callback for status messages
§Example
use kget::{download, DownloadOptions, ProxyConfig, Optimizer};
download(
"https://releases.ubuntu.com/22.04/ubuntu-22.04-desktop-amd64.iso",
ProxyConfig::default(),
Optimizer::new(),
DownloadOptions {
quiet_mode: false,
output_path: None, // Uses filename from URL
verify_iso: true, // Verify SHA256 after download
},
None,
).unwrap();§Errors
Returns an error if:
- Network connection fails after MAX_RETRIES attempts
- HTTP response indicates an error
- Insufficient disk space
- File cannot be created