Expand description
Rust bindings to NBDKit.
NBDKit is a toolkit for building Network Block Device servers.
https://gitlab.com/nbdkit/nbdkit
To use nbdkit, build your project as a cdylib. Define your plugin by
implementing Server
, and then register it with plugin!
. See
ramdisk.rs in the source code for a complete example.
#[derive(Default)]
struct MyPlugin {
// ...
}
impl Server for MyPlugin {
fn get_size(&self) -> Result<i64> {
// ...
}
fn name() -> &'static str {
"my_plugin"
}
fn open(_readonly: bool) -> Result<Box<dyn Server>> {
Ok(Box::new(MyPlugin::default()))
}
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<()> {
// ...
}
}
plugin!(MyPlugin {});
Macros§
Structs§
- Error
- The error type used by
Result
. - Extent
Handle - Used by
Server::extents
to report extents to the client - Flags
- Flags used by multiple
Server
methods
Enums§
- Cache
Flags - Return values for
Server::can_cache
- Extent
Type - Used by
Server::extents
to report extents to the client - FuaFlags
- Return values for
Server::can_fua
- Thread
Model - A plugin’s maximum thread safety model
Traits§
- Server
- Define the entry point for your plugin.
- Sockaddr
Like - Anything that, in C, can be cast back and forth to
sockaddr
.
Functions§
- disconnect
- Request nbdkit to disconnect the current client.
- export_
name - Return the optional NBD export name if one was negotiated with the current client
- is_
stdio_ safe - Is it safe to interact with stdin and stdout during the configuration phase?
- is_tls
- Did the client complete TLS authentication?
- parse_
bool - Parse a string as a boolean using
nbdkit_parse_bool
. - parse_
probability - Parse a string as a probability/percentage using
nbdkit_parse_probability
. - parse_
size - Parse a string as a size using
nbdkit_parse_size
. - peername
- Return the peer (client) address, if available.
- shutdown
- Request nbdkit to asynchronously and safely shutdown the server.