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

Function msgpack_bytes

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

Return the raw msgpack slice from a buffer that may or may not have a sidecar. Always returns valid msgpack bytes regardless of sidecar presence.

(buf: &[u8])

Source from the content-addressed store, hash-verified

59///
60/// Always returns valid msgpack bytes regardless of sidecar presence.
61pub fn msgpack_bytes(buf: &[u8]) -> &[u8] {
62 if !has_sidecar(buf) {
63 return buf;
64 }
65 let Some(msgpack_len) = sidecar_msgpack_len(buf) else {
66 return buf;
67 };
68 &buf[..msgpack_len]
69}
70
71/// Parse how many bytes the original msgpack occupies in a sidecar buffer.
72fn sidecar_msgpack_len(buf: &[u8]) -> Option<usize> {

Callers

nothing calls this directly

Calls 2

has_sidecarFunction · 0.85
sidecar_msgpack_lenFunction · 0.85

Tested by

no test coverage detected