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

Function str_bounds

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

Return `(data_start, byte_len)` for the string at `offset` without validating UTF-8. Used internally for key comparison.

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

Source from the content-addressed store, hash-verified

334/// Return `(data_start, byte_len)` for the string at `offset` without
335/// validating UTF-8. Used internally for key comparison.
336pub(crate) fn str_bounds(buf: &[u8], offset: usize) -> Option<(usize, usize)> {
337 let tag = get(buf, offset)?;
338 match tag {
339 0xa0..=0xbf => {
340 let len = (tag & 0x1f) as usize;
341 Some((offset + 1, len))
342 }
343 STR8 => {
344 let len = get(buf, offset + 1)? as usize;
345 Some((offset + 2, len))
346 }
347 STR16 => {
348 let len = read_u16_be(buf, offset + 1)? as usize;
349 Some((offset + 3, len))
350 }
351 STR32 => {
352 let len = read_u32_be(buf, offset + 1)? as usize;
353 Some((offset + 5, len))
354 }
355 _ => None,
356 }
357}
358
359/// Read a boolean from the value at `offset`.
360pub fn read_bool(buf: &[u8], offset: usize) -> Option<bool> {

Callers 6

compare_field_bytesFunction · 0.85
extract_fieldFunction · 0.85
build_sidecarFunction · 0.85
buildMethod · 0.85
read_strFunction · 0.85
read_str_advanceFunction · 0.85

Calls 3

getFunction · 0.85
read_u16_beFunction · 0.85
read_u32_beFunction · 0.85

Tested by

no test coverage detected