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

Function extract_msgpack_elements

nodedb/src/control/server/broadcast.rs:342–377  ·  view source on GitHub ↗
(payload: &[u8])

Source from the content-addressed store, hash-verified

340}
341
342fn extract_msgpack_elements(payload: &[u8]) -> Vec<Vec<u8>> {
343 if payload.is_empty() {
344 return Vec::new();
345 }
346
347 let Some((count, mut pos)) = msgpack_scan::array_header(payload, 0) else {
348 tracing::warn!(
349 payload_len = payload.len(),
350 "broadcast_to_all_cores: payload is not a msgpack array; treating as single row"
351 );
352 return vec![payload.to_vec()];
353 };
354
355 let mut rows = Vec::with_capacity(count);
356 for _ in 0..count {
357 if pos >= payload.len() {
358 break;
359 }
360 let start = pos;
361 match msgpack_scan::skip_value(payload, pos) {
362 Some(next) => {
363 rows.push(payload[start..next].to_vec());
364 pos = next;
365 }
366 None => {
367 tracing::warn!(
368 pos,
369 payload_len = payload.len(),
370 "broadcast_to_all_cores: could not skip msgpack element; stopping early"
371 );
372 break;
373 }
374 }
375 }
376 rows
377}
378
379fn decode_count_field(payload: &[u8], key: &str) -> Option<usize> {
380 if payload.is_empty() {

Calls 6

array_headerFunction · 0.85
skip_valueFunction · 0.85
is_emptyMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
to_vecMethod · 0.45