Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Binary codecs.
type 'a enc = Buffer.t -> 'a -> unit
The type for binary encoders. enc b v
binary encodes the value v
in b
. Raises Error
in case of error.
val enc_err : kind:string -> ('a, Format.formatter, unit, 'b) format4 -> 'a
enc_err ~kind fmt
raises a binary encoding error message for kind kind
formatted according to fmt
.
val enc_byte : int enc
enc_byte
encodes an integer in range [0;255].
val enc_bytes : string enc
enc_bytes
encodes the given bytes.
The type for binary decoders. dec s ~start
binary decodes a value at start
in s
. start
is either the index of a byte in s
or the length of s
. The function returns (i, v)
with v
the decoded value and i
the first index in s
after the decoded value or the length of s
if there is no such index. Raises Error
in case of error.
val dec_err :
kind:string ->
int ->
('a, Format.formatter, unit, 'b) format4 ->
'a
dec_err ~kind i fmt
raises a binary decoding error message for kind kind
at input byte index i
formatted according to fmt
.
dec_err_eoi ~kind i
raises a decoding error message for kind kind
at input byte index i
indicating an unexpected end of input.
dec_err_exceed ~kind i v ~max
raises a decoding error message for kind kind
at input byte index i
indicating v
is not in the range 0;max
.
dec_need ~kind s ~start ~len
checks that len
bytes are available starting at start
(which can be out of bounds) in s
and calls err_eoi
if that is not the case.
val dec_byte : kind:string -> int dec
dec_byte
decodes an integer in range [0;255] for the given kind
.
val dec_bytes : kind:string -> string dec
dec_bytes ~kind
decodes the given bytes for the given kind
.