Module Imandra_util.IO_chunk
Chunks for IO
type t= private{mutable bs : bytes;buffer
mutable i : int;offset of subslice
mutable len : int;length of subslice
}A single chunk, for writing or reading.
It can be used as a buffer, with active slice
b.[i … i+len-1], or just as a string-like object in an output list.Some day we might use iovec :-)
type chunk= t
val bytes_len : t -> intSize of underlying buffer
val len : t -> intLength of the slice
val free_len : t -> intSpace remaining at the end
val of_bytes : bytes -> tval of_string : string -> tval sprintf : ('a, unit, string, t) Stdlib.format4 -> 'aval to_string : t -> stringExtract content as a string
val clear : t -> unitMake the chunk empty
val map_buf : f:(bytes -> int -> int -> 'a) -> t -> 'aval extend_buf : f:(bytes -> int -> int -> int) -> t -> intextend_buf buf ~fcallsfon the free slice at the end ofbuf, and assumes the return value offis how many bytes were added.
val create : int -> tCreate a chunk with given
bytes_len
val get_char : t -> charRead and consume one char
val consume : t -> int -> unitConsume n bytes from the buffer.
val is_empty : t -> boolIs the buffer empty (i.e. len = 0)?
module Pool : sig ... endval append : ?pool:Pool.t -> t -> into:t -> unitappend c ~into:c2appends the content ofctoc2. Might reallocate the content ofc2.- parameter pool
can be used for reallocation
module FD : sig ... end