---
name: "NBD.Buffer"
section: "3"
platform: "linux"
package: "libnbd"
version: "1.24.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/NBD.Buffer"
---

# NBD.Buffer(3)

Persistent buffer used in AIO calls.

## NAME

NBD.Buffer - Persistent buffer used in AIO calls.

## Module

Module   NBD.Buffer

## Documentation

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.

In libnbd ≤ 1.18 this was a specially implemented type. This was inefficient as 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.

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.
