pve/nodes/node/hardware/
pci.rs1pub mod pciid;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
4pub struct GetParameters {
5 #[doc = "A list of blacklisted PCI classes, which will not be returned. Following are filtered by default: Memory Controller (05), Bridge (06) and Processor (0b)."]
6 #[serde(
7 rename = "pci-class-blacklist",
8 skip_serializing_if = "Option::is_none",
9 default
10 )]
11 pub pci_class_blacklist: Option<String>,
12 #[doc = "If disabled, does only print the PCI IDs. Otherwise, additional information like vendor and device will be returned."]
13 #[serde(
14 skip_serializing_if = "Option::is_none",
15 default,
16 deserialize_with = "crate::common::deserialize_option_bool_lax",
17 serialize_with = "crate::common::serialize_option_bool_as_u64"
18 )]
19 pub verbose: Option<bool>,
20}
21
22#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
23pub struct GetResponseItem {
24 #[doc = "The PCI Class of the device."]
25 pub class: String,
26 #[doc = "The Device ID."]
27 pub device: String,
28 #[serde(skip_serializing_if = "Option::is_none", default)]
29 pub device_name: Option<String>,
30 #[doc = "The PCI ID."]
31 pub id: String,
32 #[doc = "The IOMMU group in which the device is in. If no IOMMU group is detected, it is set to -1."]
33 pub iommugroup: u64,
34 #[doc = "If set, marks that the device is capable of creating mediated devices."]
35 #[serde(
36 skip_serializing_if = "Option::is_none",
37 default,
38 deserialize_with = "crate::common::deserialize_option_bool_lax",
39 serialize_with = "crate::common::serialize_option_bool_as_u64"
40 )]
41 pub mdev: Option<bool>,
42 #[doc = "The Subsystem Device ID."]
43 #[serde(skip_serializing_if = "Option::is_none", default)]
44 pub subsystem_device: Option<String>,
45 #[serde(skip_serializing_if = "Option::is_none", default)]
46 pub subsystem_device_name: Option<String>,
47 #[doc = "The Subsystem Vendor ID."]
48 #[serde(skip_serializing_if = "Option::is_none", default)]
49 pub subsystem_vendor: Option<String>,
50 #[serde(skip_serializing_if = "Option::is_none", default)]
51 pub subsystem_vendor_name: Option<String>,
52 #[doc = "The Vendor ID."]
53 pub vendor: String,
54 #[serde(skip_serializing_if = "Option::is_none", default)]
55 pub vendor_name: Option<String>,
56}
57
58#[derive(Debug, Clone)]
59pub struct PciClient<T> {
60 client: T,
61 path: String,
62}
63
64impl<T> PciClient<T>
65where
66 T: Clone,
67{
68 pub fn new(client: T, parent_path: &str) -> Self {
69 Self {
70 client,
71 path: format!("{}/{}", parent_path, "pci"),
72 }
73 }
74
75 pub fn pciid(&self, pciid: &str) -> pciid::PciidClient<T> {
76 pciid::PciidClient::<T>::new(self.client.clone(), &self.path, pciid)
77 }
78}
79impl<T> PciClient<T>
80where
81 T: crate::client::HttpClient,
82{
83 #[doc = "List local PCI devices."]
84 pub fn get(&self, parameters: GetParameters) -> Result<Vec<GetResponseItem>, T::Error> {
85 self.client.get(&self.path, ¶meters)
86 }
87}
88#[derive(Debug, Clone)]
89pub struct AsyncPciClient<T> {
90 client: T,
91 path: String,
92}
93
94impl<T> AsyncPciClient<T>
95where
96 T: Clone,
97{
98 pub fn new(client: T, parent_path: &str) -> Self {
99 Self {
100 client,
101 path: format!("{}/{}", parent_path, "pci"),
102 }
103 }
104
105 pub fn pciid(&self, pciid: &str) -> pciid::AsyncPciidClient<T> {
106 pciid::AsyncPciidClient::<T>::new(self.client.clone(), &self.path, pciid)
107 }
108}
109impl<T> AsyncPciClient<T>
110where
111 T: crate::client::AsyncHttpClient,
112{
113 #[doc = "List local PCI devices."]
114 pub async fn get(&self, parameters: GetParameters) -> Result<Vec<GetResponseItem>, T::Error> {
115 self.client.get(&self.path, ¶meters).await
116 }
117}