Module Bin_prot.Utils
val size_header_length : intsize_header_lengthis the standard number of bytes allocated for the size header in size-prefixed bin-io payloads. This size-prefixed layout is used by thebin_dumpandbin_read_streamfunctions below, as well as:Core.Bigstring.{read,write}_bin_protCore.Unpack_buffer.unpack_bin_protAsync.{Reader,Writer}.{read,write}_bin_protamong 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.
val bin_read_size_header : int Read.readerval bin_write_size_header : int Write.writerbin_read_size_headerandbin_write_size_headerare bin-prot serializers for the size header described above.
val bin_dump : ?header:bool -> 'a Type_class.writer -> 'a -> Common.bufbin_dump ?header writer vuseswriterto first compute the size ofvin the binary protocol, then allocates a buffer of exactly this size, and then writes out the value. Ifheaderistrue, the size of the resulting binary string will be prefixed as a signed 64bit integer.- returns
the buffer containing the written out value.
- parameter header
default =
false
- raises Failure
if the size of the value changes during writing, and any other exceptions that the binary writer in
writercan raise.
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 readerreads binary protocol data from a stream as generated by thereadfunction, which places data of a given length into a given buffer. Requires a header. Thereadertype class will be used for conversion to OCaml-values.- parameter max_size
default = nothing
- raises Failure
if the size of the value disagrees with the one specified in the header, and any other exceptions that the binary reader associated with
readercan raise.
- raises Failure
if the size reported in the data header is longer than
max_size.
module type Make_binable_spec = sig ... endmodule Of_minimal : functor (S : Binable.Minimal.S) -> Binable.S with type t := S.tmodule Make_binable : functor (Bin_spec : Make_binable_spec) -> Binable.S with type t := Bin_spec.tmodule type Make_binable1_spec = sig ... endmodule Make_binable1 : functor (Bin_spec : Make_binable1_spec) -> Binable.S1 with type 'a t := 'a Bin_spec.tmodule type Make_binable2_spec = sig ... endmodule Make_binable2 : functor (Bin_spec : Make_binable2_spec) -> Binable.S2 with type ('a, 'b) t := ('a, 'b) Bin_spec.tmodule type Make_binable3_spec = sig ... endmodule Make_binable3 : functor (Bin_spec : Make_binable3_spec) -> Binable.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) Bin_spec.tmodule type Make_iterable_binable_spec = sig ... endmodule Make_iterable_binable : functor (Iterable_spec : Make_iterable_binable_spec) -> Binable.S with type t := Iterable_spec.tmodule type Make_iterable_binable1_spec = sig ... endmodule Make_iterable_binable1 : functor (Iterable_spec : Make_iterable_binable1_spec) -> Binable.S1 with type 'a t := 'a Iterable_spec.tmodule type Make_iterable_binable2_spec = sig ... endmodule Make_iterable_binable2 : functor (Iterable_spec : Make_iterable_binable2_spec) -> Binable.S2 with type ('a, 'b) t := ('a, 'b) Iterable_spec.tmodule type Make_iterable_binable3_spec = sig ... endmodule Make_iterable_binable3 : functor (Iterable_spec : Make_iterable_binable3_spec) -> Binable.S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) Iterable_spec.t