MCPcopy Create free account
hub / github.com/ddd/gpb / load_mask_data

Function load_mask_data

src/utils/mask.rs:29–46  ·  view source on GitHub ↗

Load and parse the mask.json file

()

Source from the content-addressed store, hash-verified

27
28/// Load and parse the mask.json file
29pub 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
49pub fn get_countries_for_mask(mask_pattern: &str) -> Result<Vec<String>, Error> {

Callers 5

mainFunction · 0.85
get_countries_for_maskFunction · 0.85
test_load_mask_dataFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_load_mask_dataFunction · 0.68