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

Function read_value_as_string

nodedb/src/control/server/post_aggregate.rs:174–193  ·  view source on GitHub ↗

Read a msgpack value at [start..end) as a display string.

(bytes: &[u8], start: usize, end: usize)

Source from the content-addressed store, hash-verified

172
173/// Read a msgpack value at [start..end) as a display string.
174fn read_value_as_string(bytes: &[u8], start: usize, end: usize) -> String {
175 use nodedb_query::msgpack_scan::reader;
176 if let Some(s) = reader::read_str(bytes, start) {
177 return s.to_string();
178 }
179 if let Some(i) = reader::read_i64(bytes, start) {
180 return i.to_string();
181 }
182 if let Some(f) = reader::read_f64(bytes, start) {
183 return f.to_string();
184 }
185 if let Some(b) = reader::read_bool(bytes, start) {
186 return b.to_string();
187 }
188 if reader::read_null(bytes, start) {
189 return String::new();
190 }
191 // Complex value — transcode slice to JSON string.
192 nodedb_types::msgpack_to_json_string(&bytes[start..end]).unwrap_or_default()
193}
194
195/// Compute a single aggregate over a group of msgpack rows.
196fn compute_aggregate(op: &str, field: &str, rows: &[&[u8]]) -> AggValue {

Callers 1

extract_field_strFunction · 0.85

Calls 7

read_i64Function · 0.85
read_boolFunction · 0.85
read_nullFunction · 0.85
msgpack_to_json_stringFunction · 0.85
to_stringMethod · 0.80
read_strFunction · 0.50
read_f64Function · 0.50

Tested by

no test coverage detected