1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
11pub enum ResultCode {
12 #[default]
13 Success,
14 RemovedCard,
15 ResetCard,
16 UnpoweredCard,
17 UnresponsiveCard,
18 UnsupportedCard,
19 ReaderUnavailable,
20 SharingViolation,
21 NotTransacted,
22 NoSmartcard,
23 ProtoMismatch,
24 SystemCancelled,
25 NotReady,
26 Cancelled,
27 InsufficientBuffer,
28 InvalidHandle,
29 InvalidParameter,
30 InvalidValue,
31 NoMemory,
32 Timeout,
33 UnknownReader,
34 UnsupportedFeature,
35 NoReadersAvailable,
36 ServiceStopped,
37 NoService,
38 CommError,
39 InternalError,
40 ServerTooBusy,
41 Unexpected,
42 Shutdown,
43 UnknownCard,
44 Unknown,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
50pub enum ShareMode {
51 #[default]
52 Shared,
53 Exclusive,
54 Direct,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
60pub enum Disposition {
61 #[default]
62 LeaveCard,
63 ResetCard,
64 UnpowerCard,
65 EjectCard,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
71pub enum ConnectionState {
72 #[default]
73 Absent,
74 Present,
75 Swallowed,
76 Powered,
77 Negotiable,
78 Specific,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize, Default)]
84#[serde(rename_all = "camelCase")]
85pub struct ReaderStateFlags {
86
87 #[serde(skip_serializing_if = "Option::is_none")]
88 pub unaware: Option<bool>,
89
90 #[serde(skip_serializing_if = "Option::is_none")]
91 pub ignore: Option<bool>,
92
93 #[serde(skip_serializing_if = "Option::is_none")]
94 pub changed: Option<bool>,
95
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub unknown: Option<bool>,
98
99 #[serde(skip_serializing_if = "Option::is_none")]
100 pub unavailable: Option<bool>,
101
102 #[serde(skip_serializing_if = "Option::is_none")]
103 pub empty: Option<bool>,
104
105 #[serde(skip_serializing_if = "Option::is_none")]
106 pub present: Option<bool>,
107
108 #[serde(skip_serializing_if = "Option::is_none")]
109 pub exclusive: Option<bool>,
110
111 #[serde(skip_serializing_if = "Option::is_none")]
112 pub inuse: Option<bool>,
113
114 #[serde(skip_serializing_if = "Option::is_none")]
115 pub mute: Option<bool>,
116
117 #[serde(skip_serializing_if = "Option::is_none")]
118 pub unpowered: Option<bool>,
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize, Default)]
124#[serde(rename_all = "camelCase")]
125pub struct ProtocolSet {
126
127 #[serde(skip_serializing_if = "Option::is_none")]
128 pub t0: Option<bool>,
129
130 #[serde(skip_serializing_if = "Option::is_none")]
131 pub t1: Option<bool>,
132
133 #[serde(skip_serializing_if = "Option::is_none")]
134 pub raw: Option<bool>,
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
140pub enum Protocol {
141 #[default]
142 T0,
143 T1,
144 Raw,
145}
146
147
148#[derive(Debug, Clone, Serialize, Deserialize, Default)]
149#[serde(rename_all = "camelCase")]
150pub struct ReaderStateIn {
151
152 pub reader: String,
153
154 pub currentState: ReaderStateFlags,
155
156 pub currentInsertionCount: u64,
157}
158
159
160#[derive(Debug, Clone, Serialize, Deserialize, Default)]
161#[serde(rename_all = "camelCase")]
162pub struct ReaderStateOut {
163
164 pub reader: String,
165
166 pub eventState: ReaderStateFlags,
167
168 pub eventCount: u64,
169
170 pub atr: String,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize, Default)]
174pub struct EnableParams {}
175
176impl EnableParams { pub const METHOD: &'static str = "SmartCardEmulation.enable"; }
177
178impl crate::CdpCommand for EnableParams {
179 const METHOD: &'static str = "SmartCardEmulation.enable";
180 type Response = crate::EmptyReturns;
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize, Default)]
184pub struct DisableParams {}
185
186impl DisableParams { pub const METHOD: &'static str = "SmartCardEmulation.disable"; }
187
188impl crate::CdpCommand for DisableParams {
189 const METHOD: &'static str = "SmartCardEmulation.disable";
190 type Response = crate::EmptyReturns;
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize, Default)]
200#[serde(rename_all = "camelCase")]
201pub struct ReportEstablishContextResultParams {
202
203 pub requestId: String,
204
205 pub contextId: u64,
206}
207
208impl ReportEstablishContextResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportEstablishContextResult"; }
209
210impl crate::CdpCommand for ReportEstablishContextResultParams {
211 const METHOD: &'static str = "SmartCardEmulation.reportEstablishContextResult";
212 type Response = crate::EmptyReturns;
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize, Default)]
222#[serde(rename_all = "camelCase")]
223pub struct ReportReleaseContextResultParams {
224
225 pub requestId: String,
226}
227
228impl ReportReleaseContextResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportReleaseContextResult"; }
229
230impl crate::CdpCommand for ReportReleaseContextResultParams {
231 const METHOD: &'static str = "SmartCardEmulation.reportReleaseContextResult";
232 type Response = crate::EmptyReturns;
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize, Default)]
242#[serde(rename_all = "camelCase")]
243pub struct ReportListReadersResultParams {
244
245 pub requestId: String,
246
247 pub readers: Vec<String>,
248}
249
250impl ReportListReadersResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportListReadersResult"; }
251
252impl crate::CdpCommand for ReportListReadersResultParams {
253 const METHOD: &'static str = "SmartCardEmulation.reportListReadersResult";
254 type Response = crate::EmptyReturns;
255}
256
257#[derive(Debug, Clone, Serialize, Deserialize, Default)]
264#[serde(rename_all = "camelCase")]
265pub struct ReportGetStatusChangeResultParams {
266
267 pub requestId: String,
268
269 pub readerStates: Vec<ReaderStateOut>,
270}
271
272impl ReportGetStatusChangeResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportGetStatusChangeResult"; }
273
274impl crate::CdpCommand for ReportGetStatusChangeResultParams {
275 const METHOD: &'static str = "SmartCardEmulation.reportGetStatusChangeResult";
276 type Response = crate::EmptyReturns;
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize, Default)]
287#[serde(rename_all = "camelCase")]
288pub struct ReportBeginTransactionResultParams {
289
290 pub requestId: String,
291
292 pub handle: i64,
293}
294
295impl ReportBeginTransactionResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportBeginTransactionResult"; }
296
297impl crate::CdpCommand for ReportBeginTransactionResultParams {
298 const METHOD: &'static str = "SmartCardEmulation.reportBeginTransactionResult";
299 type Response = crate::EmptyReturns;
300}
301
302#[derive(Debug, Clone, Serialize, Deserialize, Default)]
323#[serde(rename_all = "camelCase")]
324pub struct ReportPlainResultParams {
325
326 pub requestId: String,
327}
328
329impl ReportPlainResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportPlainResult"; }
330
331impl crate::CdpCommand for ReportPlainResultParams {
332 const METHOD: &'static str = "SmartCardEmulation.reportPlainResult";
333 type Response = crate::EmptyReturns;
334}
335
336#[derive(Debug, Clone, Serialize, Deserialize, Default)]
343#[serde(rename_all = "camelCase")]
344pub struct ReportConnectResultParams {
345
346 pub requestId: String,
347
348 pub handle: i64,
349
350 #[serde(skip_serializing_if = "Option::is_none")]
351 pub activeProtocol: Option<Protocol>,
352}
353
354impl ReportConnectResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportConnectResult"; }
355
356impl crate::CdpCommand for ReportConnectResultParams {
357 const METHOD: &'static str = "SmartCardEmulation.reportConnectResult";
358 type Response = crate::EmptyReturns;
359}
360
361#[derive(Debug, Clone, Serialize, Deserialize, Default)]
378#[serde(rename_all = "camelCase")]
379pub struct ReportDataResultParams {
380
381 pub requestId: String,
382
383 pub data: String,
384}
385
386impl ReportDataResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportDataResult"; }
387
388impl crate::CdpCommand for ReportDataResultParams {
389 const METHOD: &'static str = "SmartCardEmulation.reportDataResult";
390 type Response = crate::EmptyReturns;
391}
392
393#[derive(Debug, Clone, Serialize, Deserialize, Default)]
400#[serde(rename_all = "camelCase")]
401pub struct ReportStatusResultParams {
402
403 pub requestId: String,
404
405 pub readerName: String,
406
407 pub state: ConnectionState,
408
409 pub atr: String,
410
411 #[serde(skip_serializing_if = "Option::is_none")]
412 pub protocol: Option<Protocol>,
413}
414
415impl ReportStatusResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportStatusResult"; }
416
417impl crate::CdpCommand for ReportStatusResultParams {
418 const METHOD: &'static str = "SmartCardEmulation.reportStatusResult";
419 type Response = crate::EmptyReturns;
420}
421
422#[derive(Debug, Clone, Serialize, Deserialize, Default)]
425#[serde(rename_all = "camelCase")]
426pub struct ReportErrorParams {
427
428 pub requestId: String,
429
430 pub resultCode: ResultCode,
431}
432
433impl ReportErrorParams { pub const METHOD: &'static str = "SmartCardEmulation.reportError"; }
434
435impl crate::CdpCommand for ReportErrorParams {
436 const METHOD: &'static str = "SmartCardEmulation.reportError";
437 type Response = crate::EmptyReturns;
438}