MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / optional_string_map

Function optional_string_map

claw-code/rust/crates/runtime/src/config.rs:747–775  ·  view source on GitHub ↗
(
    object: &BTreeMap<String, JsonValue>,
    key: &str,
    context: &str,
)

Source from the content-addressed store, hash-verified

745}
746
747fn 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
777fn deep_merge_objects(
778 target: &mut BTreeMap<String, JsonValue>,

Callers 2

parse_mcp_server_configFunction · 0.85

Calls 3

getMethod · 0.80
as_objectMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected