| 116 | } |
| 117 | |
| 118 | pub fn read_disk_cache<T>(file_path: &Path) -> std::io::Result<T> |
| 119 | where |
| 120 | T: for<'de> Decode<'de>, |
| 121 | { |
| 122 | println!("Reading cache from {}...", file_path.display()); |
| 123 | let compressed_data = std::fs::read(file_path)?; |
| 124 | let encoded_data: Vec<u8> = decompress(&compressed_data)?; |
| 125 | let decoded = bitcode::decode(&encoded_data).map_err(std::io::Error::other)?; |
| 126 | |
| 127 | Ok(decoded) |
| 128 | } |
| 129 | |
| 130 | pub fn cleanup_cache_files(prefix: &str, cache_location: &Path, max_cache_files: u32) { |
| 131 | let mut paths: Vec<PathBuf> = std::fs::read_dir(cache_location) |