1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Network Block Device (NBD) driver implementation and server functionality.
//!
//! This module provides core components for implementing an NBD server:
//!
//! - [`crate::device::NbdDriver`]: A trait for defining NBD devices
//! - [`crate::server::NbdServer`]: A struct for handling the NBD protocol
//!
//! # Protocol Compliance
//!
//! This implementation follows the NBD protocol specification as defined at
//! [NetworkBlockDevice/nbd](https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md).
//!
//! # Security Considerations
//!
//! NBD does not provide built-in authentication or encryption. For secure deployments:
//!
//! - Use on trusted networks only
//! - Consider implementing TLS support (with the `START_TLS` option)
//! - Use firewall rules to restrict access
//!
//! # Logging
//!
//! This crate uses the `tracing` crate for logging. To enable logging, you need to install
//! a tracing subscriber. For simple usage, you can use the `init_default_tracing` function
//! provided by this crate.
//!
//! ```rust,no_run
//! tokio_nbd::init_default_tracing();
//! ```
//!
//! For more advanced usage, you can use the tracing crate directly to configure logging.
/// Initializes a default tracing subscriber suitable for use with tokio-nbd.
///
/// This sets up basic console logging with RUST_LOG environment variable support.
/// If you want more advanced tracing configuration, you should set up your own
/// subscriber instead.
///
/// # Example
///
/// ```rust,no_run
/// // Initialize the default tracing subscriber at the beginning of your program
/// tokio_nbd::init_default_tracing();
///
/// // Now logs from tokio-nbd will be visible
/// ```