Skip to main content

Module scalar

Module scalar 

Source
Expand description

Typed scalar reads and container headers.

Functions§

array_header
Return the number of elements and the offset of the first element, for the array starting at offset. Returns None if not an array.
map_header
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.
read_bin_advance
Read a bin value at *off, advancing *off past it. Zero-copy — the returned slice borrows from buf. Returns None for non-bin tags or truncated input.
read_bool
Read a boolean from the value at offset.
read_f64
Read an f64 from the value at offset. Handles float32, float64, and all integer types (coerced to f64).
read_i64
Read an i64 from the value at offset. Handles all integer types. Floats return None — use read_f64 for those. A uint64 above i64::MAX returns None — use read_integer for the exact value.
read_integer
Read any msgpack integer at offset exactly. i128 holds every i64 and every u64. Floats and non-integers return None.
read_null
Check if the value at offset is nil.
read_str
Read a string slice from the value at offset. Zero-copy — borrows directly from the input buffer. Returns None for non-string types or invalid UTF-8.
read_str_advance
Read a string slice at *off, advancing *off past it. Zero-copy. Returns None for non-string types, invalid UTF-8, or truncated input.
read_u32_advance
Read an unsigned integer that fits in a u32 at *off, advancing *off past it. Accepts positive fixint, uint8, uint16, uint32. Returns None for negative, signed-typed, oversized (uint64), or non-integer values.