Luv.BufferData buffers.
See Buffers in the user guide.
type t =
(char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout)
Stdlib.Bigarray.Array1.tBuffers with C storage.
These are OCaml bigstrings (char bigarrays). Roughly speaking, they correspond to C buffers referenced by pointers of type char*, but also know their own size.
In addition to being usable with the functions in this module, the type is compatible with at least the following libraries:
Bigarray from OCaml's standard libraryLwt_bytes from Lwtval create : int -> tAllocates a fresh buffer of the given size.
val size : t -> intEvaluates to the size of the given buffer.
val get : t -> int -> charLuv.Buffer.get buffer index retrieves the character in buffer at index.
Can also be written as buffer.{index}.
val unsafe_get : t -> int -> charLike Luv.Buffer.get, but does not perform a bounds check.
val set : t -> int -> char -> unitLuv.Buffer.set buffer index value sets the character in buffer at index to value.
Can also be written as buffer.{index} <- value.
val unsafe_set : t -> int -> char -> unitLike Luv.Buffer.set, but does not perform a bounds check.
Luv.Buffer.sub buffer ~offset ~length creates a view into buffer that starts at the given offset and has the given length.
No data is copied.
Copies data from source to destination.
The amount of data copied is the minimum of the two buffers' size.
To copy part of a buffer, use Luv.Buffer.sub to create a view, and pass the view to Luv.Buffer.blit.
val fill : t -> char -> unitFills the given buffer with the given character.
val to_string : t -> stringCreates a string with the same contents as the given buffer.
val to_bytes : t -> bytesCreates a bytes buffer with the same contents as the given buffer.
val from_string : string -> tCreates a buffer from a string.
val from_bytes : bytes -> tCreates a buffer from bytes.
val blit_to_bytes : t -> bytes -> destination_offset:int -> unitCopies data from a buffer to a bytes buffer.
val blit_from_bytes : t -> bytes -> source_offset:int -> unitCopies data from a bytes buffer to a buffer.
val blit_from_string : t -> string -> source_offset:int -> unitCopies data from a string to a buffer.
Many Luv functions, such as Luv.File.write, work with lists of buffers (i.e., they do scatter-gather I/O). These are helpers for working with buffer lists.
val total_size : t list -> intEvaluates to the sum of the sizes of the buffers in the list.