View on GitHub

KelpsGet

A modern, lightweight wget clone written in Rust for fast and reliable file downloads from the command line.

Using KGet as a Library

KGet is a versatile Rust crate that provides a high-performance download engine. It is designed to be integrated into other projects while maintaining the same efficiency (RAM/Disk optimization) as the CLI app.

English Português Español

Installation

Add KGet to your Cargo.toml:

[dependencies]
kget = { version = "1.5.1", features = ["gui"] }

For local development (when working inside the repository), use a path dependency:

[dependencies]
kget = { path = "." }

Key Components

The library exposes the following building blocks:

Complete Usage Guide

For a live demonstration of all features, see the Cookbook Example.

Quick Example: Standard Download

use kget::{download, DownloadOptions, Config, Optimizer};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let config = Config::default();
    let options = DownloadOptions {
        output_path: Some("file.zip".to_string()),
        ..Default::default()
    };

    download("https://example.com/file.zip", config.proxy, Optimizer::new(config.optimization), options)?;
    Ok(())
}

Quick Example: Parallel Download

use kget::{AdvancedDownloader, Config, Optimizer};

let config = Config::default();
let downloader = AdvancedDownloader::new(
    "https://example.com/large.iso".into(),
    "large.iso".into(),
    false, // quiet_mode
    config.proxy,
    Optimizer::new(config.optimization)
);

downloader.download()?;

Interactivity vs Library Behavior

The core library functions never use stdin or prompt the user. All decisions are made via the DownloadOptions struct:

Efficiency by Design

When using KGet as a library, you automatically benefit from:

  1. Streaming I/O: 16KB read-write cycles to keep RAM usage low (~30MB).
  2. Buffered Writes: 2MB BufWriter per thread to protect disk health and prevent system freezes.
  3. Smart Detection: ISO files are automatically handled as raw binary to prevent corruption.

For more details, check the source of src/lib.rs.

Supported Protocols

More

See docs.rs/kget for full API documentation.