sig
  module State :
    sig
      type t = [ `Closed | `In_use | `Not_in_use ]
      val __t_of_sexp__ :
        Sexplib.Sexp.t -> [> `Closed | `In_use | `Not_in_use ]
      val t_of_sexp : Sexplib.Sexp.t -> [> `Closed | `In_use | `Not_in_use ]
      val sexp_of_t : [< `Closed | `In_use | `Not_in_use ] -> Sexplib.Sexp.t
    end
  module Open_flags :
    sig
      type t = Core.Core_unix.Open_flags.t
      val of_int : int -> t
      val to_int_exn : t -> int
      val equal : t -> t -> bool
      val empty : t
      val ( + ) : t -> t -> t
      val ( - ) : t -> t -> t
      val intersect : t -> t -> t
      val complement : t -> t
      val is_empty : t -> bool
      val do_intersect : t -> t -> bool
      val are_disjoint : t -> t -> bool
      val rdonly : t
      val wronly : t
      val rdwr : t
      val creat : t
      val excl : t
      val noctty : t
      val trunc : t
      val append : t
      val nonblock : t
      val dsync : t
      val sync : t
      val rsync : t
      val can_read : t -> bool
      val can_write : t -> bool
      val sexp_of_t : t -> Sexplib.Sexp.t
    end
  type open_flags = (Reader0.Internal.Open_flags.t, exn) Core.Std.Result.t
  val sexp_of_open_flags :
    (Reader0.Internal.Open_flags.t, Core_kernel.Exn.t) Core.Std.Result.t ->
    Sexplib.Sexp.t
  type t = {
    fd : Fd.t;
    id : Reader0.Id.t;
    mutable buf : Core.Std.Bigstring.t Core.Std.sexp_opaque;
    mutable close_may_destroy_buf : [ `Not_ever | `Not_now | `Yes ];
    mutable pos : int;
    mutable available : int;
    mutable bin_prot_len_buf : Core.Std.Bigstring.t Core.Std.sexp_opaque;
    mutable bin_prot_buf : Core.Std.Bigstring.t Core.Std.sexp_opaque;
    mutable state : Reader0.Internal.State.t;
    close_finished : unit Import.Ivar.t;
    mutable last_read_time : Core.Std.Time.t;
    open_flags : Reader0.Internal.open_flags Import.Deferred.t;
  }
  val sexp_of_t : Reader0.Internal.t -> Sexplib.Sexp.t
  val open_flags :
    Reader0.Internal.t -> Reader0.Internal.open_flags Import.Deferred.t
  val last_read_time : Reader0.Internal.t -> Core.Std.Time.t
  val set_last_read_time : Reader0.Internal.t -> Core.Std.Time.t -> unit
  val close_finished : t -> unit Import.Ivar.t
  val state : Reader0.Internal.t -> Reader0.Internal.State.t
  val set_state : Reader0.Internal.t -> Reader0.Internal.State.t -> unit
  val bin_prot_buf :
    Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque
  val set_bin_prot_buf :
    Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque -> unit
  val bin_prot_len_buf :
    Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque
  val set_bin_prot_len_buf :
    Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque -> unit
  val available : Reader0.Internal.t -> int
  val set_available : Reader0.Internal.t -> int -> unit
  val pos : Reader0.Internal.t -> int
  val set_pos : Reader0.Internal.t -> int -> unit
  val close_may_destroy_buf :
    Reader0.Internal.t -> [ `Not_ever | `Not_now | `Yes ]
  val set_close_may_destroy_buf :
    Reader0.Internal.t -> [ `Not_ever | `Not_now | `Yes ] -> unit
  val buf : Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque
  val set_buf :
    Reader0.Internal.t -> Core.Std.Bigstring.t Core.Std.sexp_opaque -> unit
  val id : Reader0.Internal.t -> Reader0.Id.t
  val fd : Reader0.Internal.t -> Fd.t
  module Fields :
    sig
      val names : string list
      val open_flags :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         Reader0.Internal.open_flags Import.Deferred.t)
        Fieldslib.Field.t_with_perm
      val last_read_time :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, Core.Std.Time.t)
        Fieldslib.Field.t_with_perm
      val close_finished :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         unit Import.Ivar.t)
        Fieldslib.Field.t_with_perm
      val state :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         Reader0.Internal.State.t)
        Fieldslib.Field.t_with_perm
      val bin_prot_buf :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         Core.Std.Bigstring.t Core.Std.sexp_opaque)
        Fieldslib.Field.t_with_perm
      val bin_prot_len_buf :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         Core.Std.Bigstring.t Core.Std.sexp_opaque)
        Fieldslib.Field.t_with_perm
      val available :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, int)
        Fieldslib.Field.t_with_perm
      val pos :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, int)
        Fieldslib.Field.t_with_perm
      val close_may_destroy_buf :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         [ `Not_ever | `Not_now | `Yes ])
        Fieldslib.Field.t_with_perm
      val buf :
        ([< `Read | `Set_and_create ], Reader0.Internal.t,
         Core.Std.Bigstring.t Core.Std.sexp_opaque)
        Fieldslib.Field.t_with_perm
      val id :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
        Fieldslib.Field.t_with_perm
      val fd :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
        Fieldslib.Field.t_with_perm
      val make_creator :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> '-> ('-> Fd.t) * 'c) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> '-> ('-> Reader0.Id.t) * 'd) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm ->
             '-> ('-> Core.Std.Bigstring.t Core.Std.sexp_opaque) * 'e) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm ->
                               '->
                               ('-> [ `Not_ever | `Not_now | `Yes ]) * 'f) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> '-> ('-> int) * 'g) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> '-> ('-> int) * 'h) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm ->
                          '->
                          ('-> Core.Std.Bigstring.t Core.Std.sexp_opaque) *
                          'i) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm ->
                      '->
                      ('-> Core.Std.Bigstring.t Core.Std.sexp_opaque) * 'j) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm ->
               '-> ('-> Reader0.Internal.State.t) * 'k) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm ->
                        '-> ('-> unit Import.Ivar.t) * 'l) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm ->
                        '-> ('-> Core.Std.Time.t) * 'm) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm ->
                    '->
                    ('-> Reader0.Internal.open_flags Import.Deferred.t) *
                    'n) ->
        '-> ('-> Reader0.Internal.t) * 'n
      val create :
        fd:Fd.t ->
        id:Reader0.Id.t ->
        buf:Core.Std.Bigstring.t Core.Std.sexp_opaque ->
        close_may_destroy_buf:[ `Not_ever | `Not_now | `Yes ] ->
        pos:int ->
        available:int ->
        bin_prot_len_buf:Core.Std.Bigstring.t Core.Std.sexp_opaque ->
        bin_prot_buf:Core.Std.Bigstring.t Core.Std.sexp_opaque ->
        state:Reader0.Internal.State.t ->
        close_finished:unit Import.Ivar.t ->
        last_read_time:Core.Std.Time.t ->
        open_flags:Reader0.Internal.open_flags Import.Deferred.t ->
        Reader0.Internal.t
      val map :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> Fd.t) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> Reader0.Id.t) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm ->
             Core.Std.Bigstring.t Core.Std.sexp_opaque) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm ->
                               [ `Not_ever | `Not_now | `Yes ]) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> int) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> int) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm ->
                          Core.Std.Bigstring.t Core.Std.sexp_opaque) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm ->
                      Core.Std.Bigstring.t Core.Std.sexp_opaque) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> Reader0.Internal.State.t) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> unit Import.Ivar.t) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> Core.Std.Time.t) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm ->
                    Reader0.Internal.open_flags Import.Deferred.t) ->
        Reader0.Internal.t
      val iter :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> 'a) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> 'b) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm -> 'c) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm -> 'd) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> 'e) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> 'f) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm -> 'g) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm -> 'h) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> 'i) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> 'j) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> 'k) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm -> 'l) ->
        'l
      val fold :
        init:'->
        fd:('->
            ([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> 'b) ->
        id:('->
            ([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> 'c) ->
        buf:('->
             ([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm -> 'd) ->
        close_may_destroy_buf:('->
                               ([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm -> 'e) ->
        pos:('->
             ([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> 'f) ->
        available:('->
                   ([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> 'g) ->
        bin_prot_len_buf:('->
                          ([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm -> 'h) ->
        bin_prot_buf:('->
                      ([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm -> 'i) ->
        state:('->
               ([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> 'j) ->
        close_finished:('->
                        ([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> 'k) ->
        last_read_time:('->
                        ([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> 'l) ->
        open_flags:('->
                    ([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm -> 'm) ->
        'm
      val map_poly :
        ([< `Read | `Set_and_create ], Reader0.Internal.t, 'a)
        Fieldslib.Field.user -> 'a list
      val for_all :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> bool) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> bool) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm -> bool) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm -> bool) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> bool) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> bool) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm -> bool) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm -> bool) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> bool) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> bool) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> bool) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm -> bool) ->
        bool
      val exists :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> bool) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> bool) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm -> bool) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm -> bool) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> bool) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> bool) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm -> bool) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm -> bool) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> bool) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> bool) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> bool) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm -> bool) ->
        bool
      val to_list :
        fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
            Fieldslib.Field.t_with_perm -> 'a) ->
        id:(([< `Read | `Set_and_create ], Reader0.Internal.t, Reader0.Id.t)
            Fieldslib.Field.t_with_perm -> 'a) ->
        buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
              Core.Std.Bigstring.t Core.Std.sexp_opaque)
             Fieldslib.Field.t_with_perm -> 'a) ->
        close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                Reader0.Internal.t,
                                [ `Not_ever | `Not_now | `Yes ])
                               Fieldslib.Field.t_with_perm -> 'a) ->
        pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
             Fieldslib.Field.t_with_perm -> 'a) ->
        available:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                   Fieldslib.Field.t_with_perm -> 'a) ->
        bin_prot_len_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm -> 'a) ->
        bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                       Core.Std.Bigstring.t Core.Std.sexp_opaque)
                      Fieldslib.Field.t_with_perm -> 'a) ->
        state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                Reader0.Internal.State.t)
               Fieldslib.Field.t_with_perm -> 'a) ->
        close_finished:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         unit Import.Ivar.t)
                        Fieldslib.Field.t_with_perm -> 'a) ->
        last_read_time:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Core.Std.Time.t)
                        Fieldslib.Field.t_with_perm -> 'a) ->
        open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                     Reader0.Internal.open_flags Import.Deferred.t)
                    Fieldslib.Field.t_with_perm -> 'a) ->
        'a list
      module Direct :
        sig
          val iter :
            Reader0.Internal.t ->
            fd:(([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
                Fieldslib.Field.t_with_perm ->
                Reader0.Internal.t -> Fd.t -> 'a) ->
            id:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                 Reader0.Id.t)
                Fieldslib.Field.t_with_perm ->
                Reader0.Internal.t -> Reader0.Id.t -> 'b) ->
            buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                  Core.Std.Bigstring.t Core.Std.sexp_opaque)
                 Fieldslib.Field.t_with_perm ->
                 Reader0.Internal.t ->
                 Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'c) ->
            close_may_destroy_buf:(([< `Read | `Set_and_create ],
                                    Reader0.Internal.t,
                                    [ `Not_ever | `Not_now | `Yes ])
                                   Fieldslib.Field.t_with_perm ->
                                   Reader0.Internal.t ->
                                   [ `Not_ever | `Not_now | `Yes ] -> 'd) ->
            pos:(([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                 Fieldslib.Field.t_with_perm ->
                 Reader0.Internal.t -> int -> 'e) ->
            available:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                        int)
                       Fieldslib.Field.t_with_perm ->
                       Reader0.Internal.t -> int -> 'f) ->
            bin_prot_len_buf:(([< `Read | `Set_and_create ],
                               Reader0.Internal.t,
                               Core.Std.Bigstring.t Core.Std.sexp_opaque)
                              Fieldslib.Field.t_with_perm ->
                              Reader0.Internal.t ->
                              Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'g) ->
            bin_prot_buf:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm ->
                          Reader0.Internal.t ->
                          Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'h) ->
            state:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                    Reader0.Internal.State.t)
                   Fieldslib.Field.t_with_perm ->
                   Reader0.Internal.t -> Reader0.Internal.State.t -> 'i) ->
            close_finished:(([< `Read | `Set_and_create ],
                             Reader0.Internal.t, unit Import.Ivar.t)
                            Fieldslib.Field.t_with_perm ->
                            Reader0.Internal.t -> unit Import.Ivar.t -> 'j) ->
            last_read_time:(([< `Read | `Set_and_create ],
                             Reader0.Internal.t, Core.Std.Time.t)
                            Fieldslib.Field.t_with_perm ->
                            Reader0.Internal.t -> Core.Std.Time.t -> 'k) ->
            open_flags:(([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Reader0.Internal.open_flags Import.Deferred.t)
                        Fieldslib.Field.t_with_perm ->
                        Reader0.Internal.t ->
                        Reader0.Internal.open_flags Import.Deferred.t -> 'l) ->
            'l
          val fold :
            Reader0.Internal.t ->
            init:'->
            fd:('->
                ([< `Read | `Set_and_create ], Reader0.Internal.t, Fd.t)
                Fieldslib.Field.t_with_perm ->
                Reader0.Internal.t -> Fd.t -> 'b) ->
            id:('->
                ([< `Read | `Set_and_create ], Reader0.Internal.t,
                 Reader0.Id.t)
                Fieldslib.Field.t_with_perm ->
                Reader0.Internal.t -> Reader0.Id.t -> 'c) ->
            buf:('->
                 ([< `Read | `Set_and_create ], Reader0.Internal.t,
                  Core.Std.Bigstring.t Core.Std.sexp_opaque)
                 Fieldslib.Field.t_with_perm ->
                 Reader0.Internal.t ->
                 Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'd) ->
            close_may_destroy_buf:('->
                                   ([< `Read | `Set_and_create ],
                                    Reader0.Internal.t,
                                    [ `Not_ever | `Not_now | `Yes ])
                                   Fieldslib.Field.t_with_perm ->
                                   Reader0.Internal.t ->
                                   [ `Not_ever | `Not_now | `Yes ] -> 'e) ->
            pos:('->
                 ([< `Read | `Set_and_create ], Reader0.Internal.t, int)
                 Fieldslib.Field.t_with_perm ->
                 Reader0.Internal.t -> int -> 'f) ->
            available:('->
                       ([< `Read | `Set_and_create ], Reader0.Internal.t,
                        int)
                       Fieldslib.Field.t_with_perm ->
                       Reader0.Internal.t -> int -> 'g) ->
            bin_prot_len_buf:('->
                              ([< `Read | `Set_and_create ],
                               Reader0.Internal.t,
                               Core.Std.Bigstring.t Core.Std.sexp_opaque)
                              Fieldslib.Field.t_with_perm ->
                              Reader0.Internal.t ->
                              Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'h) ->
            bin_prot_buf:('->
                          ([< `Read | `Set_and_create ], Reader0.Internal.t,
                           Core.Std.Bigstring.t Core.Std.sexp_opaque)
                          Fieldslib.Field.t_with_perm ->
                          Reader0.Internal.t ->
                          Core.Std.Bigstring.t Core.Std.sexp_opaque -> 'i) ->
            state:('->
                   ([< `Read | `Set_and_create ], Reader0.Internal.t,
                    Reader0.Internal.State.t)
                   Fieldslib.Field.t_with_perm ->
                   Reader0.Internal.t -> Reader0.Internal.State.t -> 'j) ->
            close_finished:('->
                            ([< `Read | `Set_and_create ],
                             Reader0.Internal.t, unit Import.Ivar.t)
                            Fieldslib.Field.t_with_perm ->
                            Reader0.Internal.t -> unit Import.Ivar.t -> 'k) ->
            last_read_time:('->
                            ([< `Read | `Set_and_create ],
                             Reader0.Internal.t, Core.Std.Time.t)
                            Fieldslib.Field.t_with_perm ->
                            Reader0.Internal.t -> Core.Std.Time.t -> 'l) ->
            open_flags:('->
                        ([< `Read | `Set_and_create ], Reader0.Internal.t,
                         Reader0.Internal.open_flags Import.Deferred.t)
                        Fieldslib.Field.t_with_perm ->
                        Reader0.Internal.t ->
                        Reader0.Internal.open_flags Import.Deferred.t -> 'm) ->
            'm
        end
    end
  val io_stats : Io_stats.t
  val invariant : Reader0.Internal.t -> unit
  val create : ?buf_len:int -> Fd.t -> Reader0.Internal.t
  val of_in_channel :
    Core.Std.In_channel.t -> Fd.Kind.t -> Reader0.Internal.t
  val open_file :
    ?close_on_exec:bool ->
    ?buf_len:int -> string -> Reader0.Internal.t Async_core.Deferred.t
  val stdin : Reader0.Internal.t lazy_t
  val close_finished : Reader0.Internal.t -> unit Import.Ivar.Deferred.t
  val is_closed : Reader0.Internal.t -> bool
  val empty_buf : Core.Std.Bigstring.t
  val destroy : Reader0.Internal.t -> unit
  val close : Reader0.Internal.t -> unit Import.Ivar.Deferred.t
  val with_close :
    Reader0.Internal.t ->
    f:(unit -> 'Async_core.Deferred.t) -> 'Async_core.Deferred.t
  val with_reader_exclusive :
    Reader0.Internal.t ->
    (unit -> 'Async_core.Deferred.t) -> 'Async_core.Deferred.t
  val with_file :
    ?buf_len:int ->
    ?exclusive:bool ->
    string ->
    f:(Reader0.Internal.t -> 'Async_core.Deferred.t) ->
    'Async_core.Deferred.t
  val get_data : Reader0.Internal.t -> [ `Eof | `Ok ] Import.Deferred.t
  val with_nonempty_buffer :
    Reader0.Internal.t -> ([ `Eof | `Ok ] -> 'a) -> 'Import.Deferred.t
  val with_nonempty_buffer' :
    ?force_refill:bool ->
    Reader0.Internal.t -> ([ `Eof | `Ok ] -> unit) -> unit
  val consume : Reader0.Internal.t -> int -> unit
  type 'a read_one_chunk_at_a_time_result =
      [ `Eof | `Eof_with_unconsumed_data of string | `Stopped of 'a ]
  val sexp_of_read_one_chunk_at_a_time_result :
    ('-> Sexplib.Sexp.t) ->
    'a read_one_chunk_at_a_time_result -> Sexplib.Sexp.t
  type consumed = [ `Consumed of int * [ `Need of int | `Need_unknown ] ]
  val sexp_of_consumed :
    [< `Consumed of int * [< `Need of int | `Need_unknown ] ] ->
    Sexplib.Sexp.t
  val read_one_chunk_at_a_time :
    Reader0.Internal.t ->
    handle_chunk:(Core.Std.Bigstring.t Core.Std.sexp_opaque ->
                  pos:int ->
                  len:int ->
                  [< `Consumed of
                       int * [< `Need of int | `Need_unknown ] &
                       int * [< `Need of int | `Need_unknown ]
                   | `Continue
                   | `Stop of 'a
                   | `Stop_consumed of 'a * int ]
                  Import.Deferred.t) ->
    [> `Eof | `Eof_with_unconsumed_data of string | `Stopped of 'a ]
    Import.Deferred.t
  module Read :
    functor (S : Core.Std.Substring_intf.S->
      functor (Name : sig val name : string end->
        sig
          val read_available :
            Reader0.Internal.t -> S.t -> [> `Ok of Core.Std.Int.t ]
          val read :
            Reader0.Internal.t ->
            S.t -> [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
          val really_read :
            Reader0.Internal.t ->
            S.t -> [> `Eof of int | `Ok ] Import.Deferred.t
        end
  module Read_substring :
    sig
      val read_available :
        t -> Core.Std.Substring.t -> [> `Ok of Core.Std.Int.t ]
      val read :
        t ->
        Core.Std.Substring.t ->
        [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
      val really_read :
        t -> Core.Std.Substring.t -> [> `Eof of int | `Ok ] Import.Deferred.t
    end
  val read_substring :
    Reader0.Internal.t ->
    Core.Std.Substring.t ->
    [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
  val really_read_substring :
    Reader0.Internal.t ->
    Core.Std.Substring.t -> [> `Eof of int | `Ok ] Import.Deferred.t
  module Read_bigsubstring :
    sig
      val read_available :
        t -> Core.Std.Bigsubstring.t -> [> `Ok of Core.Std.Int.t ]
      val read :
        t ->
        Core.Std.Bigsubstring.t ->
        [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
      val really_read :
        t ->
        Core.Std.Bigsubstring.t -> [> `Eof of int | `Ok ] Import.Deferred.t
    end
  val read_bigsubstring :
    Reader0.Internal.t ->
    Core.Std.Bigsubstring.t ->
    [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
  val really_read_bigsubstring :
    Reader0.Internal.t ->
    Core.Std.Bigsubstring.t -> [> `Eof of int | `Ok ] Import.Deferred.t
  val really_read_bigstring :
    Reader0.Internal.t ->
    Core_kernel.Bigstring.t -> [> `Eof of int | `Ok ] Import.Deferred.t
  val read :
    Reader0.Internal.t ->
    ?pos:int ->
    ?len:int ->
    Core.Std.Substring.base ->
    [> `Eof | `Ok of Core.Std.Int.t ] Import.Deferred.t
  val really_read :
    Reader0.Internal.t ->
    ?pos:int ->
    ?len:int ->
    Core.Std.Substring.base -> [> `Eof of int | `Ok ] Import.Deferred.t
  val read_char :
    Reader0.Internal.t -> [> `Eof | `Ok of char ] Import.Deferred.t
  val first_char :
    Reader0.Internal.t ->
    [< `Char of char | `Pred of char -> bool ] ->
    int option Core.Std.Or_error.t
  val read_until_gen :
    Reader0.Internal.t ->
    [< `Char of char | `Pred of char -> bool ] ->
    keep_delim:bool ->
    max:int option ->
    (([> `Eof
       | `Eof_without_delim of string
       | `Max_exceeded of string
       | `Ok of string ],
      Core_kernel.Error.t)
     Core.Std._result -> unit) ->
    unit
  val read_until :
    Reader0.Internal.t ->
    [< `Char of char | `Pred of char -> bool ] ->
    keep_delim:bool ->
    (([> `Eof | `Eof_without_delim of string | `Ok of string ],
      Core_kernel.Error.t)
     Core.Std._result -> unit) ->
    unit
  val line_delimiter_pred : [> `Char of char ]
  val read_line_gen :
    Reader0.Internal.t ->
    ([> `Eof | `Eof_without_delim of string | `Ok of Core.Std.String.t ] ->
     unit) ->
    unit
  val read_line :
    Reader0.Internal.t ->
    [> `Eof | `Ok of Core.Std.String.t ] Import.Deferred.t
  val really_read_line :
    wait_time:Core.Std.Time.Span.t ->
    Reader0.Internal.t -> Core.Std.String.t option Import.Deferred.t
  val space : Core.Std.Bigstring.t
  val gen_read_sexp :
    ?parse_pos:Core.Std.Sexp.Parse_pos.t ->
    Reader0.Internal.t ->
    (?parse_pos:Core.Std.Sexp.Parse_pos.t ->
     ?len:int ->
     Core.Std.Bigstring.t ->
     (Core.Std.Bigstring.t, 'a) Core.Std.Sexp.parse_result) ->
    (([> `Eof | `Ok of 'a * Core.Std.Sexp.Parse_pos.t ], Core_kernel.Error.t)
     Core.Std._result -> unit) ->
    unit
  type 'a read = ?parse_pos:Core.Std.Sexp.Parse_pos.t -> 'a
  val gen_read_sexps :
    ?parse_pos:Core.Std.Sexp.Parse_pos.t ->
    Reader0.Internal.t ->
    (?parse_pos:Core.Std.Sexp.Parse_pos.t ->
     ?len:int ->
     Core.Std.Bigstring.t ->
     (Core.Std.Bigstring.t, 'a) Core.Std.Sexp.parse_result) ->
    'Import.Pipe.Reader.t
  val read_sexps :
    ?parse_pos:Core.Std.Sexp.Parse_pos.t ->
    Reader0.Internal.t -> Core.Std.Sexp.t Import.Pipe.Reader.t
  val read_bin_prot :
    ?max_len:Core.Std.Int.t ->
    Reader0.Internal.t ->
    'Reader0.Type_class.reader ->
    ([> `Eof | `Ok of 'a ] Core.Std.Or_error.t -> unit) -> unit
  val read_marshal_raw :
    Reader0.Internal.t ->
    [> `Eof | `Ok of Core.Std.String.t ] Async_core.Deferred.t
  val read_marshal :
    Reader0.Internal.t -> [> `Eof | `Ok of 'a ] Async_core.Deferred.t
  val read_all :
    Reader0.Internal.t ->
    (Reader0.Internal.t -> [< `Eof | `Ok of 'a ] Async_core.Deferred.t) ->
    'Import.Pipe.Reader.t
  val lines : Reader0.Internal.t -> Core.Std.String.t Import.Pipe.Reader.t
  val contents : Reader0.Internal.t -> string Async_core.Deferred.t
  val recv :
    Reader0.Internal.t ->
    [> `Eof | `Ok of Core.Std.String.t ] Import.Deferred.t
  val transfer :
    Reader0.Internal.t ->
    (string, Import.Pipe.Writer.phantom) Import.Pipe.t ->
    unit Import.Deferred.t
end