package core_kernel
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=93dc40648c5e4564cb72b72ab031474372f7b169e7ba7090b28e38e1b72282f1
md5=61420bfc94dbed1667be5e2ebd7c8240
doc/core_kernel.unpack_buffer/Unpack_buffer/index.html
Module Unpack_buffer
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.
module Unpack_one : sig ... endIf unpack_one : ('a, 'state) unpack, then unpack_one ~state ~buf ~pos ~len must unpack at most one value of type 'a from buf starting at pos, and not using more than len characters. unpack_one must return one the following:
val sexp_of_t :
('a -> Ppx_sexp_conv_lib.Sexp.t) ->
'a t ->
Ppx_sexp_conv_lib.Sexp.tinclude Core_kernel.Invariant.S1 with type 'a t := 'a t
val invariant : ('a -> unit) -> 'a t -> unitval create : 'a Unpack_one.t -> 'a tval create_bin_prot : 'a Core_kernel.Bin_prot.Type_class.reader -> 'a tcreate_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.
val is_empty : _ t -> bool Core_kernel.Or_error.tis_empty returns true if all the data fed into t has been unpacked into values; false if t has unconsumed bytes or partially unpacked data. is_empty returns an error if t has encountered an unpacking error.
val feed :
?pos:int ->
?len:int ->
_ t ->
Core_kernel.Bigstring.t ->
unit Core_kernel.Or_error.tfeed 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 ->
_ t ->
string ->
unit Core_kernel.Or_error.tval feed_bytes :
?pos:int ->
?len:int ->
_ t ->
Core_kernel.Bytes.t ->
unit Core_kernel.Or_error.tval unpack_into : 'a t -> 'a Core_kernel.Queue.t -> unit Core_kernel.Or_error.tunpack_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.
val unpack_iter : 'a t -> f:('a -> unit) -> unit Core_kernel.Or_error.tunpack_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.
val debug : bool Caml.refdebug controls whether invariants are checked at each call. Setting this to true can make things very slow.