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

Function get_node_field

atomic-repository/src/query_plan.rs:511–530  ·  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

509
510/// Get a field value from a KgNode for filtering.
511fn get_node_field(node: &KgNode, field: &str) -> Option<String> {
512 match field {
513 "type" => Some(node.primary_type().to_owned()),
514 "label" => Some(node.label.clone()),
515 "source" => Some(node.source.clone()),
516 "summary" => node.summary.clone(),
517 "id" => Some(node.id.clone()),
518 // Check metadata
519 other => node
520 .metadata
521 .as_ref()
522 .and_then(|m| m.get(other))
523 .and_then(|v| match v {
524 serde_json::Value::String(s) => Some(s.clone()),
525 serde_json::Value::Number(n) => Some(n.to_string()),
526 serde_json::Value::Bool(b) => Some(b.to_string()),
527 _ => None,
528 }),
529 }
530}
531
532// ── Parse helper ────────────────────────────────────────────────
533

Callers 2

execute_plan_innerFunction · 0.85
test_filter_nodesFunction · 0.85

Calls 4

primary_typeMethod · 0.80
as_refMethod · 0.80
getMethod · 0.65
cloneMethod · 0.45

Tested by 1

test_filter_nodesFunction · 0.68