๐ฆ DWUTIL
A Rust library for downloading, verifying, decompressing, and storing files in a concurrent and customizable way.
Supports:
- โ
HTTP downloads (via
ureq) - โ
Custom progress indicators (e.g.,
indicatif) - โ Hash validation (SHA, MD5, etc.)
- โ Decompression (ZIP, GZ, TAR, XZ)
- โ Content-addressable storage (CAS)
- โ Multithreaded downloading
โจ Features
- Download files from the internet with progress updates
- Validate integrity using hashes
- Decompress archives to custom destinations
- Exclude files/folders during decompression
- Store files using content-addressable storage
- Download multiple files concurrently
Cargo Features
| Feature | Purpose |
|---|---|
sha |
Add support to sha1 and sha2 hashing |
md5 |
Add support to md5 hashing |
zip |
Add support to zip decompression |
tar |
Add support to tar decompression |
targz |
Add support to tar gz decompression |
tarxz |
Add support to tar xz decompression |
gz |
Add support to gzip decompression |
xz |
Add support to xz decompression |
indicatif |
Add indicatif indicator bar |
๐ฆ Installation
# Cargo.toml
[]
= "0.0.1"
๐ Quick Start
use ;
๐ File Configuration
The File struct represents a downloadable file.
use Sha256;
let file = new
.with_path
.with_size
.with_hash
.with_decompression
.with_store;
Optional settings:
.with_size(size)โ expected file size.with_hash(hash)โ expected hash for integrity check.with_decompression(...)โ automatically extract after download.with_store(...)โ store using content-addressable logic
๐ Decompression
Set how to decompress the file and where to extract it:
let decompression =
.with_dst
.with_exclude;
Decompression options:
- Supported formats:
.zip,.tar.gz,.xz,.gz - Exclude files/folders by relative path
๐ Hash Validation
You can validate files using several hash types (e.g., SHA1, SHA256, MD5):
use Hash;
use Sha256;
let file = file.with_hash;
If the downloaded file doesn't match the hash, it will return an error.
๐งฑ Content-Addressable Storage
Use a CAS to deduplicate and organize files by content:
use DefaultStore;
let store = new;
let file = file.with_store;
Files will be stored in the store instead of the provided path.
๐ Progress Indicators
You can implement your own progress UI using the Indicator and IndicatorFactory traits.
Example using indicatif:
use IndicatifFactory;
// Use the default style bar
let factory = new;
let dw = new;
By default the crate provides, a SilentFactory indicator and a LogFactory indicator
๐ Download Multiple Files
You can download several files at once with concurrency:
new
.with_files
.with_max_current_downloads
.start?;
๐งช Testing
Unit tests can be added inside the tests module and will run with:
๐ Modules Overview
| Module | Purpose |
|---|---|
cas |
Store files using content-addressable methods |
decompress |
Decode and extract various archive types |
hash |
File hashing (SHA1, SHA256, MD5, etc.) |
indicator |
Progress bars, logging, error reporting |
utils |
Internal tools for copying, paths, etc. |
โ Requirements
- Rust 1.70+
- Internet connection (for actual downloads)
- Supported archive formats (ZIP, TAR, etc.)
๐ Dependencies
๐ License
MIT