package ppx_protocol_conv

  1. Overview
  2. Docs

Module Runtime.HelperSource

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

Tail recursive version of map

Sourceval list_map : f:('a -> 'b) -> 'a list -> 'b list
Sourceexception Protocol_error of string

Excpetion raised if the type could not be serialized

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

Map fields names of a Record_in structure

Sourceval to_record : 't 'constr 'b. ?strict:bool -> ('t, 'constr, 'b) Record_in.t -> 'constr -> (string * 't) 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

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

Map fields names of a Record_out structure

Sourcetype 't serialize_record = (string * 't) list -> 't
Sourceval of_record : 'a 't. omit_default: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

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

to_tuplespectlist produces a tuple from the serialized values in tlist

Sourcetype 't serialize_tuple = 't list -> 't
Sourceval of_tuple : 't 'a. 't serialize_tuple -> ('t, 'a, 't) Tuple_out.t -> 'a
Sourcetype 't serialize_variant = string -> 't list -> 't
Sourceval of_variant : 't. 't serialize_variant -> string -> ('t, 'a, 't) Tuple_out.t -> 'a

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

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

Map field names in all inline records of the spec

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

Innovation. Community. Security.