1use std::io::Read;
2use tracing::info;
3use zip;
4
5pub fn get_core_gts_schemas() -> anyhow::Result<Vec<serde_json::Value>> {
16 info!("Loading core GTS schemas from embedded archive");
17
18 let mut schemas = Vec::new();
19
20 let zip_data = include_bytes!(concat!(env!("OUT_DIR"), "/core_gts_schemas.zip"));
22 let cursor = std::io::Cursor::new(zip_data);
23 let mut archive = zip::ZipArchive::new(cursor)?;
24
25 for i in 0..archive.len() {
27 let mut file = archive.by_index(i)?;
28 let file_name = file.name().to_owned();
29
30 if file_name.ends_with(".schema.json") {
32 let mut contents = String::new();
33 file.read_to_string(&mut contents)?;
34
35 let schema_json: serde_json::Value = serde_json::from_str(&contents)
36 .map_err(|e| anyhow::anyhow!("Failed to parse schema {file_name}: {e}"))?;
37
38 schemas.push(schema_json);
39 info!("Loaded core GTS schema: {}", file_name);
40 }
41 }
42
43 if schemas.is_empty() {
44 return Err(anyhow::anyhow!(
45 "no core GTS schemas found in embedded archive"
46 ));
47 }
48
49 info!("Core GTS schemas loaded: {} schemas", schemas.len());
50 Ok(schemas)
51}