Module Lwt_bytes

module Lwt_bytes : sig..end

Byte arrays


type t = 
  (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout)
  Bigarray.Array1.t

Type of array of bytes.

val create : int -> t

Creates a new byte array of the given size.

val length : t -> int

Returns the length of the given byte array.


Access


val get : t -> int -> char

get buffer offset returns the byte at offset offset in buffer.

val set : t -> int -> char -> unit

get buffer offset value changes the value of the byte at offset offset in buffer to value.

val unsafe_get : t -> int -> char

Same as Lwt_bytes.​get but without bound checking.

val unsafe_set : t -> int -> char -> unit

Same as Lwt_bytes.​set but without bound checking.


Conversions


val of_string : string -> t

of_string str returns a newly allocated byte array with the same contents as str.

val to_string : t -> string

to_string buf returns a newly allocated string with the same contents as buf.


Copying


val blit : t -> int -> t -> int -> int -> unit

blit buf1 ofs1 buf2 ofs2 len copy len bytes from buf1 starting at offset ofs1 to buf2 starting at offset ofs2.

val blit_string_bytes : string -> int -> t -> int -> int -> unit

Same as blit but the first buffer is a string instead of a byte array.

val blit_bytes_string : t -> int -> string -> int -> int -> unit

Same as blit but the second buffer is a string instead of a byte array.

val unsafe_blit : t -> int -> t -> int -> int -> unit

Same as Lwt_bytes.​blit but without bound checking.

val unsafe_blit_string_bytes : string -> int -> t -> int -> int -> unit

Same as Lwt_bytes.​blit_string_bytes but without bound checking.

val unsafe_blit_bytes_string : t -> int -> string -> int -> int -> unit

Same as Lwt_bytes.​blit_bytes_string but without bound checking.

val proxy : t -> int -> int -> t

proxy buffer offset length creates a ``proxy''. The returned byte array share the data of buffer but with different bounds.

val extract : t -> int -> int -> t

extract buffer offset length creates a new byte array of length length and copy the length bytes of buffer at offset into it.

val copy : t -> t

copy buffer creates a copy of the given byte array.


Filling


val fill : t -> int -> int -> char -> unit

fill buffer offset length value puts value in all length bytes of buffer starting at offset offset.

val unsafe_fill : t -> int -> int -> char -> unit

Same as Lwt_bytes.​fill but without bound checking.


IOs



The following functions does the same as the functions in Lwt_unix except that they use byte arrays instead of strings.

val read : Lwt_unix.file_descr -> t -> int -> int -> int