MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_str

Function extract_str

nodedb-query/src/msgpack_scan/aggregate_helpers.rs:41–47  ·  view source on GitHub ↗

Extract a display string from `field`, or evaluate `expr` if provided. Returns `None` when the field is absent.

(doc: &[u8], field: &str, expr: Option<&SqlExpr>)

Source from the content-addressed store, hash-verified

39/// Extract a display string from `field`, or evaluate `expr` if provided.
40/// Returns `None` when the field is absent.
41pub fn extract_str(doc: &[u8], field: &str, expr: Option<&SqlExpr>) -> Option<String> {
42 if let Some(expr) = expr {
43 return Some(value_ops::value_to_display_string(&eval_expr(doc, expr)?));
44 }
45 let (start, _end) = extract_field(doc, 0, field)?;
46 read_str(doc, start).map(|s| s.to_string())
47}
48
49/// Extract a field as `Value`. Uses direct msgpack→Value for scalars;
50/// falls back to full document decode only for complex types.

Callers 1

feedMethod · 0.85

Calls 5

value_to_display_stringFunction · 0.85
extract_fieldFunction · 0.85
to_stringMethod · 0.80
eval_exprFunction · 0.70
read_strFunction · 0.70

Tested by

no test coverage detected