bnr_xfs/history/
system_restart_history.rs1use crate::create_xfs_struct;
2use crate::xfs::method_response::XfsMethodResponse;
3use crate::{
4 BillIntakeCoverCount, CashModulesLockCount, Error, InternalResetCount,
5 InternalResetWithBillStoppedCount, PowerDownWithBillStoppedCount, PowerUpCount,
6 RecognitionSensorCoverCount, Result, SpineCoverCount, SystemOpeningCount, WithBillStoppedCount,
7};
8
9create_xfs_struct!(
10 SystemOpeningDetails,
11 "systemOpeningDetails",
12 [
13 with_bill_stopped_count: WithBillStoppedCount,
14 cash_modules_lock_count: CashModulesLockCount,
15 bill_intake_cover_count: BillIntakeCoverCount,
16 recognition_sensor_cover_count: RecognitionSensorCoverCount,
17 spine_cover_count: SpineCoverCount
18 ],
19 "Represents the system opening details."
20);
21
22create_xfs_struct!(
23 SystemRestartHistory,
24 "systemRestartHistory",
25 [
26 power_up_count: PowerUpCount,
27 power_down_with_bill_stopped_count: PowerDownWithBillStoppedCount,
28 internal_reset_count: InternalResetCount,
29 internal_reset_with_bill_stopped_count: InternalResetWithBillStoppedCount,
30 system_opening_count: SystemOpeningCount,
31 system_opening_details: SystemOpeningDetails
32 ],
33 "Represents the history of system restart events."
34);
35
36impl TryFrom<&XfsMethodResponse> for SystemRestartHistory {
37 type Error = Error;
38
39 fn try_from(val: &XfsMethodResponse) -> Result<Self> {
40 val.as_params()?
41 .params()
42 .iter()
43 .map(|m| m.inner())
44 .find(|m| m.value().xfs_struct().is_some())
45 .ok_or(Error::Xfs(format!(
46 "Expected SystemRestartHistory XfsMethodResponse, have: {val}"
47 )))?
48 .value()
49 .try_into()
50 }
51}
52
53impl TryFrom<XfsMethodResponse> for SystemRestartHistory {
54 type Error = Error;
55
56 fn try_from(val: XfsMethodResponse) -> Result<Self> {
57 (&val).try_into()
58 }
59}