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

Function array_header

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

Return the number of elements and the offset of the first element, for the array starting at `offset`. Returns `None` if not an array.

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

Source from the content-addressed store, hash-verified

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.
440pub fn array_header(buf: &[u8], offset: usize) -> Option<(usize, usize)> {
441 let tag = get(buf, offset)?;
442 match tag {
443 0x90..=0x9f => Some(((tag & 0x0f) as usize, offset + 1)),
444 ARRAY16 => Some((read_u16_be(buf, offset + 1)? as usize, offset + 3)),
445 ARRAY32 => Some((read_u32_be(buf, offset + 1)? as usize, offset + 5)),
446 _ => None,
447 }
448}
449
450#[cfg(test)]
451mod tests {

Callers 15

array_anyFunction · 0.85
array_header_fixarrayFunction · 0.85
read_str_advance_basicFunction · 0.85
filter_tombstoned_rowsFunction · 0.85
parse_msgpack_rowsFunction · 0.85
extract_msgpack_elementsFunction · 0.85

Calls 3

getFunction · 0.85
read_u16_beFunction · 0.85
read_u32_beFunction · 0.85