MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_node_field

Function get_node_field

atomic-repository/src/query_plan.rs:428–447  ·  view source on GitHub ↗

Get a field value from a KgNode for filtering.

(node: &KgNode, field: &str)

Source from the content-addressed store, hash-verified

426
427/// Get a field value from a KgNode for filtering.
428fn get_node_field(node: &KgNode, field: &str) -> Option<String> {
429 match field {
430 "kind" => Some(node.kind.clone()),
431 "label" => Some(node.label.clone()),
432 "source" => Some(node.source.clone()),
433 "summary" => node.summary.clone(),
434 "id" => Some(node.id.clone()),
435 // Check metadata
436 other => node
437 .metadata
438 .as_ref()
439 .and_then(|m| m.get(other))
440 .and_then(|v| match v {
441 serde_json::Value::String(s) => Some(s.clone()),
442 serde_json::Value::Number(n) => Some(n.to_string()),
443 serde_json::Value::Bool(b) => Some(b.to_string()),
444 _ => None,
445 }),
446 }
447}
448
449// ── Parse helper ────────────────────────────────────────────────
450

Callers 2

execute_planFunction · 0.85
test_filter_nodesFunction · 0.85

Calls 3

as_refMethod · 0.80
getMethod · 0.65
cloneMethod · 0.45

Tested by 1

test_filter_nodesFunction · 0.68