Skip to content

iiTONELOC/0xDL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0xDL

language Crates.io License: MIT


A Rust library for fast, reliable asynchronous file downloading.

Loading bar

0xDL provides a clean, minimal abstraction for downloading large files over HTTP/S using asynchronous Rust.

Built on Tokio and reqwest, it offers:

  • High‑performance async streaming
  • Optional progress callbacks
  • Optional SHA‑256 verification with guaranteed cleanup on failure
  • Atomic final file placement

Installation

Install 0xDL using Cargo:

cargo add oxdl

Or add it manually to Cargo.toml:

[dependencies]
oxdl = "0.1.5"

Features

  • Fully asynchronous file downloads
  • Optional Fn(f32) progress callbacks
  • Optional SHA‑256 integrity verification
  • Automatic cleanup of failed downloads
  • Atomic final file write

Screenshot

screenshot

Usage

0xDL exposes two high‑level functions.

1. download(url, path, sha256) — simple download

use oxdl::download;

#[tokio::main]
async fn main() -> Result<(), oxdl::DownloadError> {
    let url = "https://example.com/file.iso";
    let path = "file.iso";

    download(url, path, None).await?;
    Ok(())
}

2. download_with_updates(url, path, progress_callback, sha256)

use oxdl::download_with_updates;

#[tokio::main]
async fn main() -> Result<(), oxdl::DownloadError> {
    let url = "https://example.com/file.iso";
    let path = "file.iso";

    let progress = |pct: f32| println!("Progress: {:.1}%", pct);

    download_with_updates(url, path, Some(Box::new(progress)), None).await?;

    Ok(())
}

API Summary

Function Progress SHA‑256 Use Case
download ✔ optional Simple fire‑and‑forget download
download_with_updates ✔ optional ✔ optional UI/CLI progress + integrity checks

If SHA‑256 validation fails, 0xDL automatically deletes the temporary file.

Builder API

Advanced users may construct a downloader manually.

Example

use oxdl::Downloader;

let dl = Downloader::new("https://example.com/file.iso", "file.iso")?
    .on_update(|p| println!("{p:.1}%"))
    .with_sha256("deadbeef...")?;

dl.execute().await?;

Methods

Method Description
new(url, path) Validates and constructs a downloader
on_update(f) Sets a callback receiving progress 0–100%
with_sha256(hex) Enables SHA‑256 verification
execute() Performs the full download

Supported Platforms

  • Rust stable
  • Linux, macOS, Windows

Testing

0xDL organizes tests using features so expensive tests only run when requested.

Features

Feature Includes
tests Offline unit tests
net-tests Real HTTP downloads
dl-iso-test Large (>1GB) ISO stress test
all-tests tests + net-tests
all-tests-w-iso-dl everything including large ISO test

Running

cargo test --features tests
cargo test --features net-tests
cargo test --features all-tests
cargo test --features all-tests-w-iso-dl -- --nocapture
cargo test --features dl-iso-test -- --nocapture

License

MIT

Contributing

PRs welcome.

Contact

Created by Anthony Tropeanohttps://github.com/iitoneloc

About

Asynchronous Rust downloader with progress bars and SHA256 verification

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages