package data-encoding

  1. Overview
  2. Docs
type id = string
type t

A encoding that has been registered. It can be retrieved using either list or find.

val binary_schema : t -> Binary_schema.t

Descriptions and schemas of registered encodings.

val json_schema : t -> Json.schema
val description : t -> string option
val json_pretty_printer : t -> Format.formatter -> Json.t -> unit

Printers for the encodings.

val binary_pretty_printer : t -> Format.formatter -> Bytes.t -> unit
val register : ?pp:(Format.formatter -> 'a -> unit) -> 'a Encoding.t -> unit

register ~id encoding registers the encoding with the id. It can later be found using find and providing the matching id. It will also appear in the results of list.

val find : id -> t option

find id is Some r if register id e has been called, in which case r matches e. Otherwise, it is None.

val list : unit -> (id * t) list

list () is a list of pairs (id, r) where r is a registered encoding for the id.

val bytes_of_json : t -> Json.t -> Bytes.t option

Conversion functions from/to json to/from bytes.

val json_of_bytes : t -> Bytes.t -> Json.t option
OCaml

Innovation. Community. Security.