Module Msgpck.BytesBuf

MessagePack library decoding from bytes and writing in Buffers.

type buf_in = Stdlib.Bytes.t

Type of input buffer (where MessagePack data will be read)

type buf_out = Stdlib.Buffer.t

Type of output buffer (where MessagePack data will be written)

val read : ?⁠pos:int -> buf_in -> int * t

read ?pos buf is (nb_read, t), where nb_read is the number of bytes read from buf at pos ?pos, and t is the decoded MessagePack value.

@raise Invalid_argument "msg" when there is no valid MessagePack value to be read from buf at position pos.

val read_all : ?⁠pos:int -> buf_in -> int * t list

read_all ?pos buf reads all messages found in buf. @returns a tuple (pos, l) where pos is the new position in the buffer, and l is the list of read messages.

@raise Invalid_argument "msg" when there is no valid MessagePack value to be read from buf at position pos.

val write : ?⁠pos:int -> buf_out -> t -> int

write ?pos buf msg is nb_written, the number of bytes written on buf at position ?pos. The serialization of msg have been written to buf starting at ?pos.

val to_string : t -> buf_out

to_string msg is the MessagePack serialization of msg.