Module Neodriver_packstream.Packstream

PackStream — binary serialization for the Neo4j Bolt protocol.

See packstream.ml for the implementation.

type value =
  1. | Null
  2. | Bool of bool
  3. | Int of int64
  4. | Float of float
  5. | String of string
  6. | Bytes of bytes
  7. | List of value list
  8. | Map of (string * value) list
  9. | Structure of int * value list
    (*

    A PackStream value; Structure carries a tag byte and its fields.

    *)
type error =
  1. | Unexpected_end_of_data
  2. | Unknown_marker of int
  3. | Map_key_not_string
  4. | Depth_limit_exceeded of int
    (*

    Decode failures reported by unpack.

    *)
type limits = {
  1. max_depth : int;
}

Limits for unpack, guarding against stack overflow on deeply nested values.

val default_limits : limits

Default limits: max_depth = 256.

val pack : value -> Stdlib.Bytes.t

Serialize a value into its PackStream byte representation.

val unpack : ?limits:limits -> Stdlib.Bytes.t -> (value, error) Stdlib.result

Deserialize a value from PackStream bytes, subject to the given limits (defaults to default_limits).

val error_to_string : error -> string

Render a decode error as a human-readable message.

val to_string : value -> string

Render a value as a human-readable string.