rust_tokenizers 3.1.2

High performance tokenizers for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::path::PathBuf;
use std::fs;
use std::fs::File;
use std::io::copy;

pub fn download_file_to_cache(src: &str, target: &str) -> Result<PathBuf, reqwest::Error> {
    let mut home = dirs::home_dir().unwrap();
    home.push(".cache");
    home.push(".rust_tokenizers");
    home.push(target);
    if !home.exists() {
        let mut response = reqwest::blocking::get(src)?;
        fs::create_dir_all(home.parent().unwrap()).unwrap();
        let mut dest = File::create(&home).unwrap();
        copy(&mut response, &mut dest).unwrap();
    }
    Ok(home)
}