use std::collections::HashMap;
use std::fs;
pub type Index = HashMap<String, u64>;
pub fn load_index(path: &str) -> Index {
fs::read_to_string(&path)
.ok()
.and_then(|data| serde_json::from_str::<Index>(&data).ok())
.unwrap_or_default()
}
pub fn save_index(path: &str, index: &Index) {
let data = serde_json::to_string_pretty(index).unwrap();
fs::write(path, data).unwrap();
}