libnbd-rust(3)

libnbd-rust3

How to use libnbd from rust

Usage

 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" }

Overview

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).

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

Authors

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

From libnbd 1.24.4-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.