Library
Module
Module type
Parameter
Class
Class type
Buffered input stream.
val create :
?buf:bytes ->
?close:(unit -> unit) ->
fill_buffer:(bytes -> int) ->
unit ->
t
Create a new buffered input stream.
val of_bytes : ?off:int -> ?len:int -> bytes -> t
Read from the given buffer.
val of_unix_fd : ?buf:Bytes.t -> ?close_noerr:bool -> Unix.file_descr -> t
Create an in stream from a raw Unix file descriptor. The file descriptor must be opened for reading.
val of_in_channel : ?buf:bytes -> in_channel -> t
Wrap a standard input channel.
val open_file :
?buf:bytes ->
?mode:int ->
?flags:Unix.open_flag list ->
string ->
t
val with_open_file :
?buf:bytes ->
?mode:int ->
?flags:Unix.open_flag list ->
string ->
(t -> 'a) ->
'a
val fill_buffer : t -> unit
fill_buffer bic
ensures that bic.buf
is empty only if bic.ic
is empty. Always call this before looking at bic.buf
.
val fill_and_get : t -> bytes * int * int
Ensure the underlying buffer is not empty (unless end-of-input was reached), and return the active slice of it as a tuple bytes, offset, len
.
Postconditions: len = 0
if and only if the whole input stream has been consumed.
val get_bytes : t -> bytes
Direct access to the raw bytes of the underlying buffer.
val get_off : t -> int
Current offset in the underlying buffer.
val get_len : t -> int
Current length of the underlying buffer.
val input : t -> bytes -> int -> int -> int
Read into the given slice of bytes.
val consume : t -> int -> unit
consume bic n
consumes n
bytes from bic
. Precondition: n <= get_len bic
, ie. one cannot consume bytes that have not yet been obtained via fill_buffer
or fill_and_get
.
val close : t -> unit
Close the input stream.
Read a line from the input. Return None
if the stream is empty.
val to_iter : t -> (char -> unit) -> unit