1use std::fmt;
2
3use crate::impl_xfs_enum;
4
5pub const LCU_DISPENSE: u32 = 6016;
6pub const LCU_DEPOSIT: u32 = 6017;
7pub const LCU_RECYCLE: u32 = 6018;
8pub const LCU_NA: u32 = 6019;
9pub const LCU_BAIT_TRAP: u32 = 6020;
10pub const LCU_REJECT_CASSETTE: u32 = 6021;
11pub const LCU_OVERFLOW_CASSETTE: u32 = 6022;
12pub const LCU_BILL_CASSETTE: u32 = 6023;
13pub const LCU_COIN_CYLINDER: u32 = 6024;
14pub const LCU_COIN_DISPENSER: u32 = 6025;
15pub const LCU_RETRACT_CASSETTE: u32 = 6026;
16pub const LCU_COUPON: u32 = 6027;
17pub const LCU_DOCUMENT: u32 = 6028;
18pub const LCU_ESCROW: u32 = 6029;
19pub const LCU_UNKNOWN: u32 = 6030;
20pub const LCU_OK: u32 = 6031;
21pub const LCU_FULL: u32 = 6032;
22pub const LCU_HIGH: u32 = 6033;
23pub const LCU_LOW: u32 = 6034;
24pub const LCU_EMPTY: u32 = 6035;
25pub const LCU_INOP: u32 = 6036;
26pub const LCU_MISSING: u32 = 6037;
27pub const LCU_NO_VALUE: u32 = 6038;
28pub const LCU_NO_REF: u32 = 6039;
29pub const LCU_NOT_DISPENSABLE: u32 = 6040;
30pub const LCU_CURRENCY_CASSETTE: u32 = 6059;
31
32#[repr(u32)]
34#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
35pub enum CuKind {
36 #[default]
37 NotAvailable = LCU_NA,
38 Deposit = LCU_DEPOSIT,
39 Dispense = LCU_DISPENSE,
40 Recycle = LCU_RECYCLE,
41}
42
43impl CuKind {
44 pub const fn new() -> Self {
46 Self::NotAvailable
47 }
48
49 pub const fn create(val: u32) -> Self {
51 match val {
52 LCU_NA => Self::NotAvailable,
53 LCU_DEPOSIT => Self::Deposit,
54 LCU_DISPENSE => Self::Dispense,
55 LCU_RECYCLE => Self::Recycle,
56 _ => Self::NotAvailable,
57 }
58 }
59}
60
61impl From<&CuKind> for &'static str {
62 fn from(val: &CuKind) -> Self {
63 match val {
64 CuKind::NotAvailable => "N/A",
65 CuKind::Deposit => "deposit",
66 CuKind::Dispense => "dispense",
67 CuKind::Recycle => "recycle",
68 }
69 }
70}
71
72impl From<CuKind> for &'static str {
73 fn from(val: CuKind) -> Self {
74 (&val).into()
75 }
76}
77
78impl fmt::Display for CuKind {
79 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
80 write!(f, r#""{}""#, <&str>::from(self))
81 }
82}
83
84impl_xfs_enum!(CuKind, "kind");
85
86#[repr(u32)]
88#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
89pub enum CuType {
90 #[default]
91 NotAvailable = LCU_NA,
92 BillCassette = LCU_BILL_CASSETTE,
93 RejectCassette = LCU_REJECT_CASSETTE,
94}
95
96impl CuType {
97 pub const fn new() -> Self {
99 Self::NotAvailable
100 }
101
102 pub const fn create(val: u32) -> Self {
104 match val {
105 LCU_NA => Self::NotAvailable,
106 LCU_BILL_CASSETTE => Self::BillCassette,
107 LCU_REJECT_CASSETTE => Self::RejectCassette,
108 _ => Self::NotAvailable,
109 }
110 }
111}
112
113impl From<&CuType> for &'static str {
114 fn from(val: &CuType) -> Self {
115 match val {
116 CuType::NotAvailable => "N/A",
117 CuType::RejectCassette => "reject cassette",
118 CuType::BillCassette => "bill cassette",
119 }
120 }
121}
122
123impl From<CuType> for &'static str {
124 fn from(val: CuType) -> Self {
125 (&val).into()
126 }
127}
128
129impl fmt::Display for CuType {
130 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
131 write!(f, r#""{}""#, <&str>::from(self))
132 }
133}
134
135impl_xfs_enum!(CuType, "type");
136
137#[repr(u32)]
139#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
140pub enum LCU {
141 Dispense = LCU_DISPENSE,
142 Deposit = LCU_DEPOSIT,
143 Recycle = LCU_RECYCLE,
144 NA = LCU_NA,
145 BaitTrap = LCU_BAIT_TRAP,
146 RejectCassette = LCU_REJECT_CASSETTE,
147 OverflowCassette = LCU_OVERFLOW_CASSETTE,
148 BillCassette = LCU_BILL_CASSETTE,
149 CoinCylinder = LCU_COIN_CYLINDER,
150 CoinDispenser = LCU_COIN_DISPENSER,
151 RetractCassette = LCU_RETRACT_CASSETTE,
152 Coupon = LCU_COUPON,
153 Document = LCU_DOCUMENT,
154 Escrow = LCU_ESCROW,
155 #[default]
156 Unknown = LCU_UNKNOWN,
157 Ok = LCU_OK,
158 Full = LCU_FULL,
159 High = LCU_HIGH,
160 Low = LCU_LOW,
161 Empty = LCU_EMPTY,
162 Inoperable = LCU_INOP,
163 Missing = LCU_MISSING,
164 NoValue = LCU_NO_VALUE,
165 NoRef = LCU_NO_REF,
166 NotDispensable = LCU_NOT_DISPENSABLE,
167 CurrencyCassette = LCU_CURRENCY_CASSETTE,
168}
169
170impl LCU {
171 pub const fn new() -> Self {
173 Self::Unknown
174 }
175
176 pub const fn create(val: u32) -> Self {
178 match val {
179 LCU_DISPENSE => Self::Dispense,
180 LCU_DEPOSIT => Self::Deposit,
181 LCU_RECYCLE => Self::Recycle,
182 LCU_NA => Self::NA,
183 LCU_BAIT_TRAP => Self::BaitTrap,
184 LCU_REJECT_CASSETTE => Self::RejectCassette,
185 LCU_OVERFLOW_CASSETTE => Self::OverflowCassette,
186 LCU_BILL_CASSETTE => Self::BillCassette,
187 LCU_COIN_CYLINDER => Self::CoinCylinder,
188 LCU_COIN_DISPENSER => Self::CoinDispenser,
189 LCU_RETRACT_CASSETTE => Self::RetractCassette,
190 LCU_COUPON => Self::Coupon,
191 LCU_DOCUMENT => Self::Document,
192 LCU_ESCROW => Self::Escrow,
193 LCU_UNKNOWN => Self::Unknown,
194 LCU_OK => Self::Ok,
195 LCU_FULL => Self::Full,
196 LCU_HIGH => Self::High,
197 LCU_LOW => Self::Low,
198 LCU_EMPTY => Self::Empty,
199 LCU_INOP => Self::Inoperable,
200 LCU_MISSING => Self::Missing,
201 LCU_NO_VALUE => Self::NoValue,
202 LCU_NO_REF => Self::NoRef,
203 LCU_NOT_DISPENSABLE => Self::NotDispensable,
204 LCU_CURRENCY_CASSETTE => Self::CurrencyCassette,
205 _ => Self::Unknown,
206 }
207 }
208}
209
210impl From<LCU> for &'static str {
211 fn from(val: LCU) -> Self {
212 match val {
213 LCU::Dispense => "dispense",
214 LCU::Deposit => "deposit",
215 LCU::Recycle => "recycle",
216 LCU::BaitTrap => "bait trap",
217 LCU::NA => "N/A",
218 LCU::RejectCassette => "reject cassette",
219 LCU::OverflowCassette => "overflow cassette",
220 LCU::BillCassette => "bill cassette",
221 LCU::CoinCylinder => "coin cylinder",
222 LCU::CoinDispenser => "coin dispenser",
223 LCU::RetractCassette => "retract cassette",
224 LCU::Coupon => "coupon",
225 LCU::CurrencyCassette => "currency cassette",
226 LCU::Document => "document",
227 LCU::Escrow => "escrow",
228 LCU::Unknown => "unknown",
229 LCU::Ok => "OK",
230 LCU::Full => "full",
231 LCU::High => "high",
232 LCU::Low => "low",
233 LCU::Empty => "empty",
234 LCU::Inoperable => "inoperable",
235 LCU::Missing => "missing",
236 LCU::NoValue => "no value",
237 LCU::NoRef => "no ref",
238 LCU::NotDispensable => "not dispensable",
239 }
240 }
241}
242
243impl From<&LCU> for &'static str {
244 fn from(val: &LCU) -> Self {
245 (*val).into()
246 }
247}
248
249impl fmt::Display for LCU {
250 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
251 write!(f, r#""{}""#, <&str>::from(self))
252 }
253}
254
255impl_xfs_enum!(LCU, "lcu");