listdisk_rs/win32/physical_disk/typing/
mod.rs

1//! Generated by grok, from [MSDN](https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/msft-physicaldisk)
2
3use serde_repr::{Deserialize_repr, Serialize_repr};
4
5/// Bus type of the physical disk.
6///
7/// The storage bus type of the physical disk.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
9#[repr(u16)]
10pub enum BusType {
11    /// The bus type is unknown.
12    Unknown = 0,
13    /// SCSI
14    SCSI = 1,
15    /// ATAPI
16    ATAPI = 2,
17    /// ATA
18    ATA = 3,
19    /// IEEE 1394
20    Ieee1394 = 4,
21    /// SSA
22    SSA = 5,
23    /// Fibre Channel
24    FibreChannel = 6,
25    /// USB
26    USB = 7,
27    /// RAID
28    RAID = 8,
29    /// iSCSI
30    ISCSI = 9,
31    /// Serial Attached SCSI (SAS)
32    SAS = 10,
33    /// Serial ATA (SATA)
34    SATA = 11,
35    /// Secure Digital (SD)
36    SD = 12,
37    /// Multimedia Card (MMC)
38    MMC = 13,
39    /// This value is reserved for system use.
40    Max = 14,
41    /// File-Backed Virtual
42    FileBackedVirtual = 15,
43    /// Storage Spaces
44    StorageSpaces = 16,
45    /// NVMe
46    NVMe = 17,
47    // 18.. are Microsoft-reserved
48}
49
50/// Media type of the physical disk.
51#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
52#[repr(u16)]
53pub enum MediaType {
54    /// Unspecified media type.
55    Unspecified = 0,
56    /// Hard Disk Drive
57    HDD = 3,
58    /// Solid-State Drive
59    SSD = 4,
60    /// Storage Class Memory (e.g., Intel Optane)
61    SCM = 5,
62}
63
64/// High-level health indication of the device.
65#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
66#[repr(u16)]
67pub enum HealthStatus {
68    /// The disk is healthy.
69    Healthy = 0,
70    /// The disk has a warning condition.
71    Warning = 1,
72    /// The disk is unhealthy.
73    Unhealthy = 2,
74    /// Health status is unknown.
75    Unknown = 5,
76}
77
78/// Intended usage of the physical disk within a concrete pool.
79///
80/// Storage pools are required to follow the assigned policy for a physical disk.
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
82#[repr(u16)]
83pub enum Usage {
84    /// The intended usage is not specified.
85    Unknown = 0,
86    /// This physical disk should only be used for data storage.
87    AutoSelect = 1,
88    /// This physical disk should only be used if manually selected by an administrator
89    /// at the time of virtual disk creation (via `PhysicalDisksToUse`).
90    ManualSelect = 2,
91    /// This physical disk should be used as a hot spare.
92    HotSpare = 3,
93    /// This physical disk should be retired from use.
94    /// At a minimum, no new allocations should go to this disk.
95    Retired = 4,
96    /// This physical disk should be used as a cache (journal) for other devices
97    /// comprising a virtual disk. It will back a virtual disk's write-back cache,
98    /// if configured.
99    Journal = 5,
100}
101
102#[derive(Debug, Clone, Copy, PartialEq, Eq)]
103pub enum CannotPoolReason {
104    Unknown,
105    Other,
106    InAPool,
107    NotHealthy,
108    RemovableMedia,
109    InUseByCluster,
110    Offline,
111    InsufficientCapacity,
112    SpareDisk,
113    ReservedBySubSystem,
114    Starting,
115    MicrosoftReserved(u16),
116    VendorReserved(u16),
117}
118
119impl From<u16> for CannotPoolReason {
120    fn from(value: u16) -> Self {
121        match value {
122            0 => Self::Unknown,
123            1 => Self::Other,
124            2 => Self::InAPool,
125            3 => Self::NotHealthy,
126            4 => Self::RemovableMedia,
127            5 => Self::InUseByCluster,
128            6 => Self::Offline,
129            7 => Self::InsufficientCapacity,
130            8 => Self::SpareDisk,
131            9 => Self::ReservedBySubSystem,
132            10 => Self::Starting,
133            0x8000.. => Self::VendorReserved(value),
134            _ => Self::MicrosoftReserved(value),
135        }
136    }
137}
138
139impl From<CannotPoolReason> for u16 {
140    fn from(value: CannotPoolReason) -> Self {
141        match value {
142            CannotPoolReason::Unknown => 0,
143            CannotPoolReason::Other => 1,
144            CannotPoolReason::InAPool => 2,
145            CannotPoolReason::NotHealthy => 3,
146            CannotPoolReason::RemovableMedia => 4,
147            CannotPoolReason::InUseByCluster => 5,
148            CannotPoolReason::Offline => 6,
149            CannotPoolReason::InsufficientCapacity => 7,
150            CannotPoolReason::SpareDisk => 8,
151            CannotPoolReason::ReservedBySubSystem => 9,
152            CannotPoolReason::Starting => 10,
153            CannotPoolReason::MicrosoftReserved(v) => v,
154            CannotPoolReason::VendorReserved(v) => v,
155        }
156    }
157}