bb_drivelist/
device.rs

1#[derive(Debug, Default, Clone)]
2/// Mountpoints of a drive
3pub struct MountPoint {
4    pub path: String,
5    pub label: Option<String>,
6    pub total_bytes: Option<u64>,
7    pub available_bytes: Option<u64>,
8}
9
10impl MountPoint {
11    pub fn new(path: impl ToString) -> Self {
12        Self {
13            path: path.to_string(),
14            label: None,
15            total_bytes: None,
16            available_bytes: None,
17        }
18    }
19}
20
21#[derive(Debug, Clone)]
22/// Device Description
23pub struct DeviceDescriptor {
24    pub enumerator: String,
25    pub bus_type: Option<String>,
26    pub bus_version: Option<String>,
27    pub device: String,
28    pub device_path: Option<String>,
29    pub raw: String,
30    pub description: String,
31    pub error: Option<String>,
32    pub partition_table_type: Option<String>,
33    pub size: u64,
34    pub block_size: u32,
35    pub logical_block_size: u32,
36    pub mountpoints: Vec<MountPoint>,
37    pub mountpoint_labels: Vec<String>,
38    /// Device is read-only
39    pub is_readonly: bool,
40    /// Device is a system drive
41    pub is_system: bool,
42    /// Device is an SD-card
43    pub is_card: bool,
44    /// Connected via the Small Computer System Interface (SCSI)
45    pub is_scsi: bool,
46    /// Connected via Universal Serial Bus (USB)
47    pub is_usb: bool,
48    /// Device is a virtual storage device
49    pub is_virtual: bool,
50    /// Device is removable from the running system
51    pub is_removable: bool,
52    /// Connected via the USB Attached SCSI (UAS)
53    pub is_uas: Option<bool>,
54}
55
56impl Default for DeviceDescriptor {
57    fn default() -> Self {
58        Self {
59            block_size: 512,
60            logical_block_size: 512,
61            enumerator: Default::default(),
62            bus_type: Default::default(),
63            bus_version: Default::default(),
64            device: Default::default(),
65            device_path: Default::default(),
66            raw: Default::default(),
67            description: Default::default(),
68            error: Default::default(),
69            partition_table_type: Default::default(),
70            size: Default::default(),
71            mountpoints: Default::default(),
72            mountpoint_labels: Default::default(),
73            is_readonly: Default::default(),
74            is_system: Default::default(),
75            is_card: Default::default(),
76            is_scsi: Default::default(),
77            is_usb: Default::default(),
78            is_virtual: Default::default(),
79            is_removable: Default::default(),
80            is_uas: Default::default(),
81        }
82    }
83}