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_verbosefor verbose format details andModel_codec_compactfor compact format details.
Verbose Encoding
module Verbose = Model_codec_verboseCompact Encoding
module Compact = Model_codec_compactBinary Encoding
module Binary : sig ... endBinary structural encoding using CBOR-like format.
Convenience Functions
val to_verbose : Model.t -> Verbose.J.tEncode model to verbose JSON
val to_verbose_string : ?minify:bool -> Model.t -> stringEncode model to verbose JSON string
val to_verbose_bigstring :
?minify:bool ->
Model.t ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * intEncode model to verbose JSON bigstring
val of_verbose : Verbose.J.t -> Model.t optionDecode model from verbose JSON
val of_verbose_string : string -> Model.t optionDecode model from verbose JSON string
val of_verbose_bigstring :
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
len:int ->
Model.t optionDecode model from verbose JSON bigstring
val to_compact : Model.t -> Compact.J.tEncode model to compact JSON
val to_compact_string : ?minify:bool -> Model.t -> stringEncode model to compact JSON string
val to_compact_bigstring :
?minify:bool ->
Model.t ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * intEncode model to compact JSON bigstring
val of_compact : Compact.J.t -> Model.t optionDecode model from compact JSON
val of_compact_string : string -> Model.t optionDecode model from compact JSON string
val of_compact_bigstring :
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
len:int ->
Model.t optionDecode model from compact JSON bigstring
val to_binary : Model.t -> bytesEncode model to binary
val of_binary : bytes -> Model.t optionDecode model from binary