MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / flatten_param_matcher

Function flatten_param_matcher

crates/openshell-policy/src/lib.rs:403–419  ·  view source on GitHub ↗

Walk one params subtree, carrying the flattened dot-path key accumulated so far. Leaf matchers are inserted into the map consumed by the runtime policy.

(
    key: &str,
    matcher: ParamMatcherDef,
    out: &mut BTreeMap<String, QueryMatcherDef>,
)

Source from the content-addressed store, hash-verified

401// Walk one params subtree, carrying the flattened dot-path key accumulated so
402// far. Leaf matchers are inserted into the map consumed by the runtime policy.
403fn flatten_param_matcher(
404 key: &str,
405 matcher: ParamMatcherDef,
406 out: &mut BTreeMap<String, QueryMatcherDef>,
407) {
408 match matcher {
409 ParamMatcherDef::Matcher(matcher) => {
410 out.insert(key.to_string(), matcher);
411 }
412 ParamMatcherDef::Object(children) => {
413 for (child_key, child) in children {
414 let nested_key = format!("{key}.{child_key}");
415 flatten_param_matcher(&nested_key, child, out);
416 }
417 }
418 }
419}
420
421// Convert flat runtime params back to YAML. MCP gets readable nested params
422// when the flat keys can be losslessly split. Non-MCP protocols keep flat keys

Callers 1

flatten_param_matchersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected