package shuttle

  1. Overview
  2. Docs

Module Shuttle.Input_channelSource

Alternative to Async_unix.Reader, based on the low latency transport in async_rpc.

Sourcetype t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval create : ?max_buffer_size:int -> ?buf_len:int -> Async_unix.Fd.t -> t
Sourceval is_closed : t -> bool
Sourceval closed : t -> unit Async_kernel.Deferred.t
Sourceval close : t -> unit Async_kernel.Deferred.t
Sourceval refill : t -> [ `Ok | `Eof ] Async_kernel.Deferred.t
Sourceval consume : t -> int -> unit
Sourceval drain : t -> unit Async_kernel.Deferred.t

drain t reads chunks of data from the reader and discards them.

Sourceval pipe : t -> string Async_kernel.Pipe.Reader.t

pipe returns a reader pipe that contains the results of reading chunks from an input_channel.

Sourceval transfer : t -> string Async_kernel.Pipe.Writer.t -> unit Async_kernel.Deferred.t

transfer will read chunks from an input channel and write them to the provided writer end of an async pipe. The deferred returned by the function will be determined on EOF or if the writer is closed. Use transfer in scenarios where pipe is needed, but if there is a need to not close the channel automatically once the transfer is finished.

Sourceval of_pipe : Core.Info.t -> string Async_kernel.Pipe.Reader.t -> t Async_kernel.Deferred.t
Sourceval read_line : t -> [ `Ok of string | `Eof ] Async_kernel.Deferred.t
Sourceval lines : t -> string Async_kernel.Pipe.Reader.t
Sourceval read : t -> int -> [ `Ok of string | `Eof ] Async_kernel.Deferred.t
Sourceval open_file : ?buf_len:int -> Core.Filename.t -> t Async_kernel.Deferred.t

open_file ?buf_len filename opens filename and returns an Input_channel that can be used to read from the file. buf_len is an optional input and can be used to control the channel's buffer size.

Sourceval with_file : ?buf_len:int -> Core.Filename.t -> f:(t -> 'a Async_kernel.Deferred.t) -> 'a Async_kernel.Deferred.t

with_file ?buf_len filename ~f opens filename, creates a new channel and passes it to f. Once f returns, the channel and the underlying file is closed.

OCaml

Innovation. Community. Security.