sysfs_class/
dmi.rs

1use crate::SysClass;
2use std::io::Result;
3use std::path::{Path, PathBuf};
4
5const BASE_PATH: &str = "/sys/class/dmi/id";
6
7/// Provides BIOS, Board, Chassis, Product, & Vendor identifiers
8#[derive(Clone)]
9pub struct DmiId {
10    path: &'static Path,
11}
12
13impl Default for DmiId {
14    fn default() -> Self {
15        Self {
16            path: Path::new(BASE_PATH),
17        }
18    }
19}
20
21impl SysClass for DmiId {
22    fn class() -> &'static str {
23        "dmi/id"
24    }
25
26    unsafe fn from_path_unchecked(_path: PathBuf) -> Self {
27        Self::default()
28    }
29
30    fn path(&self) -> &Path {
31        self.path
32    }
33}
34
35impl DmiId {
36    method!(bios_date read_file String);
37
38    method!(bios_vendor read_file String);
39
40    method!(bios_version read_file String);
41
42    method!(board_asset_tag read_file String);
43
44    method!(board_name read_file String);
45
46    method!(board_serial read_file String);
47
48    method!(board_vendor read_file String);
49
50    method!(board_version read_file String);
51
52    method!(chassis_asset_tag read_file String);
53
54    method!(chassis_name read_file String);
55
56    method!(chassis_serial read_file String);
57
58    method!(chassis_vendor read_file String);
59
60    method!(chassis_version read_file String);
61
62    method!(modalias read_file String);
63
64    method!(product_family read_file String);
65
66    method!(product_name read_file String);
67
68    method!(product_serial read_file String);
69
70    method!(product_sku read_file String);
71
72    method!(product_uuid read_file String);
73
74    method!(product_version read_file String);
75
76    method!(sys_vendor read_file String);
77}