Crdt.Patch_codec_compact
crdt · API reference
Compact JSON codec for patches
Compact JSON codec for Patch.
Encodes/decodes patches in the json-joy compact JSON format. This is an array-based encoding that is more compact than verbose:
Patch: [id], op1, op2, ... ID: [sid, time] Operations: opcode, ...args
Timestamps in operations can be encoded as just the time component when the session ID matches the patch's session ID.
Compact opcodes (from json-joy):
- 0: new_con
- 1: new_val
- 2: new_obj
- 3: new_vec
- 4: new_str
- 5: new_bin
- 6: new_arr
- 9: ins_val
- 10: ins_obj
- 11: ins_vec
- 12: ins_str
- 13: ins_bin
- 14: ins_arr
- 15: upd_arr
- 16: del
- 17: nop
module J = Simdjsont.Jsonval compact_opcode_of_op : Op.op_data -> intval encode_ts : patch_sid:int -> Clock.timestamp -> J.tval encode_timespan : patch_sid:int -> Clock.timespan -> J.tval encode_con_value : Value.t -> J.tval encode_op : patch_sid:int -> Op.op_data -> J.tval encode_patch_json : Patch.t -> J.tval encode : Patch.t -> stringval encode_bigstring :
Patch.t ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * intval encode_pretty : Patch.t -> stringval decode_ts : patch_sid:int -> J.t -> Clock.timestamp optionval decode_timespan : patch_sid:int -> J.t -> Clock.timespan optionval decode_con_value : J.t -> Value.tval decode_int : J.t -> int optionval get_arr_elem : 'a list -> int -> 'a optionval decode_op : patch_sid:int -> J.t -> (Op.op_data, string) resultval decode_patch_json : J.t -> (Patch.t, string) resultval decode : string -> (Patch.t, string) resultval decode_bigstring :
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
len:int ->
(Patch.t, string) resultval decode_ndjson_seq :
?batch_size:int ->
Simdjsont.Raw.buffer ->
len:int ->
(Patch.t, string) result Seq.tval encode_batch_json : Patch.batch -> J.tval encode_batch : Patch.batch -> stringval encode_batch_bigstring :
Patch.batch ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * intval decode_batch_json : J.t -> (Patch.batch, string) resultval decode_batch : string -> (Patch.batch, string) resultval decode_batch_bigstring :
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
len:int ->
(Patch.batch, string) result