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

Function optional_string_array

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

Source from the content-addressed store, hash-verified

717}
718
719fn optional_string_array(
720 object: &BTreeMap<String, JsonValue>,
721 key: &str,
722 context: &str,
723) -> Result<Option<Vec<String>>, ConfigError> {
724 match object.get(key) {
725 Some(value) => {
726 let Some(array) = value.as_array() else {
727 return Err(ConfigError::Parse(format!(
728 "{context}: field {key} must be an array"
729 )));
730 };
731 array
732 .iter()
733 .map(|item| {
734 item.as_str().map(ToOwned::to_owned).ok_or_else(|| {
735 ConfigError::Parse(format!(
736 "{context}: field {key} must contain only strings"
737 ))
738 })
739 })
740 .collect::<Result<Vec<_>, _>>()
741 .map(Some)
742 }
743 None => Ok(None),
744 }
745}
746
747fn optional_string_map(
748 object: &BTreeMap<String, JsonValue>,

Callers 4

parse_mcp_server_configFunction · 0.85

Calls 3

getMethod · 0.80
as_arrayMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected