Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::io::copy;
use std::fs::File;

pub fn download_from_the_giterwebs(repo_name: &String) -> Result<(), Box<dyn std::error::Error>> {
    let url = String::from("https://github.com/") + repo_name + "/archive/refs/heads/main.tar.gz";
    let mut response = reqwest::blocking::get(url)?
        .error_for_status()?; 

    let mut file = File::create("/tmp/pkg.ospk")?;
    copy(&mut response, &mut file)?;
    Ok(())
}