Module Unpack_sequence
Unpack_sequence uses an Unpack_buffer.t to unpack a sequence of packed values coming from a string Pipe.Reader.t or a Reader.t. It can produce a pipe of upacked values or iterate a user-supplied function over the unpacked values.
module Unpack_iter_result : sig ... endmodule Unpack_result : sig ... endmodule Unpack_from : sig ... endUnpack_fromspecifies the source of the sequence of bytes to unpack from.
val unpack_into_pipe : from:Unpack_from.t -> using:'a Unpack_buffer.t -> 'a Async.Pipe.Reader.t * 'a Unpack_result.t Async.Deferred.tunpack_into_pipe ~from:input ~using:unpack_bufferreturns(output, result), and usesunpack_bufferto unpack values frominputuntilinputis closed. It puts the unpacked values intooutput, which is closed once unpacking finishes, be it normally or due to an error.resultindicates why unpacking finished.To unpack from a
bin_reader, use:unpack_into_pipe ~from ~using:(Unpack_buffer.create_bin_prot bin_reader)Using
~from:(Reader reader)is more efficient than~from:(Pipe (Reader.pipe reader))because it blits bytes directly from the reader buffer to the unpack buffer, without any intervening allocation.
val unpack_iter : from:Unpack_from.t -> using:'a Unpack_buffer.t -> f:('a -> unit) -> 'a Unpack_iter_result.t Async.Deferred.tunpack_iteris a more efficient version ofunpack_into_pipethat callsfon each value as it is unpacked, rather than putting the value into a pipe. Iffraises, then the result will beUnpack_error.