Load and parse the mask.json file
()
| 27 | |
| 28 | /// Load and parse the mask.json file |
| 29 | pub fn load_mask_data() -> Result<(), Error> { |
| 30 | let mask_path = "data/mask.json"; |
| 31 | |
| 32 | // Check if file exists |
| 33 | if !std::path::Path::new(mask_path).exists() { |
| 34 | return Err(anyhow!("Mask data file not found: {}", mask_path)); |
| 35 | } |
| 36 | |
| 37 | // Read and parse the JSON |
| 38 | let mask_json = fs::read_to_string(mask_path)?; |
| 39 | let mask_data: MaskData = serde_json::from_str(&mask_json)?; |
| 40 | |
| 41 | // Store in the global variable |
| 42 | let mut data = MASK_DATA.write().unwrap(); |
| 43 | *data = Some(mask_data); |
| 44 | |
| 45 | Ok(()) |
| 46 | } |
| 47 | |
| 48 | /// Get countries that match a given mask pattern |
| 49 | pub fn get_countries_for_mask(mask_pattern: &str) -> Result<Vec<String>, Error> { |
no outgoing calls