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

Function read_i64

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

Read an i64 from the value at `offset`. Handles all integer types. Floats return `None` — use `read_f64` for those.

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

Source from the content-addressed store, hash-verified

243/// Read an i64 from the value at `offset`. Handles all integer types.
244/// Floats return `None` — use `read_f64` for those.
245pub fn read_i64(buf: &[u8], offset: usize) -> Option<i64> {
246 let tag = get(buf, offset)?;
247 match tag {
248 0x00..=0x7f => Some(tag as i64),
249 0xe0..=0xff => Some((tag as i8) as i64),
250 UINT8 => Some(get(buf, offset + 1)? as i64),
251 UINT16 => Some(read_u16_be(buf, offset + 1)? as i64),
252 UINT32 => Some(read_u32_be(buf, offset + 1)? as i64),
253 UINT64 => {
254 let v = read_u64_be(buf, offset + 1)?;
255 Some(v as i64)
256 }
257 INT8 => Some(get(buf, offset + 1)? as i8 as i64),
258 INT16 => Some(read_u16_be(buf, offset + 1)? as i16 as i64),
259 INT32 => Some(read_u32_be(buf, offset + 1)? as i32 as i64),
260 INT64 => {
261 let v = read_u64_be(buf, offset + 1)?;
262 Some(v as i64)
263 }
264 _ => None,
265 }
266}
267
268/// Read a string slice from the value at `offset`. Zero-copy — borrows
269/// directly from the input buffer. Returns `None` for non-string types

Callers 11

compare_field_i64Function · 0.85
append_field_valueFunction · 0.85
append_field_value_rangeFunction · 0.85
roundtrip_mapFunction · 0.85
fuzz_two_byte_patternsFunction · 0.85
extract_numberFunction · 0.85
read_value_as_stringFunction · 0.85
count_facet_fieldMethod · 0.85

Calls 4

getFunction · 0.85
read_u16_beFunction · 0.85
read_u32_beFunction · 0.85
read_u64_beFunction · 0.85

Tested by 5

roundtrip_mapFunction · 0.68
fuzz_two_byte_patternsFunction · 0.68