| Crates.io | file-downloader |
| lib.rs | file-downloader |
| version | 0.2.0 |
| created_at | 2024-12-21 05:49:01.834008+00 |
| updated_at | 2025-02-06 21:49:04.770825+00 |
| description | A Rust library to download and verify files, including MD5 checksum verification. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1490772 |
| size | 104,000 |
file_downloader is a Rust library designed to help you efficiently download and verify possibly md5 checksummed files. It offers functionality to:
FileDownloader trait provides a simple interface for downloading files, so you only need to implement the download method to leverage all of this crate’s functionality.use file_downloader::{FileDownloader, PbfDownloadError};
use std::path::PathBuf;
use async_trait::async_trait;
struct PlanetDownloader;
#[async_trait]
impl FileDownloader for PlanetDownloader {
fn download_link(&self) -> &str {
"https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
}
}
#[tokio::main]
async fn main() -> Result<(), PbfDownloadError> {
let downloader = PlanetDownloader;
let local_path = downloader.find_file_locally_or_download_into("./pbf_cache").await?;
println!("file available at: {:?}", local_path);
Ok(())
}
This crate includes a comprehensive test suite that covers:
You can run tests with:
cargo test
This project is licensed under the MIT License. See the LICENSE file for details.