wip: IO streams

This commit is contained in:
Simon Cruanes 2019-11-17 15:58:29 -06:00
parent 460492ded0
commit 76408b7e39
2 changed files with 31 additions and 5 deletions

View file

@ -1,9 +1,14 @@
type input_stream = (bytes -> int -> int -> int) * (unit -> unit)
(** An input stream is a function to read bytes into a buffer,
and a function to close *)
(** An input stream. *)
type input_stream = {
ic: in_channel;
mutable buf: bytes;
}
type output_stream = (bytes -> int -> int -> unit) * (unit -> unit) * (unit -> unit)
(** An output stream is a function to output bytes, a function to [flush],
and a function to close. *)
module Input_stream = struct
end
exception Bad_req of int * string
let bad_reqf c fmt = Printf.ksprintf (fun s ->raise (Bad_req (c,s))) fmt

View file

@ -1,3 +1,24 @@
type input_stream = (bytes -> int -> int -> int) * (unit -> unit)
(** An input stream is a function to read bytes into a buffer,
and a function to close *)
type output_stream = (bytes -> int -> int -> unit) * (unit -> unit) * (unit -> unit)
(** An output stream is a function to output bytes, a function to [flush],
and a function to close. *)
module Input_stream : sig
type t = input_stream
val of_chan : in_channel -> t
val of_string : string -> t
val of_bytes : bytes -> t
end
module Output_stream : sig
type t = output_stream
val of_chan : out_channel -> t
end
module Meth : sig
type t = [