Skip to content
Snippets Groups Projects
Unverified Commit 8ebb3849 authored by Nikos Kontakis's avatar Nikos Kontakis
Browse files

add net in support and download fn

parent 1d8fe2bb
Branches
No related merge requests found
......@@ -9,4 +9,5 @@ edition = "2021"
thiserror = "1.0.40"
async-trait = "0.1.68"
futures = "0.3.28"
reqwest = "0.11.18"
pub mod fs;
pub mod net;
use std::io::Cursor;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
pub async fn download_file(url: String, dest: String) -> Result<()> {
let response = reqwest::get(url).await?;
let mut file = std::fs::File::create(dest)?;
let mut content = Cursor::new(response.bytes().await?);
std::io::copy(&mut content, &mut file)?;
Ok(())
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment