1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
use crate::{SMBiosStruct, UndefinedStruct};
use serde::{ser::SerializeStruct, Serialize, Serializer};
use std::fmt;
pub struct SMBiosSystemPowerControls<'a> {
parts: &'a UndefinedStruct,
}
impl<'a> SMBiosStruct<'a> for SMBiosSystemPowerControls<'a> {
const STRUCT_TYPE: u8 = 25u8;
fn new(parts: &'a UndefinedStruct) -> Self {
Self { parts }
}
fn parts(&self) -> &'a UndefinedStruct {
self.parts
}
}
impl<'a> SMBiosSystemPowerControls<'a> {
pub fn next_scheduled_power_on_month(&self) -> Option<u8> {
self.parts.get_field_byte(0x04)
}
pub fn next_scheduled_power_on_day_of_month(&self) -> Option<u8> {
self.parts.get_field_byte(0x05)
}
pub fn next_scheduled_power_on_hour(&self) -> Option<u8> {
self.parts.get_field_byte(0x06)
}
pub fn next_scheduled_power_on_minute(&self) -> Option<u8> {
self.parts.get_field_byte(0x07)
}
pub fn next_scheduled_power_on_second(&self) -> Option<u8> {
self.parts.get_field_byte(0x08)
}
}
impl fmt::Debug for SMBiosSystemPowerControls<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<SMBiosSystemPowerControls<'_>>())
.field("header", &self.parts.header)
.field(
"next_scheduled_power_on_month",
&self.next_scheduled_power_on_month(),
)
.field(
"next_scheduled_power_on_day_of_month",
&self.next_scheduled_power_on_day_of_month(),
)
.field(
"next_scheduled_power_on_hour",
&self.next_scheduled_power_on_hour(),
)
.field(
"next_scheduled_power_on_minute",
&self.next_scheduled_power_on_minute(),
)
.field(
"next_scheduled_power_on_second",
&self.next_scheduled_power_on_second(),
)
.finish()
}
}
impl Serialize for SMBiosSystemPowerControls<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("SMBiosSystemPowerControls", 6)?;
state.serialize_field("header", &self.parts.header)?;
state.serialize_field(
"next_scheduled_power_on_month",
&self.next_scheduled_power_on_month(),
)?;
state.serialize_field(
"next_scheduled_power_on_day_of_month",
&self.next_scheduled_power_on_day_of_month(),
)?;
state.serialize_field(
"next_scheduled_power_on_hour",
&self.next_scheduled_power_on_hour(),
)?;
state.serialize_field(
"next_scheduled_power_on_minute",
&self.next_scheduled_power_on_minute(),
)?;
state.serialize_field(
"next_scheduled_power_on_second",
&self.next_scheduled_power_on_second(),
)?;
state.end()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unit_test() {
let struct_type25 = vec![
0x19, 0x09, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
let parts = UndefinedStruct::new(&struct_type25);
let test_struct = SMBiosSystemPowerControls::new(&parts);
assert_eq!(test_struct.next_scheduled_power_on_month(), Some(0));
assert_eq!(test_struct.next_scheduled_power_on_day_of_month(), Some(0));
assert_eq!(test_struct.next_scheduled_power_on_hour(), Some(0));
assert_eq!(test_struct.next_scheduled_power_on_minute(), Some(0));
assert_eq!(test_struct.next_scheduled_power_on_second(), Some(0));
}
}