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

Function sidecar_msgpack_len

nodedb-query/src/msgpack_scan/sidecar.rs:72–79  ·  view source on GitHub ↗

Parse how many bytes the original msgpack occupies in a sidecar buffer.

(buf: &[u8])

Source from the content-addressed store, hash-verified

70
71/// Parse how many bytes the original msgpack occupies in a sidecar buffer.
72fn sidecar_msgpack_len(buf: &[u8]) -> Option<usize> {
73 if buf.len() < TRAILER_SIZE {
74 return None;
75 }
76 let entry_count = read_entry_count(buf)?;
77 let sidecar_size = (entry_count as usize) * ENTRY_SIZE + TRAILER_SIZE;
78 buf.len().checked_sub(sidecar_size)
79}
80
81/// Read the entry count from the trailer (second-to-last field before magic).
82fn read_entry_count(buf: &[u8]) -> Option<u16> {

Callers 3

msgpack_bytesFunction · 0.85
sidecar_lookupFunction · 0.85
field_index_from_sidecarFunction · 0.85

Calls 2

read_entry_countFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected