package ppx_protocol_conv

  1. Overview
  2. Docs
Ppx for generating serialisation and de-serialisation functions of ocaml types

Install

Dune Dependency

Authors

Maintainers

Sources

5.0.0.tar.gz
md5=fb107eb8055a9b2410b23e763c63bb70
sha512=fc0acc9d40665904b99ccfe4ca33a78a47ffedb6a2ee9c72c98c8bc21bda7e53fe8826784183ef9daa0fc228336169d2e0418668ffe39c149365e0a8e69a1f69

doc/ppx_protocol_conv.runtime/Protocol_conv/Runtime/Helper/index.html

Module Runtime.Helper

Module contains helper function for serializing and deserializing tuples, records and variants. Deserialization functions may raise Helper.Protocol exception. It is recommended that the calling functions convert this exception into a Driver.Protocol_exception

exception Protocol_error of Base.string

Excpetion raised if the type could not be serialized

val map_record_in : 't 'a 'b. (Base.string -> Base.string) -> ('t, 'a, 'b) Record_in.t -> ('t, 'a, 'b) Record_in.t

Map fields names of a Record_in structure

val to_record : 't 'constr 'b. ?strict:Base.bool -> ('t, 'constr, 'b) Record_in.t -> 'constr -> (Base.string * 't) Base.list -> 'b

to_recordspecconstructorts returns the constructed value. ts is a associative array (string * t) list, mapping fields to the deserialized value t if strict is true, an error will be raised if input contains an unknown field. If dublicate fields are found in the input, an error is raised

val map_record_out : 't 'a. (Base.string -> Base.string) -> ('t, 'a, 't) Record_out.t -> ('t, 'a, 't) Record_out.t

Map fields names of a Record_out structure

type 't serialize_record = (Base.string * 't) Base.list -> 't
val of_record : 't 'a. omit_default:Base.bool -> 't serialize_record -> ('t, 'a, 't) Record_out.t -> 'a

of_recordmap_fspec produces a valid deserialisation function for a record type The map_f function is called to produce the serialized result from a field_name, t association list. If omit_default is true, then default values are omitted from the output

val to_tuple : 't 'a 'b. ('t, 'a, 'b) Tuple_in.t -> 'a -> 't Base.list -> 'b

to_tuplespectlist produces a tuple from the serialized values in tlist

type 't serialize_tuple = 't Base.list -> 't
val of_tuple : 't 'a. 't serialize_tuple -> ('t, 'a, 't) Tuple_out.t -> 'a
type 't serialize_variant = Base.string -> 't Base.list -> 't
val of_variant : 't. 't serialize_variant -> Base.string -> ('t, 'a, 't) Tuple_out.t -> 'a

of_variantspecv serializes v and returns the serialized values as a list or map

val map_constructor_names : (Base.string -> Base.string) -> ('t, 'a) Variant_in.t Base.list -> ('t, 'a) Variant_in.t Base.list

Map field names in all inline records of the spec

val to_variant : ('t, 'a) Variant_in.t Base.list -> Base.string -> 't Base.list -> 'a
OCaml

Innovation. Community. Security.