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

Function map_header

nodedb-query/src/msgpack_scan/reader.rs:428–436  ·  view source on GitHub ↗

Return the number of key-value pairs and the offset of the first pair, for the map starting at `offset`. Returns `None` if not a map.

(buf: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

426/// Return the number of key-value pairs and the offset of the first pair,
427/// for the map starting at `offset`. Returns `None` if not a map.
428pub fn map_header(buf: &[u8], offset: usize) -> Option<(usize, usize)> {
429 let tag = get(buf, offset)?;
430 match tag {
431 0x80..=0x8f => Some(((tag & 0x0f) as usize, offset + 1)),
432 MAP16 => Some((read_u16_be(buf, offset + 1)? as usize, offset + 3)),
433 MAP32 => Some((read_u32_be(buf, offset + 1)? as usize, offset + 5)),
434 _ => None,
435 }
436}
437
438/// Return the number of elements and the offset of the first element,
439/// for the array starting at `offset`. Returns `None` if not an array.

Callers 15

find_field_by_suffixFunction · 0.85
extract_fieldFunction · 0.85
build_sidecarFunction · 0.85
inject_str_fieldFunction · 0.85
merge_fieldsFunction · 0.85
roundtrip_mapFunction · 0.85
buildMethod · 0.85
map_header_fixmapFunction · 0.85

Calls 3

getFunction · 0.85
read_u16_beFunction · 0.85
read_u32_beFunction · 0.85

Tested by 7

roundtrip_mapFunction · 0.68
map_header_fixmapFunction · 0.68