(path: &Path)
| 222 | |
| 223 | use crate::speech::*; |
| 224 | fn read_one_definitions_file(path: &Path) -> Result<()> { |
| 225 | // read in the file contents |
| 226 | let definition_file_contents = read_to_string_shim(path) |
| 227 | .chain_err(|| format!("trying to read {}", path.to_str().unwrap()))?; |
| 228 | |
| 229 | // callback to do the work of building up the defined vectors/hashmaps (in 'build_values') from YAML |
| 230 | let defs_build_fn = |variable_def_list: &Yaml| { |
| 231 | // Rule::DefinitionList |
| 232 | // debug!("variable_def_list {} is\n{}", yaml_to_type(variable_def_list), yaml_to_string(variable_def_list)); |
| 233 | let vec = crate::speech::as_vec_checked(variable_def_list) |
| 234 | .chain_err(||format!("in file {:?}", path.to_str()))?; |
| 235 | for variable_def in vec { |
| 236 | build_values(variable_def).chain_err(||format!("in file {:?}", path.to_str()))?; |
| 237 | } |
| 238 | return Ok(()); |
| 239 | }; |
| 240 | |
| 241 | // Convert the file contents to YAML and call the callback |
| 242 | return crate::speech::compile_rule(&definition_file_contents, defs_build_fn) |
| 243 | .chain_err(|| format!("In file '{}'", path.to_str().unwrap())); |
| 244 | } |
| 245 | |
| 246 | // Do the work of converting a single YAML def into the vec/hashset |
| 247 | fn build_values(definition: &Yaml) -> Result<()> { |
no test coverage detected