Load binary registry from the compile-time embedded registry data.
()
| 234 | |
| 235 | /// Load binary registry from the compile-time embedded registry data. |
| 236 | pub fn load_embedded_binary_registry() -> Result<BinaryRegistry> { |
| 237 | let mut binaries = HashMap::new(); |
| 238 | if let Some(dir) = EMBEDDED_REGISTRY.get_dir("binaries") { |
| 239 | for file in dir.files() { |
| 240 | if file.path().extension().is_some_and(|ext| ext == "yaml") { |
| 241 | let contents = file.contents_utf8().ok_or_else(|| { |
| 242 | miette::miette!("non-UTF8 registry file: {}", file.path().display()) |
| 243 | })?; |
| 244 | let cap = parse_binary_capability(contents, &file.path().display().to_string())?; |
| 245 | binaries.insert(cap.path.clone(), cap); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | Ok(BinaryRegistry { binaries }) |
| 250 | } |
| 251 | |
| 252 | /// Load binary registry from a filesystem directory override. |
| 253 | pub fn load_binary_registry_from_dir(registry_dir: &std::path::Path) -> Result<BinaryRegistry> { |