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

Function str_arg

nodedb-query/src/functions/shared.rs:8–16  ·  view source on GitHub ↗

Extract a string argument at `idx`, returning `None` for null/missing.

(args: &[Value], idx: usize)

Source from the content-addressed store, hash-verified

6
7/// Extract a string argument at `idx`, returning `None` for null/missing.
8pub fn str_arg(args: &[Value], idx: usize) -> Option<String> {
9 match args.get(idx)? {
10 Value::String(s) => Some(s.clone()),
11 Value::Uuid(s) | Value::Ulid(s) | Value::Regex(s) => Some(s.clone()),
12 Value::DateTime(dt) | Value::NaiveDateTime(dt) => Some(dt.to_iso8601()),
13 Value::Duration(d) => Some(d.to_human()),
14 _ => None,
15 }
16}
17
18/// Extract a numeric argument with bool coercion.
19pub fn num_arg(args: &[Value], idx: usize) -> Option<f64> {

Callers 2

try_evalFunction · 0.70
try_evalFunction · 0.70

Calls 4

to_iso8601Method · 0.80
to_humanMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected