Load and parse the format.json file
()
| 36 | |
| 37 | /// Load and parse the format.json file |
| 38 | pub fn load_format_data() -> Result<(), Error> { |
| 39 | let format_path = "data/format.json"; |
| 40 | |
| 41 | // Check if file exists |
| 42 | if !std::path::Path::new(format_path).exists() { |
| 43 | return Err(anyhow!("Format data file not found: {}", format_path)); |
| 44 | } |
| 45 | |
| 46 | // Read and parse the JSON |
| 47 | let format_json = fs::read_to_string(format_path)?; |
| 48 | let format_data: FormatData = serde_json::from_str(&format_json)?; |
| 49 | |
| 50 | // Store in the global variable |
| 51 | let mut data = FORMAT_DATA.write().unwrap(); |
| 52 | *data = Some(format_data); |
| 53 | |
| 54 | Ok(()) |
| 55 | } |
| 56 | |
| 57 | /// Get country format information |
| 58 | pub fn get_country_format(country_code: &str) -> Result<CountryFormat, Error> { |
no outgoing calls