Up

module Unpack_sequence

: sig

Unpack_sequence implements a way to take an unpack_one function that can unpack a value from a character buffer, and use it to unpack a sequence of packed values coming via a string pipe into a pipe of upacked values.

#
module Result : sig
#
type ('a, 'b) t =
# | Input_closed
# | Input_closed_in_the_middle_of_data of ('a, 'b) Core.Std.Unpack_buffer.t
# | Output_closed of 'a Core.Std.Queue.t * ('a, 'b) Core.Std.Unpack_buffer.t
# | Unpack_error of Core.Std.Error.t
#
val to_error : (_, _) t -> Core.Std.Error.t
#
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> ('b -> Sexplib.Sexp.t) -> ('a, 'b) t -> Sexplib.Sexp.t
end
#
val unpack_from_string_pipe : ('a, 'b) Core.Std.Unpack_buffer.t -> string Import.Pipe.Reader.t -> 'a Import.Pipe.Reader.t * ('a, 'b) Result.t Import.Deferred.t

unpack_from_string_pipe unpack_buffer input returns (output, result), and uses unpack_buffer to unpack values from input until input is closed. It puts the unpacked values into output, which is closed once unpacking finishes, normally or due to an error. result indicates why unpacking finished.

unpack_from_reader and unpack_bin_prot_from_reader are similar. They are more efficient in that they blit bytes directly from the reader buffer to the unpack buffer, without any intervening allocation.

#
val unpack_from_reader : ('a, 'b) Core.Std.Unpack_buffer.t -> Import.Reader.t -> 'a Import.Pipe.Reader.t * ('a, 'b) Result.t Import.Deferred.t
#
val unpack_bin_prot_from_reader : 'a Core.Std.Bin_prot.Type_class.reader -> Import.Reader.t -> 'a Import.Pipe.Reader.t * ('a, unit) Result.t Import.Deferred.t
end