package shuttle

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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

type t
val sexp_of_t : t -> Sexplib0.Sexp.t
val create : ?buf_len:int -> ?write_timeout:Core.Time_ns.Span.t -> Async_unix.Fd.t -> t

create ?buf_len ?write_timeout fd creates a new writer.

The writer doesn't flush automatically and the user is responsible for calling flush, which triggers a write system call if needed.

val monitor : t -> Async_kernel.Monitor.t

monitor returns the async monitor used by Output_channel for performing all write operations.

val remote_closed : t -> unit Async_kernel.Deferred.t

remote_closed is a deferred that's resolved when the consumer that's reading the bytes written to the Output_channel is closed, i.e. the channel has received an EPIPE or ECONNRESET when it attempts to perform a write.

val is_closed : t -> bool
val is_open : t -> bool
val close_started : t -> unit Async_kernel.Deferred.t
val close_finished : t -> unit Async_kernel.Deferred.t
val write_bigstring : t -> ?pos:int -> ?len:int -> Core.Bigstring.t -> unit

write_bigstring copies the bigstring into the channel's internal buffer. It is safe to modify the bigstring once write_bigstring returns.

val schedule_bigstring : t -> ?pos:int -> ?len:int -> Core.Bigstring.t -> unit
  • deprecated schedule_bigstring will be removed in a future release. Use [write_bigstring] instead.
val write : t -> ?pos:int -> ?len:int -> string -> unit

write copies the string into the channel's internal buffer. The string will surface the next time the writer schedules a write.

val write_string : t -> ?pos:int -> ?len:int -> string -> unit
  • deprecated write_string will be removed in a future release. Use [write] instead.
val write_char : t -> char -> unit
val writef : t -> ('a, unit, string, unit) Core.format4 -> 'a
val close : t -> unit Async_kernel.Deferred.t

close will close the underlying file descriptor after waiting for the writer to be flushed.

val schedule_flush : t -> unit

schedule_flush will schedule a write system call if one is needed.

val flushed : t -> unit Async_kernel.Deferred.t

flushed t f deferred that will get resolved when all prior writes have finished.

val flush : t -> unit Async_kernel.Deferred.t

flush schedules a write system call if one is needed and returns a deferred that will get resolved when all prior writes have finished.

val pipe : t -> string Async_kernel.Pipe.Writer.t
val open_file : ?buf_len:int -> ?append:bool -> Core.Filename.t -> t Async_kernel.Deferred.t

open_file ?buf_len ?append filename opens a new file and returns a channel that can be used to write content to the file. buf_len is an optional input and can be used to control the channel's buffer size.

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

with_file ?buf_len ?append filename ~f opens a new file and forwards the channel to the user provided callback. Once f returns the channel and the underlying file is closed.

OCaml

Innovation. Community. Security.