use crate::Result;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PCIDevice {
pub device_id: String,
pub vendor_name: String,
pub device_name: String,
pub bus_location: String,
pub device_class: String,
pub subsystem_id: Option<String>,
pub driver: Option<String>,
pub revision: Option<String>,
pub irq: Option<u32>,
pub memory_regions: Vec<String>,
}
impl PCIDevice {
pub fn query_all() -> Result<Vec<Self>> {
Ok(vec![])
}
pub fn device_id(&self) -> &str {
&self.device_id
}
pub fn vendor_name(&self) -> &str {
&self.vendor_name
}
pub fn device_name(&self) -> &str {
&self.device_name
}
pub fn device_class(&self) -> &str {
&self.device_class
}
pub fn is_graphics_device(&self) -> bool {
self.device_class.to_lowercase().contains("vga")
|| self.device_class.to_lowercase().contains("display")
|| self.device_class.to_lowercase().contains("graphics")
}
pub fn is_network_device(&self) -> bool {
self.device_class.to_lowercase().contains("network")
|| self.device_class.to_lowercase().contains("ethernet")
|| self.device_class.to_lowercase().contains("wireless")
}
pub fn is_storage_device(&self) -> bool {
self.device_class.to_lowercase().contains("storage")
|| self.device_class.to_lowercase().contains("sata")
|| self.device_class.to_lowercase().contains("nvme")
|| self.device_class.to_lowercase().contains("scsi")
}
}