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)?)) }