Bin_prot.UtilsSourceinclude Utils_intf.Utilssize_header_length is the standard number of bytes allocated for the size header in size-prefixed bin-io payloads. This size-prefixed layout is used by the bin_dump and bin_read_stream functions below, as well as:
Core.Bigstring.{read,write}_bin_protCore.Unpack_buffer.unpack_bin_protAsync.{Reader,Writer}.{read,write}_bin_prot among others.The size prefix is always 8 bytes at present. This is exposed so your program does not have to know this fact too.
We do not use a variable length header because we want to know how many bytes to read to get the size without having to peek into the payload.
bin_read_size_header and bin_write_size_header are bin-prot serializers for the size header described above.
bin_dump ?header writer v uses writer to first compute the size of v in the binary protocol, then allocates a buffer of exactly this size, and then writes out the value. If header is true, the size of the resulting binary string will be prefixed as a signed 64bit integer.
val bin_read_stream :
?max_size:int ->
read:(Common.buf -> pos:int -> len:int -> unit) ->
'a Type_class.reader ->
'abin_read_stream ?max_size ~read reader reads binary protocol data from a stream as generated by the read function, which places data of a given length into a given buffer. Requires a header. The reader type class will be used for conversion to OCaml-values.
Conversion of binable types
module Make_binable_with_uuid
(Bin_spec : Make_binable_with_uuid_spec) :
Binable.S with type t := Bin_spec.tmodule Make_binable1_with_uuid
(Bin_spec : Make_binable1_with_uuid_spec) :
Binable.S1 with type 'a t := 'a Bin_spec.tmodule Make_binable2_with_uuid
(Bin_spec : Make_binable2_with_uuid_spec) :
Binable.S2 with type ('a, 'b) t := ('a, 'b) Bin_spec.tmodule Make_binable3_with_uuid
(Bin_spec : Make_binable3_with_uuid_spec) :
Binable.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) Bin_spec.tmodule Make_binable_without_uuid
(Bin_spec : Make_binable_without_uuid_spec) :
Binable.S with type t := Bin_spec.tmodule Make_binable1_without_uuid
(Bin_spec : Make_binable1_without_uuid_spec) :
Binable.S1 with type 'a t := 'a Bin_spec.tmodule Make_binable2_without_uuid
(Bin_spec : Make_binable2_without_uuid_spec) :
Binable.S2 with type ('a, 'b) t := ('a, 'b) Bin_spec.tmodule Make_binable3_without_uuid
(Bin_spec : Make_binable3_without_uuid_spec) :
Binable.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) Bin_spec.tConversion of iterable types
module Make_iterable_binable
(Iterable_spec : Make_iterable_binable_spec) :
Binable.S with type t := Iterable_spec.tmodule Make_iterable_binable1
(Iterable_spec : Make_iterable_binable1_spec) :
Binable.S1 with type 'a t := 'a Iterable_spec.tmodule Make_iterable_binable2
(Iterable_spec : Make_iterable_binable2_spec) :
Binable.S2 with type ('a, 'b) t := ('a, 'b) Iterable_spec.tmodule Make_iterable_binable3
(Iterable_spec : Make_iterable_binable3_spec) :
Binable.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) Iterable_spec.t