#download #url #link #wget #binary

bin+lib traxex

A library to download files through url link

4 releases

0.2.1 Sep 11, 2024
0.2.0 Sep 4, 2024
0.1.1 Jan 19, 2024
0.1.0 Aug 5, 2019

#172 in HTTP client

Download history 8/week @ 2024-07-30 1/week @ 2024-08-06 9/week @ 2024-08-13 6/week @ 2024-08-20 14/week @ 2024-08-27 133/week @ 2024-09-03 346/week @ 2024-09-10 20/week @ 2024-09-17 30/week @ 2024-09-24 27/week @ 2024-10-01

200 downloads per month

MIT license

220KB
225 lines

Traxex

LICENSE Crates.io Version Crates.io Coverage Status

Linux: Build Status Windows: Build status

Introduction

Traxex is the name of a Dota hero my wife like most, so I chose this as the name. When I try to download some files in another rust application, which I am working on. I couldn't find a easy to use library for downloading like wget or something similar. Therefore, I wrote this library, a very easy download library. As I am a newbee in rust, so there may be some code can be improved. Welcome to give me some advice by issues or pull request. Thank you in advance.

Usage

There are a binary which can be used to download files through url and a library to be used in your code.

Binary Usage

USAGE:
    traxex.exe [OPTIONS] <url>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -o, --output <output>    Specify the local output filename or directory

ARGS:
    <url>

Library Usage

There is only one public method to use download. This method has two params, the first is a &str url link, and the second is the output folder or output filename Option<&str>. If you don't want to give the filename, you can just leave the second parameter as None. It will generate a given filename according to the url path or from Content-Disposition headers if present. This method can return a Result<String>, which is the filename of the downloaded file.

extern crate lib_traxex;
use lib_traxex::download::download;

fn main() {
    let url_str = "https://raw.githubusercontent.com/zhangzhishan/blogpics/dev/traxex.jpg";

    match download(url_str, None) {
        Err(why) => panic!("couldn't write to : {}", why.to_string()),
        Ok(display) => println!("successfully wrote to {}", display)
    }
}

Reference

Python wget

Dependencies

~9–22MB
~329K SLoC