package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include Bin_prot.Utils_intf.Utils
val size_header_length : int

size_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_prot
  • Core.Unpack_buffer.unpack_bin_prot
  • Async.{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.

val bin_read_size_header : int Bin_prot.Read.reader
val bin_write_size_header : int Bin_prot.Write.writer

bin_read_size_header and bin_write_size_header are bin-prot serializers for the size header described above.

val bin_dump : ?header:bool -> 'a Bin_prot.Type_class.writer -> 'a -> Bin_prot.Common.buf

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.

  • 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 writer can raise.

val bin_read_stream : ?max_size:int -> read:(Bin_prot.Common.buf -> pos:int -> len:int -> unit) -> 'a Bin_prot.Type_class.reader -> 'a

bin_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.

  • 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 reader can raise.

  • raises Failure

    if the size reported in the data header is longer than max_size.

Conversion of binable types

module type Make_binable_with_uuid_spec = Bin_prot.Utils_intf.Make_binable_with_uuid_spec
module type Make_binable1_with_uuid_spec = Bin_prot.Utils_intf.Make_binable1_with_uuid_spec
module type Make_binable2_with_uuid_spec = Bin_prot.Utils_intf.Make_binable2_with_uuid_spec
module type Make_binable3_with_uuid_spec = Bin_prot.Utils_intf.Make_binable3_with_uuid_spec
module type Make_binable_without_uuid_spec = Bin_prot.Utils_intf.Make_binable_without_uuid_spec
module type Make_binable1_without_uuid_spec = Bin_prot.Utils_intf.Make_binable1_without_uuid_spec
module type Make_binable2_without_uuid_spec = Bin_prot.Utils_intf.Make_binable2_without_uuid_spec
module type Make_binable3_without_uuid_spec = Bin_prot.Utils_intf.Make_binable3_without_uuid_spec
module Make_binable = Make_binable_without_uuid
module Make_binable1 = Make_binable1_without_uuid
module Make_binable2 = Make_binable2_without_uuid
module Make_binable3 = Make_binable3_without_uuid

Conversion of iterable types

module type Make_iterable_binable_spec = Bin_prot.Utils_intf.Make_iterable_binable_spec
module type Make_iterable_binable1_spec = Bin_prot.Utils_intf.Make_iterable_binable1_spec
module type Make_iterable_binable2_spec = Bin_prot.Utils_intf.Make_iterable_binable2_spec
module type Make_iterable_binable3_spec = Bin_prot.Utils_intf.Make_iterable_binable3_spec
OCaml

Innovation. Community. Security.