This module can be used to write compact encoding for complex types without relying on the existing combinators.
Combine multiple tags; will throw an error if the total length of the tags is more than 16.
module type S = sig ... end
make (module M) is a compact encoding for the type of
The JSON representation is entirely determined by
The binary representation is determined as follows.
- A value
v : M.inputis classified into a layout
- A tag
M.tag lis used (which may be combined with the tags of other compact encodings as described before).
- The payload is the same bytes as can be found in the string returned by
Data_encoding.Binary.to_string (M.partial_encoding l) v.
In other words, the tag of a value is
M.(tag (layout v)) and the payload of a value is
M.(partial_encoding (layout v) v).
It is the user's responsibility to ensure that all the values of
M follow the invariants documented in