Crdt.Model_codec_verbose

crdt · API reference

Verbose document codec (human-readable JSON)

Verbose structural encoding for CRDT document snapshots.

This module implements the verbose format compatible with json-joy's model.verbose.json format.

The verbose format uses a hierarchical tree structure with explicit type tags for each node, making it human-readable for debugging.

Format overview:

  • time: array of sid, time pairs (clock vector)

  • root: nested node structure starting with the root val node Node formats:

  • con: {type: "con", id: [sid, time], value?: any}

  • val: {type: "val", id: [sid, time], value?: node}

  • obj: {type: "obj", id: [sid, time], map: {key: node, ...}}

  • vec: {type: "vec", id: [sid, time], slots: node[]}

  • arr: {type: "arr", id: [sid, time], elements: node[]}

  • str: {type: "str", id: [sid, time], chunks: chunk[]}

  • bin: {type: "bin", id: [sid, time], chunks: chunk[]} Chunk format:

  • {id: [sid, time], value?: string/bytes, span?: int}

module J = Simdjsont.Json
val encode_timestamp : Clock.timestamp -> J.t
val encode_clock_vector : Clock.clock_vector -> J.t
val encode_value : Value.t -> J.t
val encode_str_chunks : string Rga.chunk list -> J.t
val encode_bin_chunks : bytes Rga.chunk list -> J.t
val encode_arr_chunks : Model.t -> Clock.timestamp Rga.chunk list -> J.t
val encode_node : Model.t -> Node.t -> J.t
val encode : Model.t -> J.t
val encode_string : ?minify:bool -> Model.t -> string
val encode_bigstring : 
  ?minify:bool ->
  Model.t ->
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * int
val get_member : string -> (string * J.t) list -> J.t option
val decode_timestamp : J.t -> Clock.timestamp option
val decode_clock_vector : J.t -> Clock.clock_vector option
val decode_value : J.t -> Value.t
val decode_str_chunks : J.t -> string Rga.t
val decode_bin_chunks : J.t -> bytes Rga.t
val decode_node : Model.t -> J.t -> Clock.timestamp option
val decode : J.t -> Model.t option
val decode_string : string -> Model.t option
val decode_bigstring : 
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
  len:int ->
  Model.t option