ferrix_lib/
dmi.rs

1/* dmi.rs
2 *
3 * Copyright 2025 Michail Krasnov <mskrasnov07@ya.ru>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21//! DMI table parser. Uses `smbios-lib` to data provider
22//!
23//! ## Usage
24//!
25//! ```no-test
26//! use ferrix::dmi::DMITable;
27//! let dmi = DMITable::new().unwrap();
28//! dbg!(dmi);
29//! ```
30
31use std::fmt::Display;
32
33use crate::traits::ToJson;
34use anyhow::{Result, anyhow};
35use serde::{Deserialize, Serialize};
36pub use smbioslib::SMBiosData;
37
38/// A structure containing data from the DMI table
39///
40/// ## Usage
41///
42/// ```no-test
43/// use ferrix::dmi::DMITable;
44/// let dmi = DMITable::new().unwrap();
45/// dbg!(dmi);
46/// ```
47#[derive(Debug, Serialize)]
48pub struct DMITable {
49    /// Information about BIOS (Type 0)
50    pub bios: Bios,
51
52    /// Information about system (Type 1)
53    pub system: System,
54
55    /// Information about baseboard (or module) - Type 2
56    pub baseboard: Baseboard,
57
58    /// Information about system enclosure or chassis - Type 3
59    pub chassis: Chassis,
60
61    /// Information about processor - Type 4
62    pub processor: Processor,
63
64    // /// Information about memory controller (Type 5)
65    // pub memory_controller: MemoryController,
66    //
67    // /// Information about memory module (Type 6)
68    // pub memory_module: MemoryModule,
69    /// Information about CPU cache (Type 7)
70    pub caches: Caches,
71
72    /// Information about port connectors (Type 8)
73    pub ports: PortConnectors,
74
75    /// Information about physical memory array (Type 16)
76    pub mem_array: MemoryArray,
77
78    /// Information about installed memory devices (Type 17)
79    pub mem_devices: MemoryDevices,
80}
81
82impl DMITable {
83    /// Get information from DMI table
84    ///
85    /// > **NOTE:** This data DOES NOT NEED to be updated periodically!
86    pub fn new() -> Result<Self> {
87        let table = smbioslib::table_load_from_device()?;
88        Ok(Self {
89            bios: Bios::new_from_table(&table)?,
90            system: System::new_from_table(&table)?,
91            baseboard: Baseboard::new_from_table(&table)?,
92            chassis: Chassis::new_from_table(&table)?,
93            processor: Processor::new_from_table(&table)?,
94            caches: Caches::new_from_table(&table)?,
95            ports: PortConnectors::new_from_table(&table)?,
96            mem_array: MemoryArray::new_from_table(&table)?,
97            mem_devices: MemoryDevices::new_from_table(&table)?,
98        })
99    }
100
101    /// Performs serialization of structure data in JSON.
102    ///
103    /// The returned value will be a SINGLE LINE of JSON data
104    /// intended for reading by third-party software or for
105    /// transmission over the network.
106    pub fn to_json(&self) -> Result<String> {
107        Ok(serde_json::to_string(&self)?)
108    }
109
110    /// Performs serialization in "pretty" JSON
111    ///
112    /// JSON will contain unnecessary newline transitions and spaces
113    /// to visually separate the blocks. It is well suited for human
114    /// reading and analysis.
115    pub fn to_json_pretty(&self) -> Result<String> {
116        Ok(serde_json::to_string_pretty(&self)?)
117    }
118
119    /// Performs data serialization in XML format
120    pub fn to_xml(&self) -> Result<String> {
121        let xml = DMITableXml::from(self);
122        xml.to_xml()
123    }
124}
125
126impl ToJson for DMITable {}
127
128/****************************** NOTE *********************************
129 * Дичайший костыль для того, чтобы структура XML была корректной    *
130 * Если не обернуть данные в поле "hardware" (тег <hardware> в XML), *
131 * то итоговый XML просто не распарсится.                            *
132 *********************************************************************/
133#[derive(Serialize, Clone)]
134pub struct DMITableXml<'a> {
135    pub hardware: &'a DMITable,
136}
137
138impl<'a> DMITableXml<'a> {
139    pub fn to_xml(&self) -> Result<String> {
140        Ok(xml_serde::to_string(&self)?)
141    }
142}
143
144impl<'a> From<&'a DMITable> for DMITableXml<'a> {
145    fn from(value: &'a DMITable) -> Self {
146        Self { hardware: value }
147    }
148}
149
150macro_rules! impl_from_struct {
151    ($s:ident, $p:path, {
152        $(
153            $field_name:ident : $field_type:ty
154        ),* $(,)?
155    }) => {
156        impl From<$p> for $s {
157            fn from(value: $p) -> Self {
158                Self {
159                    $(
160                        $field_name: value.$field_name,
161                    )*
162                }
163            }
164        }
165
166        impl ToJson for $s {}
167    };
168}
169
170/// Each SMBIOS structure has a handle or instance value associated
171/// with it. Some structs will reference other structures by using
172/// this value.
173#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
174pub struct Handle(pub u16);
175
176impl From<smbioslib::Handle> for Handle {
177    fn from(value: smbioslib::Handle) -> Self {
178        Self(value.0)
179    }
180}
181
182impl Handle {
183    pub fn from_opt(opt: Option<smbioslib::Handle>) -> Option<Self> {
184        match opt {
185            Some(handle) => Some(Handle::from(handle)),
186            None => None,
187        }
188    }
189}
190
191impl Display for Handle {
192    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
193        write!(f, "{}", self.0)
194    }
195}
196
197/// BIOS ROM Size
198#[derive(Debug, Serialize, Deserialize, Clone)]
199pub enum RomSize {
200    /// Size of this ROM in bytes
201    Kilobytes(u16),
202
203    /// Extended size of the physical device(s) containing the
204    /// BIOS (in MB)
205    Megabytes(u16),
206
207    /// Extended size of the physical device(s) containing the
208    /// BIOS (in GB)
209    Gigabytes(u16),
210
211    /// Extended size of the physical device(s) containing the
212    /// BIOS in raw form.
213    ///
214    /// The standard currently only defines MB and GB as given
215    /// in the high nibble (bits 15-14).
216    Undefined(u16),
217
218    SeeExtendedRomSize,
219}
220
221impl From<smbioslib::RomSize> for RomSize {
222    fn from(value: smbioslib::RomSize) -> Self {
223        match value {
224            smbioslib::RomSize::Kilobytes(s) => Self::Kilobytes(s),
225            smbioslib::RomSize::Megabytes(s) => Self::Megabytes(s),
226            smbioslib::RomSize::Gigabytes(s) => Self::Gigabytes(s),
227            smbioslib::RomSize::Undefined(s) => Self::Undefined(s),
228            smbioslib::RomSize::SeeExtendedRomSize => Self::SeeExtendedRomSize,
229        }
230    }
231}
232
233impl Display for RomSize {
234    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
235        write!(
236            f,
237            "{}",
238            match self {
239                Self::Kilobytes(n) => format!("{n} KB"),
240                Self::Megabytes(n) => format!("{n} MB"),
241                Self::Gigabytes(n) => format!("{n} GB"),
242                Self::Undefined(n) => format!("{n} ??"),
243                Self::SeeExtendedRomSize => format!("see extended ROM size"),
244            }
245        )
246    }
247}
248
249/// Information about BIOS/UEFI
250#[derive(Debug, Serialize, Deserialize, Clone)]
251pub struct Bios {
252    /// BIOS vendor's name
253    pub vendor: Option<String>,
254
255    /// BIOS version
256    pub version: Option<String>,
257
258    /// BIOS starting address segment
259    pub starting_address_segment: Option<u16>,
260
261    /// BIOS release date
262    pub release_date: Option<String>,
263
264    /// BIOS ROM size
265    pub rom_size: Option<RomSize>,
266
267    /// BIOS characteristics
268    pub characteristics: Option<BiosCharacteristics>,
269
270    /// BIOS vendor reserved characteristics
271    pub bios_vendor_reserved_characteristics: Option<u16>,
272
273    /// System vendor reserved characteristics
274    pub system_vendor_reserved_characteristics: Option<u16>,
275
276    /// Characteristics extension byte 0
277    pub characteristics_extension0: Option<BiosCharacteristicsExtension0>,
278
279    /// Characteristics extension byte 1
280    pub characteristics_extension1: Option<BiosCharacteristicsExtension1>,
281
282    /// System BIOS major release
283    pub system_bios_major_release: Option<u8>,
284
285    /// System BIOS minor release
286    pub system_bios_minor_release: Option<u8>,
287
288    /// Embedded controller firmware major release
289    pub e_c_firmware_major_release: Option<u8>,
290
291    /// Embedded controller firmware minor release
292    pub e_c_firmware_minor_release: Option<u8>,
293
294    /// Extended BIOS ROM size
295    pub extended_rom_size: Option<RomSize>,
296}
297
298impl Bios {
299    /// Creates a new instance of `Self`
300    ///
301    /// It is usually not required, since an instance of this
302    /// structure will be created using the method
303    /// [`Self::new_from_table(table: &SMBiosData)`] in the constructor
304    /// [`DMITable::new()`].
305    pub fn new() -> Result<Self> {
306        let table = smbioslib::table_load_from_device()?;
307        Self::new_from_table(&table)
308    }
309
310    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
311        let t = table
312            .find_map(|f: smbioslib::SMBiosInformation| Some(f))
313            .ok_or(anyhow!("Failed to get information about BIOS (type 0)!"))?;
314
315        Ok(Self {
316            vendor: t.vendor().ok(),
317            version: t.version().ok(),
318            starting_address_segment: t.starting_address_segment(),
319            release_date: t.release_date().ok(),
320            rom_size: match t.rom_size() {
321                Some(s) => Some(RomSize::from(s)),
322                None => None,
323            },
324            characteristics: match t.characteristics() {
325                Some(c) => Some(BiosCharacteristics::from(c)),
326                None => None,
327            },
328            bios_vendor_reserved_characteristics: t.bios_vendor_reserved_characteristics(),
329            system_vendor_reserved_characteristics: t.system_vendor_reserved_characteristics(),
330            characteristics_extension0: match t.characteristics_extension0() {
331                Some(ce0) => Some(BiosCharacteristicsExtension0::from(ce0)),
332                None => None,
333            },
334            characteristics_extension1: match t.characteristics_extension1() {
335                Some(ce1) => Some(BiosCharacteristicsExtension1::from(ce1)),
336                None => None,
337            },
338            system_bios_major_release: t.system_bios_major_release(),
339            system_bios_minor_release: t.system_bios_minor_release(),
340            e_c_firmware_major_release: t.e_c_firmware_major_release(),
341            e_c_firmware_minor_release: t.e_c_firmware_minor_release(),
342            extended_rom_size: match t.extended_rom_size() {
343                Some(s) => Some(RomSize::from(s)),
344                None => None,
345            },
346        })
347    }
348}
349
350impl ToJson for Bios {}
351
352/// BIOS characteristics
353#[derive(Debug, Serialize, Deserialize, Clone)]
354pub struct BiosCharacteristics {
355    /// Unknown
356    pub unknown: bool,
357
358    /// BIOS Characteristics aren't supported
359    pub bios_characteristics_not_supported: bool,
360
361    /// ISA is supported
362    pub isa_supported: bool,
363
364    /// MCA is supported
365    pub mca_supported: bool,
366
367    /// EISA is supported
368    pub eisa_supported: bool,
369
370    /// PCI is supported
371    pub pci_supported: bool,
372
373    /// PCMCIA is supported
374    pub pcmcia_supported: bool,
375
376    /// Plug-n-play is supported
377    pub plug_and_play_supported: bool,
378
379    /// APM is supported
380    pub apm_supported: bool,
381
382    /// BIOS is upgradeable (Flash)
383    pub bios_upgradeable: bool,
384
385    /// BIOS shadowing is allowed
386    pub bios_shadowing_allowed: bool,
387
388    /// VL-VESA is supported
389    pub vlvesa_supported: bool,
390
391    /// ESCD support is available
392    pub escd_support_available: bool,
393
394    /// Boot from CD is supported
395    pub boot_from_cdsupported: bool,
396
397    /// Selectable boot is supported
398    pub selectable_boot_supported: bool,
399
400    /// BIOS ROM is socketed (e.g. PLCC or SOP socket)
401    pub bios_rom_socketed: bool,
402
403    /// Boot from PCMCIA is supported
404    pub boot_from_pcmcia_supported: bool,
405
406    /// EDD specification is supported
407    pub edd_specification_supported: bool,
408
409    /// Japanese floppy for NEC 9800 1.2 MB (3.5", 1K bytes/sector,
410    /// 360 RPM) is supported
411    pub floppy_nec_japanese_supported: bool,
412
413    /// Japanese floppy for Toshiba 1.2 MB (3.5", 360 RPM) is
414    /// supported
415    pub floppy_toshiba_japanese_supported: bool,
416
417    /// 5.25" / 360 KB floppy services are supported
418    pub floppy_525_360_supported: bool,
419
420    /// 5.25" / 1.2 MB floppy services are supported
421    pub floppy_525_12_supported: bool,
422
423    /// 3.5" / 720 KB floppy services are supported
424    pub floppy_35_720_supported: bool,
425
426    /// 3.5" 2.88 MB floppy services are supported
427    pub floppy_35_288_supported: bool,
428
429    /// PrintScreen service is supported
430    pub print_screen_service_supported: bool,
431
432    /// 8042 keyboard services are supported
433    pub keyboard_8042services_supported: bool,
434
435    /// Serial services are supported
436    pub serial_services_supported: bool,
437
438    /// Printer services are supported
439    pub printer_services_supported: bool,
440
441    /// CGA/Mono Video Services are supported
442    pub cga_mono_video_services_supported: bool,
443
444    /// NEC PC-98 supported
445    pub nec_pc_98supported: bool,
446}
447
448impl From<smbioslib::BiosCharacteristics> for BiosCharacteristics {
449    fn from(value: smbioslib::BiosCharacteristics) -> Self {
450        Self {
451            unknown: value.unknown(),
452            bios_characteristics_not_supported: value.bios_characteristics_not_supported(),
453            isa_supported: value.isa_supported(),
454            mca_supported: value.mca_supported(),
455            eisa_supported: value.eisa_supported(),
456            pci_supported: value.pci_supported(),
457            pcmcia_supported: value.pcmcia_supported(),
458            plug_and_play_supported: value.plug_and_play_supported(),
459            apm_supported: value.apm_supported(),
460            bios_upgradeable: value.bios_upgradeable(),
461            bios_shadowing_allowed: value.bios_shadowing_allowed(),
462            vlvesa_supported: value.vlvesa_supported(),
463            escd_support_available: value.escd_support_available(),
464            boot_from_cdsupported: value.boot_from_cdsupported(),
465            selectable_boot_supported: value.selectable_boot_supported(),
466            bios_rom_socketed: value.bios_rom_socketed(),
467            boot_from_pcmcia_supported: value.boot_from_pcmcia_supported(),
468            edd_specification_supported: value.edd_specification_supported(),
469            floppy_nec_japanese_supported: value.floppy_nec_japanese_supported(),
470            floppy_toshiba_japanese_supported: value.floppy_toshiba_japanese_supported(),
471            floppy_525_360_supported: value.floppy_525_360_supported(),
472            floppy_525_12_supported: value.floppy_525_12_supported(),
473            floppy_35_720_supported: value.floppy_35_720_supported(),
474            floppy_35_288_supported: value.floppy_35_288_supported(),
475            print_screen_service_supported: value.print_screen_service_supported(),
476            keyboard_8042services_supported: value.keyboard_8042services_supported(),
477            serial_services_supported: value.serial_services_supported(),
478            printer_services_supported: value.printer_services_supported(),
479            cga_mono_video_services_supported: value.cga_mono_video_services_supported(),
480            nec_pc_98supported: value.nec_pc_98supported(),
481        }
482    }
483}
484impl ToJson for BiosCharacteristics {}
485
486/// Characteristics extension byte 0
487#[derive(Debug, Serialize, Deserialize, Clone)]
488pub struct BiosCharacteristicsExtension0 {
489    /// ACPI is supported
490    pub acpi_is_supported: bool,
491
492    /// USB Legacy is supported
493    pub usb_legacy_is_supported: bool,
494
495    /// AGP is supported
496    pub agp_is_supported: bool,
497
498    /// I2O boot is supported
499    pub i2oboot_is_supported: bool,
500
501    /// LS-120 SuperDisk boot is supported
502    pub ls120super_disk_boot_is_supported: bool,
503
504    /// ATAPI ZIP drive boot is supported
505    pub atapi_zip_drive_boot_is_supported: bool,
506
507    /// 1394 boot is supported
508    pub boot_1394is_supported: bool,
509
510    /// Smart battery is supported
511    pub smart_battery_is_supported: bool,
512}
513
514impl From<smbioslib::BiosCharacteristicsExtension0> for BiosCharacteristicsExtension0 {
515    fn from(value: smbioslib::BiosCharacteristicsExtension0) -> Self {
516        Self {
517            acpi_is_supported: value.acpi_is_supported(),
518            usb_legacy_is_supported: value.usb_legacy_is_supported(),
519            agp_is_supported: value.agp_is_supported(),
520            i2oboot_is_supported: value.i2oboot_is_supported(),
521            ls120super_disk_boot_is_supported: value.ls120super_disk_boot_is_supported(),
522            atapi_zip_drive_boot_is_supported: value.atapi_zip_drive_boot_is_supported(),
523            boot_1394is_supported: value.boot_1394is_supported(),
524            smart_battery_is_supported: value.smart_battery_is_supported(),
525        }
526    }
527}
528impl ToJson for BiosCharacteristicsExtension0 {}
529
530/// Characteristics extension byte 0
531#[derive(Debug, Serialize, Deserialize, Clone)]
532pub struct BiosCharacteristicsExtension1 {
533    /// BIOS Boot Specification is supported
534    pub bios_boot_specification_is_supported: bool,
535
536    /// Function key-initiated network service boot is supported.
537    /// When function key-uninitiated network service boot is not
538    /// supported, a network adapter option ROM may choose to offer
539    /// this functionality on its own, thus offering this capability
540    /// to legacy systems. When the function is supported, the
541    /// network adapter option ROM shall not offer this capability
542    pub fkey_initiated_network_boot_is_supported: bool,
543
544    /// Enable targeted content distribution. The manufacturer has
545    /// ensured that the SMBIOS data is useful in identifying the
546    /// computer for targeted delivery of model-specific software
547    /// and firmware content through third-party content
548    /// distribution services
549    pub targeted_content_distribution_is_supported: bool,
550
551    /// UEFI Specification is supported
552    pub uefi_specification_is_supported: bool,
553
554    /// SMBIOS table describes a virtual machine
555    pub smbios_table_describes_avirtual_machine: bool,
556
557    /// Manufacturing mode is supported. (Manufacturing mode is a
558    /// special boot mode, not normally available to end users, that
559    /// modifies BIOS features and settings for use while the
560    /// computer is being manufactured and tested)
561    pub manufacturing_mode_is_supported: bool,
562
563    /// Manufacturing mode is enabled
564    pub manufacturing_mode_is_enabled: bool,
565}
566
567impl From<smbioslib::BiosCharacteristicsExtension1> for BiosCharacteristicsExtension1 {
568    fn from(value: smbioslib::BiosCharacteristicsExtension1) -> Self {
569        Self {
570            bios_boot_specification_is_supported: value.bios_boot_specification_is_supported(),
571            fkey_initiated_network_boot_is_supported: value
572                .fkey_initiated_network_boot_is_supported(),
573            targeted_content_distribution_is_supported: value
574                .targeted_content_distribution_is_supported(),
575            uefi_specification_is_supported: value.uefi_specification_is_supported(),
576            smbios_table_describes_avirtual_machine: value
577                .smbios_table_describes_avirtual_machine(),
578            manufacturing_mode_is_supported: value.manufacturing_mode_is_supported(),
579            manufacturing_mode_is_enabled: value.manufacturing_mode_is_enabled(),
580        }
581    }
582}
583impl ToJson for BiosCharacteristicsExtension1 {}
584
585/// System UUID Data
586#[derive(Debug, Serialize, Deserialize, Clone)]
587pub enum SystemUuidData {
588    IdNotPresentButSettable,
589    IdNotPresent,
590    Uuid(SystemUuid),
591}
592
593impl From<smbioslib::SystemUuidData> for SystemUuidData {
594    fn from(value: smbioslib::SystemUuidData) -> Self {
595        match value {
596            smbioslib::SystemUuidData::IdNotPresentButSettable => Self::IdNotPresentButSettable,
597            smbioslib::SystemUuidData::IdNotPresent => Self::IdNotPresent,
598            smbioslib::SystemUuidData::Uuid(u) => Self::Uuid(SystemUuid::from(u)),
599        }
600    }
601}
602
603impl Display for SystemUuidData {
604    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
605        write!(
606            f,
607            "{}",
608            match self {
609                Self::IdNotPresentButSettable => format!("ID not present but settable"),
610                Self::IdNotPresent => format!("ID not present"),
611                Self::Uuid(uuid) => format!("{uuid}"),
612            }
613        )
614    }
615}
616
617/// System UUID
618#[derive(Debug, Serialize, Deserialize, Clone)]
619pub struct SystemUuid {
620    /// Raw byte array for this UUID
621    pub raw: [u8; 16],
622}
623
624impl_from_struct!(SystemUuid, smbioslib::SystemUuid, {
625    raw: [u8; 16],
626});
627
628impl Display for SystemUuid {
629    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
630        write!(f, "{}", String::from_utf8_lossy(&self.raw))
631    }
632}
633
634/// System wakeup data
635#[derive(Debug, Serialize, Deserialize, Clone)]
636pub struct SystemWakeUpTypeData {
637    /// Raw value
638    ///
639    /// Is most usable when `value` is None
640    pub raw: u8,
641
642    pub value: SystemWakeUpType,
643}
644
645impl From<smbioslib::SystemWakeUpTypeData> for SystemWakeUpTypeData {
646    fn from(value: smbioslib::SystemWakeUpTypeData) -> Self {
647        Self {
648            raw: value.raw,
649            value: SystemWakeUpType::from(value.value),
650        }
651    }
652}
653
654/// System wakeup type
655#[derive(Debug, Serialize, Deserialize, Clone)]
656pub enum SystemWakeUpType {
657    Other,
658    Unknown,
659    ApmTimer,
660    ModernRing,
661    LanRemote,
662    PowerSwitch,
663    PciPme,
664    ACPowerRestored,
665    None,
666}
667
668impl From<smbioslib::SystemWakeUpType> for SystemWakeUpType {
669    fn from(value: smbioslib::SystemWakeUpType) -> Self {
670        match value {
671            smbioslib::SystemWakeUpType::Other => Self::Other,
672            smbioslib::SystemWakeUpType::Unknown => Self::Unknown,
673            smbioslib::SystemWakeUpType::ApmTimer => Self::ApmTimer,
674            smbioslib::SystemWakeUpType::ModernRing => Self::ModernRing,
675            smbioslib::SystemWakeUpType::LanRemote => Self::LanRemote,
676            smbioslib::SystemWakeUpType::PowerSwitch => Self::PowerSwitch,
677            smbioslib::SystemWakeUpType::PciPme => Self::PciPme,
678            smbioslib::SystemWakeUpType::ACPowerRestored => Self::ACPowerRestored,
679            smbioslib::SystemWakeUpType::None => Self::None,
680        }
681    }
682}
683
684impl Display for SystemWakeUpType {
685    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
686        write!(
687            f,
688            "{}",
689            match self {
690                Self::Other => "Other",
691                Self::Unknown => "Unknown",
692                Self::ApmTimer => "APM Timer",
693                Self::ModernRing => "Modern Ring",
694                Self::LanRemote => "LAN Remote",
695                Self::PowerSwitch => "Power Switch",
696                Self::PciPme => "PCI PME#",
697                Self::ACPowerRestored => "AC Power Restored",
698                Self::None => "Unknown to this standard, check the raw value",
699            }
700        )
701    }
702}
703
704/// Attributes of the overall system
705#[derive(Debug, Serialize, Deserialize, Clone)]
706pub struct System {
707    /// System manufacturer
708    pub manufacturer: Option<String>,
709
710    /// System product name
711    pub product_name: Option<String>,
712
713    /// System version
714    pub version: Option<String>,
715
716    /// Serial number
717    pub serial_number: Option<String>,
718
719    /// System UUID
720    pub uuid: Option<SystemUuidData>,
721
722    /// Wake-up type
723    ///
724    /// Identifies the event that caused the system to power up
725    pub wakeup_type: Option<SystemWakeUpTypeData>,
726
727    /// SKU Number (particular computer information for sale.
728    /// Also called a product ID or purchase order number.
729    /// Typically for a given system board from a given OEM,
730    /// there are tens of unique processor, memory, hard
731    /// drive, and optical drive configurations).
732    pub sku_number: Option<String>,
733
734    /// Family to which a particular computer belongs
735    pub family: Option<String>,
736}
737
738impl System {
739    /// Creates a new instance of `Self`
740    ///
741    /// It is usually not required, since an instance of this
742    /// structure will be created using the method
743    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
744    /// [`DMITable::new()`].
745    pub fn new() -> Result<Self> {
746        let table = smbioslib::table_load_from_device()?;
747        Self::new_from_table(&table)
748    }
749
750    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
751        let t = table
752            .find_map(|f: smbioslib::SMBiosSystemInformation| Some(f))
753            .ok_or(anyhow!("Failed to get information about system (type 1)!"))?;
754
755        Ok(Self {
756            manufacturer: t.manufacturer().ok(),
757            product_name: t.product_name().ok(),
758            version: t.version().ok(),
759            serial_number: t.serial_number().ok(),
760            uuid: match t.uuid() {
761                Some(u) => Some(SystemUuidData::from(u)),
762                None => None,
763            },
764            wakeup_type: match t.wakeup_type() {
765                Some(wt) => Some(SystemWakeUpTypeData::from(wt)),
766                None => None,
767            },
768            sku_number: t.sku_number().ok(),
769            family: t.family().ok(),
770        })
771    }
772}
773
774impl ToJson for System {}
775
776/// Board type data
777#[derive(Debug, Serialize, Deserialize, Clone)]
778pub struct BoardTypeData {
779    pub raw: u8,
780    pub value: BoardType,
781}
782
783impl From<smbioslib::BoardTypeData> for BoardTypeData {
784    fn from(value: smbioslib::BoardTypeData) -> Self {
785        Self {
786            raw: value.raw,
787            value: BoardType::from(value.value),
788        }
789    }
790}
791
792/// Board type
793#[derive(Debug, Serialize, Deserialize, Clone)]
794pub enum BoardType {
795    Unknown,
796    Other,
797    ServerBlade,
798    ConnectivitySwitch,
799    SystemManagementModule,
800    ProcessorModule,
801    IOModule,
802    MemoryModule,
803    Daughterboard,
804    Motherboard,
805    ProcessorMemoryModule,
806    ProcessorIOModule,
807    InterconnectBoard,
808    None,
809}
810
811impl From<smbioslib::BoardType> for BoardType {
812    fn from(value: smbioslib::BoardType) -> Self {
813        match value {
814            smbioslib::BoardType::Unknown => Self::Unknown,
815            smbioslib::BoardType::Other => Self::Other,
816            smbioslib::BoardType::ServerBlade => Self::ServerBlade,
817            smbioslib::BoardType::ConnectivitySwitch => Self::ConnectivitySwitch,
818            smbioslib::BoardType::SystemManagementModule => Self::SystemManagementModule,
819            smbioslib::BoardType::ProcessorModule => Self::ProcessorModule,
820            smbioslib::BoardType::IOModule => Self::IOModule,
821            smbioslib::BoardType::MemoryModule => Self::MemoryModule,
822            smbioslib::BoardType::Daughterboard => Self::Daughterboard,
823            smbioslib::BoardType::Motherboard => Self::Motherboard,
824            smbioslib::BoardType::ProcessorMemoryModule => Self::ProcessorMemoryModule,
825            smbioslib::BoardType::ProcessorIOModule => Self::ProcessorIOModule,
826            smbioslib::BoardType::InterconnectBoard => Self::InterconnectBoard,
827            smbioslib::BoardType::None => Self::None,
828        }
829    }
830}
831
832impl Display for BoardType {
833    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
834        write!(
835            f,
836            "{}",
837            match self {
838                Self::Unknown => "Unknown",
839                Self::Other => "Other",
840                Self::ServerBlade => "Server Blade",
841                Self::ConnectivitySwitch => "Connectivity Switch",
842                Self::SystemManagementModule => "System Management Module",
843                Self::ProcessorModule => "Processor Module",
844                Self::IOModule => "I/O Module",
845                Self::MemoryModule => "Memory Module",
846                Self::Daughterboard => "Daughter Board",
847                Self::Motherboard => "Motherboard (includes processor, memory, and I/O)",
848                Self::ProcessorMemoryModule => "Processor or Memory Module",
849                Self::ProcessorIOModule => "Processor or I/O Module",
850                Self::InterconnectBoard => "Interconnect Board",
851                Self::None => "Unknown to this standard, check the raw value",
852            }
853        )
854    }
855}
856
857/// Information about baseboard/module
858#[derive(Debug, Serialize, Deserialize, Clone)]
859pub struct Baseboard {
860    /// Baseboard manufacturer
861    pub manufacturer: Option<String>,
862
863    /// Baseboard product
864    pub product: Option<String>,
865
866    /// Baseboard serial number
867    pub serial_number: Option<String>,
868
869    /// Asset tag
870    pub asset_tag: Option<String>,
871
872    /// Baseboard feature flags
873    pub feature_flags: Option<BaseboardFeatures>,
874
875    /// The board's location within the chassis
876    pub location_in_chassis: Option<String>,
877
878    /// Handle, or instance number, associated with the chassis in
879    /// which this board resides.
880    pub chassis_handle: Option<Handle>,
881
882    /// Type of baseboard
883    pub board_type: Option<BoardTypeData>,
884}
885
886impl Baseboard {
887    /// Creates a new instance of `Self`
888    ///
889    /// It is usually not required, since an instance of this
890    /// structure will be created using the method
891    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
892    /// [`DMITable::new()`].
893    pub fn new() -> Result<Self> {
894        let table = smbioslib::table_load_from_device()?;
895        Self::new_from_table(&table)
896    }
897
898    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
899        let t = table
900            .find_map(|f: smbioslib::SMBiosBaseboardInformation| Some(f))
901            .ok_or(anyhow!(
902                "Failed to get information about baseboard/module (type 2)!"
903            ))?;
904        Ok(Self {
905            manufacturer: t.manufacturer().ok(),
906            product: t.product().ok(),
907            serial_number: t.serial_number().ok(),
908            asset_tag: t.asset_tag().ok(),
909            feature_flags: match t.feature_flags() {
910                Some(ff) => Some(BaseboardFeatures::from(ff)),
911                None => None,
912            },
913            location_in_chassis: t.location_in_chassis().ok(),
914            chassis_handle: match t.chassis_handle() {
915                Some(h) => Some(Handle::from(h)),
916                None => None,
917            },
918            board_type: match t.board_type() {
919                Some(bt) => Some(BoardTypeData::from(bt)),
920                None => None,
921            },
922        })
923    }
924}
925
926impl ToJson for Baseboard {}
927
928/// Baseboard feature flags
929///
930/// Collection of flags that identify features of this board
931#[derive(Debug, Serialize, Deserialize, Clone)]
932pub struct BaseboardFeatures {
933    /// Set if the board is a hosting board (e.g. motherboard)
934    pub hosting_board: bool,
935
936    /// Set if the board requires at least one daughter board or
937    /// auxiliary card to function properly
938    pub requires_daughterboard: bool,
939
940    /// Set if the board is removable; it is designed to be taken in
941    /// and out of the chassis without impairing the function of
942    /// the chassis
943    pub is_removable: bool,
944
945    /// Set if the board is replaceable; it is possible to replace
946    /// (either as a field repair or as an upgrade) the board with a
947    /// physically different board. The board is inherently removable
948    pub is_replaceable: bool,
949
950    /// Set if the board if hot swappable; it is possible to replace
951    /// the board with a physically different but equivalent board
952    /// while power is applied to the board. The board is
953    /// inherently replaceable and removable.
954    pub is_hot_swappable: bool,
955}
956
957impl From<smbioslib::BaseboardFeatures> for BaseboardFeatures {
958    fn from(value: smbioslib::BaseboardFeatures) -> Self {
959        Self {
960            hosting_board: value.hosting_board(),
961            requires_daughterboard: value.requires_daughterboard(),
962            is_removable: value.is_removable(),
963            is_replaceable: value.is_replaceable(),
964            is_hot_swappable: value.is_hot_swappable(),
965        }
966    }
967}
968impl ToJson for BaseboardFeatures {}
969
970/// Chassis type data
971#[derive(Debug, Serialize, Deserialize, Clone)]
972pub struct ChassisTypeData {
973    pub raw: u8,
974    pub value: ChassisType,
975    pub lock_presence: ChassisLockPresence,
976}
977
978impl From<smbioslib::ChassisTypeData> for ChassisTypeData {
979    fn from(value: smbioslib::ChassisTypeData) -> Self {
980        Self {
981            raw: value.raw,
982            value: ChassisType::from(value.value),
983            lock_presence: ChassisLockPresence::from(value.lock_presence),
984        }
985    }
986}
987
988/// Chassis type
989#[derive(Debug, Serialize, Deserialize, Clone)]
990pub enum ChassisType {
991    Other,
992    Unknown,
993    Desktop,
994    LowProfileDesktop,
995    PizzaBox,
996    MiniTower,
997    Tower,
998    Portable,
999    Laptop,
1000    Notebook,
1001    HandHeld,
1002    DockingStation,
1003    AllInOne,
1004    SubNotebook,
1005    SpaceSaving,
1006    LunchBox,
1007    MainServerChassis,
1008    ExpansionChassis,
1009    SubChassis,
1010    BusExpansionChassis,
1011    PeripheralChassis,
1012    RaidChassis,
1013    RackMountChassis,
1014    SealedCasePC,
1015    MultiSystemChassis,
1016    CompactPci,
1017    AdvancedTca,
1018    Blade,
1019    BladeEnclosure,
1020    Tablet,
1021    Convertible,
1022    Detachable,
1023    IoTGateway,
1024    EmbeddedPC,
1025    MiniPC,
1026    StickPC,
1027    None,
1028}
1029
1030impl From<smbioslib::ChassisType> for ChassisType {
1031    fn from(value: smbioslib::ChassisType) -> Self {
1032        match value {
1033            smbioslib::ChassisType::Other => Self::Other,
1034            smbioslib::ChassisType::Unknown => Self::Unknown,
1035            smbioslib::ChassisType::Desktop => Self::Desktop,
1036            smbioslib::ChassisType::LowProfileDesktop => Self::LowProfileDesktop,
1037            smbioslib::ChassisType::PizzaBox => Self::PizzaBox,
1038            smbioslib::ChassisType::MiniTower => Self::MiniTower,
1039            smbioslib::ChassisType::Tower => Self::Tower,
1040            smbioslib::ChassisType::Portable => Self::Portable,
1041            smbioslib::ChassisType::Laptop => Self::Laptop,
1042            smbioslib::ChassisType::Notebook => Self::Notebook,
1043            smbioslib::ChassisType::HandHeld => Self::HandHeld,
1044            smbioslib::ChassisType::DockingStation => Self::DockingStation,
1045            smbioslib::ChassisType::AllInOne => Self::AllInOne,
1046            smbioslib::ChassisType::SubNotebook => Self::SubNotebook,
1047            smbioslib::ChassisType::SpaceSaving => Self::SpaceSaving,
1048            smbioslib::ChassisType::LunchBox => Self::LunchBox,
1049            smbioslib::ChassisType::MainServerChassis => Self::MainServerChassis,
1050            smbioslib::ChassisType::ExpansionChassis => Self::ExpansionChassis,
1051            smbioslib::ChassisType::SubChassis => Self::SubChassis,
1052            smbioslib::ChassisType::BusExpansionChassis => Self::BusExpansionChassis,
1053            smbioslib::ChassisType::PeripheralChassis => Self::PeripheralChassis,
1054            smbioslib::ChassisType::RaidChassis => Self::RaidChassis,
1055            smbioslib::ChassisType::RackMountChassis => Self::RackMountChassis,
1056            smbioslib::ChassisType::SealedCasePC => Self::SealedCasePC,
1057            smbioslib::ChassisType::MultiSystemChassis => Self::MultiSystemChassis,
1058            smbioslib::ChassisType::CompactPci => Self::CompactPci,
1059            smbioslib::ChassisType::AdvancedTca => Self::AdvancedTca,
1060            smbioslib::ChassisType::Blade => Self::Blade,
1061            smbioslib::ChassisType::BladeEnclosure => Self::BladeEnclosure,
1062            smbioslib::ChassisType::Tablet => Self::Tablet,
1063            smbioslib::ChassisType::Convertible => Self::Convertible,
1064            smbioslib::ChassisType::Detachable => Self::Detachable,
1065            smbioslib::ChassisType::IoTGateway => Self::IoTGateway,
1066            smbioslib::ChassisType::EmbeddedPC => Self::EmbeddedPC,
1067            smbioslib::ChassisType::MiniPC => Self::MiniPC,
1068            smbioslib::ChassisType::StickPC => Self::StickPC,
1069            smbioslib::ChassisType::None => Self::None,
1070        }
1071    }
1072}
1073
1074impl Display for ChassisType {
1075    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1076        write!(
1077            f,
1078            "{}",
1079            match self {
1080                Self::Other => "Other",
1081                Self::Unknown => "Unknown",
1082                Self::Desktop => "Desktop",
1083                Self::LowProfileDesktop => "Low profile desktop",
1084                Self::PizzaBox => "Pizza Box",
1085                Self::MiniTower => "Mini Tower",
1086                Self::Tower => "Tower",
1087                Self::Portable => "Portable",
1088                Self::Laptop => "Laptop",
1089                Self::Notebook => "Notebook",
1090                Self::HandHeld => "Hand Held",
1091                Self::DockingStation => "Docking Station",
1092                Self::AllInOne => "All In One",
1093                Self::SubNotebook => "Sub Notebook",
1094                Self::SpaceSaving => "Space Saving",
1095                Self::LunchBox => "Lunch Box",
1096                Self::MainServerChassis => "Main server chassis",
1097                Self::ExpansionChassis => "Expansion chassis",
1098                Self::SubChassis => "Sub chassis",
1099                Self::BusExpansionChassis => "Bus expansion chassis",
1100                Self::PeripheralChassis => "Peripheral chassis",
1101                Self::RaidChassis => "RAID chassis",
1102                Self::RackMountChassis => "Rack Mount chassis",
1103                Self::SealedCasePC => "Sealed-case chassis",
1104                Self::MultiSystemChassis => "Multi-system chassis",
1105                Self::CompactPci => "Compact PCI",
1106                Self::AdvancedTca => "Advanced TCA",
1107                Self::Blade => "Blade",
1108                Self::BladeEnclosure => "Blade encloser",
1109                Self::Tablet => "Tablet",
1110                Self::Convertible => "Convertivle",
1111                Self::Detachable => "Detachable",
1112                Self::IoTGateway => "IoT Gateway",
1113                Self::EmbeddedPC => "Embedded PC",
1114                Self::MiniPC => "Mini PC",
1115                Self::StickPC => "Stick PC",
1116                Self::None => "Unknown to this standard, check the raw value",
1117            }
1118        )
1119    }
1120}
1121
1122/// Chassis lock presence
1123#[derive(Debug, Serialize, Deserialize, Clone)]
1124pub enum ChassisLockPresence {
1125    Present,
1126    NotPresent,
1127}
1128
1129impl From<smbioslib::ChassisLockPresence> for ChassisLockPresence {
1130    fn from(value: smbioslib::ChassisLockPresence) -> Self {
1131        match value {
1132            smbioslib::ChassisLockPresence::Present => Self::Present,
1133            smbioslib::ChassisLockPresence::NotPresent => Self::NotPresent,
1134        }
1135    }
1136}
1137
1138impl Display for ChassisLockPresence {
1139    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1140        write!(
1141            f,
1142            "{}",
1143            match self {
1144                Self::Present => "Present",
1145                Self::NotPresent => "Not present",
1146            }
1147        )
1148    }
1149}
1150
1151/// Chassis state data
1152#[derive(Debug, Serialize, Deserialize, Clone)]
1153pub struct ChassisStateData {
1154    pub raw: u8,
1155    pub value: ChassisState,
1156}
1157
1158impl From<smbioslib::ChassisStateData> for ChassisStateData {
1159    fn from(value: smbioslib::ChassisStateData) -> Self {
1160        Self {
1161            raw: value.raw,
1162            value: ChassisState::from(value.value),
1163        }
1164    }
1165}
1166
1167/// Chassis state
1168#[derive(Debug, Serialize, Deserialize, Clone)]
1169pub enum ChassisState {
1170    Other,
1171    Unknown,
1172    Safe,
1173    Warning,
1174    Critical,
1175    NonRecoverable,
1176    None,
1177}
1178
1179impl From<smbioslib::ChassisState> for ChassisState {
1180    fn from(value: smbioslib::ChassisState) -> Self {
1181        match value {
1182            smbioslib::ChassisState::Other => Self::Other,
1183            smbioslib::ChassisState::Unknown => Self::Unknown,
1184            smbioslib::ChassisState::Safe => Self::Safe,
1185            smbioslib::ChassisState::Warning => Self::Warning,
1186            smbioslib::ChassisState::Critical => Self::Critical,
1187            smbioslib::ChassisState::NonRecoverable => Self::NonRecoverable,
1188            smbioslib::ChassisState::None => Self::None,
1189        }
1190    }
1191}
1192
1193impl Display for ChassisState {
1194    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1195        write!(
1196            f,
1197            "{}",
1198            match self {
1199                Self::Other => "Other",
1200                Self::Unknown => "Unknown",
1201                Self::Safe => "Safe",
1202                Self::Warning => "Warning",
1203                Self::Critical => "Critical",
1204                Self::NonRecoverable => "Non-recoverable",
1205                Self::None => "Unknown to this standard, check the raw value",
1206            }
1207        )
1208    }
1209}
1210
1211/// Chassis security status data
1212#[derive(Debug, Serialize, Deserialize, Clone)]
1213pub struct ChassisSecurityStatusData {
1214    pub raw: u8,
1215    pub value: ChassisSecurityStatus,
1216}
1217
1218impl From<smbioslib::ChassisSecurityStatusData> for ChassisSecurityStatusData {
1219    fn from(value: smbioslib::ChassisSecurityStatusData) -> Self {
1220        Self {
1221            raw: value.raw,
1222            value: ChassisSecurityStatus::from(value.value),
1223        }
1224    }
1225}
1226
1227/// Chassis security status
1228#[derive(Debug, Serialize, Deserialize, Clone)]
1229pub enum ChassisSecurityStatus {
1230    Other,
1231    Unknown,
1232    StatusNone,
1233    ExternalInterfaceLockedOut,
1234    ExternalInterfaceEnabled,
1235    None,
1236}
1237
1238impl From<smbioslib::ChassisSecurityStatus> for ChassisSecurityStatus {
1239    fn from(value: smbioslib::ChassisSecurityStatus) -> Self {
1240        match value {
1241            smbioslib::ChassisSecurityStatus::Other => Self::Other,
1242            smbioslib::ChassisSecurityStatus::Unknown => Self::Unknown,
1243            smbioslib::ChassisSecurityStatus::StatusNone => Self::StatusNone,
1244            smbioslib::ChassisSecurityStatus::ExternalInterfaceLockedOut => {
1245                Self::ExternalInterfaceLockedOut
1246            }
1247            smbioslib::ChassisSecurityStatus::ExternalInterfaceEnabled => {
1248                Self::ExternalInterfaceEnabled
1249            }
1250            smbioslib::ChassisSecurityStatus::None => Self::None,
1251        }
1252    }
1253}
1254
1255impl Display for ChassisSecurityStatus {
1256    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1257        write!(
1258            f,
1259            "{}",
1260            match self {
1261                Self::Other => "Other",
1262                Self::Unknown => "Unknown",
1263                Self::StatusNone => "None",
1264                Self::ExternalInterfaceLockedOut => "External interface locked out",
1265                Self::ExternalInterfaceEnabled => "External interface enabled",
1266                Self::None => "Unknown to this standard, check the raw value",
1267            }
1268        )
1269    }
1270}
1271
1272/// Chassis height
1273#[derive(Debug, Serialize, Deserialize, Clone)]
1274pub enum ChassisHeight {
1275    Unspecified,
1276    U(u8),
1277}
1278
1279impl From<smbioslib::ChassisHeight> for ChassisHeight {
1280    fn from(value: smbioslib::ChassisHeight) -> Self {
1281        match value {
1282            smbioslib::ChassisHeight::Unspecified => Self::Unspecified,
1283            smbioslib::ChassisHeight::U(u) => Self::U(u),
1284        }
1285    }
1286}
1287
1288impl Display for ChassisHeight {
1289    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1290        write!(
1291            f,
1292            "{}",
1293            match self {
1294                Self::Unspecified => format!("Unspecified"),
1295                Self::U(u) => format!("{u} U (1 U = 1.75 inch or 4.445 cm)"),
1296            }
1297        )
1298    }
1299}
1300
1301/// Number of Power Cords
1302#[derive(Debug, Serialize, Deserialize, Clone)]
1303pub enum PowerCords {
1304    Unspecified,
1305    Count(u8),
1306}
1307
1308impl From<smbioslib::PowerCords> for PowerCords {
1309    fn from(value: smbioslib::PowerCords) -> Self {
1310        match value {
1311            smbioslib::PowerCords::Unspecified => Self::Unspecified,
1312            smbioslib::PowerCords::Count(cnt) => Self::Count(cnt),
1313        }
1314    }
1315}
1316
1317impl Display for PowerCords {
1318    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1319        write!(
1320            f,
1321            "{}",
1322            match self {
1323                Self::Unspecified => format!("Unspecified"),
1324                Self::Count(cnt) => format!("{cnt}"),
1325            }
1326        )
1327    }
1328}
1329
1330/// Information about system enclosure or chassis
1331#[derive(Debug, Serialize, Deserialize, Clone)]
1332pub struct Chassis {
1333    /// Enclosure/chassis manufacturer
1334    pub manufacturer: Option<String>,
1335
1336    /// Chassis type
1337    pub chassis_type: Option<ChassisTypeData>,
1338
1339    /// Version
1340    pub version: Option<String>,
1341
1342    /// Serial number
1343    pub serial_number: Option<String>,
1344
1345    /// Asset tag number
1346    pub asset_tag_number: Option<String>,
1347
1348    /// State of the enclosure whet it was last booted
1349    pub bootup_state: Option<ChassisStateData>,
1350
1351    /// State of the enclosure's power supply when last booted
1352    pub power_supply_state: Option<ChassisStateData>,
1353
1354    /// Thermal state of the enclosure when last booted
1355    pub thermal_state: Option<ChassisStateData>,
1356
1357    /// Physical security status of the enclosure when last booted
1358    pub security_status: Option<ChassisSecurityStatusData>,
1359
1360    /// OEM- or BIOS vendor-specific information
1361    pub oem_defined: Option<u32>,
1362
1363    /// Height of the enclosure, in 'U's
1364    ///
1365    /// A U is a standard unit of measure for the height of a rack
1366    /// or rack-mountable component and is equal to 1.75 inches or
1367    /// 4.445 cm
1368    pub height: Option<ChassisHeight>,
1369
1370    /// Number of power cords associated with the enclosure/chassis
1371    pub number_of_power_cords: Option<PowerCords>,
1372
1373    /// Number of Contained Element records that follow, in the
1374    /// range 0 to 255 Each Contained Element group comprises m
1375    /// bytes, as specified by the Contained Element Record Length
1376    /// field that follows. If no Contained Elements are included,
1377    /// this field is set to 0.
1378    pub contained_element_count: Option<u8>,
1379
1380    /// Byte length of eact Contained Element record that follows,
1381    /// in the range 0 to 255. If no Contained Elements are included,
1382    /// this field is set to 0
1383    pub contained_element_record_length: Option<u8>,
1384
1385    // TODO: this struct doesn't included ContainedElements<'_> iter!
1386    /// Chassis or enclosure SKU number
1387    pub sku_number: Option<String>,
1388}
1389
1390impl Chassis {
1391    /// Creates a new instance of `Self`
1392    ///
1393    /// It is usually not required, since an instance of this
1394    /// structure will be created using the method
1395    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
1396    /// [`DMITable::new()`].
1397    pub fn new() -> Result<Self> {
1398        let table = smbioslib::table_load_from_device()?;
1399        Self::new_from_table(&table)
1400    }
1401
1402    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
1403        let t = table
1404            .find_map(|f: smbioslib::SMBiosSystemChassisInformation| Some(f))
1405            .ok_or(anyhow!(
1406                "Failed to get information about system enclosure/chassis (type 3)!"
1407            ))?;
1408
1409        Ok(Self {
1410            manufacturer: t.manufacturer().ok(),
1411            chassis_type: match t.chassis_type() {
1412                Some(ct) => Some(ChassisTypeData::from(ct)),
1413                None => None,
1414            },
1415            version: t.version().ok(),
1416            serial_number: t.serial_number().ok(),
1417            asset_tag_number: t.asset_tag_number().ok(),
1418            bootup_state: match t.bootup_state() {
1419                Some(bs) => Some(ChassisStateData::from(bs)),
1420                None => None,
1421            },
1422            power_supply_state: match t.power_supply_state() {
1423                Some(pss) => Some(ChassisStateData::from(pss)),
1424                None => None,
1425            },
1426            thermal_state: match t.thermal_state() {
1427                Some(ts) => Some(ChassisStateData::from(ts)),
1428                None => None,
1429            },
1430            security_status: match t.security_status() {
1431                Some(ss) => Some(ChassisSecurityStatusData::from(ss)),
1432                None => None,
1433            },
1434            oem_defined: t.oem_defined(),
1435            height: match t.height() {
1436                Some(h) => Some(ChassisHeight::from(h)),
1437                None => None,
1438            },
1439            number_of_power_cords: match t.number_of_power_cords() {
1440                Some(npc) => Some(PowerCords::from(npc)),
1441                None => None,
1442            },
1443            contained_element_count: t.contained_element_count(),
1444            contained_element_record_length: t.contained_element_record_length(),
1445            sku_number: t.sku_number().ok(),
1446        })
1447    }
1448}
1449
1450impl ToJson for Chassis {}
1451
1452/// Information about processor
1453#[derive(Debug, Serialize, Deserialize, Clone)]
1454pub struct Processor {
1455    /// Socket reference designation
1456    pub socked_designation: Option<String>,
1457
1458    /// Processor type
1459    pub processor_type: Option<ProcessorTypeData>,
1460
1461    /// Processor family
1462    pub processor_family: Option<ProcessorFamilyData>,
1463
1464    /// Processor manufacturer
1465    pub processor_manufacturer: Option<String>,
1466
1467    /// Raw processor identification data
1468    pub processor_id: Option<[u8; 8]>,
1469
1470    /// Processor version
1471    pub processor_version: Option<String>,
1472
1473    /// Processor voltage
1474    pub voltage: Option<ProcessorVoltage>,
1475
1476    /// External clock frequency, MHz. If the value is unknown,
1477    /// the field is set to 0
1478    pub external_clock: Option<ProcessorExternalClock>,
1479
1480    /// Maximum CPU speed (in MHz) supported *by the system* for this
1481    /// processor socket
1482    pub max_speed: Option<ProcessorSpeed>,
1483
1484    /// Current speed
1485    ///
1486    /// This field identifies the processor's speed at system boot;
1487    /// the processor may support more than one speed
1488    pub current_speed: Option<ProcessorSpeed>,
1489
1490    /// Status bit field
1491    pub status: Option<ProcessorStatus>,
1492
1493    /// Processor upgrade
1494    pub processor_upgrade: Option<ProcessorUpgradeData>,
1495
1496    /// Attributes of the primary (Level 1) cache for this processor
1497    pub l1cache_handle: Option<Handle>,
1498
1499    /// Attributes of the primary (Level 2) cache for this processor
1500    pub l2cache_handle: Option<Handle>,
1501
1502    /// Attributes of the primary (Level 3) cache for this processor
1503    pub l3cache_handle: Option<Handle>,
1504
1505    /// Serial number of this processor
1506    pub serial_number: Option<String>,
1507
1508    /// Asset tag of this proc
1509    pub asset_tag: Option<String>,
1510
1511    /// Part number of this processor
1512    pub part_number: Option<String>,
1513
1514    /// Number of cores per processor socket
1515    pub core_count: Option<CoreCount>,
1516
1517    /// Number of enabled cores per processor socket
1518    pub cores_enabled: Option<CoresEnabled>,
1519
1520    /// Number of threads per processor socket
1521    pub thread_count: Option<ThreadCount>,
1522
1523    /// Function that processor supports
1524    pub processors_characteristics: Option<ProcessorCharacteristics>,
1525
1526    /// Processor family 2
1527    pub processor_family_2: Option<ProcessorFamilyData2>,
1528
1529    /// Number of cores per proc socket (if cores > 255)
1530    pub core_count_2: Option<CoreCount2>,
1531
1532    /// Number of enabled cores per proc socket (if ecores > 255)
1533    pub cores_enabled_2: Option<CoresEnabled2>,
1534
1535    /// Number of threads per proc socket (if threads > 255)
1536    pub thread_count_2: Option<ThreadCount2>,
1537
1538    /// Number of threads the BIOS has enabled and available for
1539    /// OS use
1540    pub thread_enabled: Option<ThreadEnabled>,
1541}
1542
1543impl Processor {
1544    /// Creates a new instance of `Self`
1545    ///
1546    /// It is usually not required, since an instance of this
1547    /// structure will be created using the method
1548    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
1549    /// [`DMITable::new()`].
1550    pub fn new() -> Result<Self> {
1551        let table = smbioslib::table_load_from_device()?;
1552        Self::new_from_table(&table)
1553    }
1554
1555    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
1556        let t = table
1557            .find_map(|f: smbioslib::SMBiosProcessorInformation| Some(f))
1558            .ok_or(anyhow!("Failed to get information about CPU (type 4)!"))?;
1559
1560        Ok(Self {
1561            socked_designation: t.socket_designation().ok(),
1562            processor_type: match t.processor_type() {
1563                Some(pt) => Some(ProcessorTypeData::from(pt)),
1564                None => None,
1565            },
1566            processor_family: match t.processor_family() {
1567                Some(pf) => Some(ProcessorFamilyData::from(pf)),
1568                None => None,
1569            },
1570            processor_manufacturer: t.processor_manufacturer().ok(),
1571            processor_id: match t.processor_id() {
1572                Some(p_id) => Some(*p_id),
1573                None => None,
1574            },
1575            processor_version: t.processor_version().ok(),
1576            voltage: match t.voltage() {
1577                Some(v) => Some(ProcessorVoltage::from(v)),
1578                None => None,
1579            },
1580            external_clock: match t.external_clock() {
1581                Some(ec) => Some(ProcessorExternalClock::from(ec)),
1582                None => None,
1583            },
1584            max_speed: match t.max_speed() {
1585                Some(ms) => Some(ProcessorSpeed::from(ms)),
1586                None => None,
1587            },
1588            current_speed: match t.current_speed() {
1589                Some(cs) => Some(ProcessorSpeed::from(cs)),
1590                None => None,
1591            },
1592            status: match t.status() {
1593                Some(s) => Some(ProcessorStatus::from(s)),
1594                None => None,
1595            },
1596            processor_upgrade: match t.processor_upgrade() {
1597                Some(pu) => Some(ProcessorUpgradeData::from(pu)),
1598                None => None,
1599            },
1600            l1cache_handle: Handle::from_opt(t.l1cache_handle()),
1601            l2cache_handle: Handle::from_opt(t.l2cache_handle()),
1602            l3cache_handle: Handle::from_opt(t.l3cache_handle()),
1603            serial_number: t.serial_number().ok(),
1604            asset_tag: t.asset_tag().ok(),
1605            part_number: t.part_number().ok(),
1606            core_count: match t.core_count() {
1607                Some(cc) => Some(CoreCount::from(cc)),
1608                None => None,
1609            },
1610            cores_enabled: match t.cores_enabled() {
1611                Some(ce) => Some(CoresEnabled::from(ce)),
1612                None => None,
1613            },
1614            thread_count: match t.thread_count() {
1615                Some(tc) => Some(ThreadCount::from(tc)),
1616                None => None,
1617            },
1618            processors_characteristics: match t.processor_characteristics() {
1619                Some(pc) => Some(ProcessorCharacteristics::from(pc)),
1620                None => None,
1621            },
1622            processor_family_2: match t.processor_family_2() {
1623                Some(pf2) => Some(ProcessorFamilyData2::from(pf2)),
1624                None => None,
1625            },
1626            core_count_2: match t.core_count_2() {
1627                Some(cc2) => Some(CoreCount2::from(cc2)),
1628                None => None,
1629            },
1630            cores_enabled_2: match t.cores_enabled_2() {
1631                Some(ce2) => Some(CoresEnabled2::from(ce2)),
1632                None => None,
1633            },
1634            thread_count_2: match t.thread_count_2() {
1635                Some(tc2) => Some(ThreadCount2::from(tc2)),
1636                None => None,
1637            },
1638            thread_enabled: match t.thread_enabled() {
1639                Some(te) => Some(ThreadEnabled::from(te)),
1640                None => None,
1641            },
1642        })
1643    }
1644}
1645
1646impl ToJson for Processor {}
1647
1648/// Defines which functions the processor supports
1649#[derive(Debug, Serialize, Deserialize, Clone)]
1650pub struct ProcessorCharacteristics {
1651    /// Bit 1 unknown
1652    pub unknown: bool,
1653
1654    /// 64-bit capable
1655    pub bit_64capable: bool,
1656
1657    /// Multi-core
1658    pub multi_core: bool,
1659
1660    /// Hardware thread
1661    pub hardware_thread: bool,
1662
1663    /// Execute protection
1664    pub execute_protection: bool,
1665
1666    /// Enhanced Virtualization
1667    pub enhanced_virtualization: bool,
1668
1669    /// Power/perfomance control
1670    pub power_perfomance_control: bool,
1671
1672    /// 128-bit capable
1673    pub bit_128capable: bool,
1674
1675    /// Arm64 SoC ID
1676    pub arm_64soc_id: bool,
1677}
1678
1679impl From<smbioslib::ProcessorCharacteristics> for ProcessorCharacteristics {
1680    fn from(value: smbioslib::ProcessorCharacteristics) -> Self {
1681        Self {
1682            unknown: value.unknown(),
1683            bit_64capable: value.bit_64capable(),
1684            multi_core: value.multi_core(),
1685            hardware_thread: value.hardware_thread(),
1686            execute_protection: value.execute_protection(),
1687            enhanced_virtualization: value.enhanced_virtualization(),
1688            power_perfomance_control: value.power_performance_control(),
1689            bit_128capable: value.bit_128capable(),
1690            arm_64soc_id: value.arm_64soc_id(),
1691        }
1692    }
1693}
1694impl ToJson for ProcessorCharacteristics {}
1695#[derive(Debug, Deserialize, Serialize, Clone)]
1696pub struct ProcessorTypeData {
1697    pub raw: u8,
1698    pub value: ProcessorType,
1699}
1700
1701impl From<smbioslib::ProcessorTypeData> for ProcessorTypeData {
1702    fn from(value: smbioslib::ProcessorTypeData) -> Self {
1703        Self {
1704            raw: value.raw,
1705            value: ProcessorType::from(value.value),
1706        }
1707    }
1708}
1709
1710#[derive(Debug, Deserialize, Serialize, Clone)]
1711pub enum ProcessorType {
1712    Other,
1713    Unknown,
1714    CentralProcessor,
1715    MathProcessor,
1716    DspProcessor,
1717    VideoProcessor,
1718    None,
1719}
1720
1721impl Display for ProcessorType {
1722    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1723        write!(
1724            f,
1725            "{}",
1726            match self {
1727                Self::Other => "Other",
1728                Self::Unknown => "Unknown",
1729                Self::CentralProcessor => "Central Processor",
1730                Self::MathProcessor => "Math Processor",
1731                Self::DspProcessor => "DSP Processor",
1732                Self::VideoProcessor => "Video Processor",
1733                Self::None => "A value unknown for this standard, check the raw value",
1734            }
1735        )
1736    }
1737}
1738
1739impl From<smbioslib::ProcessorType> for ProcessorType {
1740    fn from(value: smbioslib::ProcessorType) -> Self {
1741        match value {
1742            smbioslib::ProcessorType::Other => Self::Other,
1743            smbioslib::ProcessorType::Unknown => Self::Unknown,
1744            smbioslib::ProcessorType::CentralProcessor => Self::CentralProcessor,
1745            smbioslib::ProcessorType::MathProcessor => Self::MathProcessor,
1746            smbioslib::ProcessorType::DspProcessor => Self::DspProcessor,
1747            smbioslib::ProcessorType::VideoProcessor => Self::VideoProcessor,
1748            smbioslib::ProcessorType::None => Self::None,
1749        }
1750    }
1751}
1752
1753#[derive(Debug, Deserialize, Serialize, Clone)]
1754pub struct ProcessorFamilyData {
1755    pub raw: u8,
1756    pub value: ProcessorFamily,
1757}
1758
1759impl From<smbioslib::ProcessorFamilyData> for ProcessorFamilyData {
1760    fn from(value: smbioslib::ProcessorFamilyData) -> Self {
1761        Self {
1762            raw: value.raw,
1763            value: ProcessorFamily::from(value.value),
1764        }
1765    }
1766}
1767
1768#[derive(Debug, Deserialize, Serialize, Clone)]
1769pub enum ProcessorFamily {
1770    Other,
1771    Unknown,
1772    IntelPentiumProcessor,
1773    PentiumProProcessor,
1774    PentiumIIProcessor,
1775    PentiumprocessorwithMMXtechnology,
1776    IntelCeleronProcessor,
1777    PentiumIIXeonProcessor,
1778    PentiumIIIProcessor,
1779    M1Family,
1780    M2Family,
1781    IntelCeleronMProcessor,
1782    IntelPentium4HTProcessor,
1783    AMDDuronProcessorFamily,
1784    K5Family,
1785    K6Family,
1786    K62,
1787    K63,
1788    AMDAthlonProcessorFamily,
1789    AMD29000Family,
1790    K62Plus,
1791    IntelCoreDuoProcessor,
1792    IntelCoreDuomobileProcessor,
1793    IntelCoreSolomobileProcessor,
1794    IntelAtomProcessor,
1795    IntelCoreMProcessor,
1796    IntelCorem3Processor,
1797    IntelCorem5Processor,
1798    IntelCorem7Processor,
1799    AMDTurionIIUltraDualCoreMobileMProcessorFamily,
1800    AMDTurionIIDualCoreMobileMProcessorFamily,
1801    AMDAthlonIIDualCoreMProcessorFamily,
1802    AMDOpteron6100SeriesProcessor,
1803    AMDOpteron4100SeriesProcessor,
1804    AMDOpteron6200SeriesProcessor,
1805    AMDOpteron4200SeriesProcessor,
1806    AMDFXSeriesProcessor,
1807    AMDCSeriesProcessor,
1808    AMDESeriesProcessor,
1809    AMDASeriesProcessor,
1810    AMDGSeriesProcessor,
1811    AMDZSeriesProcessor,
1812    AMDRSeriesProcessor,
1813    AMDOpteron4300SeriesProcessor,
1814    AMDOpteron6300SeriesProcessor,
1815    AMDOpteron3300SeriesProcessor,
1816    AMDFireProSeriesProcessor,
1817    AMDAthlonX4QuadCoreProcessorFamily,
1818    AMDOpteronX1000SeriesProcessor,
1819    AMDOpteronX2000SeriesAPU,
1820    AMDOpteronASeriesProcessor,
1821    AMDOpteronX3000SeriesAPU,
1822    AMDZenProcessorFamily,
1823    Itaniumprocessor,
1824    AMDAthlon64ProcessorFamily,
1825    AMDOpteronProcessorFamily,
1826    AMDSempronProcessorFamily,
1827    AMDTurion64MobileTechnology,
1828    DualCoreAMDOpteronProcessorFamily,
1829    AMDAthlon64X2DualCoreProcessorFamily,
1830    AMDTurion64X2MobileTechnology,
1831    QuadCoreAMDOpteronProcessorFamily,
1832    ThirdGenerationAMDOpteronProcessorFamily,
1833    AMDPhenomFXQuadCoreProcessorFamily,
1834    AMDPhenomX4QuadCoreProcessorFamily,
1835    AMDPhenomX2DualCoreProcessorFamily,
1836    AMDAthlonX2DualCoreProcessorFamily,
1837    QuadCoreIntelXeonProcessor3200Series,
1838    DualCoreIntelXeonProcessor3000Series,
1839    QuadCoreIntelXeonProcessor5300Series,
1840    DualCoreIntelXeonProcessor5100Series,
1841    DualCoreIntelXeonProcessor5000Series,
1842    DualCoreIntelXeonProcessorLV,
1843    DualCoreIntelXeonProcessorULV,
1844    DualCoreIntelXeonProcessor7100Series,
1845    QuadCoreIntelXeonProcessor5400Series,
1846    QuadCoreIntelXeonProcessor,
1847    DualCoreIntelXeonProcessor5200Series,
1848    DualCoreIntelXeonProcessor7200Series,
1849    QuadCoreIntelXeonProcessor7300Series,
1850    QuadCoreIntelXeonProcessor7400Series,
1851    MultiCoreIntelXeonProcessor7400Series,
1852    PentiumIIIXeonProcessor,
1853    PentiumIIIProcessorwithIntelSpeedStepTechnology,
1854    Pentium4Processor,
1855    IntelXeonProcessor,
1856    IntelXeonProcessorMP,
1857    AMDAthlonXPProcessorFamily,
1858    AMDAthlonMPProcessorFamily,
1859    IntelItanium2Processor,
1860    IntelPentiumMProcessor,
1861    IntelCeleronDProcessor,
1862    IntelPentiumDProcessor,
1863    IntelPentiumProcessorExtremeEdition,
1864    IntelCoreSoloProcessor,
1865    IntelCore2DuoProcessor,
1866    IntelCore2SoloProcessor,
1867    IntelCore2ExtremeProcessor,
1868    IntelCore2QuadProcessor,
1869    IntelCore2ExtremeMobileProcessor,
1870    IntelCore2DuoMobileProcessor,
1871    IntelCore2SoloMobileProcessor,
1872    IntelCorei7Processor,
1873    DualCoreIntelCeleronProcessor,
1874    IntelCorei5processor,
1875    IntelCorei3processor,
1876    IntelCorei9processor,
1877    MultiCoreIntelXeonProcessor,
1878    DualCoreIntelXeonProcessor3xxxSeries,
1879    QuadCoreIntelXeonProcessor3xxxSeries,
1880    DualCoreIntelXeonProcessor5xxxSeries,
1881    QuadCoreIntelXeonProcessor5xxxSeries,
1882    DualCoreIntelXeonProcessor7xxxSeries,
1883    QuadCoreIntelXeonProcessor7xxxSeries,
1884    MultiCoreIntelXeonProcessor7xxxSeries,
1885    MultiCoreIntelXeonProcessor3400Series,
1886    AMDOpteron3000SeriesProcessor,
1887    AMDSempronIIProcessor,
1888    EmbeddedAMDOpteronQuadCoreProcessorFamily,
1889    AMDPhenomTripleCoreProcessorFamily,
1890    AMDTurionUltraDualCoreMobileProcessorFamily,
1891    AMDTurionDualCoreMobileProcessorFamily,
1892    AMDAthlonDualCoreProcessorFamily,
1893    AMDSempronSIProcessorFamily,
1894    AMDPhenomIIProcessorFamily,
1895    AMDAthlonIIProcessorFamily,
1896    SixCoreAMDOpteronProcessorFamily,
1897    AMDSempronMProcessorFamily,
1898    SeeProcessorFamily2,
1899    ARMv7,
1900    ARMv8,
1901    ARMv9,
1902    ARM,
1903    StrongARM,
1904    VideoProcessor,
1905    None,
1906}
1907
1908impl Display for ProcessorFamily {
1909    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1910        write!(
1911            f,
1912            "{}",
1913            match self {
1914                Self::Other => "Other",
1915                Self::Unknown => "Unknown",
1916                Self::IntelPentiumProcessor => "Intel® Pentium® processor",
1917                Self::PentiumProProcessor => "Intel® Pentium® Pro processor",
1918                Self::PentiumIIProcessor => "Pentium® II processor",
1919                Self::PentiumprocessorwithMMXtechnology =>
1920                    "Pentium® processor with MMX™ technology",
1921                Self::IntelCeleronProcessor => "Intel® Celeron® processor",
1922                Self::PentiumIIXeonProcessor => "Pentium® II Xeon™ processor",
1923                Self::PentiumIIIProcessor => "Pentium® III processor",
1924                Self::M1Family => "M1 Family",
1925                Self::M2Family => "M2 Family",
1926                Self::IntelCeleronMProcessor => "Intel® Celeron® M processor",
1927                Self::IntelPentium4HTProcessor => "Intel® Pentium® 4 HT processor",
1928                Self::AMDDuronProcessorFamily => "AMD Duron™ Processor Family",
1929                Self::K5Family => "K5 Family",
1930                Self::K6Family => "K6 Family",
1931                Self::K62 => "K6-2",
1932                Self::K63 => "K6-3",
1933                Self::AMDAthlonProcessorFamily => "AMD Athlon™ Processor Family",
1934                Self::AMD29000Family => "AMD29000 Family",
1935                Self::K62Plus => "K6-2+",
1936                Self::IntelCoreDuoProcessor => "Intel® Core™ Duo processor",
1937                Self::IntelCoreDuomobileProcessor => "Intel® Core™ Duo mobile processor",
1938                Self::IntelCoreSolomobileProcessor => "Intel® Core™ Solo mobile processor",
1939                Self::IntelAtomProcessor => "Intel® Atom™ processor",
1940                Self::IntelCoreMProcessor => "Intel® Core™ M processor",
1941                Self::IntelCorem3Processor => "Intel® Core™ m3 processor",
1942                Self::IntelCorem5Processor => "Intel® Core™ m5 processor",
1943                Self::IntelCorem7Processor => "Intel® Core™ m7 processor",
1944                Self::AMDTurionIIUltraDualCoreMobileMProcessorFamily =>
1945                    "AMD Turion™ II Ultra Dual-Core Mobile M Processor Family",
1946                Self::AMDTurionIIDualCoreMobileMProcessorFamily =>
1947                    "AMD Turion™ II Dual-Core Mobile M Processor Family",
1948                Self::AMDAthlonIIDualCoreMProcessorFamily =>
1949                    "AMD Athlon™ II Dual-Core M Processor Family",
1950                Self::AMDOpteron6100SeriesProcessor => "AMD Opteron™ 6100 Series Processor",
1951                Self::AMDOpteron4100SeriesProcessor => "AMD Opteron™ 4100 Series Processor",
1952                Self::AMDOpteron6200SeriesProcessor => "AMD Opteron™ 6200 Series Processor",
1953                Self::AMDOpteron4200SeriesProcessor => "AMD Opteron™ 4200 Series Processor",
1954                Self::AMDFXSeriesProcessor => "AMD FX™ Series Processor",
1955                Self::AMDCSeriesProcessor => "AMD C-Series Processor",
1956                Self::AMDESeriesProcessor => "AMD E-Series Processor",
1957                Self::AMDASeriesProcessor => "AMD A-Series Processor",
1958                Self::AMDGSeriesProcessor => "AMD G-Series Processor",
1959                Self::AMDZSeriesProcessor => "AMD Z-Series Processor",
1960                Self::AMDRSeriesProcessor => "AMD R-Series Processor",
1961                Self::AMDOpteron4300SeriesProcessor => "AMD Opteron™ 4300 Series Processor",
1962                Self::AMDOpteron6300SeriesProcessor => "AMD Opteron™ 6300 Series Processor",
1963                Self::AMDOpteron3300SeriesProcessor => "AMD Opteron™ 3300 Series Processor",
1964                Self::AMDFireProSeriesProcessor => "AMD FirePro™ Series Processor",
1965                Self::AMDAthlonX4QuadCoreProcessorFamily =>
1966                    "AMD Athlon(TM) X4 Quad-Core Processor Family",
1967                Self::AMDOpteronX1000SeriesProcessor => "AMD Opteron(TM) X1000 Series Processor",
1968                Self::AMDOpteronX2000SeriesAPU => "AMD Opteron(TM) X2000 Series APU",
1969                Self::AMDOpteronASeriesProcessor => "AMD Opteron(TM) A-Series Processor",
1970                Self::AMDOpteronX3000SeriesAPU => "AMD Opteron(TM) X3000 Series APU",
1971                Self::AMDZenProcessorFamily => "AMD Zen Processor Family",
1972                Self::Itaniumprocessor => "Itanium™ processor",
1973                Self::AMDAthlon64ProcessorFamily => "AMD Athlon™ 64 Processor Family",
1974                Self::AMDOpteronProcessorFamily => "AMD Opteron™ Processor Family",
1975                Self::AMDSempronProcessorFamily => "AMD Sempron™ Processor Family",
1976                Self::AMDTurion64MobileTechnology => "AMD Turion™ 64 Mobile Technology",
1977                Self::DualCoreAMDOpteronProcessorFamily =>
1978                    "Dual-Core AMD Opteron™ Processor Family",
1979                Self::AMDAthlon64X2DualCoreProcessorFamily =>
1980                    "AMD Athlon™ 64 X2 Dual-Core Processor Family",
1981                Self::AMDTurion64X2MobileTechnology => "AMD Turion™ 64 X2 Mobile Technology",
1982                Self::QuadCoreAMDOpteronProcessorFamily =>
1983                    "Quad-Core AMD Opteron™ Processor Family",
1984                Self::ThirdGenerationAMDOpteronProcessorFamily =>
1985                    "Third-Generation AMD Opteron™ Processor Family",
1986                Self::AMDPhenomFXQuadCoreProcessorFamily =>
1987                    "AMD Phenom™ FX Quad-Core Processor Family",
1988                Self::AMDPhenomX4QuadCoreProcessorFamily =>
1989                    "AMD Phenom™ X4 Quad-Core Processor Family",
1990                Self::AMDPhenomX2DualCoreProcessorFamily =>
1991                    "AMD Phenom™ X2 Dual-Core Processor Family",
1992                Self::AMDAthlonX2DualCoreProcessorFamily =>
1993                    "AMD Athlon™ X2 Dual-Core Processor Family",
1994                Self::QuadCoreIntelXeonProcessor3200Series =>
1995                    "Quad-Core Intel® Xeon® processor 3200 Series",
1996                Self::DualCoreIntelXeonProcessor3000Series =>
1997                    "Dual-Core Intel® Xeon® processor 3000 Series",
1998                Self::QuadCoreIntelXeonProcessor5300Series =>
1999                    "Quad-Core Intel® Xeon® processor 5300 Series",
2000                Self::DualCoreIntelXeonProcessor5100Series =>
2001                    "Dual-Core Intel® Xeon® processor 5100 Series",
2002                Self::DualCoreIntelXeonProcessor5000Series =>
2003                    "Dual-Core Intel® Xeon® processor 5000 Series",
2004                Self::DualCoreIntelXeonProcessorLV => "Dual-Core Intel® Xeon® processor LV",
2005                Self::DualCoreIntelXeonProcessorULV => "Dual-Core Intel® Xeon® processor ULV",
2006                Self::DualCoreIntelXeonProcessor7100Series =>
2007                    "Dual-Core Intel® Xeon® processor 7100 Series",
2008                Self::QuadCoreIntelXeonProcessor5400Series =>
2009                    "Quad-Core Intel® Xeon® processor 5400 Series",
2010                Self::QuadCoreIntelXeonProcessor => "Quad-Core Intel® Xeon® processor",
2011                Self::DualCoreIntelXeonProcessor5200Series =>
2012                    "Dual-Core Intel® Xeon® processor 5200 Series",
2013                Self::DualCoreIntelXeonProcessor7200Series =>
2014                    "Dual-Core Intel® Xeon® processor 7200 Series",
2015                Self::QuadCoreIntelXeonProcessor7300Series =>
2016                    "Quad-Core Intel® Xeon® processor 7300 Series",
2017                Self::QuadCoreIntelXeonProcessor7400Series =>
2018                    "Quad-Core Intel® Xeon® processor 7400 Series",
2019                Self::MultiCoreIntelXeonProcessor7400Series =>
2020                    "Multi-Core Intel® Xeon® processor 7400 Series",
2021                Self::PentiumIIIXeonProcessor => "Pentium® III Xeon™ processor",
2022                Self::PentiumIIIProcessorwithIntelSpeedStepTechnology =>
2023                    "Pentium® III Processor with Intel® SpeedStep™ Technology",
2024                Self::Pentium4Processor => "Pentium® 4 Processor",
2025                Self::IntelXeonProcessor => "Intel® Xeon® processor",
2026                Self::IntelXeonProcessorMP => "Intel® Xeon™ processor MP",
2027                Self::AMDAthlonXPProcessorFamily => "AMD Athlon™ XP Processor Family",
2028                Self::AMDAthlonMPProcessorFamily => "AMD Athlon™ MP Processor Family",
2029                Self::IntelItanium2Processor => "Intel® Itanium® 2 processor",
2030                Self::IntelPentiumMProcessor => "Intel® Pentium® M processor",
2031                Self::IntelCeleronDProcessor => "Intel® Celeron® D processor",
2032                Self::IntelPentiumDProcessor => "Intel® Pentium® D processor",
2033                Self::IntelPentiumProcessorExtremeEdition =>
2034                    "Intel® Pentium® Processor Extreme Edition",
2035                Self::IntelCoreSoloProcessor => "Intel® Core™ Solo Processor",
2036                Self::IntelCore2DuoProcessor => "Intel® Core™ 2 Duo Processor",
2037                Self::IntelCore2SoloProcessor => "Intel® Core™ 2 Solo processor",
2038                Self::IntelCore2ExtremeProcessor => "Intel® Core™ 2 Extreme processor",
2039                Self::IntelCore2QuadProcessor => "Intel® Core™ 2 Quad processor",
2040                Self::IntelCore2ExtremeMobileProcessor => "Intel® Core™ 2 Extreme mobile processor",
2041                Self::IntelCore2DuoMobileProcessor => "Intel® Core™ 2 Duo mobile processor",
2042                Self::IntelCore2SoloMobileProcessor => "Intel® Core™ 2 Solo mobile processor",
2043                Self::IntelCorei7Processor => "Intel® Core™ i7 processor",
2044                Self::DualCoreIntelCeleronProcessor => "Dual-Core Intel® Celeron® processor",
2045                Self::IntelCorei5processor => "Intel® Core™ i5 processor",
2046                Self::IntelCorei3processor => "Intel® Core™ i3 processor",
2047                Self::IntelCorei9processor => "Intel® Core™ i9 processor",
2048                Self::MultiCoreIntelXeonProcessor => "Multi-Core Intel® Xeon® processor",
2049                Self::DualCoreIntelXeonProcessor3xxxSeries =>
2050                    "Dual-Core Intel® Xeon® processor 3xxx Series",
2051                Self::QuadCoreIntelXeonProcessor3xxxSeries =>
2052                    "Quad-Core Intel® Xeon® processor 3xxx Series",
2053                Self::DualCoreIntelXeonProcessor5xxxSeries =>
2054                    "Dual-Core Intel® Xeon® processor 5xxx Series",
2055                Self::QuadCoreIntelXeonProcessor5xxxSeries =>
2056                    "Quad-Core Intel® Xeon® processor 5xxx Series",
2057                Self::DualCoreIntelXeonProcessor7xxxSeries =>
2058                    "Dual-Core Intel® Xeon® processor 7xxx Series",
2059                Self::QuadCoreIntelXeonProcessor7xxxSeries =>
2060                    "Quad-Core Intel® Xeon® processor 7xxx Series",
2061                Self::MultiCoreIntelXeonProcessor7xxxSeries =>
2062                    "Multi-Core Intel® Xeon® processor 7xxx Series",
2063                Self::MultiCoreIntelXeonProcessor3400Series =>
2064                    "Multi-Core Intel® Xeon® processor 3400 Series",
2065                Self::AMDOpteron3000SeriesProcessor => "AMD Opteron™ 3000 Series Processor",
2066                Self::AMDSempronIIProcessor => "AMD Sempron™ II Processor",
2067                Self::EmbeddedAMDOpteronQuadCoreProcessorFamily =>
2068                    "Embedded AMD Opteron™ Quad-Core Processor Family",
2069                Self::AMDPhenomTripleCoreProcessorFamily =>
2070                    "AMD Phenom™ Triple-Core Processor Family",
2071                Self::AMDTurionUltraDualCoreMobileProcessorFamily =>
2072                    "AMD Turion™ Ultra Dual-Core Mobile Processor Family",
2073                Self::AMDTurionDualCoreMobileProcessorFamily =>
2074                    "AMD Turion™ Dual-Core Mobile Processor Family",
2075                Self::AMDAthlonDualCoreProcessorFamily => "AMD Athlon™ Dual-Core Processor Family",
2076                Self::AMDSempronSIProcessorFamily => "AMD Sempron™ SI Processor Family",
2077                Self::AMDPhenomIIProcessorFamily => "AMD Phenom™ II Processor Family",
2078                Self::AMDAthlonIIProcessorFamily => "AMD Athlon™ II Processor Family",
2079                Self::SixCoreAMDOpteronProcessorFamily => "Six-Core AMD Opteron™ Processor Family",
2080                Self::AMDSempronMProcessorFamily => "AMD Sempron™ M Processor Family",
2081                Self::SeeProcessorFamily2 => "See the next processor family field",
2082                Self::ARMv7 => "ARMv7",
2083                Self::ARMv8 => "ARMv8",
2084                Self::ARMv9 => "ARMv9",
2085                Self::ARM => "ARM",
2086                Self::StrongARM => "StrongARM",
2087                Self::VideoProcessor => "Video Processor",
2088                Self::None => "A value unknown to this standard, check the raw value",
2089            }
2090        )
2091    }
2092}
2093
2094impl From<smbioslib::ProcessorFamily> for ProcessorFamily {
2095    fn from(value: smbioslib::ProcessorFamily) -> Self {
2096        match value {
2097            smbioslib::ProcessorFamily::Other => Self::Other,
2098            smbioslib::ProcessorFamily::Unknown => Self::Unknown,
2099            smbioslib::ProcessorFamily::IntelPentiumProcessor => Self::IntelPentiumProcessor,
2100            smbioslib::ProcessorFamily::PentiumProProcessor => Self::PentiumProProcessor,
2101            smbioslib::ProcessorFamily::PentiumIIProcessor => Self::PentiumIIProcessor,
2102            smbioslib::ProcessorFamily::PentiumprocessorwithMMXtechnology => {
2103                Self::PentiumprocessorwithMMXtechnology
2104            }
2105            smbioslib::ProcessorFamily::IntelCeleronProcessor => Self::IntelCeleronProcessor,
2106            smbioslib::ProcessorFamily::PentiumIIXeonProcessor => Self::PentiumIIXeonProcessor,
2107            smbioslib::ProcessorFamily::PentiumIIIProcessor => Self::PentiumIIIProcessor,
2108            smbioslib::ProcessorFamily::M1Family => Self::M1Family,
2109            smbioslib::ProcessorFamily::M2Family => Self::M2Family,
2110            smbioslib::ProcessorFamily::IntelCeleronMProcessor => Self::IntelCeleronMProcessor,
2111            smbioslib::ProcessorFamily::IntelPentium4HTProcessor => Self::IntelPentium4HTProcessor,
2112            smbioslib::ProcessorFamily::AMDDuronProcessorFamily => Self::AMDDuronProcessorFamily,
2113            smbioslib::ProcessorFamily::K5Family => Self::K5Family,
2114            smbioslib::ProcessorFamily::K6Family => Self::K6Family,
2115            smbioslib::ProcessorFamily::K62 => Self::K62,
2116            smbioslib::ProcessorFamily::K63 => Self::K63,
2117            smbioslib::ProcessorFamily::AMDAthlonProcessorFamily => Self::AMDAthlonProcessorFamily,
2118            smbioslib::ProcessorFamily::AMD29000Family => Self::AMD29000Family,
2119            smbioslib::ProcessorFamily::K62Plus => Self::K62Plus,
2120            smbioslib::ProcessorFamily::IntelCoreDuoProcessor => Self::IntelCoreDuoProcessor,
2121            smbioslib::ProcessorFamily::IntelCoreDuomobileProcessor => {
2122                Self::IntelCoreDuomobileProcessor
2123            }
2124            smbioslib::ProcessorFamily::IntelCoreSolomobileProcessor => {
2125                Self::IntelCoreSolomobileProcessor
2126            }
2127            smbioslib::ProcessorFamily::IntelAtomProcessor => Self::IntelAtomProcessor,
2128            smbioslib::ProcessorFamily::IntelCoreMProcessor => Self::IntelCoreMProcessor,
2129            smbioslib::ProcessorFamily::IntelCorem3Processor => Self::IntelCorem3Processor,
2130            smbioslib::ProcessorFamily::IntelCorem5Processor => Self::IntelCorem5Processor,
2131            smbioslib::ProcessorFamily::IntelCorem7Processor => Self::IntelCorem7Processor,
2132            smbioslib::ProcessorFamily::AMDTurionIIUltraDualCoreMobileMProcessorFamily => {
2133                Self::AMDTurionIIUltraDualCoreMobileMProcessorFamily
2134            }
2135            smbioslib::ProcessorFamily::AMDTurionIIDualCoreMobileMProcessorFamily => {
2136                Self::AMDTurionIIDualCoreMobileMProcessorFamily
2137            }
2138            smbioslib::ProcessorFamily::AMDAthlonIIDualCoreMProcessorFamily => {
2139                Self::AMDAthlonIIDualCoreMProcessorFamily
2140            }
2141            smbioslib::ProcessorFamily::AMDOpteron6100SeriesProcessor => {
2142                Self::AMDOpteron6100SeriesProcessor
2143            }
2144            smbioslib::ProcessorFamily::AMDOpteron4100SeriesProcessor => {
2145                Self::AMDOpteron4100SeriesProcessor
2146            }
2147            smbioslib::ProcessorFamily::AMDOpteron6200SeriesProcessor => {
2148                Self::AMDOpteron6200SeriesProcessor
2149            }
2150            smbioslib::ProcessorFamily::AMDOpteron4200SeriesProcessor => {
2151                Self::AMDOpteron4200SeriesProcessor
2152            }
2153            smbioslib::ProcessorFamily::AMDFXSeriesProcessor => Self::AMDFXSeriesProcessor,
2154            smbioslib::ProcessorFamily::AMDCSeriesProcessor => Self::AMDCSeriesProcessor,
2155            smbioslib::ProcessorFamily::AMDESeriesProcessor => Self::AMDESeriesProcessor,
2156            smbioslib::ProcessorFamily::AMDASeriesProcessor => Self::AMDASeriesProcessor,
2157            smbioslib::ProcessorFamily::AMDGSeriesProcessor => Self::AMDGSeriesProcessor,
2158            smbioslib::ProcessorFamily::AMDZSeriesProcessor => Self::AMDZSeriesProcessor,
2159            smbioslib::ProcessorFamily::AMDRSeriesProcessor => Self::AMDRSeriesProcessor,
2160            smbioslib::ProcessorFamily::AMDOpteron4300SeriesProcessor => {
2161                Self::AMDOpteron4300SeriesProcessor
2162            }
2163            smbioslib::ProcessorFamily::AMDOpteron6300SeriesProcessor => {
2164                Self::AMDOpteron6300SeriesProcessor
2165            }
2166            smbioslib::ProcessorFamily::AMDOpteron3300SeriesProcessor => {
2167                Self::AMDOpteron3300SeriesProcessor
2168            }
2169            smbioslib::ProcessorFamily::AMDFireProSeriesProcessor => {
2170                Self::AMDFireProSeriesProcessor
2171            }
2172            smbioslib::ProcessorFamily::AMDAthlonX4QuadCoreProcessorFamily => {
2173                Self::AMDAthlonX4QuadCoreProcessorFamily
2174            }
2175            smbioslib::ProcessorFamily::AMDOpteronX1000SeriesProcessor => {
2176                Self::AMDOpteronX1000SeriesProcessor
2177            }
2178            smbioslib::ProcessorFamily::AMDOpteronX2000SeriesAPU => Self::AMDOpteronX2000SeriesAPU,
2179            smbioslib::ProcessorFamily::AMDOpteronASeriesProcessor => {
2180                Self::AMDOpteronASeriesProcessor
2181            }
2182            smbioslib::ProcessorFamily::AMDOpteronX3000SeriesAPU => Self::AMDOpteronX3000SeriesAPU,
2183            smbioslib::ProcessorFamily::AMDZenProcessorFamily => Self::AMDZenProcessorFamily,
2184            smbioslib::ProcessorFamily::Itaniumprocessor => Self::Itaniumprocessor,
2185            smbioslib::ProcessorFamily::AMDAthlon64ProcessorFamily => {
2186                Self::AMDAthlon64ProcessorFamily
2187            }
2188            smbioslib::ProcessorFamily::AMDOpteronProcessorFamily => {
2189                Self::AMDOpteronProcessorFamily
2190            }
2191            smbioslib::ProcessorFamily::AMDSempronProcessorFamily => {
2192                Self::AMDSempronProcessorFamily
2193            }
2194            smbioslib::ProcessorFamily::AMDTurion64MobileTechnology => {
2195                Self::AMDTurion64MobileTechnology
2196            }
2197            smbioslib::ProcessorFamily::DualCoreAMDOpteronProcessorFamily => {
2198                Self::DualCoreAMDOpteronProcessorFamily
2199            }
2200            smbioslib::ProcessorFamily::AMDAthlon64X2DualCoreProcessorFamily => {
2201                Self::AMDAthlon64X2DualCoreProcessorFamily
2202            }
2203            smbioslib::ProcessorFamily::AMDTurion64X2MobileTechnology => {
2204                Self::AMDTurion64X2MobileTechnology
2205            }
2206            smbioslib::ProcessorFamily::QuadCoreAMDOpteronProcessorFamily => {
2207                Self::QuadCoreAMDOpteronProcessorFamily
2208            }
2209            smbioslib::ProcessorFamily::ThirdGenerationAMDOpteronProcessorFamily => {
2210                Self::ThirdGenerationAMDOpteronProcessorFamily
2211            }
2212            smbioslib::ProcessorFamily::AMDPhenomFXQuadCoreProcessorFamily => {
2213                Self::AMDPhenomFXQuadCoreProcessorFamily
2214            }
2215            smbioslib::ProcessorFamily::AMDPhenomX4QuadCoreProcessorFamily => {
2216                Self::AMDPhenomX4QuadCoreProcessorFamily
2217            }
2218            smbioslib::ProcessorFamily::AMDPhenomX2DualCoreProcessorFamily => {
2219                Self::AMDPhenomX2DualCoreProcessorFamily
2220            }
2221            smbioslib::ProcessorFamily::AMDAthlonX2DualCoreProcessorFamily => {
2222                Self::AMDAthlonX2DualCoreProcessorFamily
2223            }
2224            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor3200Series => {
2225                Self::QuadCoreIntelXeonProcessor3200Series
2226            }
2227            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor3000Series => {
2228                Self::DualCoreIntelXeonProcessor3000Series
2229            }
2230            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor5300Series => {
2231                Self::QuadCoreIntelXeonProcessor5300Series
2232            }
2233            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor5100Series => {
2234                Self::DualCoreIntelXeonProcessor5100Series
2235            }
2236            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor5000Series => {
2237                Self::DualCoreIntelXeonProcessor5000Series
2238            }
2239            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessorLV => {
2240                Self::DualCoreIntelXeonProcessorLV
2241            }
2242            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessorULV => {
2243                Self::DualCoreIntelXeonProcessorULV
2244            }
2245            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor7100Series => {
2246                Self::DualCoreIntelXeonProcessor7100Series
2247            }
2248            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor5400Series => {
2249                Self::QuadCoreIntelXeonProcessor5400Series
2250            }
2251            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor => {
2252                Self::QuadCoreIntelXeonProcessor
2253            }
2254            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor5200Series => {
2255                Self::DualCoreIntelXeonProcessor5200Series
2256            }
2257            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor7200Series => {
2258                Self::DualCoreIntelXeonProcessor7200Series
2259            }
2260            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor7300Series => {
2261                Self::QuadCoreIntelXeonProcessor7300Series
2262            }
2263            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor7400Series => {
2264                Self::QuadCoreIntelXeonProcessor7400Series
2265            }
2266            smbioslib::ProcessorFamily::MultiCoreIntelXeonProcessor7400Series => {
2267                Self::MultiCoreIntelXeonProcessor7400Series
2268            }
2269            smbioslib::ProcessorFamily::PentiumIIIXeonProcessor => Self::PentiumIIIXeonProcessor,
2270            smbioslib::ProcessorFamily::PentiumIIIProcessorwithIntelSpeedStepTechnology => {
2271                Self::PentiumIIIProcessorwithIntelSpeedStepTechnology
2272            }
2273            smbioslib::ProcessorFamily::Pentium4Processor => Self::Pentium4Processor,
2274            smbioslib::ProcessorFamily::IntelXeonProcessor => Self::IntelXeonProcessor,
2275            smbioslib::ProcessorFamily::IntelXeonProcessorMP => Self::IntelXeonProcessorMP,
2276            smbioslib::ProcessorFamily::AMDAthlonXPProcessorFamily => {
2277                Self::AMDAthlonXPProcessorFamily
2278            }
2279            smbioslib::ProcessorFamily::AMDAthlonMPProcessorFamily => {
2280                Self::AMDAthlonMPProcessorFamily
2281            }
2282            smbioslib::ProcessorFamily::IntelItanium2Processor => Self::IntelItanium2Processor,
2283            smbioslib::ProcessorFamily::IntelPentiumMProcessor => Self::IntelPentiumMProcessor,
2284            smbioslib::ProcessorFamily::IntelCeleronDProcessor => Self::IntelCeleronDProcessor,
2285            smbioslib::ProcessorFamily::IntelPentiumDProcessor => Self::IntelPentiumDProcessor,
2286            smbioslib::ProcessorFamily::IntelPentiumProcessorExtremeEdition => {
2287                Self::IntelPentiumProcessorExtremeEdition
2288            }
2289            smbioslib::ProcessorFamily::IntelCoreSoloProcessor => Self::IntelCoreSoloProcessor,
2290            smbioslib::ProcessorFamily::IntelCore2DuoProcessor => Self::IntelCore2DuoProcessor,
2291            smbioslib::ProcessorFamily::IntelCore2SoloProcessor => Self::IntelCore2SoloProcessor,
2292            smbioslib::ProcessorFamily::IntelCore2ExtremeProcessor => {
2293                Self::IntelCore2ExtremeProcessor
2294            }
2295            smbioslib::ProcessorFamily::IntelCore2QuadProcessor => Self::IntelCore2QuadProcessor,
2296            smbioslib::ProcessorFamily::IntelCore2ExtremeMobileProcessor => {
2297                Self::IntelCore2ExtremeMobileProcessor
2298            }
2299            smbioslib::ProcessorFamily::IntelCore2DuoMobileProcessor => {
2300                Self::IntelCore2DuoMobileProcessor
2301            }
2302            smbioslib::ProcessorFamily::IntelCore2SoloMobileProcessor => {
2303                Self::IntelCore2SoloMobileProcessor
2304            }
2305            smbioslib::ProcessorFamily::IntelCorei7Processor => Self::IntelCorei7Processor,
2306            smbioslib::ProcessorFamily::DualCoreIntelCeleronProcessor => {
2307                Self::DualCoreIntelCeleronProcessor
2308            }
2309            smbioslib::ProcessorFamily::IntelCorei5processor => Self::IntelCorei5processor,
2310            smbioslib::ProcessorFamily::IntelCorei3processor => Self::IntelCorei3processor,
2311            smbioslib::ProcessorFamily::IntelCorei9processor => Self::IntelCorei9processor,
2312            smbioslib::ProcessorFamily::MultiCoreIntelXeonProcessor => {
2313                Self::MultiCoreIntelXeonProcessor
2314            }
2315            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor3xxxSeries => {
2316                Self::DualCoreIntelXeonProcessor3xxxSeries
2317            }
2318            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor3xxxSeries => {
2319                Self::QuadCoreIntelXeonProcessor3xxxSeries
2320            }
2321            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor5xxxSeries => {
2322                Self::DualCoreIntelXeonProcessor5xxxSeries
2323            }
2324            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor5xxxSeries => {
2325                Self::QuadCoreIntelXeonProcessor5xxxSeries
2326            }
2327            smbioslib::ProcessorFamily::DualCoreIntelXeonProcessor7xxxSeries => {
2328                Self::DualCoreIntelXeonProcessor7xxxSeries
2329            }
2330            smbioslib::ProcessorFamily::QuadCoreIntelXeonProcessor7xxxSeries => {
2331                Self::QuadCoreIntelXeonProcessor7xxxSeries
2332            }
2333            smbioslib::ProcessorFamily::MultiCoreIntelXeonProcessor7xxxSeries => {
2334                Self::MultiCoreIntelXeonProcessor7xxxSeries
2335            }
2336            smbioslib::ProcessorFamily::MultiCoreIntelXeonProcessor3400Series => {
2337                Self::MultiCoreIntelXeonProcessor3400Series
2338            }
2339            smbioslib::ProcessorFamily::AMDOpteron3000SeriesProcessor => {
2340                Self::AMDOpteron3000SeriesProcessor
2341            }
2342            smbioslib::ProcessorFamily::AMDSempronIIProcessor => Self::AMDSempronIIProcessor,
2343            smbioslib::ProcessorFamily::EmbeddedAMDOpteronQuadCoreProcessorFamily => {
2344                Self::EmbeddedAMDOpteronQuadCoreProcessorFamily
2345            }
2346            smbioslib::ProcessorFamily::AMDPhenomTripleCoreProcessorFamily => {
2347                Self::AMDPhenomTripleCoreProcessorFamily
2348            }
2349            smbioslib::ProcessorFamily::AMDTurionUltraDualCoreMobileProcessorFamily => {
2350                Self::AMDTurionUltraDualCoreMobileProcessorFamily
2351            }
2352            smbioslib::ProcessorFamily::AMDTurionDualCoreMobileProcessorFamily => {
2353                Self::AMDTurionDualCoreMobileProcessorFamily
2354            }
2355            smbioslib::ProcessorFamily::AMDAthlonDualCoreProcessorFamily => {
2356                Self::AMDAthlonDualCoreProcessorFamily
2357            }
2358            smbioslib::ProcessorFamily::AMDSempronSIProcessorFamily => {
2359                Self::AMDSempronSIProcessorFamily
2360            }
2361            smbioslib::ProcessorFamily::AMDPhenomIIProcessorFamily => {
2362                Self::AMDPhenomIIProcessorFamily
2363            }
2364            smbioslib::ProcessorFamily::AMDAthlonIIProcessorFamily => {
2365                Self::AMDAthlonIIProcessorFamily
2366            }
2367            smbioslib::ProcessorFamily::SixCoreAMDOpteronProcessorFamily => {
2368                Self::SixCoreAMDOpteronProcessorFamily
2369            }
2370            smbioslib::ProcessorFamily::AMDSempronMProcessorFamily => {
2371                Self::AMDSempronMProcessorFamily
2372            }
2373            smbioslib::ProcessorFamily::SeeProcessorFamily2 => Self::SeeProcessorFamily2,
2374            smbioslib::ProcessorFamily::ARMv7 => Self::ARMv7,
2375            smbioslib::ProcessorFamily::ARMv8 => Self::ARMv8,
2376            smbioslib::ProcessorFamily::ARMv9 => Self::ARMv9,
2377            smbioslib::ProcessorFamily::ARM => Self::ARM,
2378            smbioslib::ProcessorFamily::StrongARM => Self::StrongARM,
2379            smbioslib::ProcessorFamily::VideoProcessor => Self::VideoProcessor,
2380            smbioslib::ProcessorFamily::None => Self::None,
2381            _ => Self::Unknown,
2382        }
2383    }
2384}
2385
2386#[derive(Debug, Deserialize, Serialize, Clone)]
2387pub struct ProcessorFamilyData2 {
2388    pub raw: u16,
2389    pub value: ProcessorFamily,
2390}
2391
2392impl From<smbioslib::ProcessorFamilyData2> for ProcessorFamilyData2 {
2393    fn from(value: smbioslib::ProcessorFamilyData2) -> Self {
2394        Self {
2395            raw: value.raw,
2396            value: ProcessorFamily::from(value.value),
2397        }
2398    }
2399}
2400
2401#[derive(Debug, Deserialize, Serialize, Clone)]
2402pub enum ProcessorVoltage {
2403    CurrentVolts(f32),
2404    SupportedVolts(ProcessorSupportedVoltages),
2405}
2406
2407impl From<smbioslib::ProcessorVoltage> for ProcessorVoltage {
2408    fn from(value: smbioslib::ProcessorVoltage) -> Self {
2409        match value {
2410            smbioslib::ProcessorVoltage::CurrentVolts(volts) => Self::CurrentVolts(volts),
2411            smbioslib::ProcessorVoltage::SupportedVolts(volts) => {
2412                Self::SupportedVolts(ProcessorSupportedVoltages::from(volts))
2413            }
2414        }
2415    }
2416}
2417
2418#[derive(Debug, Deserialize, Serialize, Clone)]
2419pub struct ProcessorSupportedVoltages {
2420    pub volts_5_0: bool,
2421    pub volts_3_3: bool,
2422    pub volts_2_9: bool,
2423    pub voltages: Vec<f32>,
2424}
2425
2426impl From<smbioslib::ProcessorSupportedVoltages> for ProcessorSupportedVoltages {
2427    fn from(value: smbioslib::ProcessorSupportedVoltages) -> Self {
2428        Self {
2429            volts_5_0: value.volts_5_0(),
2430            volts_3_3: value.volts_3_3(),
2431            volts_2_9: value.volts_2_9(),
2432            voltages: value.voltages(),
2433        }
2434    }
2435}
2436
2437#[derive(Debug, Deserialize, Serialize, Clone)]
2438pub enum ProcessorExternalClock {
2439    Unknown,
2440    MHz(u16),
2441}
2442
2443impl Display for ProcessorExternalClock {
2444    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2445        match self {
2446            Self::Unknown => write!(f, "Unknown"),
2447            Self::MHz(mhz) => write!(f, "{} MHz", mhz),
2448        }
2449    }
2450}
2451
2452impl From<smbioslib::ProcessorExternalClock> for ProcessorExternalClock {
2453    fn from(value: smbioslib::ProcessorExternalClock) -> Self {
2454        match value {
2455            smbioslib::ProcessorExternalClock::Unknown => Self::Unknown,
2456            smbioslib::ProcessorExternalClock::MHz(mhz) => Self::MHz(mhz),
2457        }
2458    }
2459}
2460
2461#[derive(Debug, Deserialize, Serialize, Clone)]
2462pub enum ProcessorSpeed {
2463    Unknown,
2464    MHz(u16),
2465}
2466
2467impl Display for ProcessorSpeed {
2468    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2469        match self {
2470            Self::Unknown => write!(f, "Unknown"),
2471            Self::MHz(mhz) => write!(f, "{} MHz", mhz),
2472        }
2473    }
2474}
2475
2476impl From<smbioslib::ProcessorSpeed> for ProcessorSpeed {
2477    fn from(value: smbioslib::ProcessorSpeed) -> Self {
2478        match value {
2479            smbioslib::ProcessorSpeed::Unknown => Self::Unknown,
2480            smbioslib::ProcessorSpeed::MHz(mhz) => Self::MHz(mhz),
2481        }
2482    }
2483}
2484
2485/// Processor Socket and CPU Status
2486#[derive(Debug, Deserialize, Serialize, Clone)]
2487pub struct ProcessorStatus {
2488    pub raw: u8,
2489
2490    /// CPU Socket Populated
2491    pub socket_populated: bool,
2492
2493    /// CPU Status
2494    pub cpu_status: CpuStatus,
2495}
2496
2497impl From<smbioslib::ProcessorStatus> for ProcessorStatus {
2498    fn from(value: smbioslib::ProcessorStatus) -> Self {
2499        Self {
2500            raw: value.raw,
2501            socket_populated: value.socket_populated(),
2502            cpu_status: CpuStatus::from(value.cpu_status()),
2503        }
2504    }
2505}
2506
2507#[derive(Debug, Deserialize, Serialize, Clone)]
2508pub enum CpuStatus {
2509    Unknown,
2510    Enabled,
2511    UserDisabled,
2512    BiosDisabled,
2513    Idle,
2514    Other,
2515    None,
2516}
2517
2518impl Display for CpuStatus {
2519    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2520        write!(
2521            f,
2522            "{}",
2523            match self {
2524                Self::Unknown => "Unknown",
2525                Self::Enabled => "CPU Enabled",
2526                Self::UserDisabled => "CPU disabled by user through BIOS Setup",
2527                Self::BiosDisabled => "CPU disabled by BIOS (POST Error)",
2528                Self::Idle => "CPU is Idle, waiting to be enabled",
2529                Self::Other => "Other",
2530                Self::None => "A value unknown to this standard, check the raw value",
2531            }
2532        )
2533    }
2534}
2535
2536impl From<smbioslib::CpuStatus> for CpuStatus {
2537    fn from(value: smbioslib::CpuStatus) -> Self {
2538        match value {
2539            smbioslib::CpuStatus::Unknown => Self::Unknown,
2540            smbioslib::CpuStatus::Enabled => Self::Enabled,
2541            smbioslib::CpuStatus::UserDisabled => Self::UserDisabled,
2542            smbioslib::CpuStatus::BiosDisabled => Self::BiosDisabled,
2543            smbioslib::CpuStatus::Idle => Self::Idle,
2544            smbioslib::CpuStatus::Other => Self::Other,
2545            smbioslib::CpuStatus::None => Self::None,
2546        }
2547    }
2548}
2549
2550#[derive(Debug, Deserialize, Serialize, Clone)]
2551pub struct ProcessorUpgradeData {
2552    pub raw: u8,
2553    pub value: ProcessorUpgrade,
2554}
2555
2556impl From<smbioslib::ProcessorUpgradeData> for ProcessorUpgradeData {
2557    fn from(value: smbioslib::ProcessorUpgradeData) -> Self {
2558        Self {
2559            raw: value.raw,
2560            value: ProcessorUpgrade::from(value.value),
2561        }
2562    }
2563}
2564
2565#[derive(Debug, Deserialize, Serialize, Clone)]
2566pub enum ProcessorUpgrade {
2567    Other,
2568    Unknown,
2569    DaughterBoard,
2570    ZIFSocket,
2571    ReplaceablePiggyBack,
2572    NoUpgrade,
2573    LIFSocket,
2574    Slot1,
2575    Slot2,
2576    PinSocket370,
2577    SlotA,
2578    SlotM,
2579    Socket423,
2580    SocketASocket462,
2581    Socket478,
2582    Socket754,
2583    Socket940,
2584    Socket939,
2585    SocketmPGA604,
2586    SocketLGA771,
2587    SocketLGA775,
2588    SocketS1,
2589    SocketAM2,
2590    SocketF1207,
2591    SocketLGA1366,
2592    SocketG34,
2593    SocketAM3,
2594    SocketC32,
2595    SocketLGA1156,
2596    SocketLGA1567,
2597    SocketPGA988A,
2598    SocketBGA1288,
2599    SocketrPGA988B,
2600    SocketBGA1023,
2601    SocketBGA1224,
2602    SocketLGA1155,
2603    SocketLGA1356,
2604    SocketLGA2011,
2605    SocketFS1,
2606    SocketFS2,
2607    SocketFM1,
2608    SocketFM2,
2609    SocketLGA2011_3,
2610    SocketLGA1356_3,
2611    SocketLGA1150,
2612    SocketBGA1168,
2613    SocketBGA1234,
2614    SocketBGA1364,
2615    SocketAM4,
2616    SocketLGA1151,
2617    SocketBGA1356,
2618    SocketBGA1440,
2619    SocketBGA1515,
2620    SocketLGA3647_1,
2621    SocketSP3,
2622    SocketSP3r23,
2623    SocketLGA2066,
2624    SocketBGA1392,
2625    SocketBGA1510,
2626    SocketBGA1528,
2627    SocketLGA4189,
2628    SocketLGA1200,
2629    SocketLGA4677,
2630    SocketLGA1700,
2631    SocketBGA1744,
2632    SocketBGA1781,
2633    SocketBGA1211,
2634    SocketBGA2422,
2635    SocketLGA1211,
2636    SocketLGA2422,
2637    SocketLGA5773,
2638    SocketBGA5773,
2639    SocketAM5,
2640    SocketSP5,
2641    SocketSP6,
2642    SocketBGA883,
2643    SocketBGA1190,
2644    SocketBGA4129,
2645    SocketLGA4710,
2646    SocketLGA7529,
2647    None,
2648}
2649
2650impl Display for ProcessorUpgrade {
2651    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2652        write!(
2653            f,
2654            "{}",
2655            match self {
2656                Self::Other => "Other",
2657                Self::Unknown => "Unknown",
2658                Self::DaughterBoard => "Daughter Board",
2659                Self::ZIFSocket => "ZIF Socket",
2660                Self::ReplaceablePiggyBack => "Replaceable Piggy Back",
2661                Self::NoUpgrade => "No Upgrade",
2662                Self::LIFSocket => "LIF Socket",
2663                Self::Slot1 => "Slot #1",
2664                Self::Slot2 => "Slot #2",
2665                Self::SlotA => "Slot A",
2666                Self::SlotM => "Slot M",
2667                Self::PinSocket370 => "370-pin socket",
2668                Self::Socket423 => "Socket 423",
2669                Self::SocketASocket462 => "Socket A (Socket 462)",
2670                Self::Socket478 => "Socket 478",
2671                Self::Socket754 => "Socket 754",
2672                Self::Socket940 => "Socket 940",
2673                Self::Socket939 => "Socket 939",
2674                Self::SocketmPGA604 => "Socket mPGA604",
2675                Self::SocketLGA771 => "Socket LGA771",
2676                Self::SocketLGA775 => "Socket LGA775",
2677                Self::SocketS1 => "Socket S1",
2678                Self::SocketAM2 => "Socket AM2",
2679                Self::SocketF1207 => "Socket F (1207)",
2680                Self::SocketLGA1366 => "Socket LGA1366",
2681                Self::SocketG34 => "Socket G34",
2682                Self::SocketAM3 => "Socket AM3",
2683                Self::SocketC32 => "Socket C32",
2684                Self::SocketLGA1156 => "Socket LGA1156",
2685                Self::SocketLGA1567 => "Socket LGA1567",
2686                Self::SocketPGA988A => "Socket PGA988A",
2687                Self::SocketBGA1288 => "Socket BGA1288",
2688                Self::SocketrPGA988B => "Socket rPGA988B",
2689                Self::SocketBGA1023 => "Socket BGA1023",
2690                Self::SocketBGA1224 => "Socket BGA1224",
2691                Self::SocketLGA1155 => "Socket LGA1155",
2692                Self::SocketLGA1356 => "Socket LGA1356",
2693                Self::SocketLGA2011 => "Socket LGA2011",
2694                Self::SocketFS1 => "Socket FS1",
2695                Self::SocketFS2 => "Socket FS2",
2696                Self::SocketFM1 => "Socket FM1",
2697                Self::SocketFM2 => "Socket FM2",
2698                Self::SocketLGA2011_3 => "Socket LGA2011-3",
2699                Self::SocketLGA1356_3 => "Socket LGA1356-3",
2700                Self::SocketLGA1150 => "Socket LGA1150",
2701                Self::SocketBGA1168 => "Socket BGA1168",
2702                Self::SocketBGA1234 => "Socket BGA1234",
2703                Self::SocketBGA1364 => "Socket BGA1364",
2704                Self::SocketAM4 => "Socket AM4",
2705                Self::SocketLGA1151 => "Socket LGA1151",
2706                Self::SocketBGA1356 => "Socket BGA1356",
2707                Self::SocketBGA1440 => "Socket BGA1440",
2708                Self::SocketBGA1515 => "Socket BGA1515",
2709                Self::SocketLGA3647_1 => "Socket LGA3647-1",
2710                Self::SocketSP3 => "Socket SP3",
2711                Self::SocketSP3r23 => "Socket SP3r2",
2712                Self::SocketLGA2066 => "Socket LGA2066",
2713                Self::SocketBGA1392 => "Socket BGA1392",
2714                Self::SocketBGA1510 => "Socket BGA1510",
2715                Self::SocketBGA1528 => "Socket BGA1528",
2716                Self::SocketLGA4189 => "Socket LGA4189",
2717                Self::SocketLGA1200 => "Socket LGA1200",
2718                Self::SocketLGA4677 => "Socket LGA4677",
2719                Self::SocketLGA1700 => "Socket LGA1700",
2720                Self::SocketBGA1744 => "Socket BGA1744",
2721                Self::SocketBGA1781 => "Socket BGA1781",
2722                Self::SocketBGA1211 => "Socket BGA1211",
2723                Self::SocketBGA2422 => "Socket BGA2422",
2724                Self::SocketLGA1211 => "Socket LGA1211",
2725                Self::SocketLGA2422 => "Socket LGA2422",
2726                Self::SocketLGA5773 => "Socket LGA5773",
2727                Self::SocketBGA5773 => "Socket BGA5773",
2728                Self::SocketAM5 => "Socket AM5",
2729                Self::SocketSP5 => "Socket SP5",
2730                Self::SocketSP6 => "Socket SP6",
2731                Self::SocketBGA883 => "Socket BGA883",
2732                Self::SocketBGA1190 => "Socket BGA1190",
2733                Self::SocketBGA4129 => "Socket BGA4129",
2734                Self::SocketLGA4710 => "Socket LGA4710",
2735                Self::SocketLGA7529 => "Socket LGA7529",
2736                Self::None => "A value unknown to this standard, check the raw value",
2737            }
2738        )
2739    }
2740}
2741
2742impl From<smbioslib::ProcessorUpgrade> for ProcessorUpgrade {
2743    fn from(value: smbioslib::ProcessorUpgrade) -> Self {
2744        match value {
2745            smbioslib::ProcessorUpgrade::Other => Self::Other,
2746            smbioslib::ProcessorUpgrade::Unknown => Self::Unknown,
2747            smbioslib::ProcessorUpgrade::DaughterBoard => Self::DaughterBoard,
2748            smbioslib::ProcessorUpgrade::ZIFSocket => Self::ZIFSocket,
2749            smbioslib::ProcessorUpgrade::ReplaceablePiggyBack => Self::ReplaceablePiggyBack,
2750            smbioslib::ProcessorUpgrade::NoUpgrade => Self::NoUpgrade,
2751            smbioslib::ProcessorUpgrade::LIFSocket => Self::LIFSocket,
2752            smbioslib::ProcessorUpgrade::Slot1 => Self::Slot1,
2753            smbioslib::ProcessorUpgrade::Slot2 => Self::Slot2,
2754            smbioslib::ProcessorUpgrade::PinSocket370 => Self::PinSocket370,
2755            smbioslib::ProcessorUpgrade::SlotA => Self::SlotA,
2756            smbioslib::ProcessorUpgrade::SlotM => Self::SlotM,
2757            smbioslib::ProcessorUpgrade::Socket423 => Self::Socket423,
2758            smbioslib::ProcessorUpgrade::SocketASocket462 => Self::SocketASocket462,
2759            smbioslib::ProcessorUpgrade::Socket478 => Self::Socket478,
2760            smbioslib::ProcessorUpgrade::Socket754 => Self::Socket754,
2761            smbioslib::ProcessorUpgrade::Socket940 => Self::Socket940,
2762            smbioslib::ProcessorUpgrade::Socket939 => Self::Socket939,
2763            smbioslib::ProcessorUpgrade::SocketmPGA604 => Self::SocketmPGA604,
2764            smbioslib::ProcessorUpgrade::SocketLGA771 => Self::SocketLGA771,
2765            smbioslib::ProcessorUpgrade::SocketLGA775 => Self::SocketLGA775,
2766            smbioslib::ProcessorUpgrade::SocketS1 => Self::SocketS1,
2767            smbioslib::ProcessorUpgrade::SocketAM2 => Self::SocketAM2,
2768            smbioslib::ProcessorUpgrade::SocketF1207 => Self::SocketF1207,
2769            smbioslib::ProcessorUpgrade::SocketLGA1366 => Self::SocketLGA1366,
2770            smbioslib::ProcessorUpgrade::SocketG34 => Self::SocketG34,
2771            smbioslib::ProcessorUpgrade::SocketAM3 => Self::SocketAM3,
2772            smbioslib::ProcessorUpgrade::SocketC32 => Self::SocketC32,
2773            smbioslib::ProcessorUpgrade::SocketLGA1156 => Self::SocketLGA1156,
2774            smbioslib::ProcessorUpgrade::SocketLGA1567 => Self::SocketLGA1567,
2775            smbioslib::ProcessorUpgrade::SocketPGA988A => Self::SocketPGA988A,
2776            smbioslib::ProcessorUpgrade::SocketBGA1288 => Self::SocketBGA1288,
2777            smbioslib::ProcessorUpgrade::SocketrPGA988B => Self::SocketrPGA988B,
2778            smbioslib::ProcessorUpgrade::SocketBGA1023 => Self::SocketBGA1023,
2779            smbioslib::ProcessorUpgrade::SocketBGA1224 => Self::SocketBGA1224,
2780            smbioslib::ProcessorUpgrade::SocketLGA1155 => Self::SocketLGA1155,
2781            smbioslib::ProcessorUpgrade::SocketLGA1356 => Self::SocketLGA1356,
2782            smbioslib::ProcessorUpgrade::SocketLGA2011 => Self::SocketLGA2011,
2783            smbioslib::ProcessorUpgrade::SocketFS1 => Self::SocketFS1,
2784            smbioslib::ProcessorUpgrade::SocketFS2 => Self::SocketFS2,
2785            smbioslib::ProcessorUpgrade::SocketFM1 => Self::SocketFM1,
2786            smbioslib::ProcessorUpgrade::SocketFM2 => Self::SocketFM2,
2787            smbioslib::ProcessorUpgrade::SocketLGA2011_3 => Self::SocketLGA2011_3,
2788            smbioslib::ProcessorUpgrade::SocketLGA1356_3 => Self::SocketLGA1356_3,
2789            smbioslib::ProcessorUpgrade::SocketLGA1150 => Self::SocketLGA1150,
2790            smbioslib::ProcessorUpgrade::SocketBGA1168 => Self::SocketBGA1168,
2791            smbioslib::ProcessorUpgrade::SocketBGA1234 => Self::SocketBGA1234,
2792            smbioslib::ProcessorUpgrade::SocketBGA1364 => Self::SocketBGA1364,
2793            smbioslib::ProcessorUpgrade::SocketAM4 => Self::SocketAM4,
2794            smbioslib::ProcessorUpgrade::SocketLGA1151 => Self::SocketLGA1151,
2795            smbioslib::ProcessorUpgrade::SocketBGA1356 => Self::SocketBGA1356,
2796            smbioslib::ProcessorUpgrade::SocketBGA1440 => Self::SocketBGA1440,
2797            smbioslib::ProcessorUpgrade::SocketBGA1515 => Self::SocketBGA1515,
2798            smbioslib::ProcessorUpgrade::SocketLGA3647_1 => Self::SocketLGA3647_1,
2799            smbioslib::ProcessorUpgrade::SocketSP3 => Self::SocketSP3,
2800            smbioslib::ProcessorUpgrade::SocketSP3r23 => Self::SocketSP3r23,
2801            smbioslib::ProcessorUpgrade::SocketLGA2066 => Self::SocketLGA2066,
2802            smbioslib::ProcessorUpgrade::SocketBGA1392 => Self::SocketBGA1392,
2803            smbioslib::ProcessorUpgrade::SocketBGA1510 => Self::SocketBGA1510,
2804            smbioslib::ProcessorUpgrade::SocketBGA1528 => Self::SocketBGA1528,
2805            smbioslib::ProcessorUpgrade::SocketLGA4189 => Self::SocketLGA4189,
2806            smbioslib::ProcessorUpgrade::SocketLGA1200 => Self::SocketLGA1200,
2807            smbioslib::ProcessorUpgrade::SocketLGA4677 => Self::SocketLGA4677,
2808            smbioslib::ProcessorUpgrade::SocketLGA1700 => Self::SocketLGA1700,
2809            smbioslib::ProcessorUpgrade::SocketBGA1744 => Self::SocketBGA1744,
2810            smbioslib::ProcessorUpgrade::SocketBGA1781 => Self::SocketBGA1781,
2811            smbioslib::ProcessorUpgrade::SocketBGA1211 => Self::SocketBGA1211,
2812            smbioslib::ProcessorUpgrade::SocketBGA2422 => Self::SocketBGA2422,
2813            smbioslib::ProcessorUpgrade::SocketLGA1211 => Self::SocketLGA1211,
2814            smbioslib::ProcessorUpgrade::SocketLGA2422 => Self::SocketLGA2422,
2815            smbioslib::ProcessorUpgrade::SocketLGA5773 => Self::SocketLGA5773,
2816            smbioslib::ProcessorUpgrade::SocketBGA5773 => Self::SocketBGA5773,
2817            smbioslib::ProcessorUpgrade::SocketAM5 => Self::SocketAM5,
2818            smbioslib::ProcessorUpgrade::SocketSP5 => Self::SocketSP5,
2819            smbioslib::ProcessorUpgrade::SocketSP6 => Self::SocketSP6,
2820            smbioslib::ProcessorUpgrade::SocketBGA883 => Self::SocketBGA883,
2821            smbioslib::ProcessorUpgrade::SocketBGA1190 => Self::SocketBGA1190,
2822            smbioslib::ProcessorUpgrade::SocketBGA4129 => Self::SocketBGA4129,
2823            smbioslib::ProcessorUpgrade::SocketLGA4710 => Self::SocketLGA4710,
2824            smbioslib::ProcessorUpgrade::SocketLGA7529 => Self::SocketLGA7529,
2825            smbioslib::ProcessorUpgrade::None => Self::None,
2826        }
2827    }
2828}
2829
2830#[derive(Debug, Deserialize, Serialize, Clone)]
2831pub enum CoreCount {
2832    Unknown,
2833    Count(u8),
2834    SeeCoreCount2,
2835}
2836
2837impl Display for CoreCount {
2838    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2839        match self {
2840            Self::Unknown => write!(f, "Unknown"),
2841            Self::SeeCoreCount2 => write!(f, "See next core count entry"),
2842            Self::Count(cnt) => write!(f, "{}", cnt),
2843        }
2844    }
2845}
2846
2847impl From<smbioslib::CoreCount> for CoreCount {
2848    fn from(value: smbioslib::CoreCount) -> Self {
2849        match value {
2850            smbioslib::CoreCount::Unknown => Self::Unknown,
2851            smbioslib::CoreCount::SeeCoreCount2 => Self::SeeCoreCount2,
2852            smbioslib::CoreCount::Count(cnt) => Self::Count(cnt),
2853        }
2854    }
2855}
2856
2857#[derive(Debug, Deserialize, Serialize, Clone)]
2858pub enum CoreCount2 {
2859    Unknown,
2860    Count(u16),
2861    Reserved,
2862}
2863
2864impl Display for CoreCount2 {
2865    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2866        match self {
2867            Self::Unknown => write!(f, "Unknown"),
2868            Self::Reserved => write!(f, "Reserved"),
2869            Self::Count(cnt) => write!(f, "{}", cnt),
2870        }
2871    }
2872}
2873
2874impl From<smbioslib::CoreCount2> for CoreCount2 {
2875    fn from(value: smbioslib::CoreCount2) -> Self {
2876        match value {
2877            smbioslib::CoreCount2::Unknown => Self::Unknown,
2878            smbioslib::CoreCount2::Reserved => Self::Reserved,
2879            smbioslib::CoreCount2::Count(cnt) => Self::Count(cnt),
2880        }
2881    }
2882}
2883
2884#[derive(Debug, Deserialize, Serialize, Clone)]
2885pub enum CoresEnabled {
2886    Unknown,
2887    Count(u8),
2888    SeeCoresEnabled2,
2889}
2890
2891impl Display for CoresEnabled {
2892    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2893        match self {
2894            Self::Unknown => write!(f, "Unknown"),
2895            Self::SeeCoresEnabled2 => write!(f, "See next cores enabled entry"),
2896            Self::Count(cnt) => write!(f, "{}", cnt),
2897        }
2898    }
2899}
2900
2901impl From<smbioslib::CoresEnabled> for CoresEnabled {
2902    fn from(value: smbioslib::CoresEnabled) -> Self {
2903        match value {
2904            smbioslib::CoresEnabled::Unknown => Self::Unknown,
2905            smbioslib::CoresEnabled::SeeCoresEnabled2 => Self::SeeCoresEnabled2,
2906            smbioslib::CoresEnabled::Count(cnt) => Self::Count(cnt),
2907        }
2908    }
2909}
2910
2911#[derive(Debug, Deserialize, Serialize, Clone)]
2912pub enum CoresEnabled2 {
2913    Unknown,
2914    Count(u16),
2915    Reserved,
2916}
2917
2918impl Display for CoresEnabled2 {
2919    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2920        match self {
2921            Self::Unknown => write!(f, "Unknown"),
2922            Self::Reserved => write!(f, "Reserved"),
2923            Self::Count(cnt) => write!(f, "{}", cnt),
2924        }
2925    }
2926}
2927
2928impl From<smbioslib::CoresEnabled2> for CoresEnabled2 {
2929    fn from(value: smbioslib::CoresEnabled2) -> Self {
2930        match value {
2931            smbioslib::CoresEnabled2::Unknown => Self::Unknown,
2932            smbioslib::CoresEnabled2::Reserved => Self::Reserved,
2933            smbioslib::CoresEnabled2::Count(cnt) => Self::Count(cnt),
2934        }
2935    }
2936}
2937
2938#[derive(Debug, Deserialize, Serialize, Clone)]
2939pub enum ThreadCount {
2940    Unknown,
2941    Count(u8),
2942    SeeThreadCount2,
2943}
2944
2945impl Display for ThreadCount {
2946    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2947        match self {
2948            Self::Unknown => write!(f, "Unknown"),
2949            Self::SeeThreadCount2 => write!(f, "See next thread enabled entry"),
2950            Self::Count(cnt) => write!(f, "{}", cnt),
2951        }
2952    }
2953}
2954
2955impl From<smbioslib::ThreadCount> for ThreadCount {
2956    fn from(value: smbioslib::ThreadCount) -> Self {
2957        match value {
2958            smbioslib::ThreadCount::SeeThreadCount2 => Self::SeeThreadCount2,
2959            smbioslib::ThreadCount::Unknown => Self::Unknown,
2960            smbioslib::ThreadCount::Count(cnt) => Self::Count(cnt),
2961        }
2962    }
2963}
2964
2965#[derive(Debug, Deserialize, Serialize, Clone)]
2966pub enum ThreadCount2 {
2967    Unknown,
2968    Count(u16),
2969    Reserved,
2970}
2971
2972impl Display for ThreadCount2 {
2973    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2974        match self {
2975            Self::Unknown => write!(f, "Unknown"),
2976            Self::Reserved => write!(f, "Reserved"),
2977            Self::Count(cnt) => write!(f, "{}", cnt),
2978        }
2979    }
2980}
2981
2982impl From<smbioslib::ThreadCount2> for ThreadCount2 {
2983    fn from(value: smbioslib::ThreadCount2) -> Self {
2984        match value {
2985            smbioslib::ThreadCount2::Reserved => Self::Reserved,
2986            smbioslib::ThreadCount2::Unknown => Self::Unknown,
2987            smbioslib::ThreadCount2::Count(cnt) => Self::Count(cnt),
2988        }
2989    }
2990}
2991
2992#[derive(Debug, Deserialize, Serialize, Clone)]
2993pub enum ThreadEnabled {
2994    Unknown,
2995    Count(u16),
2996    Reserved,
2997}
2998
2999impl Display for ThreadEnabled {
3000    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3001        match self {
3002            Self::Unknown => write!(f, "Unknown"),
3003            Self::Reserved => write!(f, "Reserved"),
3004            Self::Count(cnt) => write!(f, "{}", cnt),
3005        }
3006    }
3007}
3008
3009impl From<smbioslib::ThreadEnabled> for ThreadEnabled {
3010    fn from(value: smbioslib::ThreadEnabled) -> Self {
3011        match value {
3012            smbioslib::ThreadEnabled::Reserved => Self::Reserved,
3013            smbioslib::ThreadEnabled::Unknown => Self::Unknown,
3014            smbioslib::ThreadEnabled::Count(cnt) => Self::Count(cnt),
3015        }
3016    }
3017}
3018
3019/// Attributes of each CPU cache device in the system
3020#[derive(Debug, Serialize)]
3021pub struct Caches {
3022    pub caches: Vec<Cache>,
3023}
3024
3025impl Caches {
3026    /// Creates a new instance of `Self`
3027    ///
3028    /// It is usually not required, since an instance of this
3029    /// structure will be created using the method
3030    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
3031    /// [`DMITable::new()`].
3032    pub fn new() -> Result<Self> {
3033        let table = smbioslib::table_load_from_device()?;
3034        Self::new_from_table(&table)
3035    }
3036
3037    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
3038        let mut caches = vec![];
3039
3040        for cache_device in table.collect::<smbioslib::SMBiosCacheInformation>() {
3041            caches.push(Cache::from(cache_device));
3042        }
3043
3044        Ok(Self { caches })
3045    }
3046}
3047
3048impl ToJson for Caches {}
3049
3050// struct_migrate!(CacheConfiguration, smbioslib::CacheConfiguaration, {
3051//     raw: u16,
3052// });
3053
3054#[derive(Debug, Serialize)]
3055pub struct CacheConfiguaration {
3056    pub raw: u16,
3057}
3058
3059/// This structure defines the attributes of CPU cache device in the
3060/// system. One structure is specified for each such device, whether
3061/// the device is internal to or external to the CPU module.
3062#[derive(Debug, Serialize)]
3063pub struct Cache {
3064    /// String number for reference designation
3065    pub socket_designation: Option<String>,
3066
3067    /// Bit fields describing the cache configuration
3068    pub cache_configuration: Option<CacheConfiguaration>,
3069
3070    /// Maximum size that can be installed
3071    pub maximum_cache_size: Option<smbioslib::CacheMemorySize>,
3072
3073    /// Same format as Max Cache Size field; set 0 if no cache
3074    /// is installed.
3075    pub installed_size: Option<smbioslib::CacheMemorySize>,
3076
3077    /// Supported SRAM type
3078    pub supported_sram_type: Option<smbioslib::SramTypes>,
3079
3080    /// Current SRAM type
3081    pub current_sram_type: Option<smbioslib::SramTypes>,
3082
3083    /// Cache module speed, in nanosecs. The value is 0 if the
3084    /// speed is unknown
3085    pub cache_speed: Option<u8>,
3086
3087    /// Error-correction scheme supported by this cache component
3088    pub error_correction_type: Option<smbioslib::ErrorCorrectionTypeData>,
3089
3090    /// Logical type of cache
3091    pub system_cache_type: Option<smbioslib::SystemCacheTypeData>,
3092
3093    /// Associativity of the cache
3094    pub associativity: Option<smbioslib::CacheAssociativityData>,
3095
3096    /// Maximum cache size
3097    pub maximum_cache_size_2: Option<smbioslib::CacheMemorySize>,
3098
3099    /// Installed cache size
3100    pub installed_cache_size_2: Option<smbioslib::CacheMemorySize>,
3101}
3102
3103impl<'a> From<smbioslib::SMBiosCacheInformation<'a>> for Cache {
3104    fn from(value: smbioslib::SMBiosCacheInformation) -> Self {
3105        Self {
3106            socket_designation: value.socket_designation().ok(),
3107            cache_configuration: match value.cache_configuration() {
3108                Some(conf) => Some(CacheConfiguaration { raw: conf.raw }),
3109                None => None,
3110            },
3111            maximum_cache_size: value.maximum_cache_size(),
3112            installed_size: value.installed_size(),
3113            supported_sram_type: value.supported_sram_type(),
3114            current_sram_type: value.current_sram_type(),
3115            cache_speed: value.cache_speed(),
3116            error_correction_type: value.error_correction_type(),
3117            system_cache_type: value.system_cache_type(),
3118            associativity: value.associativity(),
3119            maximum_cache_size_2: value.maximum_cache_size_2(),
3120            installed_cache_size_2: value.installed_cache_size_2(),
3121        }
3122    }
3123}
3124impl ToJson for Cache {}
3125
3126/// Attributes of a system port connectors
3127#[derive(Debug, Serialize)]
3128pub struct PortConnectors {
3129    pub ports: Vec<Port>,
3130}
3131
3132impl PortConnectors {
3133    /// Creates a new instance of `Self`
3134    ///
3135    /// It is usually not required, since an instance of this
3136    /// structure will be created using the method
3137    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
3138    /// [`DMITable::new()`].
3139    pub fn new() -> Result<Self> {
3140        let table = smbioslib::table_load_from_device()?;
3141        Self::new_from_table(&table)
3142    }
3143
3144    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
3145        let mut ports = vec![];
3146
3147        for port in table.collect::<smbioslib::SMBiosPortConnectorInformation>() {
3148            ports.push(Port::from(port));
3149        }
3150
3151        Ok(Self { ports })
3152    }
3153}
3154
3155impl ToJson for PortConnectors {}
3156
3157/// Attributes of a system port connector (serial, parallel,
3158/// keyboard or mouse ports)
3159#[derive(Debug, Serialize)]
3160pub struct Port {
3161    /// Internal reference designator, that is, internal to the
3162    /// system enclosure
3163    pub internal_reference_designator: Option<String>,
3164
3165    /// Internal connector type
3166    pub internal_connector_type: Option<smbioslib::PortInformationConnectorTypeData>,
3167
3168    /// External reference designation, external to the system
3169    /// enclosure
3170    pub external_reference_designator: Option<String>,
3171
3172    /// External connector type
3173    pub external_connector_type: Option<smbioslib::PortInformationConnectorTypeData>,
3174
3175    /// Function of the port
3176    pub port_type: Option<smbioslib::PortInformationPortTypeData>,
3177}
3178
3179impl<'a> From<smbioslib::SMBiosPortConnectorInformation<'a>> for Port {
3180    fn from(value: smbioslib::SMBiosPortConnectorInformation) -> Self {
3181        Self {
3182            internal_reference_designator: value.internal_reference_designator().ok(),
3183            internal_connector_type: value.internal_connector_type(),
3184            external_reference_designator: value.external_reference_designator().ok(),
3185            external_connector_type: value.external_connector_type(),
3186            port_type: value.port_type(),
3187        }
3188    }
3189}
3190impl ToJson for Port {}
3191
3192/// Collection of memory devices that operate together to form a memory address space
3193#[derive(Debug, Serialize)]
3194pub struct MemoryArray {
3195    /// Physical location of the Memory Array, whether on the system
3196    /// board or an add-in board
3197    pub location: Option<smbioslib::MemoryArrayLocationData>,
3198
3199    /// Which the array is used
3200    pub usage: Option<smbioslib::MemoryArrayUseData>,
3201
3202    /// Primary hardware error correction or detection method
3203    /// supported by this memory array
3204    pub memory_error_correction: Option<smbioslib::MemoryArrayErrorCorrectionData>,
3205
3206    /// Maximum memory capacity, in kbytes, for this array
3207    pub maximum_capacity: Option<smbioslib::MaximumMemoryCapacity>,
3208
3209    /// Handle, or instance number, associated with any error that
3210    /// was previously detected for the array
3211    pub memory_error_information_handle: Option<smbioslib::Handle>,
3212
3213    /// Number of slots/sockets available for memory devices in
3214    /// this array
3215    pub number_of_memory_devices: Option<u16>,
3216
3217    /// Maximum memory capacity, in bytes, for this array. This
3218    /// field is only valid when the Maximum Capacity field
3219    /// contains 8000 0000h.
3220    pub extended_maximum_capacity: Option<u64>,
3221}
3222
3223impl MemoryArray {
3224    /// Creates a new instance of `Self`
3225    ///
3226    /// It is usually not required, since an instance of this
3227    /// structure will be created using the method
3228    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
3229    /// [`DMITable::new()`].
3230    pub fn new() -> Result<Self> {
3231        let table = smbioslib::table_load_from_device()?;
3232        Self::new_from_table(&table)
3233    }
3234
3235    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
3236        let t = table
3237            .find_map(|f: smbioslib::SMBiosPhysicalMemoryArray| Some(f))
3238            .ok_or(anyhow!(
3239                "Failed to get information about memory array (type 16)!"
3240            ))?;
3241
3242        Ok(Self {
3243            location: t.location(),
3244            usage: t.usage(),
3245            memory_error_correction: t.memory_error_correction(),
3246            maximum_capacity: t.maximum_capacity(),
3247            memory_error_information_handle: t.memory_error_information_handle(),
3248            number_of_memory_devices: t.number_of_memory_devices(),
3249            extended_maximum_capacity: t.extended_maximum_capacity(),
3250        })
3251    }
3252}
3253
3254impl ToJson for MemoryArray {}
3255
3256/// Information about all installed memory devices
3257#[derive(Debug, Serialize)]
3258pub struct MemoryDevices {
3259    pub memory: Vec<MemoryDevice>,
3260}
3261
3262impl MemoryDevices {
3263    /// Creates a new instance of `Self`
3264    ///
3265    /// It is usually not required, since an instance of this
3266    /// structure will be created using the method
3267    /// `Self::new_from_table(table: &SMBiosData)` in the constructor
3268    /// [`DMITable::new()`].
3269    pub fn new() -> Result<Self> {
3270        let table = smbioslib::table_load_from_device()?;
3271        Self::new_from_table(&table)
3272    }
3273
3274    pub fn new_from_table(table: &SMBiosData) -> Result<Self> {
3275        let mut memory = vec![];
3276
3277        for mem in table.collect::<smbioslib::SMBiosMemoryDevice>() {
3278            memory.push(MemoryDevice::from(mem));
3279        }
3280
3281        Ok(Self { memory })
3282    }
3283}
3284
3285impl ToJson for MemoryDevices {}
3286
3287/// Information about single memory device
3288#[derive(Debug, Serialize)]
3289pub struct MemoryDevice {
3290    /// Handle or instance number, associated with the physical
3291    /// memory array to which this device belongs
3292    pub physical_memory_array_handle: Option<smbioslib::Handle>,
3293
3294    /// Handle or instance number, associated with any error that
3295    /// was previously detected for the device. If the system does
3296    /// not provide the error information structure, the field
3297    /// containes FFFEH
3298    pub memory_error_information_handle: Option<smbioslib::Handle>,
3299
3300    /// Total width, in bits, of this memory device, including any
3301    /// check or error-correction bits
3302    pub total_width: Option<u16>,
3303
3304    /// Data width, in bits, of this memory device
3305    pub data_width: Option<u16>,
3306
3307    /// Size of memory device
3308    pub size: Option<smbioslib::MemorySize>,
3309
3310    /// Form factor for this memory device
3311    pub form_factor: Option<smbioslib::MemoryFormFactorData>,
3312
3313    /// Identifies when the Memory Device is one of a set of
3314    /// Memory Devices that must be populated with all devices
3315    /// of the same type and size, and the set to which this
3316    /// device belongs A value of 0 indicates that the device
3317    /// is not part of a set; a value of FFh indicates that the
3318    /// attribute is unknown
3319    pub device_set: Option<u8>,
3320
3321    /// Physically-labeled socket or board position where the
3322    /// memory device is located
3323    pub device_locator: Option<String>,
3324
3325    /// Physically-labeled bank where the memory device is located
3326    pub bank_locator: Option<String>,
3327
3328    /// Type of memory used in this device
3329    pub memory_type: Option<smbioslib::MemoryDeviceTypeData>,
3330
3331    /// Additional detail on the memory device type
3332    pub type_detail: Option<smbioslib::MemoryTypeDetails>,
3333
3334    /// The maximum capable speed of the device (MT/s)
3335    pub speed: Option<smbioslib::MemorySpeed>,
3336
3337    /// Manufacturer of this memory device
3338    pub manufacturer: Option<String>,
3339
3340    /// Serial number of this memory device
3341    pub serial_number: Option<String>,
3342
3343    /// Asset tag of this memory device
3344    pub asset_tag: Option<String>,
3345
3346    /// Part number of this memory device
3347    pub part_number: Option<String>,
3348
3349    /// Bits 7-4: reserved Bits 3-0: rank Value=0 for unknown rank information
3350    pub attributes: Option<u8>,
3351
3352    /// Extended suze of the memory device in MB
3353    pub extended_size: Option<smbioslib::MemorySizeExtended>,
3354
3355    /// Configured speed of the memory device, in megatransfers per second (MT/s)
3356    pub configured_memory_speed: Option<smbioslib::MemorySpeed>,
3357
3358    /// Minimum operating voltage for this device, in millivolts
3359    pub minimum_voltage: Option<u16>,
3360
3361    /// Maximum operating voltage for this device, in millivolts
3362    pub maximum_voltage: Option<u16>,
3363
3364    /// Configured voltage for this device, in millivolts
3365    pub configured_voltage: Option<u16>,
3366
3367    /// Memory technology type for this memory device
3368    pub memory_technology: Option<smbioslib::MemoryDeviceTechnologyData>,
3369
3370    /// The operating modes supported by this memory device
3371    pub memory_operating_mode_capability: Option<smbioslib::MemoryOperatingModeCapabilities>,
3372
3373    /// Firmware version of this memory device
3374    pub firmware_version: Option<String>,
3375
3376    /// Two-byte module manufacturer ID found in the SPD of this
3377    /// memory device; LSB first
3378    pub module_manufacturer_id: Option<u16>,
3379
3380    /// Two-byte module product id found in the SPD of this memory
3381    /// device; LSB first
3382    pub module_product_id: Option<u16>,
3383
3384    /// Two-byte memory subsystem controller manufacturer ID found
3385    /// in the SPD of this memory device; LSB first
3386    pub memory_subsystem_controller_manufacturer_id: Option<u16>,
3387
3388    /// Two-byte memory subsystem controller product ID found in
3389    /// the SPD of this memory device; LSB first
3390    pub memory_subsystem_controller_product_id: Option<u16>,
3391
3392    /// Size of the Non-volatile portion of the memory device in
3393    /// Bytes, if any
3394    pub non_volatile_size: Option<smbioslib::MemoryIndicatedSize>,
3395
3396    /// Size of the Volatile portion of the memory device in
3397    /// Bytes, if any
3398    pub volatile_size: Option<smbioslib::MemoryIndicatedSize>,
3399
3400    /// Size of the Cache portion of the memory device in Bytes,
3401    /// if any
3402    pub cache_size: Option<smbioslib::MemoryIndicatedSize>,
3403
3404    /// Size of the Logical memory device in Bytes
3405    pub logical_size: Option<smbioslib::MemoryIndicatedSize>,
3406
3407    /// Extended speed of the memory device (complements the
3408    /// Speed field at offset 15h). Identifies the maximum capable
3409    /// speed of the device, in MT/s
3410    pub extended_speed: Option<smbioslib::MemorySpeedExtended>,
3411
3412    /// Extended configured memory speed of the memory device
3413    /// (complements the `configure_memory_speed` field at offset
3414    /// 20h). Identifies the configured speed of the memory device,
3415    /// in MT/s
3416    pub extended_configured_speed: Option<smbioslib::MemorySpeedExtended>,
3417
3418    /// Two-byte PMIC0 manufacturer ID found in the SPD of this
3419    /// memory device; LSB first
3420    pub pmic0_manufacturer_id: Option<u16>,
3421
3422    /// PMIC 0 Revision Number found in the SPD of this memory
3423    /// device
3424    pub pmic0_revision_number: Option<u16>,
3425
3426    /// Two-byte RCD manufacturer ID found in the SPD of this
3427    /// memory device; LSB first
3428    pub rcd_manufacturer_id: Option<u16>,
3429
3430    /// RCD 0 Revision Number found in the SPD of this memory
3431    /// device
3432    pub rcd_revision_number: Option<u16>,
3433}
3434
3435impl<'a> From<smbioslib::SMBiosMemoryDevice<'a>> for MemoryDevice {
3436    fn from(value: smbioslib::SMBiosMemoryDevice) -> Self {
3437        Self {
3438            physical_memory_array_handle: value.physical_memory_array_handle(),
3439            memory_error_information_handle: value.memory_error_information_handle(),
3440            total_width: value.total_width(),
3441            data_width: value.data_width(),
3442            size: value.size(),
3443            form_factor: value.form_factor(),
3444            device_set: value.device_set(),
3445            device_locator: value.device_locator().ok(),
3446            bank_locator: value.bank_locator().ok(),
3447            memory_type: value.memory_type(),
3448            type_detail: value.type_detail(),
3449            speed: value.speed(),
3450            manufacturer: value.manufacturer().ok(),
3451            serial_number: value.serial_number().ok(),
3452            asset_tag: value.asset_tag().ok(),
3453            part_number: value.part_number().ok(),
3454            attributes: value.attributes(),
3455            extended_size: value.extended_size(),
3456            configured_memory_speed: value.configured_memory_speed(),
3457            minimum_voltage: value.minimum_voltage(),
3458            maximum_voltage: value.maximum_voltage(),
3459            configured_voltage: value.configured_voltage(),
3460            memory_technology: value.memory_technology(),
3461            memory_operating_mode_capability: value.memory_operating_mode_capability(),
3462            firmware_version: value.firmware_version().ok(),
3463            module_manufacturer_id: value.module_manufacturer_id(),
3464            module_product_id: value.module_product_id(),
3465            memory_subsystem_controller_manufacturer_id: value
3466                .memory_subsystem_controller_manufacturer_id(),
3467            memory_subsystem_controller_product_id: value.memory_subsystem_controller_product_id(),
3468            non_volatile_size: value.non_volatile_size(),
3469            volatile_size: value.volatile_size(),
3470            cache_size: value.cache_size(),
3471            logical_size: value.logical_size(),
3472            extended_speed: value.extended_speed(),
3473            extended_configured_speed: value.extended_speed(),
3474            pmic0_manufacturer_id: value.pmic0_manufacturer_id(),
3475            pmic0_revision_number: value.pmic0_revision_number(),
3476            rcd_manufacturer_id: value.rcd_manufacturer_id(),
3477            rcd_revision_number: value.rcd_revision_number(),
3478        }
3479    }
3480}
3481impl ToJson for MemoryDevice {}