Cbor_pack
CBOR-pack.
CBOR pack is a data serialization scheme built on top of CBOR. It introduces a notion of heap (an array of CBOR values) and pointers into this heap (CBOR values consisting of an integer wrapped in a specific tag). The heap is then turned into a CBOR array, so that the resulting "pack" is just a large CBOR value with a specific internal structure (some of which are pointers into the large internal heap).
When serializing a complex data structure that presents internal sharing (typically, with pointers/references), the heap can be used to represent that sharing directly in the CBOR value. This is done by serializing a value once, adding it to the heap (which is an array); the position of the value in the heap can then be wrapped with tag 6 to become a pointer. All other references to this value are serialized as pointers.
val pp_diagnostic : Stdlib.Format.formatter -> cbor -> unit
Debug printer for CBOR values.
module Ser : sig ... end
Serialization
val to_string : 'a Ser.t -> 'a -> string
to_string ser x
seralizes x
using ser
, and returns the pack containing the shared heap, and an entry point.
module Deser : sig ... end
Deserialization
of_cbor_exn deser cbor
deserializes an object using deser
from the shared heap cbor.h
, starting at cbor.key
.
val of_cbor : 'a Deser.t -> cbor -> 'a Deser.or_error
Deserialize a pack into a value of type 'a
val of_string_exn : 'a Deser.t -> string -> 'a
Parse CBOR and deserialize it
val of_string : 'a Deser.t -> string -> 'a Deser.or_error
module Private_ : sig ... end
Private utilities, no guarantees of stability