axdriver/structs/
mod.rs

1#[cfg_attr(feature = "dyn", path = "dyn.rs")]
2#[cfg_attr(not(feature = "dyn"), path = "static.rs")]
3mod imp;
4
5use axdriver_base::{BaseDriverOps, DeviceType};
6
7pub use imp::*;
8
9/// A unified enum that represents different categories of devices.
10#[allow(clippy::large_enum_variant)]
11pub enum AxDeviceEnum {
12    /// Network card device.
13    #[cfg(feature = "net")]
14    Net(AxNetDevice),
15    /// Block storage device.
16    #[cfg(feature = "block")]
17    Block(AxBlockDevice),
18    /// Graphic display device.
19    #[cfg(feature = "display")]
20    Display(AxDisplayDevice),
21}
22
23impl BaseDriverOps for AxDeviceEnum {
24    #[inline]
25    #[allow(unreachable_patterns)]
26    fn device_type(&self) -> DeviceType {
27        match self {
28            #[cfg(feature = "net")]
29            Self::Net(_) => DeviceType::Net,
30            #[cfg(feature = "block")]
31            Self::Block(_) => DeviceType::Block,
32            #[cfg(feature = "display")]
33            Self::Display(_) => DeviceType::Display,
34            _ => unreachable!(),
35        }
36    }
37
38    #[inline]
39    #[allow(unreachable_patterns)]
40    fn device_name(&self) -> &str {
41        match self {
42            #[cfg(feature = "net")]
43            Self::Net(dev) => dev.device_name(),
44            #[cfg(feature = "block")]
45            Self::Block(dev) => dev.device_name(),
46            #[cfg(feature = "display")]
47            Self::Display(dev) => dev.device_name(),
48            _ => unreachable!(),
49        }
50    }
51}