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

Function decode_count_field

nodedb/src/control/server/broadcast.rs:379–388  ·  view source on GitHub ↗
(payload: &[u8], key: &str)

Source from the content-addressed store, hash-verified

377}
378
379fn decode_count_field(payload: &[u8], key: &str) -> Option<usize> {
380 if payload.is_empty() {
381 return Some(0);
382 }
383
384 let json = nodedb_types::json_from_msgpack(payload)
385 .ok()
386 .or_else(|| sonic_rs::from_slice::<serde_json::Value>(payload).ok())?;
387 json.get(key).and_then(|v| v.as_u64()).map(|v| v as usize)
388}
389
390fn encode_msgpack_array(rows: &[Vec<u8>]) -> Vec<u8> {
391 let total_data: usize = rows.iter().map(|row| row.len()).sum();

Callers 1

Calls 5

json_from_msgpackFunction · 0.85
is_emptyMethod · 0.45
okMethod · 0.45
getMethod · 0.45
as_u64Method · 0.45

Tested by

no test coverage detected