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

Function load_format_data

src/format/format.rs:38–55  ·  view source on GitHub ↗

Load and parse the format.json file

()

Source from the content-addressed store, hash-verified

36
37/// Load and parse the format.json file
38pub 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
58pub fn get_country_format(country_code: &str) -> Result<CountryFormat, Error> {

Calls

no outgoing calls