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

# libnbd-rust(3)

how to use libnbd from Rust

## NAME

libnbd-rust - how to use libnbd from Rust

## SYNOPSIS

```
 let nbd = libnbd::Handle::new().unwrap();
 nbd.connect_uri("nbd://localhost").unwrap();
 let size = nbd.get_size().unwrap();
 println!("{size} bytes");
```

In `"Cargo.toml"` add:

```
 [dependencies]
 libnbd = VERSION | { path = "libnbd/rust" }
```

## DESCRIPTION

This manual page documents how to use libnbd to access Network Block Device (NBD) servers from the Rust programming language.

The Rust bindings work very similarly to the C bindings so you should start by reading [**libnbd**(3)](/libnbd/3.md).

There is also a higher level asynchronous API using Tokio.

If you build libnbd from source, the main documentation can be found in *libnbd/rust/target/doc/libnbd/index.html*

For the ordinary interface, start by reading the documentation for `"Handle"`.  For the higher level asynchronous API, start by reading `"AsyncHandle"`.

`"libnbd-sys"` is a very low level wrapper around the libnbd API which should not be used directly.

## EXAMPLES

This directory contains examples written in Rust:

https://gitlab.com/nbdkit/libnbd/tree/master/rust/examples

## SEE ALSO

[**libnbd**(3)](/libnbd/3.md).

## AUTHORS

Tage Johansson

## COPYRIGHT

Copyright Tage Johansson

## LICENSE

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
