Crate nbdkit[][src]

Expand description

Rust bindings to NBDKit.

NBDKit is a toolkit for building Network Block Device servers.

To use nbdkit, build your project as a cdylib. Define your plugin by implementing Server, and then register it with plugin!. See in the source code for a complete example.

struct MyPlugin {
    // ...
impl Server for MyPlugin {
    fn get_size(&self) -> Result<i64> {
        // ...

    fn name() -> &'static str {

    fn open(_readonly: bool) -> Box<dyn Server> {

    fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<()> {
        // ...
plugin!(MyPlugin {});


Register your plugin with NBDKit.


The error type used by Result.

Used by Server::extents to report extents to the client

Flags used by multiple Server methods


Return values for Server::can_cache

Used by Server::extents to report extents to the client

Return values for Server::can_fua

Represents a socket address

A plugin’s maximum thread safety model


Define the entry point for your plugin.


Return the optional NBD export name if one was negotiated with the current client

Is it safe to interact with stdin and stdout during the configuration phase?

Return the peer (client) address, if available.

Request nbdkit to asynchronously and safely shutdown the server.

Return the appropriate SockAddr type from a sockaddr_storage of a certain size. In C this would usually be done by casting. The len argument should be the number of bytes in the sockaddr_storage that are actually allocated and valid. It must be at least as large as all the useful parts of the structure. Note that in the case of a sockaddr_un, len need not include the terminating null.

Type Definitions

The Result type returned by all Server callbacks.