Module Conv.Bin
Binary codecs.
Encoding
type 'a enc= Stdlib.Buffer.t -> 'a -> unitThe type for binary encoders.
enc b vbinary encodes the valuevinb. RaisesErrorin case of error.
val enc_err : kind:string -> ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'aenc_err ~kind fmtraises a binary encoding error message for kindkindformatted according tofmt.
val enc_byte : int encenc_byteencodes an integer in range [0;255].
val enc_bytes : string encenc_bytesencodes the given bytes.
Decoding
type 'a dec= string -> start:int -> int * 'aThe type for binary decoders.
dec s ~startbinary decodes a value atstartins.startis either the index of a byte insor the length ofs. The function returns(i, v)withvthe decoded value andithe first index insafter the decoded value or the length ofsif there is no such index. RaisesErrorin case of error.
val dec_err : kind:string -> int -> ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'adec_err ~kind i fmtraises a binary decoding error message for kindkindat input byte indexiformatted according tofmt.
val dec_err_eoi : kind:string -> int -> 'adec_err_eoi ~kind iraises a decoding error message for kindkindat input byte indexiindicating an unexpected end of input.
val dec_err_exceed : kind:string -> int -> int -> max:int -> 'adec_err_exceed ~kind i v ~maxraises a decoding error message for kindkindat input byte indexiindicatingvis not in the range0;max.
val dec_need : kind:string -> string -> start:int -> len:int -> unitdec_need ~kind s ~start ~lenchecks thatlenbytes are available starting atstart(which can be out of bounds) insand callserr_eoiif that is not the case.
val dec_byte : kind:string -> int decdec_bytedecodes an integer in range [0;255] for the givenkind.
val dec_bytes : kind:string -> string decdec_bytes ~kinddecodes the given bytes for the givenkind.