package async_extra

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

File_writer is a thin wrapper around Writer with a couple of extra features:

1. It keeps track of all the file writers that have been created so that it can iterate over them to find out how many bytes in total they have to write.

2. It keeps track of whether the underlying writer has failed, and if so silently ignores future operations. This can prevent pointlessly filling up a writer's buffer with data that will never go anywhere.

type t
include sig ... end
val sexp_of_t : t -> Sexplib.Sexp.t
val create : ?append:bool -> string -> t Async_kernel.Deferred.t

create file opens file, creating it if it doesn't exist.

val write : t -> string -> unit

write t s writes s to the file.

val write_substring : t -> Core.Substring.t -> unit
val write_bigsubstring : t -> Core.Bigsubstring.t -> unit
val write_bigstring : t -> ?pos:int -> ?len:int -> Core.Bigstring.t -> unit
val schedule_bigstring : t -> Core.Bigstring.t -> unit
val write_iobuf : t -> ?pos:int -> ?len:int -> ([> Core.read ], _) Core.Iobuf.t -> unit
val write_bin_prot : t -> 'a Core.Bin_prot.Type_class.writer -> 'a -> unit
val write_sexp : ?hum:bool -> t -> Async_unix.Sexp.t -> unit
val monitor : t -> Async_kernel.Monitor.t
val bytes_to_write : unit -> int

bytes_to_write () returns the sum over all async_file_writers of how many bytes they need to write.

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

Innovation. Community. Security.