A buffer for incremental decoding of an input stream.
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.
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.
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_into t q
unpacks all the values that it can from t
and enqueues them in
q
. If there is an unpacking error, unpack_into
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
.
unpack_iter t ~f
unpacks all the values that it can from t
, calling f
on each
value as it's unpacked. If there is an unpacking error (including if f
raises),
unpack_iter
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
.
Behavior is unspecified if f
operates on t
.
debug
controls whether invariants are checked at each call. Setting this to true
can make things very slow.