Module Bytebuffer
Extensible buffers using bigstrings.
type bigstring= (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.ttype t
module View : sig ... endval create : int -> tcreate sizereturns a new empty bytebuffer. This function will allocate a new bigstring of sizesize. The bytebuffer will be resized automatically if attempting to add more thansizecharacters to the bytebuffer.
val of_bigstring : bigstring -> tof_bigstringcreates a new bytebuffer and uses the user provided bigstring as the backing store.
val contents_string : t -> stringcontents_stringis the same ascontentsexcept it returns the copy as astring.
val length : t -> intlengthreturns the number of characters in the bytebuffer.
val capacity : t -> intcapacityis the size of the underlying bigstring.
val clear : t -> unitclearempties the bytebuffer.
val reset : t -> unitresetclears the bytebuffer and resets the underlying bigstring to the initial bigstring used duringcreate.
val add_char : t -> char -> unitadd_charappends a charater at the end of the bytebuffer.
val add_string : t -> string -> unitadd_stringappends a string at the end of the bytebuffer.
val add_bigstring : t -> ?pos:int -> ?len:int -> bigstring -> unitadd_bigstringappends a bigstring at the end of the bytebuffer.
val fill : t -> View.tfillreturns a view into the buffer's underlying bigstring that can be used to blit bytes directly into the buffer. This can be useful to directly read content into the buffer.
val consume : t -> View.tconsumereturns a view into the buffer's underlying bigstring that can be used to blit bytes from the buffer. This can be useful to consume bytes from the buffer and blit them directly for I/O operations.
val addf : t -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'aval index : ?pos:int -> ?len:int -> char -> t -> int optionindexreturns the index of the character if it exists within the buffer.
val unsafe_index : ?pos:int -> ?len:int -> char -> t -> intunsafe_indexis similar toindexbut instead of options it returns a negative integer if the character isn't present in the buffer.
val drop : t -> int -> unitdrop ndeletes the firstnbytes from the buffer.