Module Lwt_bytesSource
Byte arrays
type t =
(char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout)
Stdlib.Bigarray.Array1.tType of array of bytes.
Creates a new byte array of the given size.
Returns the length of the given byte array.
Access
get buffer offset returns the byte at offset offset in buffer.
get buffer offset value changes the value of the byte at offset offset in buffer to value.
Same as get but without bounds checking.
Same as set but without bounds checking.
Conversions
of_bytes buf returns a newly allocated byte array with the same contents as buf.
of_string buf returns a newly allocated byte array with the same contents as buf.
to_bytes buf returns newly allocated bytes with the same contents as buf.
to_string buf returns a newly allocated string with the same contents as buf.
Copying
blit buf1 ofs1 buf2 ofs2 len copies len bytes from buf1 starting at offset ofs1 to buf2 starting at offset ofs2.
Same as blit but the first buffer is a String.t instead of a byte array.
Same as blit but the first buffer is a Bytes.t instead of a byte array.
Same as blit but the second buffer is a Bytes.t instead of a byte array.
Same as blit but without bound checking.
Same as Lwt_bytes.blit_from_bytes but without bounds checking.
Same as Lwt_bytes.blit_from_string but without bounds checking.
Same as Lwt_bytes.blit_to_bytes but without bounds checking.
proxy buffer offset length creates a ``proxy''. The returned byte array share the data of buffer but with different bounds.
extract buffer offset length creates a new byte array of length length and copy the length bytes of buffer at offset into it.
copy buffer creates a copy of the given byte array.
Filling
fill buffer offset length value puts value in all length bytes of buffer starting at offset offset.
Same as fill but without bounds checking.
IOs
The following functions behave similarly to the ones in Lwt_unix, except they use byte arrays instead of Bytes.t, and they never perform extra copies of the data.
val recv :
Lwt_unix.file_descr ->
Lwt_bytes.t ->
int ->
int ->
Unix.msg_flag list ->
int Lwt.tNot implemented on Windows.
val send :
Lwt_unix.file_descr ->
Lwt_bytes.t ->
int ->
int ->
Unix.msg_flag list ->
int Lwt.tNot implemented on Windows.
val recvfrom :
Lwt_unix.file_descr ->
Lwt_bytes.t ->
int ->
int ->
Unix.msg_flag list ->
(int * Unix.sockaddr) Lwt.tNot implemented on Windows.
val sendto :
Lwt_unix.file_descr ->
Lwt_bytes.t ->
int ->
int ->
Unix.msg_flag list ->
Unix.sockaddr ->
int Lwt.tNot implemented on Windows.
val recv_msg :
socket:Lwt_unix.file_descr ->
io_vectors:Lwt_bytes.io_vector list ->
(int * Unix.file_descr list) Lwt.tNot implemented on Windows.
val send_msg :
socket:Lwt_unix.file_descr ->
io_vectors:Lwt_bytes.io_vector list ->
fds:Unix.file_descr list ->
int Lwt.tNot implemented on Windows.
Memory mapped files
val map_file :
fd:Unix.file_descr ->
?pos:int64 ->
shared:bool ->
?size:int ->
unit ->
Lwt_bytes.tmap_file ~fd ?pos ~shared ?size () maps the file descriptor fd to an array of bytes.
mapped buffer returns true iff buffer is a memory mapped file.
Type of advise that can be sent to the kernel by the program. See the manual madvise(2) for a description of each.
madvise buffer pos len advice advises the kernel how the program will use the memory mapped file between pos and pos + len.
This call is not available on windows.
Size of pages.
mincore buffer offset states tests whether the given pages are in the system memory (the RAM). The offset argument must be a multiple of page_size. states is used to store the result; each cases is true if the corresponding page is in RAM and false otherwise.
This call is not available on windows and cygwin.
wait_mincore buffer offset waits until the page containing the byte at offset offset is in RAM.
This functions is not available on windows and cygwin.