Crdt.Model_codec

crdt · API reference

Document model codec (all formats: verbose, compact, binary)

Model codecs for document serialization.

This module provides codec implementations for CRDT document snapshots.

Three formats are supported:

  • Verbose: Human-readable JSON with explicit type tags (see Model_codec_verbose)
  • Compact: Compact JSON with type codes and relative IDs (see Model_codec_compact)
  • Binary: CBOR-based binary format for efficiency See Model_codec_verbose for verbose format details and Model_codec_compact for compact format details.

Verbose Encoding

module Verbose = Model_codec_verbose

Compact Encoding

module Compact = Model_codec_compact

Binary Encoding

module Binary : sig ... end

Binary structural encoding using CBOR-like format.

Convenience Functions

val to_verbose : Model.t -> Verbose.J.t

Encode model to verbose JSON

val to_verbose_string : ?minify:bool -> Model.t -> string

Encode model to verbose JSON string

val to_verbose_bigstring : 
  ?minify:bool ->
  Model.t ->
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * int

Encode model to verbose JSON bigstring

val of_verbose : Verbose.J.t -> Model.t option

Decode model from verbose JSON

val of_verbose_string : string -> Model.t option

Decode model from verbose JSON string

val of_verbose_bigstring : 
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
  len:int ->
  Model.t option

Decode model from verbose JSON bigstring

val to_compact : Model.t -> Compact.J.t

Encode model to compact JSON

val to_compact_string : ?minify:bool -> Model.t -> string

Encode model to compact JSON string

val to_compact_bigstring : 
  ?minify:bool ->
  Model.t ->
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * int

Encode model to compact JSON bigstring

val of_compact : Compact.J.t -> Model.t option

Decode model from compact JSON

val of_compact_string : string -> Model.t option

Decode model from compact JSON string

val of_compact_bigstring : 
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
  len:int ->
  Model.t option

Decode model from compact JSON bigstring

val to_binary : Model.t -> bytes

Encode model to binary

val of_binary : bytes -> Model.t option

Decode model from binary