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

Function value_to_display_string

nodedb-query/src/value_ops.rs:84–101  ·  view source on GitHub ↗

Convert a Value to a display string. - Strings: returned as-is (no quotes) - Null: empty string - Numbers/Bools: `.to_string()` - Objects/Arrays: JSON serialization

(v: &Value)

Source from the content-addressed store, hash-verified

82/// - Numbers/Bools: `.to_string()`
83/// - Objects/Arrays: JSON serialization
84pub fn value_to_display_string(v: &Value) -> String {
85 match v {
86 Value::String(s) => s.clone(),
87 Value::Null => String::new(),
88 Value::Integer(i) => i.to_string(),
89 Value::Float(f) => f.to_string(),
90 Value::Bool(b) => b.to_string(),
91 Value::Uuid(s) | Value::Ulid(s) | Value::Regex(s) => s.clone(),
92 Value::DateTime(dt) | Value::NaiveDateTime(dt) => dt.to_iso8601(),
93 Value::Duration(d) => d.to_human(),
94 Value::Decimal(d) => d.to_string(),
95 other => {
96 // Fallback: convert to JSON string representation.
97 let json = serde_json::Value::from(other.clone());
98 json.to_string()
99 }
100 }
101}
102
103/// Convert an f64 to a Value, preferring integer representation.
104///

Callers 7

compare_valuesFunction · 0.85
eval_castFunction · 0.85
eval_binary_opFunction · 0.85
try_evalFunction · 0.85
try_evalFunction · 0.85
extract_strFunction · 0.85
extract_str_valFunction · 0.85

Calls 4

to_stringMethod · 0.80
to_iso8601Method · 0.80
to_humanMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected