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
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! Runtime domain exposes JavaScript runtime by means of remote evaluation
//! and mirror objects. Evaluation results are returned as mirror object that
//! expose object type, string representation and unique identifier that can
//! be used for further object reference. Original objects are maintained in
//! memory unless they are either explicitly released or are released along
//! with the other objects in their object group.
//!
//! Types, command parameters and event payloads for the `Runtime`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].

use serde::{Deserialize, Serialize};

/// Unique script identifier.
pub type ScriptId = String;

/// Represents options for serialization. Overrides `generatePreview` and
/// `returnByValue`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SerializationOptions {
    pub serialization: SerializationOptionsSerialization,
    /// Deep serialization depth. Default is full depth. Respected only in `deep`
    /// serialization mode.
    #[serde(rename = "maxDepth", default, skip_serializing_if = "Option::is_none")]
    pub max_depth: Option<i64>,
    /// Embedder-specific parameters. For example if connected to V8 in Chrome
    /// these control DOM serialization via `maxNodeDepth: integer` and
    /// `includeShadowTree: "none" | "open" | "all"`. Values can be only of type
    /// string or integer.
    #[serde(
        rename = "additionalParameters",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub additional_parameters: Option<serde_json::Value>,
}

/// The values `serialization` accepts on `SerializationOptions`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SerializationOptionsSerialization {
    /// `deep`
    #[serde(rename = "deep")]
    Deep,
    /// `json`
    #[serde(rename = "json")]
    Json,
    /// `idOnly`
    #[serde(rename = "idOnly")]
    IdOnly,
    /// 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),
}

/// Represents deep serialized value.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeepSerializedValue {
    pub r#type: DeepSerializedValueType,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<serde_json::Value>,
    #[serde(rename = "objectId", default, skip_serializing_if = "Option::is_none")]
    pub object_id: Option<String>,
    /// Set if value reference met more then once during serialization. In such
    /// case, value is provided only to one of the serialized values. Unique per
    /// value in the scope of one CDP call.
    #[serde(
        rename = "weakLocalObjectReference",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub weak_local_object_reference: Option<i64>,
}

/// The values `type` accepts on `DeepSerializedValue`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DeepSerializedValueType {
    /// `undefined`
    #[serde(rename = "undefined")]
    Undefined,
    /// `null`
    #[serde(rename = "null")]
    Null,
    /// `string`
    #[serde(rename = "string")]
    String,
    /// `number`
    #[serde(rename = "number")]
    Number,
    /// `boolean`
    #[serde(rename = "boolean")]
    Boolean,
    /// `bigint`
    #[serde(rename = "bigint")]
    Bigint,
    /// `regexp`
    #[serde(rename = "regexp")]
    Regexp,
    /// `date`
    #[serde(rename = "date")]
    Date,
    /// `symbol`
    #[serde(rename = "symbol")]
    Symbol,
    /// `array`
    #[serde(rename = "array")]
    Array,
    /// `object`
    #[serde(rename = "object")]
    Object,
    /// `function`
    #[serde(rename = "function")]
    Function,
    /// `map`
    #[serde(rename = "map")]
    Map,
    /// `set`
    #[serde(rename = "set")]
    Set,
    /// `weakmap`
    #[serde(rename = "weakmap")]
    Weakmap,
    /// `weakset`
    #[serde(rename = "weakset")]
    Weakset,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `proxy`
    #[serde(rename = "proxy")]
    Proxy,
    /// `promise`
    #[serde(rename = "promise")]
    Promise,
    /// `typedarray`
    #[serde(rename = "typedarray")]
    Typedarray,
    /// `arraybuffer`
    #[serde(rename = "arraybuffer")]
    Arraybuffer,
    /// `node`
    #[serde(rename = "node")]
    Node,
    /// `window`
    #[serde(rename = "window")]
    Window,
    /// `generator`
    #[serde(rename = "generator")]
    Generator,
    /// 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),
}

/// Unique object identifier.
pub type RemoteObjectId = String;

/// Primitive value which cannot be JSON-stringified. Includes values `-0`,
/// `NaN`, `Infinity`, `-Infinity`, and bigint literals.
pub type UnserializableValue = String;

/// Mirror object referencing original JavaScript object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RemoteObject {
    /// Object type.
    pub r#type: RemoteObjectType,
    /// Object subtype hint. Specified for `object` type values only. NOTE: If you
    /// change anything here, make sure to also update `subtype` in
    /// `ObjectPreview` and `PropertyPreview` below.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subtype: Option<RemoteObjectSubtype>,
    /// Object class (constructor) name. Specified for `object` type values only.
    #[serde(rename = "className", default, skip_serializing_if = "Option::is_none")]
    pub class_name: Option<String>,
    /// Remote object value in case of primitive values or JSON values (if it was
    /// requested).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<serde_json::Value>,
    /// Primitive value which can not be JSON-stringified does not have `value`,
    /// but gets this property.
    #[serde(
        rename = "unserializableValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub unserializable_value: Option<UnserializableValue>,
    /// String representation of the object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Deep serialized value.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "deepSerializedValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub deep_serialized_value: Option<DeepSerializedValue>,
    /// Unique object identifier (for non-primitive values).
    #[serde(rename = "objectId", default, skip_serializing_if = "Option::is_none")]
    pub object_id: Option<RemoteObjectId>,
    /// Preview containing abbreviated property values. Specified for `object`
    /// type values only.
    ///
    /// Experimental: may change without notice.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub preview: Option<ObjectPreview>,
    /// Experimental: may change without notice.
    #[serde(
        rename = "customPreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub custom_preview: Option<CustomPreview>,
}

/// The values `type` accepts on `RemoteObject`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RemoteObjectType {
    /// `object`
    #[serde(rename = "object")]
    Object,
    /// `function`
    #[serde(rename = "function")]
    Function,
    /// `undefined`
    #[serde(rename = "undefined")]
    Undefined,
    /// `string`
    #[serde(rename = "string")]
    String,
    /// `number`
    #[serde(rename = "number")]
    Number,
    /// `boolean`
    #[serde(rename = "boolean")]
    Boolean,
    /// `symbol`
    #[serde(rename = "symbol")]
    Symbol,
    /// `bigint`
    #[serde(rename = "bigint")]
    Bigint,
    /// 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),
}

/// The values `subtype` accepts on `RemoteObject`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RemoteObjectSubtype {
    /// `array`
    #[serde(rename = "array")]
    Array,
    /// `null`
    #[serde(rename = "null")]
    Null,
    /// `node`
    #[serde(rename = "node")]
    Node,
    /// `regexp`
    #[serde(rename = "regexp")]
    Regexp,
    /// `date`
    #[serde(rename = "date")]
    Date,
    /// `map`
    #[serde(rename = "map")]
    Map,
    /// `set`
    #[serde(rename = "set")]
    Set,
    /// `weakmap`
    #[serde(rename = "weakmap")]
    Weakmap,
    /// `weakset`
    #[serde(rename = "weakset")]
    Weakset,
    /// `iterator`
    #[serde(rename = "iterator")]
    Iterator,
    /// `generator`
    #[serde(rename = "generator")]
    Generator,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `proxy`
    #[serde(rename = "proxy")]
    Proxy,
    /// `promise`
    #[serde(rename = "promise")]
    Promise,
    /// `typedarray`
    #[serde(rename = "typedarray")]
    Typedarray,
    /// `arraybuffer`
    #[serde(rename = "arraybuffer")]
    Arraybuffer,
    /// `dataview`
    #[serde(rename = "dataview")]
    Dataview,
    /// `webassemblymemory`
    #[serde(rename = "webassemblymemory")]
    Webassemblymemory,
    /// `wasmvalue`
    #[serde(rename = "wasmvalue")]
    Wasmvalue,
    /// `deferredmodule`
    #[serde(rename = "deferredmodule")]
    Deferredmodule,
    /// `trustedtype`
    #[serde(rename = "trustedtype")]
    Trustedtype,
    /// 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),
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CustomPreview {
    /// The JSON-stringified result of formatter.header(object, config) call. It
    /// contains json ML array that represents RemoteObject.
    pub header: String,
    /// If formatter returns true as a result of formatter.hasBody call then
    /// bodyGetterId will contain RemoteObjectId for the function that returns
    /// result of formatter.body(object, config) call. The result value is json ML
    /// array.
    #[serde(
        rename = "bodyGetterId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub body_getter_id: Option<RemoteObjectId>,
}

/// Object containing abbreviated remote object value.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ObjectPreview {
    /// Object type.
    pub r#type: ObjectPreviewType,
    /// Object subtype hint. Specified for `object` type values only.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subtype: Option<ObjectPreviewSubtype>,
    /// String representation of the object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// True iff some of the properties or entries of the original object did not
    /// fit.
    pub overflow: bool,
    /// List of the properties.
    pub properties: Vec<PropertyPreview>,
    /// List of the entries. Specified for `map` and `set` subtype values only.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entries: Option<Vec<EntryPreview>>,
}

/// The values `type` accepts on `ObjectPreview`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ObjectPreviewType {
    /// `object`
    #[serde(rename = "object")]
    Object,
    /// `function`
    #[serde(rename = "function")]
    Function,
    /// `undefined`
    #[serde(rename = "undefined")]
    Undefined,
    /// `string`
    #[serde(rename = "string")]
    String,
    /// `number`
    #[serde(rename = "number")]
    Number,
    /// `boolean`
    #[serde(rename = "boolean")]
    Boolean,
    /// `symbol`
    #[serde(rename = "symbol")]
    Symbol,
    /// `bigint`
    #[serde(rename = "bigint")]
    Bigint,
    /// 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),
}

/// The values `subtype` accepts on `ObjectPreview`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ObjectPreviewSubtype {
    /// `array`
    #[serde(rename = "array")]
    Array,
    /// `null`
    #[serde(rename = "null")]
    Null,
    /// `node`
    #[serde(rename = "node")]
    Node,
    /// `regexp`
    #[serde(rename = "regexp")]
    Regexp,
    /// `date`
    #[serde(rename = "date")]
    Date,
    /// `map`
    #[serde(rename = "map")]
    Map,
    /// `set`
    #[serde(rename = "set")]
    Set,
    /// `weakmap`
    #[serde(rename = "weakmap")]
    Weakmap,
    /// `weakset`
    #[serde(rename = "weakset")]
    Weakset,
    /// `iterator`
    #[serde(rename = "iterator")]
    Iterator,
    /// `generator`
    #[serde(rename = "generator")]
    Generator,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `proxy`
    #[serde(rename = "proxy")]
    Proxy,
    /// `promise`
    #[serde(rename = "promise")]
    Promise,
    /// `typedarray`
    #[serde(rename = "typedarray")]
    Typedarray,
    /// `arraybuffer`
    #[serde(rename = "arraybuffer")]
    Arraybuffer,
    /// `dataview`
    #[serde(rename = "dataview")]
    Dataview,
    /// `webassemblymemory`
    #[serde(rename = "webassemblymemory")]
    Webassemblymemory,
    /// `wasmvalue`
    #[serde(rename = "wasmvalue")]
    Wasmvalue,
    /// `deferredmodule`
    #[serde(rename = "deferredmodule")]
    Deferredmodule,
    /// `trustedtype`
    #[serde(rename = "trustedtype")]
    Trustedtype,
    /// 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),
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PropertyPreview {
    /// Property name.
    pub name: String,
    /// Object type. Accessor means that the property itself is an accessor
    /// property.
    pub r#type: PropertyPreviewType,
    /// User-friendly property value string.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    /// Nested value preview.
    #[serde(
        rename = "valuePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub value_preview: Option<ObjectPreview>,
    /// Object subtype hint. Specified for `object` type values only.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subtype: Option<PropertyPreviewSubtype>,
}

/// The values `type` accepts on `PropertyPreview`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PropertyPreviewType {
    /// `object`
    #[serde(rename = "object")]
    Object,
    /// `function`
    #[serde(rename = "function")]
    Function,
    /// `undefined`
    #[serde(rename = "undefined")]
    Undefined,
    /// `string`
    #[serde(rename = "string")]
    String,
    /// `number`
    #[serde(rename = "number")]
    Number,
    /// `boolean`
    #[serde(rename = "boolean")]
    Boolean,
    /// `symbol`
    #[serde(rename = "symbol")]
    Symbol,
    /// `accessor`
    #[serde(rename = "accessor")]
    Accessor,
    /// `bigint`
    #[serde(rename = "bigint")]
    Bigint,
    /// 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),
}

/// The values `subtype` accepts on `PropertyPreview`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PropertyPreviewSubtype {
    /// `array`
    #[serde(rename = "array")]
    Array,
    /// `null`
    #[serde(rename = "null")]
    Null,
    /// `node`
    #[serde(rename = "node")]
    Node,
    /// `regexp`
    #[serde(rename = "regexp")]
    Regexp,
    /// `date`
    #[serde(rename = "date")]
    Date,
    /// `map`
    #[serde(rename = "map")]
    Map,
    /// `set`
    #[serde(rename = "set")]
    Set,
    /// `weakmap`
    #[serde(rename = "weakmap")]
    Weakmap,
    /// `weakset`
    #[serde(rename = "weakset")]
    Weakset,
    /// `iterator`
    #[serde(rename = "iterator")]
    Iterator,
    /// `generator`
    #[serde(rename = "generator")]
    Generator,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `proxy`
    #[serde(rename = "proxy")]
    Proxy,
    /// `promise`
    #[serde(rename = "promise")]
    Promise,
    /// `typedarray`
    #[serde(rename = "typedarray")]
    Typedarray,
    /// `arraybuffer`
    #[serde(rename = "arraybuffer")]
    Arraybuffer,
    /// `dataview`
    #[serde(rename = "dataview")]
    Dataview,
    /// `webassemblymemory`
    #[serde(rename = "webassemblymemory")]
    Webassemblymemory,
    /// `wasmvalue`
    #[serde(rename = "wasmvalue")]
    Wasmvalue,
    /// `deferredmodule`
    #[serde(rename = "deferredmodule")]
    Deferredmodule,
    /// `trustedtype`
    #[serde(rename = "trustedtype")]
    Trustedtype,
    /// 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),
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EntryPreview {
    /// Preview of the key. Specified for map-like collection entries.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub key: Option<ObjectPreview>,
    /// Preview of the value.
    pub value: ObjectPreview,
}

/// Object property descriptor.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PropertyDescriptor {
    /// Property name or symbol description.
    pub name: String,
    /// The value associated with the property.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<RemoteObject>,
    /// True if the value associated with the property may be changed (data
    /// descriptors only).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub writable: Option<bool>,
    /// A function which serves as a getter for the property, or `undefined` if
    /// there is no getter (accessor descriptors only).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub get: Option<RemoteObject>,
    /// A function which serves as a setter for the property, or `undefined` if
    /// there is no setter (accessor descriptors only).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<RemoteObject>,
    /// True if the type of this property descriptor may be changed and if the
    /// property may be deleted from the corresponding object.
    pub configurable: bool,
    /// True if this property shows up during enumeration of the properties on the
    /// corresponding object.
    pub enumerable: bool,
    /// True if the result was thrown during the evaluation.
    #[serde(rename = "wasThrown", default, skip_serializing_if = "Option::is_none")]
    pub was_thrown: Option<bool>,
    /// True if the property is owned for the object.
    #[serde(rename = "isOwn", default, skip_serializing_if = "Option::is_none")]
    pub is_own: Option<bool>,
    /// Property symbol object, if the property is of the `symbol` type.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub symbol: Option<RemoteObject>,
}

/// Object internal property descriptor. This property isn't normally visible
/// in JavaScript code.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct InternalPropertyDescriptor {
    /// Conventional property name.
    pub name: String,
    /// The value associated with the property.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<RemoteObject>,
}

/// Object private field descriptor.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PrivatePropertyDescriptor {
    /// Private property name.
    pub name: String,
    /// The value associated with the private property.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<RemoteObject>,
    /// A function which serves as a getter for the private property, or
    /// `undefined` if there is no getter (accessor descriptors only).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub get: Option<RemoteObject>,
    /// A function which serves as a setter for the private property, or
    /// `undefined` if there is no setter (accessor descriptors only).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<RemoteObject>,
}

/// Represents function call argument. Either remote object id `objectId`,
/// primitive `value`, unserializable primitive value or neither of (for
/// undefined) them should be specified.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CallArgument {
    /// Primitive value or serializable javascript object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<serde_json::Value>,
    /// Primitive value which can not be JSON-stringified.
    #[serde(
        rename = "unserializableValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub unserializable_value: Option<UnserializableValue>,
    /// Remote object handle.
    #[serde(rename = "objectId", default, skip_serializing_if = "Option::is_none")]
    pub object_id: Option<RemoteObjectId>,
}

/// Id of an execution context.
pub type ExecutionContextId = i64;

/// Description of an isolated world.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExecutionContextDescription {
    /// Unique id of the execution context. It can be used to specify in which
    /// execution context script evaluation should be performed.
    pub id: ExecutionContextId,
    /// Execution context origin.
    pub origin: String,
    /// Human readable name describing given context.
    pub name: String,
    /// A system-unique execution context identifier. Unlike the id, this is
    /// unique across multiple processes, so can be reliably used to identify
    /// specific context while backend performs a cross-process navigation.
    ///
    /// Experimental: may change without notice.
    #[serde(rename = "uniqueId")]
    pub unique_id: String,
    /// Embedder-specific auxiliary data likely matching {isDefault: boolean,
    /// type: 'default'|'isolated'|'worker', frameId: string}
    #[serde(rename = "auxData", default, skip_serializing_if = "Option::is_none")]
    pub aux_data: Option<serde_json::Value>,
}

/// Detailed information about exception (or error) that was thrown during
/// script compilation or execution.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExceptionDetails {
    /// Exception id.
    #[serde(rename = "exceptionId")]
    pub exception_id: i64,
    /// Exception text, which should be used together with exception object when
    /// available.
    pub text: String,
    /// Line number of the exception location (0-based).
    #[serde(rename = "lineNumber")]
    pub line_number: i64,
    /// Column number of the exception location (0-based).
    #[serde(rename = "columnNumber")]
    pub column_number: i64,
    /// Script ID of the exception location.
    #[serde(rename = "scriptId", default, skip_serializing_if = "Option::is_none")]
    pub script_id: Option<ScriptId>,
    /// URL of the exception location, to be used when the script was not
    /// reported.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// JavaScript stack trace if available.
    #[serde(
        rename = "stackTrace",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stack_trace: Option<StackTrace>,
    /// Exception object if available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exception: Option<RemoteObject>,
    /// Identifier of the context where exception happened.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
    /// Dictionary with entries of meta data that the client associated with this
    /// exception, such as information about associated network requests, etc.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "exceptionMetaData",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_meta_data: Option<serde_json::Value>,
}

/// Number of milliseconds since epoch.
pub type Timestamp = f64;

/// Number of milliseconds.
pub type TimeDelta = f64;

/// Stack entry for runtime errors and assertions.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CallFrame {
    /// JavaScript function name.
    #[serde(rename = "functionName")]
    pub function_name: String,
    /// JavaScript script id.
    #[serde(rename = "scriptId")]
    pub script_id: ScriptId,
    /// JavaScript script name or url.
    pub url: String,
    /// JavaScript script line number (0-based).
    #[serde(rename = "lineNumber")]
    pub line_number: i64,
    /// JavaScript script column number (0-based).
    #[serde(rename = "columnNumber")]
    pub column_number: i64,
}

/// Call frames for assertions or error messages.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StackTrace {
    /// String label of this stack trace. For async traces this may be a name of
    /// the function that initiated the async call.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// JavaScript function name.
    #[serde(rename = "callFrames")]
    pub call_frames: Vec<CallFrame>,
    /// Asynchronous JavaScript stack trace that preceded this stack, if
    /// available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub parent: Option<Box<StackTrace>>,
    /// Asynchronous JavaScript stack trace that preceded this stack, if
    /// available.
    ///
    /// Experimental: may change without notice.
    #[serde(rename = "parentId", default, skip_serializing_if = "Option::is_none")]
    pub parent_id: Option<StackTraceId>,
}

/// Unique identifier of current debugger.
///
/// Experimental: may change without notice.
pub type UniqueDebuggerId = String;

/// If `debuggerId` is set stack trace comes from another debugger and can be
/// resolved there. This allows to track cross-debugger calls. See
/// `Runtime.StackTrace` and `Debugger.paused` for usages.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StackTraceId {
    pub id: String,
    #[serde(
        rename = "debuggerId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub debugger_id: Option<UniqueDebuggerId>,
}

/// Add handler to promise with given promise object id.
///
/// Parameters of `Runtime.awaitPromise`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AwaitPromiseParams {
    /// Identifier of the promise.
    #[serde(rename = "promiseObjectId")]
    pub promise_object_id: RemoteObjectId,
    /// Whether the result is expected to be a JSON object that should be sent by
    /// value.
    #[serde(
        rename = "returnByValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub return_by_value: Option<bool>,
    /// Whether preview should be generated for the result.
    #[serde(
        rename = "generatePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub generate_preview: Option<bool>,
}

/// What `Runtime.awaitPromise` answers with.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AwaitPromiseReturns {
    /// Promise result. Will contain rejected value if promise was rejected.
    pub result: RemoteObject,
    /// Exception details if stack strace is available.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for AwaitPromiseParams {
    const METHOD: &'static str = "Runtime.awaitPromise";
    type Returns = AwaitPromiseReturns;
}

/// Calls function with given declaration on the given object. Object group of
/// the result is inherited from the target object.
///
/// Parameters of `Runtime.callFunctionOn`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CallFunctionOnParams {
    /// Declaration of the function to call.
    #[serde(rename = "functionDeclaration")]
    pub function_declaration: String,
    /// Identifier of the object to call function on. Either objectId or
    /// executionContextId should be specified.
    #[serde(rename = "objectId", default, skip_serializing_if = "Option::is_none")]
    pub object_id: Option<RemoteObjectId>,
    /// Call arguments. All call arguments must belong to the same JavaScript
    /// world as the target object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub arguments: Option<Vec<CallArgument>>,
    /// In silent mode exceptions thrown during evaluation are not reported and do
    /// not pause execution. Overrides `setPauseOnException` state.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub silent: Option<bool>,
    /// Whether the result is expected to be a JSON object which should be sent by
    /// value. Can be overriden by `serializationOptions`.
    #[serde(
        rename = "returnByValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub return_by_value: Option<bool>,
    /// Whether preview should be generated for the result.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "generatePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub generate_preview: Option<bool>,
    /// Whether execution should be treated as initiated by user in the UI.
    #[serde(
        rename = "userGesture",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub user_gesture: Option<bool>,
    /// Whether execution should `await` for resulting value and return once
    /// awaited promise is resolved.
    #[serde(
        rename = "awaitPromise",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub await_promise: Option<bool>,
    /// Specifies execution context which global object will be used to call
    /// function on. Either executionContextId or objectId should be specified.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
    /// Symbolic group name that can be used to release multiple objects. If
    /// objectGroup is not specified and objectId is, objectGroup will be
    /// inherited from object.
    #[serde(
        rename = "objectGroup",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub object_group: Option<String>,
    /// Whether to throw an exception if side effect cannot be ruled out during
    /// evaluation.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "throwOnSideEffect",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub throw_on_side_effect: Option<bool>,
    /// An alternative way to specify the execution context to call function on.
    /// Compared to contextId that may be reused across processes, this is
    /// guaranteed to be system-unique, so it can be used to prevent accidental
    /// function call in context different than intended (e.g. as a result of
    /// navigation across process boundaries). This is mutually exclusive with
    /// `executionContextId`.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "uniqueContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub unique_context_id: Option<String>,
    /// Specifies the result serialization. If provided, overrides
    /// `generatePreview` and `returnByValue`.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "serializationOptions",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub serialization_options: Option<SerializationOptions>,
}

/// What `Runtime.callFunctionOn` answers with.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CallFunctionOnReturns {
    /// Call result.
    pub result: RemoteObject,
    /// Exception details.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for CallFunctionOnParams {
    const METHOD: &'static str = "Runtime.callFunctionOn";
    type Returns = CallFunctionOnReturns;
}

/// Compiles expression.
///
/// Parameters of `Runtime.compileScript`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CompileScriptParams {
    /// Expression to compile.
    pub expression: String,
    /// Source url to be set for the script.
    #[serde(rename = "sourceURL")]
    pub source_url: String,
    /// Specifies whether the compiled script should be persisted.
    #[serde(rename = "persistScript")]
    pub persist_script: bool,
    /// Specifies in which execution context to perform script run. If the
    /// parameter is omitted the evaluation will be performed in the context of
    /// the inspected page.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
}

/// What `Runtime.compileScript` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CompileScriptReturns {
    /// Id of the script.
    #[serde(rename = "scriptId", default, skip_serializing_if = "Option::is_none")]
    pub script_id: Option<ScriptId>,
    /// Exception details.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for CompileScriptParams {
    const METHOD: &'static str = "Runtime.compileScript";
    type Returns = CompileScriptReturns;
}

/// Disables reporting of execution contexts creation.
///
/// Parameters of `Runtime.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

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

/// Discards collected exceptions and console API calls.
///
/// Parameters of `Runtime.discardConsoleEntries`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DiscardConsoleEntriesParams {}

impl crate::typed::Command for DiscardConsoleEntriesParams {
    const METHOD: &'static str = "Runtime.discardConsoleEntries";
    type Returns = crate::typed::NoReturns;
}

/// Enables reporting of execution contexts creation by means of
/// `executionContextCreated` event. When the reporting gets enabled the event
/// will be sent immediately for each existing execution context.
///
/// Parameters of `Runtime.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

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

/// Evaluates expression on global object.
///
/// Parameters of `Runtime.evaluate`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EvaluateParams {
    /// Expression to evaluate.
    pub expression: String,
    /// Symbolic group name that can be used to release multiple objects.
    #[serde(
        rename = "objectGroup",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub object_group: Option<String>,
    /// Determines whether Command Line API should be available during the
    /// evaluation.
    #[serde(
        rename = "includeCommandLineAPI",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_command_line_api: Option<bool>,
    /// In silent mode exceptions thrown during evaluation are not reported and do
    /// not pause execution. Overrides `setPauseOnException` state.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub silent: Option<bool>,
    /// Specifies in which execution context to perform evaluation. If the
    /// parameter is omitted the evaluation will be performed in the context of
    /// the inspected page. This is mutually exclusive with `uniqueContextId`,
    /// which offers an alternative way to identify the execution context that is
    /// more reliable in a multi-process environment.
    #[serde(rename = "contextId", default, skip_serializing_if = "Option::is_none")]
    pub context_id: Option<ExecutionContextId>,
    /// Whether the result is expected to be a JSON object that should be sent by
    /// value.
    #[serde(
        rename = "returnByValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub return_by_value: Option<bool>,
    /// Whether preview should be generated for the result.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "generatePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub generate_preview: Option<bool>,
    /// Whether execution should be treated as initiated by user in the UI.
    #[serde(
        rename = "userGesture",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub user_gesture: Option<bool>,
    /// Whether execution should `await` for resulting value and return once
    /// awaited promise is resolved.
    #[serde(
        rename = "awaitPromise",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub await_promise: Option<bool>,
    /// Whether to throw an exception if side effect cannot be ruled out during
    /// evaluation. This implies `disableBreaks` below.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "throwOnSideEffect",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub throw_on_side_effect: Option<bool>,
    /// Terminate execution after timing out (number of milliseconds).
    ///
    /// Experimental: may change without notice.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<TimeDelta>,
    /// Disable breakpoints during execution.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "disableBreaks",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub disable_breaks: Option<bool>,
    /// Setting this flag to true enables `let` re-declaration and top-level
    /// `await`. Note that `let` variables can only be re-declared if they
    /// originate from `replMode` themselves.
    ///
    /// Experimental: may change without notice.
    #[serde(rename = "replMode", default, skip_serializing_if = "Option::is_none")]
    pub repl_mode: Option<bool>,
    /// The Content Security Policy (CSP) for the target might block 'unsafe-eval'
    /// which includes eval(), Function(), setTimeout() and setInterval() when
    /// called with non-callable arguments. This flag bypasses CSP for this
    /// evaluation and allows unsafe-eval. Defaults to true.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "allowUnsafeEvalBlockedByCSP",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub allow_unsafe_eval_blocked_by_csp: Option<bool>,
    /// An alternative way to specify the execution context to evaluate in.
    /// Compared to contextId that may be reused across processes, this is
    /// guaranteed to be system-unique, so it can be used to prevent accidental
    /// evaluation of the expression in context different than intended (e.g. as a
    /// result of navigation across process boundaries). This is mutually
    /// exclusive with `contextId`.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "uniqueContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub unique_context_id: Option<String>,
    /// Specifies the result serialization. If provided, overrides
    /// `generatePreview` and `returnByValue`.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "serializationOptions",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub serialization_options: Option<SerializationOptions>,
}

/// What `Runtime.evaluate` answers with.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EvaluateReturns {
    /// Evaluation result.
    pub result: RemoteObject,
    /// Exception details.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for EvaluateParams {
    const METHOD: &'static str = "Runtime.evaluate";
    type Returns = EvaluateReturns;
}

/// Returns the isolate id.
///
/// Experimental: may change without notice.
///
/// Parameters of `Runtime.getIsolateId`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetIsolateIdParams {}

/// What `Runtime.getIsolateId` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetIsolateIdReturns {
    /// The isolate id.
    pub id: String,
}

impl crate::typed::Command for GetIsolateIdParams {
    const METHOD: &'static str = "Runtime.getIsolateId";
    type Returns = GetIsolateIdReturns;
}

/// Returns the JavaScript heap usage. It is the total usage of the
/// corresponding isolate not scoped to a particular Runtime.
///
/// Experimental: may change without notice.
///
/// Parameters of `Runtime.getHeapUsage`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHeapUsageParams {}

/// What `Runtime.getHeapUsage` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHeapUsageReturns {
    /// Used JavaScript heap size in bytes.
    #[serde(rename = "usedSize")]
    pub used_size: f64,
    /// Allocated JavaScript heap size in bytes.
    #[serde(rename = "totalSize")]
    pub total_size: f64,
    /// Used size in bytes in the embedder's garbage-collected heap.
    #[serde(rename = "embedderHeapUsedSize")]
    pub embedder_heap_used_size: f64,
    /// Size in bytes of backing storage for array buffers and external strings.
    #[serde(rename = "backingStorageSize")]
    pub backing_storage_size: f64,
}

impl crate::typed::Command for GetHeapUsageParams {
    const METHOD: &'static str = "Runtime.getHeapUsage";
    type Returns = GetHeapUsageReturns;
}

/// Returns properties of a given object. Object group of the result is
/// inherited from the target object.
///
/// Parameters of `Runtime.getProperties`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetPropertiesParams {
    /// Identifier of the object to return properties for.
    #[serde(rename = "objectId")]
    pub object_id: RemoteObjectId,
    /// If true, returns properties belonging only to the element itself, not to
    /// its prototype chain.
    #[serde(
        rename = "ownProperties",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub own_properties: Option<bool>,
    /// If true, returns accessor properties (with getter/setter) only; internal
    /// properties are not returned either.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "accessorPropertiesOnly",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub accessor_properties_only: Option<bool>,
    /// Whether preview should be generated for the results.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "generatePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub generate_preview: Option<bool>,
    /// If true, returns non-indexed properties only.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "nonIndexedPropertiesOnly",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub non_indexed_properties_only: Option<bool>,
}

/// What `Runtime.getProperties` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetPropertiesReturns {
    /// Object properties.
    pub result: Vec<PropertyDescriptor>,
    /// Internal object properties (only of the element itself).
    #[serde(
        rename = "internalProperties",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub internal_properties: Option<Vec<InternalPropertyDescriptor>>,
    /// Object private properties.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "privateProperties",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub private_properties: Option<Vec<PrivatePropertyDescriptor>>,
    /// Exception details.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for GetPropertiesParams {
    const METHOD: &'static str = "Runtime.getProperties";
    type Returns = GetPropertiesReturns;
}

/// Returns all let, const and class variables from global scope.
///
/// Parameters of `Runtime.globalLexicalScopeNames`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GlobalLexicalScopeNamesParams {
    /// Specifies in which execution context to lookup global scope variables.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
}

/// What `Runtime.globalLexicalScopeNames` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GlobalLexicalScopeNamesReturns {
    pub names: Vec<String>,
}

impl crate::typed::Command for GlobalLexicalScopeNamesParams {
    const METHOD: &'static str = "Runtime.globalLexicalScopeNames";
    type Returns = GlobalLexicalScopeNamesReturns;
}

/// Parameters of `Runtime.queryObjects`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct QueryObjectsParams {
    /// Identifier of the prototype to return objects for.
    #[serde(rename = "prototypeObjectId")]
    pub prototype_object_id: RemoteObjectId,
    /// Symbolic group name that can be used to release the results.
    #[serde(
        rename = "objectGroup",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub object_group: Option<String>,
}

/// What `Runtime.queryObjects` answers with.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct QueryObjectsReturns {
    /// Array with objects.
    pub objects: RemoteObject,
}

impl crate::typed::Command for QueryObjectsParams {
    const METHOD: &'static str = "Runtime.queryObjects";
    type Returns = QueryObjectsReturns;
}

/// Releases remote object with given id.
///
/// Parameters of `Runtime.releaseObject`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReleaseObjectParams {
    /// Identifier of the object to release.
    #[serde(rename = "objectId")]
    pub object_id: RemoteObjectId,
}

impl crate::typed::Command for ReleaseObjectParams {
    const METHOD: &'static str = "Runtime.releaseObject";
    type Returns = crate::typed::NoReturns;
}

/// Releases all remote objects that belong to a given group.
///
/// Parameters of `Runtime.releaseObjectGroup`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReleaseObjectGroupParams {
    /// Symbolic object group name.
    #[serde(rename = "objectGroup")]
    pub object_group: String,
}

impl crate::typed::Command for ReleaseObjectGroupParams {
    const METHOD: &'static str = "Runtime.releaseObjectGroup";
    type Returns = crate::typed::NoReturns;
}

/// Tells inspected instance to run if it was waiting for debugger to attach.
///
/// Parameters of `Runtime.runIfWaitingForDebugger`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RunIfWaitingForDebuggerParams {}

impl crate::typed::Command for RunIfWaitingForDebuggerParams {
    const METHOD: &'static str = "Runtime.runIfWaitingForDebugger";
    type Returns = crate::typed::NoReturns;
}

/// Runs script with given id in a given context.
///
/// Parameters of `Runtime.runScript`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RunScriptParams {
    /// Id of the script to run.
    #[serde(rename = "scriptId")]
    pub script_id: ScriptId,
    /// Specifies in which execution context to perform script run. If the
    /// parameter is omitted the evaluation will be performed in the context of
    /// the inspected page.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
    /// Symbolic group name that can be used to release multiple objects.
    #[serde(
        rename = "objectGroup",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub object_group: Option<String>,
    /// In silent mode exceptions thrown during evaluation are not reported and do
    /// not pause execution. Overrides `setPauseOnException` state.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub silent: Option<bool>,
    /// Determines whether Command Line API should be available during the
    /// evaluation.
    #[serde(
        rename = "includeCommandLineAPI",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_command_line_api: Option<bool>,
    /// Whether the result is expected to be a JSON object which should be sent by
    /// value.
    #[serde(
        rename = "returnByValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub return_by_value: Option<bool>,
    /// Whether preview should be generated for the result.
    #[serde(
        rename = "generatePreview",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub generate_preview: Option<bool>,
    /// Whether execution should `await` for resulting value and return once
    /// awaited promise is resolved.
    #[serde(
        rename = "awaitPromise",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub await_promise: Option<bool>,
}

/// What `Runtime.runScript` answers with.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RunScriptReturns {
    /// Run result.
    pub result: RemoteObject,
    /// Exception details.
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for RunScriptParams {
    const METHOD: &'static str = "Runtime.runScript";
    type Returns = RunScriptReturns;
}

/// Enables or disables async call stacks tracking.
///
/// Parameters of `Runtime.setAsyncCallStackDepth`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetAsyncCallStackDepthParams {
    /// Maximum depth of async call stacks. Setting to `0` will effectively
    /// disable collecting async call stacks (default).
    #[serde(rename = "maxDepth")]
    pub max_depth: i64,
}

impl crate::typed::Command for SetAsyncCallStackDepthParams {
    const METHOD: &'static str = "Runtime.setAsyncCallStackDepth";
    type Returns = crate::typed::NoReturns;
}

/// Experimental: may change without notice.
///
/// Parameters of `Runtime.setCustomObjectFormatterEnabled`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetCustomObjectFormatterEnabledParams {
    pub enabled: bool,
}

impl crate::typed::Command for SetCustomObjectFormatterEnabledParams {
    const METHOD: &'static str = "Runtime.setCustomObjectFormatterEnabled";
    type Returns = crate::typed::NoReturns;
}

/// Experimental: may change without notice.
///
/// Parameters of `Runtime.setMaxCallStackSizeToCapture`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetMaxCallStackSizeToCaptureParams {
    pub size: i64,
}

impl crate::typed::Command for SetMaxCallStackSizeToCaptureParams {
    const METHOD: &'static str = "Runtime.setMaxCallStackSizeToCapture";
    type Returns = crate::typed::NoReturns;
}

/// Terminate current or next JavaScript execution. Will cancel the
/// termination when the outer-most script execution ends.
///
/// Experimental: may change without notice.
///
/// Parameters of `Runtime.terminateExecution`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct TerminateExecutionParams {}

impl crate::typed::Command for TerminateExecutionParams {
    const METHOD: &'static str = "Runtime.terminateExecution";
    type Returns = crate::typed::NoReturns;
}

/// If executionContextId is empty, adds binding with the given name on the
/// global objects of all inspected contexts, including those created later,
/// bindings survive reloads. Binding function takes exactly one argument,
/// this argument should be string, in case of any other input, function
/// throws an exception. Each binding function call produces
/// Runtime.bindingCalled notification.
///
/// Parameters of `Runtime.addBinding`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddBindingParams {
    pub name: String,
    /// If specified, the binding would only be exposed to the specified execution
    /// context. If omitted and `executionContextName` is not set, the binding is
    /// exposed to all execution contexts of the target. This parameter is
    /// mutually exclusive with `executionContextName`. Deprecated in favor of
    /// `executionContextName` due to an unclear use case and bugs in
    /// implementation (crbug.com/1169639). `executionContextId` will be removed
    /// in the future.
    ///
    /// Deprecated in the protocol.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
    /// If specified, the binding is exposed to the executionContext with matching
    /// name, even for contexts created after the binding is added. See also
    /// `ExecutionContext.name` and `worldName` parameter to
    /// `Page.addScriptToEvaluateOnNewDocument`. This parameter is mutually
    /// exclusive with `executionContextId`.
    #[serde(
        rename = "executionContextName",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_name: Option<String>,
}

impl crate::typed::Command for AddBindingParams {
    const METHOD: &'static str = "Runtime.addBinding";
    type Returns = crate::typed::NoReturns;
}

/// This method does not remove binding function from global object but
/// unsubscribes current runtime agent from Runtime.bindingCalled
/// notifications.
///
/// Parameters of `Runtime.removeBinding`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RemoveBindingParams {
    pub name: String,
}

impl crate::typed::Command for RemoveBindingParams {
    const METHOD: &'static str = "Runtime.removeBinding";
    type Returns = crate::typed::NoReturns;
}

/// This method tries to lookup and populate exception details for a
/// JavaScript Error object. Note that the stackTrace portion of the resulting
/// exceptionDetails will only be populated if the Runtime domain was enabled
/// at the time when the Error was thrown.
///
/// Experimental: may change without notice.
///
/// Parameters of `Runtime.getExceptionDetails`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetExceptionDetailsParams {
    /// The error object for which to resolve the exception details.
    #[serde(rename = "errorObjectId")]
    pub error_object_id: RemoteObjectId,
}

/// What `Runtime.getExceptionDetails` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetExceptionDetailsReturns {
    #[serde(
        rename = "exceptionDetails",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub exception_details: Option<ExceptionDetails>,
}

impl crate::typed::Command for GetExceptionDetailsParams {
    const METHOD: &'static str = "Runtime.getExceptionDetails";
    type Returns = GetExceptionDetailsReturns;
}

/// Notification is issued every time when binding is called.
///
/// Experimental: may change without notice.
///
/// Payload of the `Runtime.bindingCalled` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BindingCalledEvent {
    pub name: String,
    pub payload: String,
    /// Identifier of the context where the call was made.
    #[serde(rename = "executionContextId")]
    pub execution_context_id: ExecutionContextId,
}

impl crate::typed::Event for BindingCalledEvent {
    const METHOD: &'static str = "Runtime.bindingCalled";
}

/// Issued when console API was called.
///
/// Payload of the `Runtime.consoleAPICalled` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConsoleApiCalledEvent {
    /// Type of the call.
    pub r#type: ConsoleApiCalledType,
    /// Call arguments.
    pub args: Vec<RemoteObject>,
    /// Identifier of the context where the call was made.
    #[serde(rename = "executionContextId")]
    pub execution_context_id: ExecutionContextId,
    /// Call timestamp.
    pub timestamp: Timestamp,
    /// Stack trace captured when the call was made. The async stack chain is
    /// automatically reported for the following call types: `assert`, `error`,
    /// `trace`, `warning`. For other types the async call chain can be retrieved
    /// using `Debugger.getStackTrace` and `stackTrace.parentId` field.
    #[serde(
        rename = "stackTrace",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stack_trace: Option<StackTrace>,
    /// Console context descriptor for calls on non-default console context (not
    /// console.*): 'anonymous#unique-logger-id' for call on unnamed context,
    /// 'name#unique-logger-id' for call on named context.
    ///
    /// Experimental: may change without notice.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub context: Option<String>,
}

/// The values `type` accepts on `consoleAPICalled`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConsoleApiCalledType {
    /// `log`
    #[serde(rename = "log")]
    Log,
    /// `debug`
    #[serde(rename = "debug")]
    Debug,
    /// `info`
    #[serde(rename = "info")]
    Info,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `warning`
    #[serde(rename = "warning")]
    Warning,
    /// `dir`
    #[serde(rename = "dir")]
    Dir,
    /// `dirxml`
    #[serde(rename = "dirxml")]
    Dirxml,
    /// `table`
    #[serde(rename = "table")]
    Table,
    /// `trace`
    #[serde(rename = "trace")]
    Trace,
    /// `clear`
    #[serde(rename = "clear")]
    Clear,
    /// `startGroup`
    #[serde(rename = "startGroup")]
    StartGroup,
    /// `startGroupCollapsed`
    #[serde(rename = "startGroupCollapsed")]
    StartGroupCollapsed,
    /// `endGroup`
    #[serde(rename = "endGroup")]
    EndGroup,
    /// `assert`
    #[serde(rename = "assert")]
    Assert,
    /// `profile`
    #[serde(rename = "profile")]
    Profile,
    /// `profileEnd`
    #[serde(rename = "profileEnd")]
    ProfileEnd,
    /// `count`
    #[serde(rename = "count")]
    Count,
    /// `timeEnd`
    #[serde(rename = "timeEnd")]
    TimeEnd,
    /// 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),
}

impl crate::typed::Event for ConsoleApiCalledEvent {
    const METHOD: &'static str = "Runtime.consoleAPICalled";
}

/// Issued when unhandled exception was revoked.
///
/// Payload of the `Runtime.exceptionRevoked` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExceptionRevokedEvent {
    /// Reason describing why exception was revoked.
    pub reason: String,
    /// The id of revoked exception, as reported in `exceptionThrown`.
    #[serde(rename = "exceptionId")]
    pub exception_id: i64,
}

impl crate::typed::Event for ExceptionRevokedEvent {
    const METHOD: &'static str = "Runtime.exceptionRevoked";
}

/// Issued when exception was thrown and unhandled.
///
/// Payload of the `Runtime.exceptionThrown` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExceptionThrownEvent {
    /// Timestamp of the exception.
    pub timestamp: Timestamp,
    #[serde(rename = "exceptionDetails")]
    pub exception_details: ExceptionDetails,
}

impl crate::typed::Event for ExceptionThrownEvent {
    const METHOD: &'static str = "Runtime.exceptionThrown";
}

/// Issued when new execution context is created.
///
/// Payload of the `Runtime.executionContextCreated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExecutionContextCreatedEvent {
    /// A newly created execution context.
    pub context: ExecutionContextDescription,
}

impl crate::typed::Event for ExecutionContextCreatedEvent {
    const METHOD: &'static str = "Runtime.executionContextCreated";
}

/// Issued when execution context is destroyed.
///
/// Payload of the `Runtime.executionContextDestroyed` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExecutionContextDestroyedEvent {
    /// Id of the destroyed context
    ///
    /// Deprecated in the protocol.
    #[serde(rename = "executionContextId")]
    pub execution_context_id: ExecutionContextId,
    /// Unique Id of the destroyed context
    ///
    /// Experimental: may change without notice.
    #[serde(rename = "executionContextUniqueId")]
    pub execution_context_unique_id: String,
}

impl crate::typed::Event for ExecutionContextDestroyedEvent {
    const METHOD: &'static str = "Runtime.executionContextDestroyed";
}

/// Issued when all executionContexts were cleared in browser
///
/// Payload of the `Runtime.executionContextsCleared` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExecutionContextsClearedEvent {}

impl crate::typed::Event for ExecutionContextsClearedEvent {
    const METHOD: &'static str = "Runtime.executionContextsCleared";
}

/// Issued when object should be inspected (for example, as a result of
/// inspect() command line API call).
///
/// Payload of the `Runtime.inspectRequested` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InspectRequestedEvent {
    pub object: RemoteObject,
    pub hints: serde_json::Value,
    /// Identifier of the context where the call was made.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "executionContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_context_id: Option<ExecutionContextId>,
}

impl crate::typed::Event for InspectRequestedEvent {
    const METHOD: &'static str = "Runtime.inspectRequested";
}