package biniou
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8bf3ff17cd0ecb2d6b6d1d94cb08ef089d44caef96e9bae6be6839d428fa318f
sha512=7d03b3759a3a2e1c77713aa1b8375a1f1917f49d14fe5e3cb01d5e53a12e6385b7a3b0f4827f3be71182c31c416d780e1f9ef011dc205cb8f9b0ab2d8fc23cfd
doc/biniou/Bi_inbuf/index.html
Module Bi_inbufSource
Input buffer
type t = {mutable i_s : bytes;(*This is the buffer string. It can be accessed for reading but should normally only be written to or replaced only by the
*)i_refillfunction.mutable i_pos : int;(*This is the current position in the input buffer. All data before that may be erased at anytime.
*)mutable i_len : int;(*This is the position of the first byte of invalid input data. Data starting at
*)i_posand ending ati_len-1is considered valid input data that is available to the user. Beware that calls totry_preread,readand other read functions may move data around and therefore modify the values ofi_posandi_lenin order to keep pointing to the correct data segment.mutable i_offs : int;(*Length of data read and discarded from the buffer. This indicates the position in the input stream of the first byte of the buffer. The current position in the input stream is
*)i_offs + i_pos. The total length of input stream data put into the buffer isi_offs + i_len.mutable i_max_len : int;(*This is the length of
*)i_s.i_refill : t -> int -> unit;(*Function called when not enough data is available in the buffer. The int argument is the total number of bytes that must be available starting at position
*)i_poswhen the function returns. This function typically does nothing if all input data already has been placed into the buffer. Thei_posandi_lenfields can be modified thei_refillfunction, as long as the available data that was starting fromi_posstill starts from the new value ofi_pos. All the other fields can be modified as well.
}Exception raised by all the functions of this module when it is not possible to return a valid result because there is not enough data to read from the buffer.
try_preread ib n make at least n bytes available for reading in ib.i_s, unless the end of the input is reached. The result indicates how many bytes were made available. If smaller than n, the result indicates that the end of the input was reached. ib.i_pos is set to point to the first available byte.
read ib n makes at least n bytes available for reading or raises the End_of_input exception. The result is the position of the first available byte. ib.i_pos is moved to point to the next position after the n bytes.
Create an input buffer from an in_channel. Such a buffer is not extensible and read requests may not exceed len.