(
object: &BTreeMap<String, JsonValue>,
key: &str,
context: &str,
)
| 745 | } |
| 746 | |
| 747 | fn optional_string_map( |
| 748 | object: &BTreeMap<String, JsonValue>, |
| 749 | key: &str, |
| 750 | context: &str, |
| 751 | ) -> Result<Option<BTreeMap<String, String>>, ConfigError> { |
| 752 | match object.get(key) { |
| 753 | Some(value) => { |
| 754 | let Some(map) = value.as_object() else { |
| 755 | return Err(ConfigError::Parse(format!( |
| 756 | "{context}: field {key} must be an object" |
| 757 | ))); |
| 758 | }; |
| 759 | map.iter() |
| 760 | .map(|(entry_key, entry_value)| { |
| 761 | entry_value |
| 762 | .as_str() |
| 763 | .map(|text| (entry_key.clone(), text.to_string())) |
| 764 | .ok_or_else(|| { |
| 765 | ConfigError::Parse(format!( |
| 766 | "{context}: field {key} must contain only string values" |
| 767 | )) |
| 768 | }) |
| 769 | }) |
| 770 | .collect::<Result<BTreeMap<_, _>, _>>() |
| 771 | .map(Some) |
| 772 | } |
| 773 | None => Ok(None), |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | fn deep_merge_objects( |
| 778 | target: &mut BTreeMap<String, JsonValue>, |
no test coverage detected