langcodec_cli/transformers/
langcodec_resource_array.rs1use std::fs;
2
3pub fn transform(input: String) -> Result<Vec<langcodec::Resource>, String> {
6 let content =
8 fs::read_to_string(&input).map_err(|e| format!("Error reading file {}: {}", input, e))?;
9
10 let resources: Vec<langcodec::Resource> = serde_json::from_str(&content)
12 .map_err(|e| format!("Error parsing JSON as Resource array: {}", e))?;
13
14 if resources.is_empty() {
16 return Err("Resource array is empty".to_string());
17 }
18
19 Ok(resources)
20}