module Unpack_buffer:sig
..end
An Unpack_buffer.t
is a buffer to which one can feed
strings, and then unpack
from the buffer to produce a queue of values.
module Unpack_one:sig
..end
type ('value, 'partial_unpack)
t
val invariant : ('a, 'b) t -> unit
val create : ?partial_unpack:'partial_unpack ->
('value, 'partial_unpack) Unpack_one.t ->
('value, 'partial_unpack) t
val create_bin_prot : 'a Bin_prot.Type_class.reader -> ('a, unit) t
create_bin_prot reader
returns an unpack buffer that unpacks the "size-prefixed"
bin_prot encoding, in which a value is encoded by first writing the length of the
bin_prot data as a 64-bit int, and then writing the bin_prot data itself. This
encoding makes it trivial to know if enough data is available in the buffer, so there
is no need to represent partially unpacked values, and hence 'partial_unpack =
unit
.val is_empty : ('a, 'b) t -> bool Or_error.t
is_empty t
returns true
if t
has no unconsumed bytes, and false
if it does.
is_empty
returns an error if t
has encountered an unpacking error.val feed : ?pos:int ->
?len:int -> ('a, 'b) t -> Bigstring.t -> unit Or_error.t
feed t buf ?pos ?len
adds the specified substring of buf
to t
's buffer. It
returns an error if t
has encountered an unpacking error.val feed_string : ?pos:int -> ?len:int -> ('a, 'b) t -> string -> unit Or_error.t
val unpack : ('value, 'a) t -> 'value Std_internal.Queue.t Or_error.t
unpack t
unpacks all the values that it can from t
. The resulting queue will be
empty if nothing could be unpacked. If there is an unpacking error, unpack
returns
an error, and subsequent feed
and unpack
operations on t
will return that same
error. I.e. no more data can be fed to or unpacked from t
.val debug : bool Pervasives.ref
debug
controls whether invariants are checked at each call. Setting this to true
can make things very slow.val sexp_of_t : ('value -> Sexplib.Sexp.t) ->
('partial_unpack -> Sexplib.Sexp.t) ->
('value, 'partial_unpack) t -> Sexplib.Sexp.t
create_bin_prot reader
returns an unpack buffer that unpacks the "size-prefixed"
bin_prot encoding, in which a value is encoded by first writing the length of the
bin_prot data as a 64-bit int, and then writing the bin_prot data itself. This
encoding makes it trivial to know if enough data is available in the buffer, so there
is no need to represent partially unpacked values, and hence 'partial_unpack =
unit
.is_empty t
returns true
if t
has no unconsumed bytes, and false
if it does.
is_empty
returns an error if t
has encountered an unpacking error.feed t buf ?pos ?len
adds the specified substring of buf
to t
's buffer. It
returns an error if t
has encountered an unpacking error.unpack t
unpacks all the values that it can from t
. The resulting queue will be
empty if nothing could be unpacked. If there is an unpacking error, unpack
returns
an error, and subsequent feed
and unpack
operations on t
will return that same
error. I.e. no more data can be fed to or unpacked from t
.debug
controls whether invariants are checked at each call. Setting this to true
can make things very slow.