create cache module

This commit is contained in:
2024-12-09 04:31:00 +01:00
parent b0c2c8d478
commit 573fc14767
5 changed files with 52 additions and 50 deletions

View File

@@ -1,5 +1,4 @@
use crate::misc;
use crate::structs::{PrintPrefix, StoredGameData};
use crate::structs::PrintPrefix;
use colored::Colorize;
use once_cell::sync::Lazy;
use std::collections::HashMap;
@@ -66,17 +65,3 @@ pub async fn check_connectivity() -> bool {
}
}
}
pub fn get_stored_data() -> Option<StoredGameData> {
let dir = std::env::current_dir().ok()?;
let cache = misc::get_cache(&dir);
cache.stored_data
}
pub fn store_game_data(data: &StoredGameData) -> Result<(), Box<dyn std::error::Error>> {
let dir = std::env::current_dir()?;
let mut cache = misc::get_cache(&dir);
cache.stored_data = Some((*data).clone());
misc::save_cache(&dir, cache);
Ok(())
}