blob: 4a622f520e956e55a594dba6a6fdb272de4eef33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
pub mod hash;
pub mod json;
pub mod mime;
pub mod slot_map;
pub mod sqlite;
use std::{fs::File, path::PathBuf};
use data_encoding::Encoding;
use data_encoding_macro::new_encoding;
use rand::{thread_rng, Rng};
pub const BASE32: Encoding = new_encoding! {
symbols: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
translate_from: "abcdefghijklmnopqrstuvwxyz",
translate_to: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
};
pub fn temp_file() -> std::io::Result<(PathBuf, File)> {
let key: [u8; 16] = thread_rng().gen();
let mut path = std::env::temp_dir();
path.push(format!("carton-{}", BASE32.encode(&key)));
Ok((path.clone(), File::create_new(path)?))
}
|