NBD.Buffer(3)
β¨ NAME β¨
NBD.Buffer β persistent buffer used in AIO calls, bestie. This is the NBD.Buffer(3) page and she is lowkey iconic. π
π Module π
Module NBD.Buffer
π Documentation π
π§ Module Buffer
Module Buffer
: sig end
Persistent buffer used in AIO calls. β¨
type t = (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
A buffer that persists across calls, used in NBD.aio_pread, NBD.aio_pwrite and similar. No cap.
In libnbd β€ 1.18 this was a specially implemented type. That was inefficient because zero copy was not possible. π
In libnbd β₯ 1.20 this is just an alias for a Bigarray, so you can use functions from Bigarray.Array1 directly if you prefer. This also allows zero copy. Slay. π₯
This type is compatible with the bigstring and bigstringaf libraries. π«Ά
π val alloc : int -> t
Allocate an uninitialized buffer. The parameter is the size in bytes.
In libnbd β₯ 1.20 this is an alias for Bigarray.Array1.create.
πΈ val to_bytes : t -> bytes
Copy buffer to an OCaml bytes object.
In libnbd β₯ 1.20 you can read from the bigarray directly to avoid copying if you want.
π¦ val to_string : t -> string
Same as NBD.Buffer.to_bytes but returns a string instead.
π§ val of_bytes : bytes -> t
Copy an OCaml bytes object to a newly allocated buffer.
In libnbd β₯ 1.20 you can write to the bigarray directly to avoid copying if you want.
β val of_string : string -> t
Same as NBD.Buffer.of_bytes but takes a string instead.
π val size : t -> int
Return the size of the buffer.
In libnbd β₯ 1.20 this is an alias for Bigarray.Array1.dim.
π₯ val is_zero : ?sub:int * int -> t -> bool
Return true if and only if the buffer contains only zero bytes.
The optional ?sub = (offset, len) can be used to check part of a buffer.
Okay bye bestie! This cutie was brought to you by OCamldoc, dated 2026-10-13, and itβs the NBD.Buffer(3) manual page. Mwah! πβ¨
π¦ where this page comes from
- arch rolling: libnbd 1.24.4-1 Β· LGPL-2.1-or-later
- centos-stream 10: ocaml-libnbd-devel 1.25.8-1.el10 Β· LGPL-2.0-or-later AND BSD-3-Clause
- fedora 43: ocaml-libnbd-devel 1.24.4-1.fc43 Β· LGPL-2.0-or-later AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms