Library
Module
Module type
Parameter
Class
Class type
Input stream.
type t = private {
input : bytes -> int -> int -> int;
Read into the slice. Returns 0
only if the stream is closed.
close : unit -> unit;
Close the input. Must be idempotent.
*)as_fd : unit -> Unix.file_descr option;
Cast into a file descriptor, if it actually is a direct wrapper of a Unix FD.
*)}
An input stream, i.e an incoming stream of bytes.
This can be a string
, an int_channel
, an Unix.file_descr
, a decompression wrapper around another input stream, etc.
val create :
?as_fd:(unit -> Unix.file_descr option) ->
?close:(unit -> unit) ->
input:(bytes -> int -> int -> int) ->
unit ->
t
val empty : t
Empty input, contains 0 bytes.
val of_unix_fd : ?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 : ?close_noerr:bool -> in_channel -> t
Wrap a standard input channel.
val open_file : ?mode:int -> ?flags:Unix.open_flag list -> string -> t
val with_open_file :
?mode:int ->
?flags:Unix.open_flag list ->
string ->
(t -> 'a) ->
'a
val of_string : ?off:int -> ?len:int -> string -> t
An input channel reading from the string.
val of_bytes : ?off:int -> ?len:int -> bytes -> t
An input channel reading from the bytes buffer. See of_string
for more details.
val input : t -> bytes -> int -> int -> int
Read bytes into the given buffer. This returns 0
only if the stream has reached its end.
val seek : t -> int -> unit
If available, seek in the underlying stream.
val pos : t -> int
If available, return current offset in underlying stream.
val close : t -> unit
Close the input stream. This is idempotent.