cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! The `SmartCardEmulation` domain.
//!
//! Types, command parameters and event payloads for the `SmartCardEmulation`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

/// Indicates the PC/SC error code. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__ErrorCodes.html> Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/secauthn/authentication-return-values>
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ResultCode {
    /// `success`
    #[serde(rename = "success")]
    Success,
    /// `removed-card`
    #[serde(rename = "removed-card")]
    RemovedCard,
    /// `reset-card`
    #[serde(rename = "reset-card")]
    ResetCard,
    /// `unpowered-card`
    #[serde(rename = "unpowered-card")]
    UnpoweredCard,
    /// `unresponsive-card`
    #[serde(rename = "unresponsive-card")]
    UnresponsiveCard,
    /// `unsupported-card`
    #[serde(rename = "unsupported-card")]
    UnsupportedCard,
    /// `reader-unavailable`
    #[serde(rename = "reader-unavailable")]
    ReaderUnavailable,
    /// `sharing-violation`
    #[serde(rename = "sharing-violation")]
    SharingViolation,
    /// `not-transacted`
    #[serde(rename = "not-transacted")]
    NotTransacted,
    /// `no-smartcard`
    #[serde(rename = "no-smartcard")]
    NoSmartcard,
    /// `proto-mismatch`
    #[serde(rename = "proto-mismatch")]
    ProtoMismatch,
    /// `system-cancelled`
    #[serde(rename = "system-cancelled")]
    SystemCancelled,
    /// `not-ready`
    #[serde(rename = "not-ready")]
    NotReady,
    /// `cancelled`
    #[serde(rename = "cancelled")]
    Cancelled,
    /// `insufficient-buffer`
    #[serde(rename = "insufficient-buffer")]
    InsufficientBuffer,
    /// `invalid-handle`
    #[serde(rename = "invalid-handle")]
    InvalidHandle,
    /// `invalid-parameter`
    #[serde(rename = "invalid-parameter")]
    InvalidParameter,
    /// `invalid-value`
    #[serde(rename = "invalid-value")]
    InvalidValue,
    /// `no-memory`
    #[serde(rename = "no-memory")]
    NoMemory,
    /// `timeout`
    #[serde(rename = "timeout")]
    Timeout,
    /// `unknown-reader`
    #[serde(rename = "unknown-reader")]
    UnknownReader,
    /// `unsupported-feature`
    #[serde(rename = "unsupported-feature")]
    UnsupportedFeature,
    /// `no-readers-available`
    #[serde(rename = "no-readers-available")]
    NoReadersAvailable,
    /// `service-stopped`
    #[serde(rename = "service-stopped")]
    ServiceStopped,
    /// `no-service`
    #[serde(rename = "no-service")]
    NoService,
    /// `comm-error`
    #[serde(rename = "comm-error")]
    CommError,
    /// `internal-error`
    #[serde(rename = "internal-error")]
    InternalError,
    /// `server-too-busy`
    #[serde(rename = "server-too-busy")]
    ServerTooBusy,
    /// `unexpected`
    #[serde(rename = "unexpected")]
    Unexpected,
    /// `shutdown`
    #[serde(rename = "shutdown")]
    Shutdown,
    /// `unknown-card`
    #[serde(rename = "unknown-card")]
    UnknownCard,
    /// `unknown`
    #[serde(rename = "unknown")]
    Unknown,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Maps to the |SCARD_SHARE_*| values.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ShareMode {
    /// `shared`
    #[serde(rename = "shared")]
    Shared,
    /// `exclusive`
    #[serde(rename = "exclusive")]
    Exclusive,
    /// `direct`
    #[serde(rename = "direct")]
    Direct,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Indicates what the reader should do with the card.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Disposition {
    /// `leave-card`
    #[serde(rename = "leave-card")]
    LeaveCard,
    /// `reset-card`
    #[serde(rename = "reset-card")]
    ResetCard,
    /// `unpower-card`
    #[serde(rename = "unpower-card")]
    UnpowerCard,
    /// `eject-card`
    #[serde(rename = "eject-card")]
    EjectCard,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Maps to |SCARD_*| connection state values.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConnectionState {
    /// `absent`
    #[serde(rename = "absent")]
    Absent,
    /// `present`
    #[serde(rename = "present")]
    Present,
    /// `swallowed`
    #[serde(rename = "swallowed")]
    Swallowed,
    /// `powered`
    #[serde(rename = "powered")]
    Powered,
    /// `negotiable`
    #[serde(rename = "negotiable")]
    Negotiable,
    /// `specific`
    #[serde(rename = "specific")]
    Specific,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Maps to the |SCARD_STATE_*| flags.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReaderStateFlags {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unaware: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ignore: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub changed: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unknown: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unavailable: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub empty: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub present: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exclusive: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub inuse: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mute: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unpowered: Option<bool>,
}

/// Maps to the |SCARD_PROTOCOL_*| flags.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ProtocolSet {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub t0: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub t1: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub raw: Option<bool>,
}

/// Maps to the |SCARD_PROTOCOL_*| values.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Protocol {
    /// `t0`
    #[serde(rename = "t0")]
    T0,
    /// `t1`
    #[serde(rename = "t1")]
    T1,
    /// `raw`
    #[serde(rename = "raw")]
    Raw,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReaderStateIn {
    pub reader: String,
    #[serde(rename = "currentState")]
    pub current_state: ReaderStateFlags,
    #[serde(rename = "currentInsertionCount")]
    pub current_insertion_count: i64,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReaderStateOut {
    pub reader: String,
    #[serde(rename = "eventState")]
    pub event_state: ReaderStateFlags,
    #[serde(rename = "eventCount")]
    pub event_count: i64,
    pub atr: String,
}

/// Enables the |SmartCardEmulation| domain.
///
/// Parameters of `SmartCardEmulation.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

impl crate::typed::Command for EnableParams {
    const METHOD: &'static str = "SmartCardEmulation.enable";
    type Returns = crate::typed::NoReturns;
}

/// Disables the |SmartCardEmulation| domain.
///
/// Parameters of `SmartCardEmulation.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

impl crate::typed::Command for DisableParams {
    const METHOD: &'static str = "SmartCardEmulation.disable";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardEstablishContext| call. This maps
/// to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardestablishcontext>
///
/// Parameters of `SmartCardEmulation.reportEstablishContextResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportEstablishContextResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
}

impl crate::typed::Command for ReportEstablishContextResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportEstablishContextResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardReleaseContext| call. This maps
/// to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga6aabcba7744c5c9419fdd6404f73a934>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardreleasecontext>
///
/// Parameters of `SmartCardEmulation.reportReleaseContextResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportReleaseContextResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
}

impl crate::typed::Command for ReportReleaseContextResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportReleaseContextResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardListReaders| call. This maps to:
/// PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga93b07815789b3cf2629d439ecf20f0d9>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreadersa>
///
/// Parameters of `SmartCardEmulation.reportListReadersResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportListReadersResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub readers: Vec<String>,
}

impl crate::typed::Command for ReportListReadersResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportListReadersResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardGetStatusChange| call. This maps
/// to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetstatuschangea>
///
/// Parameters of `SmartCardEmulation.reportGetStatusChangeResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportGetStatusChangeResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "readerStates")]
    pub reader_states: Vec<ReaderStateOut>,
}

impl crate::typed::Command for ReportGetStatusChangeResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportGetStatusChangeResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the result of a |SCardBeginTransaction| call. On success, this
/// creates a new transaction object. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardbegintransaction>
///
/// Parameters of `SmartCardEmulation.reportBeginTransactionResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportBeginTransactionResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
}

impl crate::typed::Command for ReportBeginTransactionResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportBeginTransactionResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a call that returns only a result code.
/// Used for: |SCardCancel|, |SCardDisconnect|, |SCardSetAttrib|,
/// |SCardEndTransaction|. This maps to: 1. SCardCancel PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcancel>
/// 2. SCardDisconnect PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga4be198045c73ec0deb79e66c0ca1738a>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scarddisconnect>
/// 3. SCardSetAttrib PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardsetattrib>
/// 4. SCardEndTransaction PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gae8742473b404363e5c587f570d7e2f3b>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardendtransaction>
///
/// Parameters of `SmartCardEmulation.reportPlainResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportPlainResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
}

impl crate::typed::Command for ReportPlainResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportPlainResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardConnect| call. This maps to:
/// PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardconnecta>
///
/// Parameters of `SmartCardEmulation.reportConnectResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportConnectResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    #[serde(
        rename = "activeProtocol",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub active_protocol: Option<Protocol>,
}

impl crate::typed::Command for ReportConnectResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportConnectResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a call that sends back data on success.
/// Used for |SCardTransmit|, |SCardControl|, and |SCardGetAttrib|. This maps
/// to: 1. SCardTransmit PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga9a2d77242a271310269065e64633ab99>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardtransmit>
/// 2. SCardControl PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcontrol>
/// 3. SCardGetAttrib PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaacfec51917255b7a25b94c5104961602>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetattrib>
///
/// Parameters of `SmartCardEmulation.reportDataResult`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportDataResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub data: String,
}

impl crate::typed::Command for ReportDataResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportDataResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports the successful result of a |SCardStatus| call. This maps to: PC/SC
/// Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gae49c3c894ad7ac12a5b896bde70d0382>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardstatusa>
///
/// Parameters of `SmartCardEmulation.reportStatusResult`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReportStatusResultParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "readerName")]
    pub reader_name: String,
    pub state: ConnectionState,
    pub atr: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub protocol: Option<Protocol>,
}

impl crate::typed::Command for ReportStatusResultParams {
    const METHOD: &'static str = "SmartCardEmulation.reportStatusResult";
    type Returns = crate::typed::NoReturns;
}

/// Reports an error result for the given request.
///
/// Parameters of `SmartCardEmulation.reportError`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReportErrorParams {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "resultCode")]
    pub result_code: ResultCode,
}

impl crate::typed::Command for ReportErrorParams {
    const METHOD: &'static str = "SmartCardEmulation.reportError";
    type Returns = crate::typed::NoReturns;
}

/// Fired when |SCardEstablishContext| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardestablishcontext>
///
/// Payload of the `SmartCardEmulation.establishContextRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EstablishContextRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
}

impl crate::typed::Event for EstablishContextRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.establishContextRequested";
}

/// Fired when |SCardReleaseContext| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga6aabcba7744c5c9419fdd6404f73a934>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardreleasecontext>
///
/// Payload of the `SmartCardEmulation.releaseContextRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReleaseContextRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
}

impl crate::typed::Event for ReleaseContextRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.releaseContextRequested";
}

/// Fired when |SCardListReaders| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga93b07815789b3cf2629d439ecf20f0d9>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreadersa>
///
/// Payload of the `SmartCardEmulation.listReadersRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ListReadersRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
}

impl crate::typed::Event for ListReadersRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.listReadersRequested";
}

/// Fired when |SCardGetStatusChange| is called. Timeout is specified in
/// milliseconds. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetstatuschangea>
///
/// Payload of the `SmartCardEmulation.getStatusChangeRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetStatusChangeRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
    #[serde(rename = "readerStates")]
    pub reader_states: Vec<ReaderStateIn>,
    /// in milliseconds, if absent, it means "infinite"
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i64>,
}

impl crate::typed::Event for GetStatusChangeRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.getStatusChangeRequested";
}

/// Fired when |SCardCancel| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcancel>
///
/// Payload of the `SmartCardEmulation.cancelRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CancelRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
}

impl crate::typed::Event for CancelRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.cancelRequested";
}

/// Fired when |SCardConnect| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardconnecta>
///
/// Payload of the `SmartCardEmulation.connectRequested` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConnectRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    #[serde(rename = "contextId")]
    pub context_id: i64,
    pub reader: String,
    #[serde(rename = "shareMode")]
    pub share_mode: ShareMode,
    #[serde(rename = "preferredProtocols")]
    pub preferred_protocols: ProtocolSet,
}

impl crate::typed::Event for ConnectRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.connectRequested";
}

/// Fired when |SCardDisconnect| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga4be198045c73ec0deb79e66c0ca1738a>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scarddisconnect>
///
/// Payload of the `SmartCardEmulation.disconnectRequested` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DisconnectRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    pub disposition: Disposition,
}

impl crate::typed::Event for DisconnectRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.disconnectRequested";
}

/// Fired when |SCardTransmit| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga9a2d77242a271310269065e64633ab99>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardtransmit>
///
/// Payload of the `SmartCardEmulation.transmitRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct TransmitRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    pub data: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub protocol: Option<Protocol>,
}

impl crate::typed::Event for TransmitRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.transmitRequested";
}

/// Fired when |SCardControl| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcontrol>
///
/// Payload of the `SmartCardEmulation.controlRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ControlRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    #[serde(rename = "controlCode")]
    pub control_code: i64,
    pub data: String,
}

impl crate::typed::Event for ControlRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.controlRequested";
}

/// Fired when |SCardGetAttrib| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaacfec51917255b7a25b94c5104961602>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetattrib>
///
/// Payload of the `SmartCardEmulation.getAttribRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetAttribRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    #[serde(rename = "attribId")]
    pub attrib_id: i64,
}

impl crate::typed::Event for GetAttribRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.getAttribRequested";
}

/// Fired when |SCardSetAttrib| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardsetattrib>
///
/// Payload of the `SmartCardEmulation.setAttribRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetAttribRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    #[serde(rename = "attribId")]
    pub attrib_id: i64,
    pub data: String,
}

impl crate::typed::Event for SetAttribRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.setAttribRequested";
}

/// Fired when |SCardStatus| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gae49c3c894ad7ac12a5b896bde70d0382>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardstatusa>
///
/// Payload of the `SmartCardEmulation.statusRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StatusRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
}

impl crate::typed::Event for StatusRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.statusRequested";
}

/// Fired when |SCardBeginTransaction| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardbegintransaction>
///
/// Payload of the `SmartCardEmulation.beginTransactionRequested` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BeginTransactionRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
}

impl crate::typed::Event for BeginTransactionRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.beginTransactionRequested";
}

/// Fired when |SCardEndTransaction| is called. This maps to: PC/SC Lite:
/// <https://pcsclite.apdu.fr/api/group__API.html#gae8742473b404363e5c587f570d7e2f3b>
/// Microsoft:
/// <https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardendtransaction>
///
/// Payload of the `SmartCardEmulation.endTransactionRequested` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EndTransactionRequestedEvent {
    #[serde(rename = "requestId")]
    pub request_id: String,
    pub handle: i64,
    pub disposition: Disposition,
}

impl crate::typed::Event for EndTransactionRequestedEvent {
    const METHOD: &'static str = "SmartCardEmulation.endTransactionRequested";
}