traxex

Crates.iotraxex
lib.rstraxex
version0.2.1
sourcesrc
created_at2019-08-05 23:33:35.229587
updated_at2024-09-11 14:27:17.110249
descriptionA library to download files through url link.
homepage
repositoryhttps://github.com/zhangzhishan/traxex/tree/master
max_upload_size
id154420
size283,236
Zhang Zhishan (zhangzhishan)

documentation

README

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

Commit count: 0

cargo fmt