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

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

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