1use crate::Result;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct PCIDevice {
7 pub device_id: String,
9 pub vendor_name: String,
11 pub device_name: String,
13 pub bus_location: String,
15 pub device_class: String,
17 pub subsystem_id: Option<String>,
19 pub driver: Option<String>,
21 pub revision: Option<String>,
23 pub irq: Option<u32>,
25 pub memory_regions: Vec<String>,
27}
28
29impl PCIDevice {
30 pub fn query_all() -> Result<Vec<Self>> {
32 Ok(vec![])
35 }
36
37 pub fn device_id(&self) -> &str {
39 &self.device_id
40 }
41
42 pub fn vendor_name(&self) -> &str {
44 &self.vendor_name
45 }
46
47 pub fn device_name(&self) -> &str {
49 &self.device_name
50 }
51
52 pub fn device_class(&self) -> &str {
54 &self.device_class
55 }
56
57 pub fn is_graphics_device(&self) -> bool {
59 self.device_class.to_lowercase().contains("vga")
60 || self.device_class.to_lowercase().contains("display")
61 || self.device_class.to_lowercase().contains("graphics")
62 }
63
64 pub fn is_network_device(&self) -> bool {
66 self.device_class.to_lowercase().contains("network")
67 || self.device_class.to_lowercase().contains("ethernet")
68 || self.device_class.to_lowercase().contains("wireless")
69 }
70
71 pub fn is_storage_device(&self) -> bool {
73 self.device_class.to_lowercase().contains("storage")
74 || self.device_class.to_lowercase().contains("sata")
75 || self.device_class.to_lowercase().contains("nvme")
76 || self.device_class.to_lowercase().contains("scsi")
77 }
78}