module Iobuf: Iobufinclude ??
include ??
type (+'data_perm_read_write, +'seek_permission) t 
    To allow read_write or read_only access, a function's type uses _ rather than
    read_only as the type argument to t.  Analogously, to allow no_seek or seek
    access, a function's type uses _ rather than no_seek as the type argument to t.
    Using _ allows the function to be directly applied to either permission.  Using
    a specific permission would require code to use coercion :>.
include Invariant.S2
val create : len:int -> ('a, 'b) tcreate ~len creates a new iobuf, backed by a bigstring of length len,
    with the limits and window set to the entire bigstring.val of_bigstring : ?pos:int -> ?len:int -> Bigstring.t -> ('a, 'b) tof_bigstring bigstring ~pos ~len returns an iobuf backed by bigstring, with the
    window and limits specified starting at pos and of length len.val of_string : string -> ('a, 'b) tof_string s returns a new iobuf whose contents are s.val sub : ?pos:int -> ?len:int -> ('d, 'a) t -> ('d, 'b) tsub t ~pos ~len returns a new iobuf with limits and window set to the subrange of
    t specified by pos and len.  sub preserves data permissions, but allows
    arbitrary seek permissions on the resulting iobuf.val capacity : ('a, 'b) t -> intcapacity t returns the size of t's limits subrange.  The capacity of an iobuf can
    be reduced via narrow.val length : ('a, 'b) t -> intlength t returns the size of t's window.val is_empty : ('a, 'b) t -> boolis_empty t is length t = 0.val narrow : ('a, seek) t -> unitnarrow t sets t's limits to the current window.Lo_bound.window t to get a snapshot of the lower bound of the
    window, and then later restore that snapshot with Lo_bound.restore.  This is
    useful for speculatively parsing, and then rewinding when there isn't enough data to
    finish.
    Similarly for Hi_bound.window and Lo_bound.restore.
    Using a snapshot with a different iobuf, even a sub iobuf of the snapshotted one, has
    unspecified results.  An exception may be raised, or a silent error may occur.
    However, the safety guarantees of the iobuf will not be violated, i.e., the attempt
    will not enlarge the limits of the subject iobuf.
module type Bound =Boundwith type ('d, 'w) iobuf := ('d, 'w) t
module Lo_bound:Bound
module Hi_bound:Bound
val advance : ('a, seek) t -> int -> unitadvance t amount advances the lower bound of the window by amount.  It is an error
    to advance past the upper bound of the window or the lower limit.val resize : ('a, seek) t -> len:int -> unitresize t sets the length of t's window, provided it does not exceed limits.val rewind : ('a, seek) t -> unitrewind t sets the lower bound of the window to the lower limit.val reset : ('a, seek) t -> unitreset t sets the window to the limits.val flip_lo : ('a, seek) t -> unitflip_lo t sets the window to range from the lower limit to the lower bound of the
    old window.  This is typically called after a series of Fills, to reposition the
    window in preparation to Consume the newly written data.
    The bounded version narrows the effective limit.  This can preserve some data near the
    limit, such as an hypothetical packet header, in the case of bounded_flip_lo or
    unfilled suffix of a buffer, in bounded_flip_hi.
val bounded_flip_lo : ('a, seek) t -> Lo_bound.t -> unitval compact : (Common.read_write, seek) t -> unitcompact t copies data from the window to the lower limit of the iobuf and sets the
    window to range from the end of the copied data to the upper limit.  This is typically
    called after a series of Consumes to save unread data and prepare for the next
    series of Fills and flip_lo.val bounded_compact : (Common.read_write, seek) t -> Lo_bound.t -> Hi_bound.t -> unitval flip_hi : ('a, seek) t -> unitflip_hi t sets the window to range from the the upper bound of the current window to
    the upper limit.  This operation is dual to flip_lo and is typically called when the
    data in the current (narrowed) window has been processed and the window needs to be
    positioned over the remaining data in the buffer.  For example:
      (* ... determine initial_data_len ... *)
      Iobuf.resize buf ~len:initial_data_len;
      (* ... and process initial data ... *)
      Iobuf.flip_hi buf;
    
    Now the window of buf ranges over the remainder of the data.
val bounded_flip_hi : ('a, seek) t -> Hi_bound.t -> unitval to_string : ?len:int -> ('a, 'b) t -> stringto_string t returns the bytes in t as a string.  It does not alter the window.val consume_into_string : ?pos:int -> ?len:int -> ('a, seek) t -> string -> unitconsume_into_string t s ~pos ~len reads len bytes from t, advancing t's window
    accordingly, and writes them into s starting at pos.  By default pos = 0 and
    len = String.length s - pos.  It is an error if pos and len don't specify a
    valid region of s or len > length t.val consume_into_bigstring : ?pos:int -> ?len:int -> ('a, seek) t -> Bigstring.t -> unitmodule Consume:Accessorswith type ('a, 'd, 'w) t = ('d, seek) t -> 'a
Consume.string t ~len reads len characters (all, by default) from t into a new
    string and advances the lower bound of the window accordingly.
module Fill:Accessorswith type ('a, 'd, 'w) t = (read_write, seek) t -> 'a -> unit
Peek and Poke functions access a value at pos from the lower bound of the window
    and do not advance.
module Peek:Accessorswith type ('a, 'd, 'w) t = ('d, 'w) t -> pos:int -> 'a
module Poke:Accessorswith type ('a, 'd, 'w) t = (read_write, 'w) t -> pos:int -> 'a -> unit
module Unsafe:sig..end
Unsafe has submodules that are like their corresponding module, except with no range
    checks.
val fill_bin_prot : (Common.read_write, seek) t ->
       'a Bin_prot.Type_class.writer -> 'a -> unit Or_error.tfill_bin_prot writes a bin-prot value to the lower bound of the window, prefixed by
    its length, and advances by the amount written.  fill_bin_prot returns an error if
    the window is too small to write the value.
    consume_bin_prot t reader reads a bin-prot value from the lower bound of the window,
    which should have been written using fill_bin_prot, and advances the window by the
    amount read.  consume_bin_prot returns an error if there is not a complete message
    in the window and in that case the window is left unchanged.
val consume_bin_prot : ('b, seek) t -> 'a Bin_prot.Type_class.reader -> 'a Or_error.tval transfer : ?len:int ->
       src:('a, seek) t -> dst:(Common.read_write, seek) t -> unittransfer blits len bytes from src to dst, advancing the lower bounds of both
    windows.  It is an error if len > length src || len > length dst || phys_equal src
    dst.val memmove : (Common.read_write, 'a) t ->
       src_pos:int -> dst_pos:int -> len:int -> unitmemmove blits len bytes from src_pos to dst_pos in an iobuf, both relative to
    the lower bound of the window.  The window is not advanced.val read_assume_fd_is_nonblocking : (Common.read_write, seek) t -> Iobuf_intf.Unix.File_descr.t -> intIobuf has analogs of various Bigstring functions.  These analogs advance by the
    amount written/read.val pread_assume_fd_is_nonblocking : (Common.read_write, seek) t ->
       Iobuf_intf.Unix.File_descr.t -> offset:int -> intval recvfrom_assume_fd_is_nonblocking : (Common.read_write, seek) t ->
       Iobuf_intf.Unix.File_descr.t -> int * Iobuf_intf.Unix.sockaddrval recvmmsg_assume_fd_is_nonblocking : (Iobuf_intf.Unix.File_descr.t ->
        ?count:int ->
        ?srcs:Iobuf_intf.Unix.sockaddr array ->
        (Common.read_write, seek) t array -> int)
       Or_error.tval send_nonblocking_no_sigpipe : unit ->
       (('a, seek) t -> Iobuf_intf.Unix.File_descr.t -> int option) Or_error.tval sendto_nonblocking_no_sigpipe : unit ->
       (('a, seek) t ->
        Iobuf_intf.Unix.File_descr.t -> Iobuf_intf.Unix.sockaddr -> int option)
       Or_error.tval write_assume_fd_is_nonblocking : ('a, seek) t -> Iobuf_intf.Unix.File_descr.t -> intval pwrite_assume_fd_is_nonblocking : ('a, seek) t -> Iobuf_intf.Unix.File_descr.t -> offset:int -> intval sexp_of_seek : seek -> Sexplib.Sexp.tval sexp_of_no_seek : no_seek -> Sexplib.Sexp.tval sexp_of_t : ('data_perm_read_write -> Sexplib.Sexp.t) ->
       ('seek_permission -> Sexplib.Sexp.t) ->
       ('data_perm_read_write, 'seek_permission) t -> Sexplib.Sexp.t
    To allow read_write or read_only access, a function's type uses _ rather than
    read_only as the type argument to t.  Analogously, to allow no_seek or seek
    access, a function's type uses _ rather than no_seek as the type argument to t.
    Using _ allows the function to be directly applied to either permission.  Using
    a specific permission would require code to use coercion :>.
create ~len creates a new iobuf, backed by a bigstring of length len,
    with the limits and window set to the entire bigstring.of_bigstring bigstring ~pos ~len returns an iobuf backed by bigstring, with the
    window and limits specified starting at pos and of length len.0Bigstring.length bigstring - posof_string s returns a new iobuf whose contents are s.sub t ~pos ~len returns a new iobuf with limits and window set to the subrange of
    t specified by pos and len.  sub preserves data permissions, but allows
    arbitrary seek permissions on the resulting iobuf.capacity t returns the size of t's limits subrange.  The capacity of an iobuf can
    be reduced via narrow.length t returns the size of t's window.is_empty t is length t = 0.narrow t sets t's limits to the current window.Lo_bound.window t to get a snapshot of the lower bound of the
    window, and then later restore that snapshot with Lo_bound.restore.  This is
    useful for speculatively parsing, and then rewinding when there isn't enough data to
    finish.
    Similarly for Hi_bound.window and Lo_bound.restore.
    Using a snapshot with a different iobuf, even a sub iobuf of the snapshotted one, has
    unspecified results.  An exception may be raised, or a silent error may occur.
    However, the safety guarantees of the iobuf will not be violated, i.e., the attempt
    will not enlarge the limits of the subject iobuf.
advance t amount advances the lower bound of the window by amount.  It is an error
    to advance past the upper bound of the window or the lower limit.
resize t sets the length of t's window, provided it does not exceed limits.
rewind t sets the lower bound of the window to the lower limit.
reset t sets the window to the limits.
flip_lo t sets the window to range from the lower limit to the lower bound of the
    old window.  This is typically called after a series of Fills, to reposition the
    window in preparation to Consume the newly written data.
    The bounded version narrows the effective limit.  This can preserve some data near the
    limit, such as an hypothetical packet header, in the case of bounded_flip_lo or
    unfilled suffix of a buffer, in bounded_flip_hi.
compact t copies data from the window to the lower limit of the iobuf and sets the
    window to range from the end of the copied data to the upper limit.  This is typically
    called after a series of Consumes to save unread data and prepare for the next
    series of Fills and flip_lo.
flip_hi t sets the window to range from the the upper bound of the current window to
    the upper limit.  This operation is dual to flip_lo and is typically called when the
    data in the current (narrowed) window has been processed and the window needs to be
    positioned over the remaining data in the buffer.  For example:
      (* ... determine initial_data_len ... *)
      Iobuf.resize buf ~len:initial_data_len;
      (* ... and process initial data ... *)
      Iobuf.flip_hi buf;
    
    Now the window of buf ranges over the remainder of the data.
to_string t returns the bytes in t as a string.  It does not alter the window.consume_into_string t s ~pos ~len reads len bytes from t, advancing t's window
    accordingly, and writes them into s starting at pos.  By default pos = 0 and
    len = String.length s - pos.  It is an error if pos and len don't specify a
    valid region of s or len > length t.Consume.string t ~len reads len characters (all, by default) from t into a new
    string and advances the lower bound of the window accordingly.Peek and Poke functions access a value at pos from the lower bound of the window
    and do not advance.Unsafe has submodules that are like their corresponding module, except with no range
    checks.  Hence, mistaken uses can cause segfaults.  Be careful!fill_bin_prot writes a bin-prot value to the lower bound of the window, prefixed by
    its length, and advances by the amount written.  fill_bin_prot returns an error if
    the window is too small to write the value.
    consume_bin_prot t reader reads a bin-prot value from the lower bound of the window,
    which should have been written using fill_bin_prot, and advances the window by the
    amount read.  consume_bin_prot returns an error if there is not a complete message
    in the window and in that case the window is left unchanged.
transfer blits len bytes from src to dst, advancing the lower bounds of both
    windows.  It is an error if len > length src || len > length dst || phys_equal src
    dst.
default is min (length src) (length dst)
memmove blits len bytes from src_pos to dst_pos in an iobuf, both relative to
    the lower bound of the window.  The window is not advanced.
Iobuf has analogs of various Bigstring functions.  These analogs advance by the
    amount written/read.