Crates.io | traxex |
lib.rs | traxex |
version | 0.2.1 |
source | src |
created_at | 2019-08-05 23:33:35.229587 |
updated_at | 2024-09-11 14:27:17.110249 |
description | A library to download files through url link. |
homepage | |
repository | https://github.com/zhangzhishan/traxex/tree/master |
max_upload_size | |
id | 154420 |
size | 283,236 |
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.
There are a binary which can be used to download files through url and a library to be used in your code.
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>
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)
}
}