package data-encoding

  1. Overview
  2. Docs
type input

The type of input this module allows to encode.

type layout

The various ways to efficiently encode input.

val layouts : layout list

The list of layouts available to encode input.

val tag_len : int

The number of bits necessary to distinguish between the various layouts.

val tag : layout -> tag

tag layout computes the tag of Data_encoding.union to be used to encode values classified as layout.

Warning: It is expected that tag layout < 2^tag_len - 1.

val title : layout -> string option

title layout computes the title to be used in documentation for the given layout. The title is not always available (some elements don't have one) and None is used in that case.

val partial_encoding : layout -> input encoding

partial_encoding layout returns the encoding to use for values classified as layout.

This encoding can be partial in the sense that it may fail (it will raise an Invalid_argument) for some values of x. However, it is expected that partial_encoding (classify x) x will always succeed.

val classify : input -> layout

classify x returns the layout to be used to encode x.

val json_encoding : input encoding

The encoding to use when targeting a JSON output.