package bin_there

  1. Overview
  2. Docs

Module Bin_there.UtilSource

Low-level deserialization helpers shared across the library.

These functions operate directly on bytes values and are not intended for use by end users; they are exposed so that the runtime and tests can share a single implementation of binary decoding primitives.

Sourceexception Truncated_input

Raised by read_raw_byte and read_raw_varint when the buffer is exhausted before the expected data is fully read.

Sourceval read_raw_byte : bytes -> pos_ref:int ref -> int

read_raw_byte bytes ~pos_ref reads one byte from bytes at !pos_ref, increments pos_ref, and returns the byte value as an integer in 0..255.

Sourceval read_raw_varint : bytes -> pos_ref:int ref -> int

read_raw_varint bytes ~pos_ref reads an unsigned LEB128-encoded integer from bytes starting at !pos_ref, advances pos_ref past the varint, and returns the decoded value.

Sourceval read_raw_int32_be : bytes -> pos_ref:int ref -> int32

read_raw_int32_be bytes ~pos_ref reads a big-endian 32-bit integer, advances pos_ref by 4.

Sourceval read_raw_int64_be : bytes -> pos_ref:int ref -> int64

read_raw_int64_be bytes ~pos_ref reads a big-endian 64-bit integer, advances pos_ref by 8.

Sourceval read_raw_bytes : bytes -> pos_ref:int ref -> n:int -> bytes

read_raw_bytes bytes ~pos_ref ~n returns n bytes starting at !pos_ref, advances pos_ref by n.

Sourceval read_raw_string : bytes -> pos_ref:int ref -> n:int -> string

read_raw_string bytes ~pos_ref ~n returns n bytes as a string starting at !pos_ref, advances pos_ref by n.

Sourceval blit_advance : bytes -> pos_ref:int ref -> bytes -> n:int -> unit

blit_advance src ~pos_ref dst ~n copies n bytes from src at !pos_ref into dst at offset 0, advances pos_ref by n.

Sourcemodule Obj_tbl : Hashtbl.S with type key = Obj.t

A hash table keyed by physical identity (==) rather than structural equality (=). Used internally to track which heap objects have already been serialized, enabling correct handling of shared and cyclic values.