objc2-core-nfc 0.3.2

Bindings to the CoreNFC framework
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
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
// This file has been automatically generated by `objc2`'s `header-translator`.
// DO NOT EDIT

#![allow(unused_imports)]
#![allow(deprecated)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(missing_docs)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::identity_op)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::doc_lazy_continuation)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::invalid_html_tags)]

#[link(name = "CoreNFC", kind = "framework")]
extern "C" {}

use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcerrordomain?language=objc)
    pub static NFCErrorDomain: &'static NSErrorDomain;
}

/// Possible errors returned by CoreNFC framework reader session.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcreadererror?language=objc)
// NS_ERROR_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCReaderError(pub NSInteger);
impl NFCReaderError {
    #[doc(alias = "NFCReaderErrorUnsupportedFeature")]
    pub const ReaderErrorUnsupportedFeature: Self = Self(1);
    #[doc(alias = "NFCReaderErrorSecurityViolation")]
    pub const ReaderErrorSecurityViolation: Self = Self(2);
    #[doc(alias = "NFCReaderErrorInvalidParameter")]
    pub const ReaderErrorInvalidParameter: Self = Self(3);
    #[doc(alias = "NFCReaderErrorInvalidParameterLength")]
    pub const ReaderErrorInvalidParameterLength: Self = Self(4);
    #[doc(alias = "NFCReaderErrorParameterOutOfBound")]
    pub const ReaderErrorParameterOutOfBound: Self = Self(5);
    #[doc(alias = "NFCReaderErrorRadioDisabled")]
    pub const ReaderErrorRadioDisabled: Self = Self(6);
    #[doc(alias = "NFCReaderErrorIneligible")]
    pub const ReaderErrorIneligible: Self = Self(7);
    #[doc(alias = "NFCReaderErrorAccessNotAccepted")]
    pub const ReaderErrorAccessNotAccepted: Self = Self(8);
    #[doc(alias = "NFCReaderTransceiveErrorTagConnectionLost")]
    pub const ReaderTransceiveErrorTagConnectionLost: Self = Self(100);
    #[doc(alias = "NFCReaderTransceiveErrorRetryExceeded")]
    pub const ReaderTransceiveErrorRetryExceeded: Self = Self(101);
    #[doc(alias = "NFCReaderTransceiveErrorTagResponseError")]
    pub const ReaderTransceiveErrorTagResponseError: Self = Self(102);
    #[doc(alias = "NFCReaderTransceiveErrorSessionInvalidated")]
    pub const ReaderTransceiveErrorSessionInvalidated: Self = Self(103);
    #[doc(alias = "NFCReaderTransceiveErrorTagNotConnected")]
    pub const ReaderTransceiveErrorTagNotConnected: Self = Self(104);
    #[doc(alias = "NFCReaderTransceiveErrorPacketTooLong")]
    pub const ReaderTransceiveErrorPacketTooLong: Self = Self(105);
    #[doc(alias = "NFCReaderSessionInvalidationErrorUserCanceled")]
    pub const ReaderSessionInvalidationErrorUserCanceled: Self = Self(200);
    #[doc(alias = "NFCReaderSessionInvalidationErrorSessionTimeout")]
    pub const ReaderSessionInvalidationErrorSessionTimeout: Self = Self(201);
    #[doc(alias = "NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly")]
    pub const ReaderSessionInvalidationErrorSessionTerminatedUnexpectedly: Self = Self(202);
    #[doc(alias = "NFCReaderSessionInvalidationErrorSystemIsBusy")]
    pub const ReaderSessionInvalidationErrorSystemIsBusy: Self = Self(203);
    #[doc(alias = "NFCReaderSessionInvalidationErrorFirstNDEFTagRead")]
    pub const ReaderSessionInvalidationErrorFirstNDEFTagRead: Self = Self(204);
    #[doc(alias = "NFCTagCommandConfigurationErrorInvalidParameters")]
    pub const TagCommandConfigurationErrorInvalidParameters: Self = Self(300);
    #[doc(alias = "NFCNdefReaderSessionErrorTagNotWritable")]
    pub const NdefReaderSessionErrorTagNotWritable: Self = Self(400);
    #[doc(alias = "NFCNdefReaderSessionErrorTagUpdateFailure")]
    pub const NdefReaderSessionErrorTagUpdateFailure: Self = Self(401);
    #[doc(alias = "NFCNdefReaderSessionErrorTagSizeTooSmall")]
    pub const NdefReaderSessionErrorTagSizeTooSmall: Self = Self(402);
    #[doc(alias = "NFCNdefReaderSessionErrorZeroLengthMessage")]
    pub const NdefReaderSessionErrorZeroLengthMessage: Self = Self(403);
}

unsafe impl Encode for NFCReaderError {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCReaderError {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// Key in NSError userInfo dictionary.  The corresponding value is the NSUInteger error code from tag's response.
    /// Refer to ISO15693 specification for the error code values.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693tagresponseerrorkey?language=objc)
    pub static NFCISO15693TagResponseErrorKey: &'static NSString;
}

extern "C" {
    /// Key in NSError userInfo dictionary.  Presence of this key indicates the received response packet length is invalid.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctagresponseunexpectedlengtherrorkey?language=objc)
    pub static NFCTagResponseUnexpectedLengthErrorKey: &'static NSString;
}

extern_protocol!(
    /// General reader session functions
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcreadersessionprotocol?language=objc)
    #[doc(alias = "NFCReaderSession")]
    #[name = "NFCReaderSession"]
    pub unsafe trait NFCReaderSessionProtocol: NSObjectProtocol {
        /// Returns: <i>
        /// YES
        /// </i>
        /// if the reader session is started and ready to use.
        ///
        ///
        /// The RF discovery polling begins immediately when a reader session is activated successfully.
        /// The
        ///
        /// ```text
        ///  readerSession:didDetectTags: @link/ will be called when a tag is detected.
        ///  
        ///
        /// ```
        #[unsafe(method(isReady))]
        #[unsafe(method_family = none)]
        unsafe fn isReady(&self) -> bool;

        /// Descriptive text message that is displayed on the alert action sheet once tag scanning has started.  The string can be update
        /// dynamically in any thread context as long as the session is valid.  This should be set prior to calling
        ///
        /// ```text
        ///  beginSession @link/ to display
        ///              the correct message.  Use this string to provide additional context about the NFC reader mode operation.
        ///  
        ///
        /// ```
        #[unsafe(method(alertMessage))]
        #[unsafe(method_family = none)]
        unsafe fn alertMessage(&self) -> Retained<NSString>;

        /// Setter for [`alertMessage`][Self::alertMessage].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAlertMessage:))]
        #[unsafe(method_family = none)]
        unsafe fn setAlertMessage(&self, alert_message: &NSString);

        /// Starts the session.  The
        ///
        /// ```text
        ///  [NFCReaderSessionDelegate readerSessionDidBecomeActive:] @link/ will be called when the reader session
        ///                   is activated successfully.  @link [NFCReaderSessionDelegate readerSession:didDetectTags:] @link/ will return tag objects that are
        ///                   conformed to the @link NFCTag @link/ protocol.  @link [NFCReaderSessionDelegate readerSession:didInvalidateWithError:] will return
        ///                   errors related to the session start.
        ///  
        ///
        /// ```
        #[unsafe(method(beginSession))]
        #[unsafe(method_family = none)]
        unsafe fn beginSession(&self);

        /// Closes the reader session.  The session cannot be re-used.
        #[unsafe(method(invalidateSession))]
        #[unsafe(method_family = none)]
        unsafe fn invalidateSession(&self);

        /// Closes the reader session.  The session cannot be re-used.  The specified error message and an error symbol will be displayed momentarily
        /// on the action sheet before it is automatically dismissed.
        #[unsafe(method(invalidateSessionWithErrorMessage:))]
        #[unsafe(method_family = none)]
        unsafe fn invalidateSessionWithErrorMessage(&self, error_message: &NSString);
    }
);

extern_protocol!(
    /// General reader session callbacks
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcreadersessiondelegate?language=objc)
    pub unsafe trait NFCReaderSessionDelegate: NSObjectProtocol {
        /// Parameter `session`: The session object in the active state.
        ///
        ///
        /// Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for tags.
        /// The
        ///
        /// ```text
        ///  readerSession:didDetectTags: @link/ will be called when a tag is detected.
        ///  
        ///
        /// ```
        #[unsafe(method(readerSessionDidBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSessionDidBecomeActive(&self, session: &NFCReaderSession);

        /// Parameter `session`: The session object that is invalidated.
        ///
        /// Parameter `error`: The error indicates the invalidation reason.
        ///
        ///
        /// Gets called when a session becomes invalid.  At this point the client is expected to discard
        /// the returned session object.
        #[unsafe(method(readerSession:didInvalidateWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didInvalidateWithError(
            &self,
            session: &NFCReaderSession,
            error: &NSError,
        );

        /// Parameter `session`: The session object used for tag detection.
        ///
        /// Parameter `tags`: Array of
        ///
        /// ```text
        ///  NFCTag @link/ objects.
        ///
        ///  @discussion      Gets called when the reader detects NFC tag(s) in the polling sequence.
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(readerSession:didDetectTags:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didDetectTags(
            &self,
            session: &NFCReaderSession,
            tags: &NSArray<ProtocolObject<dyn NFCTag>>,
        );
    }
);

extern_class!(
    /// This represents a NFC reader session for processing tags; this base class cannot be instantiate. Only one NFCReaderSession
    /// can be active at any time in the system.  Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcreadersession?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCReaderSession {}
);

impl NFCReaderSession {
    extern_methods!(
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;

        /// YES if device supports NFC tag reading.
        #[unsafe(method(readingAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn readingAvailable() -> bool;

        #[cfg(feature = "dispatch2")]
        /// The NFCReaderSessionDelegate delegate callbacks and the completion block handlers for tag operation will be dispatched on this queue.
        #[unsafe(method(sessionQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn sessionQueue(&self) -> Retained<DispatchQueue>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctagtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCTagType(pub NSUInteger);
impl NFCTagType {
    #[doc(alias = "NFCTagTypeISO15693")]
    pub const ISO15693: Self = Self(1);
    #[doc(alias = "NFCTagTypeFeliCa")]
    pub const FeliCa: Self = Self(2);
    #[doc(alias = "NFCTagTypeISO7816Compatible")]
    pub const ISO7816Compatible: Self = Self(3);
    #[doc(alias = "NFCTagTypeMiFare")]
    pub const MiFare: Self = Self(4);
}

unsafe impl Encode for NFCTagType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NFCTagType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// A NFC / RFID tag object conforms to this protocol.  The NFCReaderSession returns an instance of this type when a tag is detected.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctag?language=objc)
    pub unsafe trait NFCTag: NSObjectProtocol + NSSecureCoding + NSCopying {
        /// See
        ///
        /// ```text
        ///  CNFCTagType @link/
        ///  
        ///
        /// ```
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        unsafe fn r#type(&self) -> NFCTagType;

        /// Session that provides this tag.
        #[unsafe(method(session))]
        #[unsafe(method_family = none)]
        unsafe fn session(&self) -> Option<Retained<ProtocolObject<dyn NFCReaderSessionProtocol>>>;

        /// Returns: <i>
        /// YES
        /// </i>
        /// if tag is available in the current reader session.  A tag remove from the RF field will become
        /// unavailable.  Tag in disconnected state will return NO.
        ///
        ///
        /// Check whether a detected tag is available.
        #[unsafe(method(isAvailable))]
        #[unsafe(method_family = none)]
        unsafe fn isAvailable(&self) -> bool;

        /// Returns: Returns self if it conforms to the NFCISO15693Tag protocol; else returns nil.
        #[unsafe(method(asNFCISO15693Tag))]
        #[unsafe(method_family = none)]
        unsafe fn asNFCISO15693Tag(&self) -> Option<Retained<ProtocolObject<dyn NFCISO15693Tag>>>;

        /// Returns: Returns self if it conforms to the NFCISO7816Tag protocol; else returns nil.
        #[unsafe(method(asNFCISO7816Tag))]
        #[unsafe(method_family = none)]
        unsafe fn asNFCISO7816Tag(&self) -> Option<Retained<ProtocolObject<dyn NFCISO7816Tag>>>;

        /// Returns nil if tag does not conform to NFCFeliCaTag.
        #[unsafe(method(asNFCFeliCaTag))]
        #[unsafe(method_family = none)]
        unsafe fn asNFCFeliCaTag(&self) -> Option<Retained<ProtocolObject<dyn NFCFeliCaTag>>>;

        /// Returns nil if tag does not conform to NFCMiFareTag.
        #[unsafe(method(asNFCMiFareTag))]
        #[unsafe(method_family = none)]
        unsafe fn asNFCMiFareTag(&self) -> Option<Retained<ProtocolObject<dyn NFCMiFareTag>>>;
    }
);

extern_class!(
    /// Define configuration parameters for tag commands.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctagcommandconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCTagCommandConfiguration;
);

extern_conformance!(
    unsafe impl NSCopying for NFCTagCommandConfiguration {}
);

unsafe impl CopyingHelper for NFCTagCommandConfiguration {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCTagCommandConfiguration {}
);

impl NFCTagCommandConfiguration {
    extern_methods!(
        /// Maximum number of retries.  Valid value is 0 to 256.  Default is 0.
        #[unsafe(method(maximumRetries))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumRetries(&self) -> NSUInteger;

        /// Setter for [`maximumRetries`][Self::maximumRetries].
        #[unsafe(method(setMaximumRetries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaximumRetries(&self, maximum_retries: NSUInteger);

        /// Delay in seconds before retry occurs.  Default is 0.
        #[unsafe(method(retryInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn retryInterval(&self) -> NSTimeInterval;

        /// Setter for [`retryInterval`][Self::retryInterval].
        #[unsafe(method(setRetryInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRetryInterval(&self, retry_interval: NSTimeInterval);
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCTagCommandConfiguration {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// Tag reader session delegate
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctagreadersessiondelegate?language=objc)
    pub unsafe trait NFCTagReaderSessionDelegate: NSObjectProtocol {
        /// Parameter `session`: The session object that is invalidated.
        ///
        /// Parameter `error`: The error indicates the invalidation reason.
        ///
        ///
        /// Gets called when a session becomes invalid.  At this point the client is expected to discard
        /// the returned session object.
        #[unsafe(method(tagReaderSession:didInvalidateWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn tagReaderSession_didInvalidateWithError(
            &self,
            session: &NFCTagReaderSession,
            error: &NSError,
        );

        /// Parameter `session`: The session object in the active state.
        ///
        ///
        /// Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for tags.
        /// The
        ///
        /// ```text
        ///  readerSession:didDetectTags: @link/ will be called when a tag is detected.
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(tagReaderSessionDidBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn tagReaderSessionDidBecomeActive(&self, session: &NFCTagReaderSession);

        /// Parameter `session`: The session object used for tag detection.
        ///
        /// Parameter `tags`: Array of
        ///
        /// ```text
        ///  NFCTag @link/ objects.
        ///
        ///  @discussion      Gets called when the reader detects NFC tag(s) in the polling sequence.
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(tagReaderSession:didDetectTags:))]
        #[unsafe(method_family = none)]
        unsafe fn tagReaderSession_didDetectTags(
            &self,
            session: &NFCTagReaderSession,
            tags: &NSArray<ProtocolObject<dyn NFCTag>>,
        );
    }
);

/// This is an exclusive value that cannot be combine with other NFCPollingOption values; this will override all other combinations.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcpollingoption?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCPollingOption(pub NSInteger);
bitflags::bitflags! {
    impl NFCPollingOption: NSInteger {
        #[doc(alias = "NFCPollingISO14443")]
        const ISO14443 = 0x1;
        #[doc(alias = "NFCPollingISO15693")]
        const ISO15693 = 0x2;
        #[doc(alias = "NFCPollingISO18092")]
        const ISO18092 = 0x4;
        #[doc(alias = "NFCPollingPACE")]
        const PACE = 0x8;
    }
}

unsafe impl Encode for NFCPollingOption {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCPollingOption {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Reader session for processing NFC tags supporting one of the
    ///
    /// ```text
    ///  NFCTagType @link/ types.  @link [NFCTagReaderSessionDelegate readerSession:didDetectTags:] @link/
    ///               will return tag objects matching the requested type for the session.  This session requires the "com.apple.developer.nfc.readersession.formats" entitlement
    ///               in your process.  In addition your application's Info.plist must contain a non-empty usage description string. @link NFCReaderErrorSecurityViolation @link/ will be
    ///               returned from @link [NFCTagReaderSessionDelegate tagReaderSession:didInvalidateWithError:] @link/ if the required entitlement is missing when session is started.
    ///
    ///  NOTE:
    ///  - Only one NFCReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///  - If the session is configured with @link NFCPollingISO14443 @link/ and an ISO7816 compliant MiFare tag that contains one of the applications listed in the
    ///    "com.apple.developer.nfc.readersession.iso7816.select-identifiers" array in Info.plist is found, then @link [NFCTagReaderSessionDelegate readerSession:didDetectTags:] @link/
    ///    will return a tag instance conform to the @link NFCISO7816Tag @link/ protocol.
    ///  - Use of @link NFCPollingPACE @link/ requires "PACE" to be added into the "com.apple.developer.nfc.readersession.formats" entitlement.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctagreadersession?language=objc)
    #[unsafe(super(NFCReaderSession, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCTagReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCTagReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCTagReaderSession {}
);

impl NFCTagReaderSession {
    extern_methods!(
        #[unsafe(method(connectedTag))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectedTag(&self) -> Option<Retained<ProtocolObject<dyn NFCTag>>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `pollingOption`: Configures the RF polling of the reader session; multiple options can be OR'ed together.  This option affects the possible NFC tag type discover.
        ///
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCTagReaderSessionDelegate @link/ object.
        ///  @param queue         A dispatch queue where NFCTagReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                       cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///
        ///  @return              A new NFCTagReaderSession instance.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithPollingOption:delegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPollingOption_delegate_queue(
            this: Allocated<Self>,
            polling_option: NFCPollingOption,
            delegate: &ProtocolObject<dyn NFCTagReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;

        /// Restart the polling sequence in this session to discover new tags.  New tags discovered from polling will return in the subsequent
        ///
        /// ```text
        ///  [NFCTagReaderSessionDelegate tagReaderSession:didDetectTags:]
        ///              @link/ call. Tags that are returned previously by @link [NFCTagReaderSessionDelegate tagReaderSession:didDetectTags:] @link/ will become invalid,
        ///              and all references to these tags shall be removed to properly release the resources.  Calling this method on an invalidated session
        ///              will have no effect; a new reader session is required to restart the reader.
        ///  
        ///
        /// ```
        #[unsafe(method(restartPolling))]
        #[unsafe(method_family = none)]
        pub unsafe fn restartPolling(&self);

        #[cfg(feature = "block2")]
        /// Parameter `tag`: A NFCTag protocol compliant tag object that will be connected to.
        ///
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///
        ///  @discussion  This method establishes a tag connection and activates the tag.  Connecting to the same tag that is currently opened has no effect.
        ///               Connecting to a different tag will automatically terminate the previous tag connection and put it into the halt state.  Tag stays in the
        ///               connected state until another tag is connected or the polling is restarted.
        ///  
        ///
        /// ```
        #[unsafe(method(connectToTag:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectToTag_completionHandler(
            &self,
            tag: &ProtocolObject<dyn NFCTag>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCTagReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// NDEF reader session callbacks.  Presence of the -readerSession:didDetectTags: optional method will change the session behavior
    /// into a read-write session where
    ///
    /// ```text
    ///  NFCNDEFTag @link/ objects are returned.
    ///
    ///  @note       A read-write session does not trigger the -readerSession:didDetectNDEFs: method.
    ///  @note       A read-write session does not get invalidate automatically after a successful tag detection.  Invalidation occurs when
    ///              the invalidation method is called explicitly or the 60 seconds session time limit is reached.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndefreadersessiondelegate?language=objc)
    pub unsafe trait NFCNDEFReaderSessionDelegate: NSObjectProtocol {
        /// Parameter `session`: The session object that is invalidated.
        ///
        /// Parameter `error`: The error indicates the invalidation reason.
        ///
        ///
        /// Gets called when a session becomes invalid.  At this point the client is expected to discard
        /// the returned session object.
        #[unsafe(method(readerSession:didInvalidateWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didInvalidateWithError(
            &self,
            session: &NFCNDEFReaderSession,
            error: &NSError,
        );

        /// Parameter `session`: The session object used for tag detection.
        ///
        /// Parameter `messages`: Array of
        ///
        /// ```text
        ///  NFCNDEFMessage @link/ objects.
        ///
        ///  @discussion      Gets called when the reader detects NFC tag(s) with NDEF messages in the polling sequence.  Polling
        ///                   is automatically restarted once the detected tag is removed from the reader's read range.  This method
        ///                   is only get call if the optional -readerSession:didDetectTags: method is not
        ///                   implemented.
        ///  
        ///
        /// ```
        #[unsafe(method(readerSession:didDetectNDEFs:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didDetectNDEFs(
            &self,
            session: &NFCNDEFReaderSession,
            messages: &NSArray<NFCNDEFMessage>,
        );

        /// Parameter `session`: The session object used for NDEF tag detection.
        ///
        /// Parameter `tags`: Array of
        ///
        /// ```text
        ///  NFCNDEFTag @link/ objects.
        ///
        ///  @discussion      Gets called when the reader detects NDEF tag(s) in the RF field.  Presence of this method overrides -readerSession:didDetectNDEFs: and enables
        ///                   read-write capability for the session.
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(readerSession:didDetectTags:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didDetectTags(
            &self,
            session: &NFCNDEFReaderSession,
            tags: &NSArray<ProtocolObject<dyn NFCNDEFTag>>,
        );

        /// Parameter `session`: The session object in the active state.
        ///
        ///
        /// Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for tags.
        #[optional]
        #[unsafe(method(readerSessionDidBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSessionDidBecomeActive(&self, session: &NFCNDEFReaderSession);
    }
);

extern_class!(
    /// NFC reader session for processing NFC Data Exchange Format (NDEF) tags.  This session requires the "com.apple.developer.nfc.readersession.formats"
    /// entitlement in your process.  In addition your application's Info.plist must contain a non-empty usage description string.
    ///
    /// ```text
    ///  NFCReaderErrorSecurityViolation @link/ will be returned from @link [NFCNDEFReaderSessionDelegate readerSession:didInvalidateWithError:] @link/
    ///              if the required entitlement is missing when session is started.
    ///
    ///  @note       Only one NFCNDEFReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///  @note       If the delegate object implements the optional -readerSession:didDetectTags: method the NFCNDEFReaderSession will become a read-write session; see @link
    ///              NFCNDEFReaderSessionDelegate @link/ for detail description.
    ///  @note       The error symbol will not be drawn on the action sheet if -invalidateSessionWithError: method is called on a session that is not a read-write session;
    ///              -invalidateSession: method should be used in a read-only session.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndefreadersession?language=objc)
    #[unsafe(super(NFCReaderSession, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCNDEFReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCNDEFReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCNDEFReaderSession {}
);

impl NFCNDEFReaderSession {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCNDEFReaderSessionDelegate @link/ object.
        ///  @param queue     A dispatch queue where NFCNDEFReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                   cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///  @param invalidateAfterFirstRead  Session will automatically invalidate after the first NDEF tag is read successfully when this is set to YES, and
        ///                                   -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorFirstNDEFTagRead in this case.
        ///                                   Set to NO if the delegate object implements the -readerSession:didDetectTags: optional method.
        ///
        ///  @return          A new NFCNDEFReaderSession instance.
        ///
        ///  @discussion      A NDEF reader session will scan and detect NFC Forum tags that contain a valid NDEF message.  NFC Forum Tag type 1 to 5 that
        ///                   is NDEF formatted are supported.  A modal system UI will present once -beginSession is called to inform the start of the session; the UI sheet
        ///                   is automatically dismissed when the session is invalidated either by the user or by calling -invalidateSession.  The alertMessage property shall be set
        ///                   prior to -beginSession to display a message on the action sheet UI for the tag scanning operation.
        ///
        ///                   The reader session has the following properties:
        ///                   + An opened session has a 60 seconds time limit restriction after -beginSession is called; -readerSession:didInvalidateWithError: will return
        ///                   NFCReaderSessionInvalidationErrorSessionTimeout error when the time limit is reached.
        ///                   + Only 1 active reader session is allowed in the system; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSystemIsBusy
        ///                   when a new reader session is initiated by -beginSession when there is an active reader session.  
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorUserCanceled when user clicks on the done button on the UI.
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly when the client application enters
        ///                   the background state.
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderErrorUnsupportedFeature when 1) reader mode feature is not available on the hardware,
        ///                   2) client application does not have the required entitlement.
        ///
        ///                   The session's mode of operation is determined by the implementation of the delegate object.  The -readerSession:didDetectTags: optional method will
        ///                   enable the read-write capability and suppress the -readerSession:didDetectNDEFs: callback for the session.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithDelegate:queue:invalidateAfterFirstRead:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate_queue_invalidateAfterFirstRead(
            this: Allocated<Self>,
            delegate: &ProtocolObject<dyn NFCNDEFReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
            invalidate_after_first_read: bool,
        ) -> Retained<Self>;

        /// Restart the polling sequence in this session to discover new NDEF tags.  New tags discovered from polling will return in the subsequent
        ///
        /// ```text
        ///  [NFCNDEFReaderSessionDelegate readerSession:didDetectTags:]
        ///              @link/ call.  Tags that are returned previously by @link [NFCNDEFReaderSessionDelegate -readerSession:didDetectTags:] @link/ will become invalid,
        ///              and all references to these tags shall be removed to properly release the resources.  Calling this method on an invalidated session
        ///              will have no effect; a new reader session is required to restart the reader. Calling this method on an instance initiated with a delegate object that does not implement
        ///              the optional -readerSession:didDetectTags: method has no effect as RF polling restart is done automatically.
        ///  
        ///
        /// ```
        #[unsafe(method(restartPolling))]
        #[unsafe(method_family = none)]
        pub unsafe fn restartPolling(&self);

        #[cfg(feature = "block2")]
        /// Parameter `tag`: A NFCTag protocol compliant tag object that will be connect to.
        ///
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///
        ///  @discussion  This method establishes a tag connection and activates the tag.  Connecting to the same tag that is currently opened has no effect.
        ///               Connecting to a different tag will automatically terminate the previous tag connection and put it into the halt state.  Tag stays in the
        ///               connected state until another tag is connected or the polling is restarted.
        ///  
        ///
        /// ```
        #[unsafe(method(connectToTag:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectToTag_completionHandler(
            &self,
            tag: &ProtocolObject<dyn NFCNDEFTag>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCNDEFReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

mod private_NSUserActivityCoreNFC {
    pub trait Sealed {}
}

/// Category "CoreNFC" on [`NSUserActivity`].
#[doc(alias = "CoreNFC")]
pub unsafe trait NSUserActivityCoreNFC:
    ClassType + Sized + private_NSUserActivityCoreNFC::Sealed
{
    extern_methods!(
        /// The NFC NDEF message with an Universal Link object that triggers the application launch.
        #[unsafe(method(ndefMessagePayload))]
        #[unsafe(method_family = none)]
        unsafe fn ndefMessagePayload(&self) -> Retained<NFCNDEFMessage>;
    );
}

impl private_NSUserActivityCoreNFC::Sealed for NSUserActivity {}
unsafe impl NSUserActivityCoreNFC for NSUserActivity {}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693requestflag?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCISO15693RequestFlag(pub u8);
bitflags::bitflags! {
    impl NFCISO15693RequestFlag: u8 {
        #[doc(alias = "NFCISO15693RequestFlagDualSubCarriers")]
        const DualSubCarriers = 1<<0;
        #[doc(alias = "NFCISO15693RequestFlagHighDataRate")]
        const HighDataRate = 1<<1;
        #[doc(alias = "NFCISO15693RequestFlagProtocolExtension")]
        const ProtocolExtension = 1<<3;
        #[doc(alias = "NFCISO15693RequestFlagSelect")]
        const Select = 1<<4;
        #[doc(alias = "NFCISO15693RequestFlagAddress")]
        const Address = 1<<5;
        #[doc(alias = "NFCISO15693RequestFlagOption")]
        const Option = 1<<6;
        #[doc(alias = "NFCISO15693RequestFlagCommandSpecificBit8")]
        const CommandSpecificBit8 = 1<<7;
#[deprecated]
        const RequestFlagDualSubCarriers = NFCISO15693RequestFlag::DualSubCarriers.0;
#[deprecated]
        const RequestFlagHighDataRate = NFCISO15693RequestFlag::HighDataRate.0;
#[deprecated]
        const RequestFlagProtocolExtension = NFCISO15693RequestFlag::ProtocolExtension.0;
#[deprecated]
        const RequestFlagSelect = NFCISO15693RequestFlag::Select.0;
#[deprecated]
        const RequestFlagAddress = NFCISO15693RequestFlag::Address.0;
#[deprecated]
        const RequestFlagOption = NFCISO15693RequestFlag::Option.0;
    }
}

unsafe impl Encode for NFCISO15693RequestFlag {
    const ENCODING: Encoding = u8::ENCODING;
}

unsafe impl RefEncode for NFCISO15693RequestFlag {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/requestflag?language=objc)
pub type RequestFlag = NFCISO15693RequestFlag;

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693responseflag?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCISO15693ResponseFlag(pub u8);
bitflags::bitflags! {
    impl NFCISO15693ResponseFlag: u8 {
        #[doc(alias = "NFCISO15693ResponseFlagError")]
        const Error = 1<<0;
        #[doc(alias = "NFCISO15693ResponseFlagResponseBufferValid")]
        const ResponseBufferValid = 1<<1;
        #[doc(alias = "NFCISO15693ResponseFlagFinalResponse")]
        const FinalResponse = 1<<2;
        #[doc(alias = "NFCISO15693ResponseFlagProtocolExtension")]
        const ProtocolExtension = 1<<3;
        #[doc(alias = "NFCISO15693ResponseFlagBlockSecurityStatusBit5")]
        const BlockSecurityStatusBit5 = 1<<4;
        #[doc(alias = "NFCISO15693ResponseFlagBlockSecurityStatusBit6")]
        const BlockSecurityStatusBit6 = 1<<5;
        #[doc(alias = "NFCISO15693ResponseFlagWaitTimeExtension")]
        const WaitTimeExtension = 1<<6;
    }
}

unsafe impl Encode for NFCISO15693ResponseFlag {
    const ENCODING: Encoding = u8::ENCODING;
}

unsafe impl RefEncode for NFCISO15693ResponseFlag {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Configuration options for the Manufacturer Custom command.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693customcommandconfiguration?language=objc)
    #[unsafe(super(NFCTagCommandConfiguration, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCISO15693CustomCommandConfiguration;
);

extern_conformance!(
    unsafe impl NSCopying for NFCISO15693CustomCommandConfiguration {}
);

unsafe impl CopyingHelper for NFCISO15693CustomCommandConfiguration {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCISO15693CustomCommandConfiguration {}
);

impl NFCISO15693CustomCommandConfiguration {
    extern_methods!(
        /// Manufacturer code. Valid range is 0x00 to 0xFF.
        #[unsafe(method(manufacturerCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn manufacturerCode(&self) -> NSUInteger;

        /// Setter for [`manufacturerCode`][Self::manufacturerCode].
        #[unsafe(method(setManufacturerCode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setManufacturerCode(&self, manufacturer_code: NSUInteger);

        /// Manufacturer Custom Command Index.  Valid range is 0xA0 to 0xDF.
        #[unsafe(method(customCommandCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn customCommandCode(&self) -> NSUInteger;

        /// Setter for [`customCommandCode`][Self::customCommandCode].
        #[unsafe(method(setCustomCommandCode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCustomCommandCode(&self, custom_command_code: NSUInteger);

        /// Custom request data.
        #[unsafe(method(requestParameters))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestParameters(&self) -> Retained<NSData>;

        /// Setter for [`requestParameters`][Self::requestParameters].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setRequestParameters:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRequestParameters(&self, request_parameters: &NSData);

        /// Parameter `manufacturerCode`: 8 bits manufacturer code.
        ///
        /// Parameter `customCommandCode`: 8 bits custom command code.  Valid range is 0xA0 to 0xDF.
        ///
        /// Parameter `requestParameters`: Optional custom request parameters.
        ///
        ///
        /// Initialize with default zero maximum retry and zero retry interval.
        #[unsafe(method(initWithManufacturerCode:customCommandCode:requestParameters:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithManufacturerCode_customCommandCode_requestParameters(
            this: Allocated<Self>,
            manufacturer_code: NSUInteger,
            custom_command_code: NSUInteger,
            request_parameters: Option<&NSData>,
        ) -> Retained<Self>;

        /// Parameter `manufacturerCode`: 8 bits manufacturer code.
        ///
        /// Parameter `customCommandCode`: 8 bits custom command code.  Valid range is 0xA0 to 0xDF.
        ///
        /// Parameter `requestParameters`: Optional custom request parameters.
        ///
        /// Parameter `maximumRetries`: Maximum number of retry attempt when tag response is not received.
        ///
        /// Parameter `retryInterval`: Time interval wait between each retry attempt.
        #[unsafe(method(initWithManufacturerCode:customCommandCode:requestParameters:maximumRetries:retryInterval:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithManufacturerCode_customCommandCode_requestParameters_maximumRetries_retryInterval(
            this: Allocated<Self>,
            manufacturer_code: NSUInteger,
            custom_command_code: NSUInteger,
            request_parameters: Option<&NSData>,
            maximum_retries: NSUInteger,
            retry_interval: NSTimeInterval,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCISO15693CustomCommandConfiguration {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Configuration options for the Read Multiple Blocks command.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693readmultipleblocksconfiguration?language=objc)
    #[unsafe(super(NFCTagCommandConfiguration, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCISO15693ReadMultipleBlocksConfiguration;
);

extern_conformance!(
    unsafe impl NSCopying for NFCISO15693ReadMultipleBlocksConfiguration {}
);

unsafe impl CopyingHelper for NFCISO15693ReadMultipleBlocksConfiguration {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCISO15693ReadMultipleBlocksConfiguration {}
);

impl NFCISO15693ReadMultipleBlocksConfiguration {
    extern_methods!(
        /// Range to read in blocks.  Valid start index range is 0x00 to 0xFF.  Length shall not be 0.
        #[unsafe(method(range))]
        #[unsafe(method_family = none)]
        pub unsafe fn range(&self) -> NSRange;

        /// Setter for [`range`][Self::range].
        #[unsafe(method(setRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRange(&self, range: NSRange);

        /// Number of blocks to read per Read Multiple Blocks command. This may be limited by the tag hardware.
        #[unsafe(method(chunkSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn chunkSize(&self) -> NSUInteger;

        /// Setter for [`chunkSize`][Self::chunkSize].
        #[unsafe(method(setChunkSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setChunkSize(&self, chunk_size: NSUInteger);

        /// Initialize with default zero maximum retry and zero retry interval.
        #[unsafe(method(initWithRange:chunkSize:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithRange_chunkSize(
            this: Allocated<Self>,
            range: NSRange,
            chunk_size: NSUInteger,
        ) -> Retained<Self>;

        /// Parameter `range`: Read range specify by the starting block index and the total number of blocks.
        ///
        /// Parameter `chunkSize`: Specify number of blocks parameter for the Read multiple blocks command.
        ///
        /// Parameter `maximumRetries`: Maximum number of retry attempt when tag response is not received.
        ///
        /// Parameter `retryInterval`: Time interval wait between each retry attempt.
        #[unsafe(method(initWithRange:chunkSize:maximumRetries:retryInterval:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithRange_chunkSize_maximumRetries_retryInterval(
            this: Allocated<Self>,
            range: NSRange,
            chunk_size: NSUInteger,
            maximum_retries: NSUInteger,
            retry_interval: NSTimeInterval,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCISO15693ReadMultipleBlocksConfiguration {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// A
    ///
    /// ```text
    ///  NFCISO15693ReaderSession @link/ or @link NFCTagReaderSession @link/ reader session returns an instance conforming
    ///               to this protocol when an ISO15693 tag is detected.  Unless it is specified all block completion handlers are dispatched on the
    ///               reader session work queue that is associated with the tag.  Your process requires to include the "com.apple.developer.nfc.readersession.formats"
    ///               entitlement to receive this tag object from the @link NFCReaderSessionDelegate @link/ delegate.
    ///               @link NFCReaderErrorSecurityViolation @link/ will be returned from the @link NFCTagReaderSessionDelegate @link/ invalidation method if the required
    ///               entitlement is missing when session is started.
    ///               Tag must be in the connected state for NFCNDEFTag protocol properties and methods to work correctly.  Each data frame send out by the reader may not
    ///               exceed 256 bytes total.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693tag?language=objc)
    pub unsafe trait NFCISO15693Tag: NFCTag + NFCNDEFTag {
        /// The 64 bit hardware UID of the tag. Data is in Big Endian byte order.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        unsafe fn identifier(&self) -> Retained<NSData>;

        /// The IC manufacturer code (bits 56 – 49) in UID according to ISO/IEC 7816-6:2004.
        #[unsafe(method(icManufacturerCode))]
        #[unsafe(method_family = none)]
        unsafe fn icManufacturerCode(&self) -> NSUInteger;

        /// The IC serial number (bits 48 – 1) in UID assigned by the manufacturer.  Data is in Big Endian byte order.
        #[unsafe(method(icSerialNumber))]
        #[unsafe(method_family = none)]
        unsafe fn icSerialNumber(&self) -> Retained<NSData>;

        #[cfg(feature = "block2")]
        /// Parameter `commandConfiguration`: Configuration for the Manufacturer Custom Command.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                               responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion Send a manufacturer dependent custom command using command code range from 0xA0 to 0xDF.  Refer to ISO15693-3
        ///              specification for details.
        ///  
        ///
        /// ```
        #[unsafe(method(sendCustomCommandWithConfiguration:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendCustomCommandWithConfiguration_completionHandler(
            &self,
            command_configuration: &NFCISO15693CustomCommandConfiguration,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `readConfiguration`: Configuration For the Read Multiple Blocks command.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully read data blocks will be returned from NSData object.  All blocks are concatenated into the NSData object.
        ///
        ///  @discussion  Performs read operation using Read Multiple Blocks command (0x23 command code) as defined in ISO15693-3 specification.
        ///               Multiple Read Multiple Blocks commands will be sent if necessary to complete the operation.
        ///  
        ///
        /// ```
        #[unsafe(method(readMultipleBlocksWithConfiguration:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readMultipleBlocksWithConfiguration_completionHandler(
            &self,
            read_configuration: &NFCISO15693ReadMultipleBlocksConfiguration,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Stay quiet command (0x02 command code) as defined in ISO15693-3 specification.
        ///  
        ///
        /// ```
        #[unsafe(method(stayQuietWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn stayQuietWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: Block number. Blocks are numbered from 0 to 255 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully read data blocks will be returned from NSData object. If Option flag in the request flags is set,
        ///                           then first byte of data block will contain the associated block security status.
        ///
        ///  @discussion              Read single block command (0x20 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(readSingleBlockWithRequestFlags:blockNumber:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readSingleBlockWithRequestFlags_blockNumber_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: u8,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: Block number. Blocks are numbered from 0 to 255 inclusively.
        ///
        /// Parameter `dataBlock`: A single block of data.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Write single block command (0x21 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(writeSingleBlockWithRequestFlags:blockNumber:dataBlock:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeSingleBlockWithRequestFlags_blockNumber_dataBlock_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: u8,
            data_block: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: Block number. Blocks are numbered from 0 to 255 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully read data blocks will be returned from NSData object.
        ///
        ///  @discussion              Lock block command (0x22 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///
        /// ```
        #[unsafe(method(lockBlockWithRequestFlags:blockNumber:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn lockBlockWithRequestFlags_blockNumber_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: u8,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 255 inclusively.  Valid length is 1 to 256 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully read data blocks will be returned from NSArray of NSData object. If Option flag in the request flags is set,
        ///                           then first byte of each returned data block will contain the associated block security status.  Each data block element
        ///                           would have identical size.
        ///
        ///  @discussion              Read multiple blocks command (0x23 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(readMultipleBlocksWithRequestFlags:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readMultipleBlocksWithRequestFlags_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 255 inclusively.  Valid length is 1 to 256 inclusively.
        ///
        /// Parameter `dataBlocks`: Blocks of data represent in NSArray of NSData.  The number of blocks shall match the length value of the blockRange parameter.
        /// Each block element should have identical size and should match the physical block size of the tag.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Write multiple blocks command (0x24 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(writeMultipleBlocksWithRequestFlags:blockRange:dataBlocks:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeMultipleBlocksWithRequestFlags_blockRange_dataBlocks_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            data_blocks: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Select command (0x25 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(selectWithRequestFlags:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn selectWithRequestFlags_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Reset To Ready command (0x26 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(resetToReadyWithRequestFlags:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn resetToReadyWithRequestFlags_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `afi`: Application Family Identifier.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Write AFI command (0x27 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(writeAFIWithRequestFlag:afi:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeAFIWithRequestFlag_afi_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            afi: u8,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Lock AFI command (0x28 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(lockAFIWithRequestFlag:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn lockAFIWithRequestFlag_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `dsfid`: Data Storage Format Identifier.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Write DSFID command (0x29 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(writeDSFIDWithRequestFlag:dsfid:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeDSFIDWithRequestFlag_dsfid_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            dsfid: u8,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Use the replacement -lockDSFIDWithRequestFlag:completionHandler:.
        ///  
        ///
        /// ```
        #[deprecated]
        #[unsafe(method(lockDFSIDWithRequestFlag:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn lockDFSIDWithRequestFlag_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Lock DSFID command (0x2A command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(lockDSFIDWithRequestFlag:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn lockDSFIDWithRequestFlag_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Value of -1 will be returned from dsfid, afi, blockSize, blockCount, or icReference if tag response does not contain the information.
        ///                           blockSize returns the actual block size in bytes ranged from 1 to 32.  blockCount returns the actual number of blocks
        ///                           ranged from 1 to 256 blocks.
        ///
        ///  @discussion              Use the replacement -getSystemInfoAndUIDWithRequestFlag:completionHandler:.
        ///  
        ///
        /// ```
        #[deprecated]
        #[unsafe(method(getSystemInfoWithRequestFlag:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn getSystemInfoWithRequestFlag_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<
                dyn Fn(NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Value of -1 will be returned from dsfid, afi, blockSize, blockCount, or icReference, and a nil UID value if tag response does not contain the information.
        ///                           blockSize returns the actual block size in bytes ranged from 1 to 32.  blockCount returns the actual number of blocks
        ///                           ranged from 1 to 256 blocks.  64bits UID value in little endian byte order from the response packet is returned.
        ///
        ///  @discussion              Get system information command (0x2B command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///
        /// ```
        #[unsafe(method(getSystemInfoAndUIDWithRequestFlag:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn getSystemInfoAndUIDWithRequestFlag_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<
                dyn Fn(
                    *mut NSData,
                    NSInteger,
                    NSInteger,
                    NSInteger,
                    NSInteger,
                    NSInteger,
                    *mut NSError,
                ),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 255 inclusively.  Valid length is 1 to 256 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           The 8 bits security status of the requested blocks are returned in NSArray; the array will be empty when error occurs.
        ///
        ///  @discussion              Get multiple block security status command (0x2C command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(getMultipleBlockSecurityStatusWithRequestFlag:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn getMultipleBlockSecurityStatusWithRequestFlag_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSNumber>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 255 inclusively.  Valid length is 1 to 256 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        ///
        ///
        /// Fast read multiple blocks command (0x2D command code) as defined in ISO15693-3 specification.
        #[unsafe(method(fastReadMultipleBlocksWithRequestFlag:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn fastReadMultipleBlocksWithRequestFlag_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `customCommandCode`: Custom command code defined by the IC manufacturer.  Valid range is 0xA0 to 0xDF inclusively.
        ///
        /// Parameter `customRequestParameters`: Custom request parameters defined by the command.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                                   A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                                   responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                                   The custom response parameters are returned on success.
        ///
        ///  @discussion                      Custom command (0xA0 to 0xDF command code) as defined in ISO15693-3 specification.  IC manufacturer code from the tag is
        ///                                   automatically inserted after the command byte before appending the custom request parameters in forming the packet.
        ///  
        ///
        /// ```
        #[unsafe(method(customCommandWithRequestFlag:customCommandCode:customRequestParameters:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn customCommandWithRequestFlag_customCommandCode_customRequestParameters_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            custom_command_code: NSInteger,
            custom_request_parameters: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: 2 bytes block number, valid range from 0 to 65535 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           If Option flag in the request flags is set, then first byte of the returned data block will contain the associated block security status.
        ///
        ///  @discussion              Extended read single block command (0x30 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedReadSingleBlockWithRequestFlags:blockNumber:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedReadSingleBlockWithRequestFlags_blockNumber_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: NSInteger,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: 2 bytes block number, valid range from 0 to 65535 inclusively.
        ///
        /// Parameter `dataBlock`: A single block of data.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Extended write single block command (0x31 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedWriteSingleBlockWithRequestFlags:blockNumber:dataBlock:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedWriteSingleBlockWithRequestFlags_blockNumber_dataBlock_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: NSInteger,
            data_block: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockNumber`: 2 bytes block number, valid range from 0 to 65535 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Extended lock single block command (0x32 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedLockBlockWithRequestFlags:blockNumber:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedLockBlockWithRequestFlags_blockNumber_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_number: NSInteger,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 65535 inclusively.  Valid length is 1 to 65536 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully read data blocks will be returned from NSData object.  If Option flag in the request flags is set,
        ///                           then first byte of each returned data blocks will contain the associated block security status.
        ///
        ///  @discussion              Extended read multiple block command (0x33 command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedReadMultipleBlocksWithRequestFlags:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedReadMultipleBlocksWithRequestFlags_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 65535 inclusively.  Valid length is 1 to 65536 inclusively.
        ///
        /// Parameter `dataBlocks`: Blocks of data represented in NSArray of NSData.  The number of blocks shall match the length value of the blockRange parameter.
        /// Each block element should have identical size and should match the physical block size of the tag.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion              Extended write multiple block command (0x34 command code) as defined in ISO15693-3 specification. Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedWriteMultipleBlocksWithRequestFlags:blockRange:dataBlocks:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedWriteMultipleBlocksWithRequestFlags_blockRange_dataBlocks_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            data_blocks: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `cryptoSuiteIdentifier`: 8 bits Crypto Suite Indicator as defined in ISO/IEC 29167 specification.
        ///
        /// Parameter `message`: Content of the Authenticate command as dictated by the Crypto Suite Indicator.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                               A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                               responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                               Successfully command response will be return as NSData object excluding the 8 bits response flag.
        ///
        ///  @discussion                  Authenticate command (0x35 command code) as defined in ISO15693-3 specification.  Please note that in-process reply is returned to the caller without any processing.
        ///  
        ///
        /// ```
        #[unsafe(method(authenticateWithRequestFlags:cryptoSuiteIdentifier:message:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn authenticateWithRequestFlags_cryptoSuiteIdentifier_message_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            crypto_suite_identifier: NSInteger,
            message: &NSData,
            completion_handler: &block2::DynBlock<
                dyn Fn(NFCISO15693ResponseFlag, NonNull<NSData>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `keyIdentifier`: 8 bits key identifier
        ///
        /// Parameter `message`: Content of the Key Update command as dictated by the Crypto Suite Indicator used in Authenticate.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully command response will be return as NSData object excluding the 8 bits response flag.
        ///
        ///  @discussion              Key update command (0x36 command code) as defined in ISO15693-3 specification.  Please note that in-process reply is returned to the caller without any processing.
        ///  
        ///
        /// ```
        #[unsafe(method(keyUpdateWithRequestFlags:keyIdentifier:message:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn keyUpdateWithRequestFlags_keyIdentifier_message_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            key_identifier: NSInteger,
            message: &NSData,
            completion_handler: &block2::DynBlock<
                dyn Fn(NFCISO15693ResponseFlag, NonNull<NSData>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `cryptoSuiteIdentifier`: 8 bits Crypto Suite Indicator as defined in ISO/IEC 29167 specification.
        ///
        /// Parameter `message`: Content of the Key Update command as dictated by the Crypto Suite Indicator used in Authenticate.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                               A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                               responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///
        ///  @discussion                  Challenge command (0x39 command code) as defined in ISO15693-3 specification.
        ///  
        ///
        /// ```
        #[unsafe(method(challengeWithRequestFlags:cryptoSuiteIdentifier:message:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn challengeWithRequestFlags_cryptoSuiteIdentifier_message_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            crypto_suite_identifier: NSInteger,
            message: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           Successfully command response will be return as NSData object excluding the 8 bits response flag.
        ///
        ///  @discussion              Read buffer command (0x3A command code) as defined in ISO15693-3 specification.
        ///  
        ///
        /// ```
        #[unsafe(method(readBufferWithRequestFlags:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readBufferWithRequestFlags_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            completion_handler: &block2::DynBlock<
                dyn Fn(NFCISO15693ResponseFlag, NonNull<NSData>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `blockRange`: The range of blocks.  Valid start index range is 0 to 255 inclusively.  Valid length is 1 to 256 inclusively.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///                           A @link NFCISO15693TagResponseErrorKey @link/ in NSError userInfo dictionary is returned when the tag
        ///                           responded to the command with an error, and the error code value is defined in ISO15693-3 specification.
        ///                           The 8 bits security status of the requested blocks are returned in NSArray; the array will be empty when error occurs.
        ///
        ///  @discussion              Get multiple block security status command (0x3C command code) as defined in ISO15693-3 specification.  Address flag is automatically
        ///                           enforced by default and the tag's UID is sent with the command; setting RequestFlagSelect to flags will disable the Address flag.
        ///  
        ///
        /// ```
        #[unsafe(method(extendedGetMultipleBlockSecurityStatusWithRequestFlag:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedGetMultipleBlockSecurityStatusWithRequestFlag_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSNumber>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        ///
        ///
        /// Fast read multiple blocks command (0x3D command code) as defined in ISO15693-3 specification.
        #[unsafe(method(extendedFastReadMultipleBlocksWithRequestFlag:blockRange:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn extendedFastReadMultipleBlocksWithRequestFlag_blockRange_completionHandler(
            &self,
            flags: NFCISO15693RequestFlag,
            block_range: NSRange,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `flags`: Request flags.
        ///
        /// Parameter `commandCode`: 8 bits command code.
        ///
        /// Parameter `data`: Data follows after the command code.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        ///
        ///
        /// Send a command according to the ISO15693-3 specification.  The request data frame is concatenation of 8 bits request flag, 8 bits command code, and optional data.
        /// Total length of the data frame cannot exceed 256 bytes.  The 8 bits response flag and the data are returned in the completion handler.
        #[unsafe(method(sendRequestWithFlag:commandCode:data:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendRequestWithFlag_commandCode_data_completionHandler(
            &self,
            flags: NSInteger,
            command_code: NSInteger,
            data: Option<&NSData>,
            completion_handler: &block2::DynBlock<
                dyn Fn(NFCISO15693ResponseFlag, *mut NSData, *mut NSError),
            >,
        );
    }
);

extern_class!(
    /// Reader session for processing ISO15693 tags.
    ///
    /// ```text
    ///  [NFCReaderSessionDelegate readerSession:didDetectTags:] @link/ will return tag objects that
    ///              are conformed to the NFCISO15693Tag protocol.  This session requires the "com.apple.developer.nfc.readersession.formats" entitlement in your process.
    ///
    ///  NOTE:
    ///  Only one NFCReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///  The NFCISO15693 tag object returned by this session will only respond to the legacy APIs that are introduced in iOS11.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso15693readersession?language=objc)
    #[unsafe(super(NFCReaderSession, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated]
    pub struct NFCISO15693ReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCISO15693ReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCISO15693ReaderSession {}
);

impl NFCISO15693ReaderSession {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCReaderSessionDelegate @link/ object.
        ///  @param queue     A dispatch queue where NFCReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                   cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///
        ///  @return          A new NFCISO15693ReaderSession instance.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[deprecated = "No longer supported"]
        #[unsafe(method(initWithDelegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate_queue(
            this: Allocated<Self>,
            delegate: &ProtocolObject<dyn NFCReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;

        /// Restart the polling sequence in this session to discover new tags.  Tags that are returned previously by
        ///
        /// ```text
        ///  [NFCReaderSessionDelegate readerSession:didDetectTags:]
        ///              @link/ will become invalid, and all references to these tags shall be removed to properly release the resources.  Calling this method on an invalidated session
        ///              will have no effect; a new reader session is required to restart the reader.
        ///  
        ///
        /// ```
        #[deprecated = "No longer supported"]
        #[unsafe(method(restartPolling))]
        #[unsafe(method_family = none)]
        pub unsafe fn restartPolling(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCISO15693ReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndefstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCNDEFStatus(pub NSUInteger);
impl NFCNDEFStatus {
    #[doc(alias = "NFCNDEFStatusNotSupported")]
    pub const NotSupported: Self = Self(1);
    #[doc(alias = "NFCNDEFStatusReadWrite")]
    pub const ReadWrite: Self = Self(2);
    #[doc(alias = "NFCNDEFStatusReadOnly")]
    pub const ReadOnly: Self = Self(3);
}

unsafe impl Encode for NFCNDEFStatus {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NFCNDEFStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// Operations on a NDEF formatted tag.  Unless it is specified all block completion handlers are dispatched on the session work queue that is associated with the tag.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndeftag?language=objc)
    pub unsafe trait NFCNDEFTag: NSObjectProtocol + NSSecureCoding + NSCopying {
        /// Returns: <i>
        /// YES
        /// </i>
        /// if NDEF tag is available in the current reader session.  A tag remove from the RF field will become
        /// unavailable.  Tag in disconnected state will return NO.
        ///
        ///
        /// Check whether a detected NDEF tag is available.
        #[unsafe(method(isAvailable))]
        #[unsafe(method_family = none)]
        unsafe fn isAvailable(&self) -> bool;

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Return the NFCNDEFStatus of the tag.  capacity indicates the maximum NDEF message size in bytes that can be store on the tag.
        /// error returns a valid NSError object when query fails.
        ///
        ///
        /// Query the NDEF support status of the tag.
        #[unsafe(method(queryNDEFStatusWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn queryNDEFStatusWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(NFCNDEFStatus, NSUInteger, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Returns the NDEF message from read operation.  Successful read would return a valid NFCNDEFMessage object with NSError object set to nil;
        /// read failure returns a nil NFCNDEFMessage and a valid NSError object.
        ///
        ///
        /// Reads NDEF message from the tag.
        #[unsafe(method(readNDEFWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readNDEFWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NFCNDEFMessage, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Returns operation status.  A nil NSError object indicates a successful write operation.
        ///
        ///
        /// Writes a NDEF message to the tag.
        #[unsafe(method(writeNDEF:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeNDEF_completionHandler(
            &self,
            ndef_message: &NFCNDEFMessage,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Returns operation status. A nil NSError object indicates a successful lock operation.
        ///
        ///
        /// Locks the NDEF tag to read-only state; tag can no longer be written afterward.  This is a permanent operation.  A successful lock operation via this method
        /// will change the NFCNDEFStatus value of the tag to
        ///
        /// ```text
        ///  NFCNDEFStatusReadOnly @link/.
        ///  
        ///
        /// ```
        #[unsafe(method(writeLockWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeLockWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    }
);

/// Request code parameter for the polling command
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcfelicapollingrequestcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCFeliCaPollingRequestCode(pub NSInteger);
impl NFCFeliCaPollingRequestCode {
    #[doc(alias = "NFCFeliCaPollingRequestCodeNoRequest")]
    pub const NoRequest: Self = Self(0);
    #[doc(alias = "NFCFeliCaPollingRequestCodeSystemCode")]
    pub const SystemCode: Self = Self(1);
    #[doc(alias = "NFCFeliCaPollingRequestCodeCommunicationPerformance")]
    pub const CommunicationPerformance: Self = Self(2);
    #[deprecated]
    pub const PollingRequestCodeNoRequest: Self = Self(NFCFeliCaPollingRequestCode::NoRequest.0);
    #[deprecated]
    pub const PollingRequestCodeSystemCode: Self = Self(NFCFeliCaPollingRequestCode::SystemCode.0);
    #[deprecated]
    pub const PollingRequestCodeCommunicationPerformance: Self =
        Self(NFCFeliCaPollingRequestCode::CommunicationPerformance.0);
}

unsafe impl Encode for NFCFeliCaPollingRequestCode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCFeliCaPollingRequestCode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/pollingrequestcode?language=objc)
#[deprecated]
pub type PollingRequestCode = NFCFeliCaPollingRequestCode;

/// Time slot parameter for the polling command
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcfelicapollingtimeslot?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCFeliCaPollingTimeSlot(pub NSInteger);
impl NFCFeliCaPollingTimeSlot {
    #[doc(alias = "NFCFeliCaPollingTimeSlotMax1")]
    pub const Max1: Self = Self(0);
    #[doc(alias = "NFCFeliCaPollingTimeSlotMax2")]
    pub const Max2: Self = Self(1);
    #[doc(alias = "NFCFeliCaPollingTimeSlotMax4")]
    pub const Max4: Self = Self(3);
    #[doc(alias = "NFCFeliCaPollingTimeSlotMax8")]
    pub const Max8: Self = Self(7);
    #[doc(alias = "NFCFeliCaPollingTimeSlotMax16")]
    pub const Max16: Self = Self(15);
    #[deprecated]
    pub const PollingTimeSlotMax1: Self = Self(NFCFeliCaPollingTimeSlot::Max1.0);
    #[deprecated]
    pub const PollingTimeSlotMax2: Self = Self(NFCFeliCaPollingTimeSlot::Max2.0);
    #[deprecated]
    pub const PollingTimeSlotMax4: Self = Self(NFCFeliCaPollingTimeSlot::Max4.0);
    #[deprecated]
    pub const PollingTimeSlotMax8: Self = Self(NFCFeliCaPollingTimeSlot::Max8.0);
    #[deprecated]
    pub const PollingTimeSlotMax16: Self = Self(NFCFeliCaPollingTimeSlot::Max16.0);
}

unsafe impl Encode for NFCFeliCaPollingTimeSlot {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCFeliCaPollingTimeSlot {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/pollingtimeslot?language=objc)
#[deprecated]
pub type PollingTimeSlot = NFCFeliCaPollingTimeSlot;

/// Encryption Identifier parameter in response of Request Service V2
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcfelicaencryptionid?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCFeliCaEncryptionId(pub NSInteger);
impl NFCFeliCaEncryptionId {
    #[doc(alias = "NFCFeliCaEncryptionIdAES")]
    pub const AES: Self = Self(0x4F);
    #[doc(alias = "NFCFeliCaEncryptionIdAES_DES")]
    pub const AES_DES: Self = Self(0x41);
    #[deprecated]
    pub const EncryptionIdAES: Self = Self(NFCFeliCaEncryptionId::AES.0);
    #[deprecated]
    pub const EncryptionIdAES_DES: Self = Self(NFCFeliCaEncryptionId::AES_DES.0);
}

unsafe impl Encode for NFCFeliCaEncryptionId {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCFeliCaEncryptionId {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/encryptionid?language=objc)
#[deprecated]
pub type EncryptionId = NFCFeliCaEncryptionId;

extern_protocol!(
    /// A
    ///
    /// ```text
    ///  NFCTagReaderSession @link/ reader session returns an instance conforming to this protocol
    ///               when a FeliCa tag is detected.  Unless it is specified all block completion handlers are dispatched on the
    ///               session work queue that is associated with the tag.  Your process requires to include the
    ///               "com.apple.developer.nfc.readersession.formats" entitlement and the "com.apple.developer.nfc.readersession.felica.systemcodes"
    ///               key in the application's Info.plist to receive this tag object from the @link NFCTagReaderSessionDelegate @link/ delegate.
    ///               @link NFCReaderErrorSecurityViolation @link/ will be returned from the @link NFCTagReaderSessionDelegate @link/ invalidation
    ///               method if the required entitlement is missing or "com.apple.developer.nfc.readersession.felica.systemcodes" does not contain
    ///               at least one valid entry.
    ///               When the reader discovers a FeliCa tag it automatically performs a Polling command using the system code values provided in the
    ///               "com.apple.developer.nfc.readersession.felica.systemcodes" in the specified array order. System code
    ///               specified in the array must not contain a wildcard value (0xFF) in the upper or the lower byte, i.e. full
    ///               matching value is required.  The tag is returned from the [NFCTagReaderSessionDelegate readerSession:didDetectTags:] call
    ///               on the first successful Polling command matching one of the system codes.  Tag will not be returned
    ///               to the NFCTagReaderSessionDelegate if no matching system is found based on entries listed in the Info.plist.
    ///               Tag must be in the connected state for NFCNDEFTag protocol properties and methods to work correctly.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcfelicatag?language=objc)
    pub unsafe trait NFCFeliCaTag: NFCTag + NFCNDEFTag {
        /// This will match one of the entries in the "com.apple.developer.nfc.readersession.felica.systemcodes"
        /// in the Info.plist.
        #[unsafe(method(currentSystemCode))]
        #[unsafe(method_family = none)]
        unsafe fn currentSystemCode(&self) -> Retained<NSData>;

        /// It will be empty if system selection fails.
        #[unsafe(method(currentIDm))]
        #[unsafe(method_family = none)]
        unsafe fn currentIDm(&self) -> Retained<NSData>;

        #[cfg(feature = "block2")]
        /// Parameter `systemCode`: Designation of System Code.  Wildcard value (0xFF) in the upper or the lower byte is not supported.
        ///
        /// Parameter `requestCode`: Designation of Request Data output.
        ///
        /// Parameter `timeSlot`: Maximum number of slots possible to respond.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation
        /// succeeds, else all other return values shall be ignored.  Non-zero length requestData is return when
        /// requestCode is a non-zero parameter and feature is supported by the tag.  The
        ///
        /// ```text
        ///  currentIDM @link/ property will be updated
        ///                           on each execution, except when an invalid systemCode is provided and the existing selected system will stay selected.
        ///
        ///  @discussion              Polling command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        ///                           System code must be one of the provided values in the "com.apple.developer.nfc.readersession.felica.systemcodes"
        ///                           in the Info.plist; @link NFCReaderErrorSecurityViolation @link/ will be returned when an invalid system code is used.
        ///                           Polling with wildcard value in the upper or lower byte is not supported.
        ///  
        ///
        /// ```
        #[unsafe(method(pollingWithSystemCode:requestCode:timeSlot:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn pollingWithSystemCode_requestCode_timeSlot_completionHandler(
            &self,
            system_code: &NSData,
            request_code: NFCFeliCaPollingRequestCode,
            time_slot: NFCFeliCaPollingTimeSlot,
            completion_handler: &block2::DynBlock<
                dyn Fn(NonNull<NSData>, NonNull<NSData>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `nodeCodeList`: Node Code list represented in a NSArray of NSData objects.  Number of nodes specified should be between 1 to 32 inclusive.
        /// Each node code should be 2 bytes stored in Little Endian format.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  Node key version list is return as NSArray of NSData objects,
        /// and each data object is stored in Little Endian format per FeliCa specification.
        ///
        ///
        /// Request Service command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(requestServiceWithNodeCodeList:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn requestServiceWithNodeCodeList_completionHandler(
            &self,
            node_code_list: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  Valid mode value ranges from 0 to 3 inclusively.
        ///
        ///
        /// Request Response command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(requestResponseWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn requestResponseWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `serviceCodeList`: Service Code list represented in a NSArray of NSData objects.  Number of nodes specified should be between 1 to 16 inclusive.
        /// Each service code should be 2 bytes stored in Little Endian format.
        ///
        /// Parameter `blockList`: Block List represent in a NSArray of NSData objects.  2-Byte or 3-Byte block list element is supported.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  Valid read data blocks (block length of 16 bytes)
        /// are returned in NSArray of NSData objects when Status Flag 1 equals zero.
        ///
        ///
        /// Read Without Encryption command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(readWithoutEncryptionWithServiceCodeList:blockList:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn readWithoutEncryptionWithServiceCodeList_blockList_completionHandler(
            &self,
            service_code_list: &NSArray<NSData>,
            block_list: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<
                dyn Fn(NSInteger, NSInteger, NonNull<NSArray<NSData>>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `serviceCodeList`: Service Code list represented in a NSArray of NSData objects.  Number of nodes specified should be between 1 to 16 inclusive.
        /// Each service code should be 2 bytes stored in Little Endian format.
        ///
        /// Parameter `blockList`: Block List represent in a NSArray of NSData objects.  Total blockList items and blockData items should match.
        /// 2-Byte or 3-Byte block list element is supported.
        ///
        /// Parameter `blockData`: Block data represent in a NSArray of NSData objects.  Total blockList items and blockData items should match.
        /// Data block should be 16 bytes in length.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.
        ///
        ///
        /// Write Without Encryption command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(writeWithoutEncryptionWithServiceCodeList:blockList:blockData:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn writeWithoutEncryptionWithServiceCodeList_blockList_blockData_completionHandler(
            &self,
            service_code_list: &NSArray<NSData>,
            block_list: &NSArray<NSData>,
            block_data: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<dyn Fn(NSInteger, NSInteger, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  Each system code is 2 bytes stored in Little Endian format.
        ///
        ///
        /// Request System Code command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(requestSystemCodeWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn requestSystemCodeWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSData>>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `nodeCodeList`: Node Code list represent in a NSArray of NSData.  Number of nodes specified should be between 1 to 32 inclusive.
        /// Each node code should be 2 bytes stored in Little Endian format.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  encryptionIdentifier value shall be ignored if Status Flag 1 value indicates an error.
        /// nodeKeyVersionListAES and nodeKeyVersionListDES may be empty depending on the Status Flag 1 value and the Encryption Identifier value.
        /// The 2 bytes node key version (AES and DES) is in Little Endian format.
        ///
        ///
        /// Request Service V2 command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(requestServiceV2WithNodeCodeList:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn requestServiceV2WithNodeCodeList_completionHandler(
            &self,
            node_code_list: &NSArray<NSData>,
            completion_handler: &block2::DynBlock<
                dyn Fn(
                    NSInteger,
                    NSInteger,
                    NFCFeliCaEncryptionId,
                    NonNull<NSArray<NSData>>,
                    NonNull<NSArray<NSData>>,
                    *mut NSError,
                ),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.  basicVersion and optionVersion may be empty depending on the Status Flag 1 value
        /// and if the tag supports AES/DES.
        ///
        ///
        /// Request Specification Version command defined by FeliCa card specification.  This command supports response format version `00`h.
        /// Refer to the FeliCa specification for details.
        #[unsafe(method(requestSpecificationVersionWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn requestSpecificationVersionWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<
                dyn Fn(NSInteger, NSInteger, NonNull<NSData>, NonNull<NSData>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if the contactless transceive operation succeeds,
        /// else all other return values shall be ignored.
        ///
        ///
        /// Reset Mode command defined by FeliCa card specification.  Refer to the FeliCa specification for details.
        #[unsafe(method(resetModeWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn resetModeWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(NSInteger, NSInteger, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `commandPacket`: Command packet send to the FeliCa card.  Maximum packet length is 254.  Data length (LEN) byte and CRC bytes are calculated and inserted
        /// automatically to the provided packet data frame.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
        ///
        ///  @discussion              Transmission of FeliCa Command Packet Data at the application layer.  Refer to the FeliCa specification for details.
        ///                           Manufacturer ID (IDm) of the currently selected system can be read from the currentIDm property.
        ///  
        ///
        /// ```
        #[unsafe(method(sendFeliCaCommandPacket:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendFeliCaCommandPacket_completionHandler(
            &self,
            command_packet: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );
    }
);

extern_class!(
    /// ISO7816 Application Data Unit (APDU).
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso7816apdu?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCISO7816APDU;
);

extern_conformance!(
    unsafe impl NSCopying for NFCISO7816APDU {}
);

unsafe impl CopyingHelper for NFCISO7816APDU {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCISO7816APDU {}
);

impl NFCISO7816APDU {
    extern_methods!(
        #[unsafe(method(instructionClass))]
        #[unsafe(method_family = none)]
        pub unsafe fn instructionClass(&self) -> u8;

        #[unsafe(method(instructionCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn instructionCode(&self) -> u8;

        #[unsafe(method(p1Parameter))]
        #[unsafe(method_family = none)]
        pub unsafe fn p1Parameter(&self) -> u8;

        #[unsafe(method(p2Parameter))]
        #[unsafe(method_family = none)]
        pub unsafe fn p2Parameter(&self) -> u8;

        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub unsafe fn data(&self) -> Option<Retained<NSData>>;

        #[unsafe(method(expectedResponseLength))]
        #[unsafe(method_family = none)]
        pub unsafe fn expectedResponseLength(&self) -> NSInteger;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Parameter `instructionClass`: Instruction class (CLA) byte
        ///
        /// Parameter `instructionCode`: Instruction code (INS) byte
        ///
        /// Parameter `p1Parameter`: P1 parameter byte
        ///
        /// Parameter `p2Parameter`: P2 parameter byte
        ///
        /// Parameter `data`: Data to transmit.  Value of Lc field is set according to the data size.
        ///
        /// Parameter `expectedResponseLength`: Response data length (Le) in bytes. Valid range is from 1 to 65536 inclusively;
        /// -1 means no response data field is expected.  Use 256 if you want to send '00' as the short Le field
        /// assuming the data field is less than 256 bytes.  Use 65536 if you want to send '0000' as the extended
        /// Le field.
        ///
        ///
        /// Generates an ISO7816 APDU object.  The Lc value is generated base on the size of the data object; possible value ranges from
        /// 1 to 65535 inclusively.  Use
        ///
        /// ```text
        ///  -initWithData: @link/ in cases where a finer control on the APDU format is required.
        ///  
        ///
        /// ```
        #[unsafe(method(initWithInstructionClass:instructionCode:p1Parameter:p2Parameter:data:expectedResponseLength:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithInstructionClass_instructionCode_p1Parameter_p2Parameter_data_expectedResponseLength(
            this: Allocated<Self>,
            instruction_class: u8,
            instruction_code: u8,
            p1_parameter: u8,
            p2_parameter: u8,
            data: &NSData,
            expected_response_length: NSInteger,
        ) -> Retained<Self>;

        /// Parameter `data`: Data buffer containing the full APDU.
        ///
        ///
        /// Returns: nil if input data does not contain a valid APDU.
        #[unsafe(method(initWithData:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCISO7816APDU {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// A
    ///
    /// ```text
    ///  NFCTagReaderSession @link/ reader session returns an instance conforming to this protocol
    ///               when an ISO7816 compatible tag is detected.  Unless it is specified all block completion handlers are dispatched on the
    ///               session work queue that is associated with the tag.  Your process requires to include the
    ///               "com.apple.developer.nfc.readersession.formats" entitlement and the "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
    ///               key in the application's Info.plist to receive this tag object from the @link NFCTagReaderSessionDelegate @link/ delegate.
    ///               @link NFCReaderErrorSecurityViolation @link/ will be returned from the @link NFCTagReaderSessionDelegate @link/ invalidation
    ///               method if the required entitlement is missing or "com.apple.developer.nfc.readersession.iso7816.select-identifiers" does not contain
    ///               at least one valid entry.
    ///               When the reader discovered a compatible ISO7816 tag it automatically performs a SELECT command (by DF name) using the values provided in
    ///               "com.apple.developer.nfc.readersession.iso7816.select-identifiers" in the specified array order.  The tag is
    ///               returned from the [NFCTagReaderSessionDelegate readerSession:didDetectTags:] call on the first successful SELECT command.
    ///               The initialSelectedAID property returns the application identifier of the selected application.  Tag will not be returned
    ///               to the NFCTagReaderSessionDelegate if no application described in "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
    ///               is found.  Tag must be in the connected state for NFCNDEFTag protocol properties and methods to work correctly.
    ///
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfciso7816tag?language=objc)
    pub unsafe trait NFCISO7816Tag: NFCTag + NFCNDEFTag {
        /// This will match one of the entries in the "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
        /// in the Info.plist.
        #[unsafe(method(initialSelectedAID))]
        #[unsafe(method_family = none)]
        unsafe fn initialSelectedAID(&self) -> Retained<NSString>;

        /// The hardware UID of the tag.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        unsafe fn identifier(&self) -> Retained<NSData>;

        /// The optional historical bytes extracted from the Type A Answer To Select response.
        #[unsafe(method(historicalBytes))]
        #[unsafe(method_family = none)]
        unsafe fn historicalBytes(&self) -> Option<Retained<NSData>>;

        /// The optional Application Data bytes extracted from the Type B Answer To Request response.
        #[unsafe(method(applicationData))]
        #[unsafe(method_family = none)]
        unsafe fn applicationData(&self) -> Option<Retained<NSData>>;

        /// Indicates if
        ///
        /// ```text
        ///  applicationData @link/ follows proprietary data coding.  If false, the format of the application data is
        ///              defined in the ISO14443-3 specification.
        ///  
        ///
        /// ```
        #[unsafe(method(proprietaryApplicationDataCoding))]
        #[unsafe(method_family = none)]
        unsafe fn proprietaryApplicationDataCoding(&self) -> bool;

        #[cfg(feature = "block2")]
        /// Parameter `apdu`: The command APDU object
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.  responseData may be
        ///                           empty.  Command processing status bytes (SW1-SW2) are always valid.
        ///
        ///  @discussion  Send a command APDU to the tag and receives a response APDU.  Note that a SELECT command with a P1 value of 0x04 (selection by DF name)
        ///               will be checked against the values listed in the "com.apple.developer.nfc.readersession.iso7816.select-identifiers" in the Info.plist.
        ///               Selecting an application outside of the permissible list will result in a NFCReaderErrorSecurityViolation error.
        ///  
        ///
        /// ```
        #[unsafe(method(sendCommandAPDU:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendCommandAPDU_completionHandler(
            &self,
            apdu: &NFCISO7816APDU,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, u8, u8, *mut NSError)>,
        );
    }
);

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcmifarefamily?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCMiFareFamily(pub NSUInteger);
impl NFCMiFareFamily {
    #[doc(alias = "NFCMiFareUnknown")]
    pub const Unknown: Self = Self(1);
    #[doc(alias = "NFCMiFareUltralight")]
    pub const Ultralight: Self = Self(2);
    #[doc(alias = "NFCMiFarePlus")]
    pub const Plus: Self = Self(3);
    #[doc(alias = "NFCMiFareDESFire")]
    pub const DESFire: Self = Self(4);
}

unsafe impl Encode for NFCMiFareFamily {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NFCMiFareFamily {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// A
    ///
    /// ```text
    ///  NFCTagReaderSession @link/ reader session returns an instance conforming to this protocol when a MiFare tag is detected.  Unless it is specified
    ///               all block completion handlers are dispatched on the session work queue that is associated with the tag.  Your process requires to include the
    ///               "com.apple.developer.nfc.readersession.formats" entitlement to receive this tag object from the @link NFCTagReaderSessionDelegate @link/ delegate.
    ///               Tag must be in the connected state for NFCNDEFTag protocol properties and methods to work correctly.
    ///               @link NFCReaderErrorSecurityViolation @link/ will be returned from the @link NFCTagReaderSessionDelegate @link/ invalidation method if the required entitlement
    ///               is missing when session is started.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcmifaretag?language=objc)
    pub unsafe trait NFCMiFareTag: NFCTag + NFCNDEFTag {
        #[unsafe(method(mifareFamily))]
        #[unsafe(method_family = none)]
        unsafe fn mifareFamily(&self) -> NFCMiFareFamily;

        /// The hardware UID of the tag.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        unsafe fn identifier(&self) -> Retained<NSData>;

        /// The optional historical bytes extracted from the Answer To Select response.
        #[unsafe(method(historicalBytes))]
        #[unsafe(method_family = none)]
        unsafe fn historicalBytes(&self) -> Option<Retained<NSData>>;

        #[cfg(feature = "block2")]
        /// Parameter `command`: The complete MiFare command.  CRC bytes are calculated and inserted automatically to the provided packet data frame.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds. A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error
        ///                           is returned when there is a communication issue with the tag. Successfully read data blocks will be returned from the NSData object.
        ///
        ///  @discussion              Send native MIFARE command to a tag.  Support MIFARE UltraLight, Plus, and DESFire products.
        ///                           Crypto1 protocol is not supported.  Command chaining is handled internally by the method and the full response composed of the
        ///                           individual fragment is returned in the completion handler.
        ///  
        ///
        /// ```
        #[unsafe(method(sendMiFareCommand:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendMiFareCommand_completionHandler(
            &self,
            command: &NSData,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Parameter `apdu`: The ISO7816-4 command APDU object.
        ///
        /// Parameter `completionHandler`: Completion handler called when the operation is completed.  error is nil if operation succeeds.
        /// A
        ///
        /// ```text
        ///  NFCErrorDomain @link/ error is returned when there is a communication issue with the tag or tag does not support ISO7816-4 commands,
        ///                           and all other parameters should be ignore.
        ///
        ///  @discussion  Send a ISO7816 command APDU to the tag and receives a response APDU.  Only available when @link mifareFamily @link/ returns NFCMiFarePlus, NFCMiFareDESFire.
        ///  
        ///
        /// ```
        #[unsafe(method(sendMiFareISO7816Command:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn sendMiFareISO7816Command_completionHandler(
            &self,
            apdu: &NFCISO7816APDU,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSData>, u8, u8, *mut NSError)>,
        );
    }
);

/// Type Name Format value defined by NFC Data Exchange Format (NDEF) Technical Specification
/// from NFC Forum.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfctypenameformat?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCTypeNameFormat(pub u8);
impl NFCTypeNameFormat {
    #[doc(alias = "NFCTypeNameFormatEmpty")]
    pub const Empty: Self = Self(0x00);
    #[doc(alias = "NFCTypeNameFormatNFCWellKnown")]
    pub const NFCWellKnown: Self = Self(0x01);
    #[doc(alias = "NFCTypeNameFormatMedia")]
    pub const Media: Self = Self(0x02);
    #[doc(alias = "NFCTypeNameFormatAbsoluteURI")]
    pub const AbsoluteURI: Self = Self(0x03);
    #[doc(alias = "NFCTypeNameFormatNFCExternal")]
    pub const NFCExternal: Self = Self(0x04);
    #[doc(alias = "NFCTypeNameFormatUnknown")]
    pub const Unknown: Self = Self(0x05);
    #[doc(alias = "NFCTypeNameFormatUnchanged")]
    pub const Unchanged: Self = Self(0x06);
}

unsafe impl Encode for NFCTypeNameFormat {
    const ENCODING: Encoding = u8::ENCODING;
}

unsafe impl RefEncode for NFCTypeNameFormat {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A NDEF message payload consists of Type Name Format, Type, Payload Identifier, and Payload data.
    /// The NDEF payload cannot result into a record that is greater than 128KB in size.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndefpayload?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCNDEFPayload;
);

extern_conformance!(
    unsafe impl NSCoding for NFCNDEFPayload {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCNDEFPayload {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for NFCNDEFPayload {}
);

impl NFCNDEFPayload {
    extern_methods!(
        #[unsafe(method(typeNameFormat))]
        #[unsafe(method_family = none)]
        pub unsafe fn typeNameFormat(&self) -> NFCTypeNameFormat;

        /// Setter for [`typeNameFormat`][Self::typeNameFormat].
        #[unsafe(method(setTypeNameFormat:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTypeNameFormat(&self, type_name_format: NFCTypeNameFormat);

        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> Retained<NSData>;

        /// Setter for [`type`][Self::type].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setType(&self, r#type: &NSData);

        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSData>;

        /// Setter for [`identifier`][Self::identifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIdentifier(&self, identifier: &NSData);

        #[unsafe(method(payload))]
        #[unsafe(method_family = none)]
        pub unsafe fn payload(&self) -> Retained<NSData>;

        /// Setter for [`payload`][Self::payload].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPayload:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPayload(&self, payload: &NSData);

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Parameter `format`: NFCTypeNameFormat value.
        ///
        /// Parameter `type`: Identifier describing the type of the payload.  Empty data indicates field is absent from the payload.
        ///
        /// Parameter `identifier`: Identifier in the form of a URI reference.  Empty data indicates field is absent from the payload.
        ///
        /// Parameter `payload`: Payload data.  Empty data indicates field is absent from the payload.
        ///
        /// This initializer uses the maximum payload chunk size defined by the NFC NDEF specification, i.e. 2^32-1 octets.
        #[unsafe(method(initWithFormat:type:identifier:payload:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFormat_type_identifier_payload(
            this: Allocated<Self>,
            format: NFCTypeNameFormat,
            r#type: &NSData,
            identifier: &NSData,
            payload: &NSData,
        ) -> Retained<Self>;

        /// Parameter `format`: NFCTypeNameFormat value.
        ///
        /// Parameter `type`: Identifier describing the type of the payload.  Empty data indicates field is absent from the payload.
        ///
        /// Parameter `identifier`: Identifier in the form of a URI reference.  Empty data indicates field is absent from the payload.
        ///
        /// Parameter `payload`: Payload data.  Empty data indicates field is absent from the payload.
        ///
        /// Parameter `chunkSize`: Maximum size of a payload chunk.  0 means no chunking on the payload, i.e. payload is fit in a single record.
        #[unsafe(method(initWithFormat:type:identifier:payload:chunkSize:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFormat_type_identifier_payload_chunkSize(
            this: Allocated<Self>,
            format: NFCTypeNameFormat,
            r#type: &NSData,
            identifier: &NSData,
            payload: &NSData,
            chunk_size: usize,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCNDEFPayload {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// ConvenienceHelpers.
impl NFCNDEFPayload {
    extern_methods!(
        /// Parameter `uri`: URI string.  UTF-8 encoding representation will be used.
        ///
        ///
        /// Used for creating NDEF URI payloads which cannot be represented with NSURL object.  These are URIs that contain characters
        /// such as 'ä' and 'ö' which cannot be represent by the 7 bits ASCII encoding.
        #[unsafe(method(wellKnownTypeURIPayloadWithString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnownTypeURIPayloadWithString(uri: &NSString) -> Option<Retained<Self>>;

        /// Parameter `url`: NSURL object.
        ///
        ///
        /// Preferred convenience function for creating NDEF URI payload with common URLs such as "https://www.apple.com" or "tel:+1-555-555-5555".
        #[unsafe(method(wellKnownTypeURIPayloadWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnownTypeURIPayloadWithURL(url: &NSURL) -> Option<Retained<Self>>;

        /// Parameter `text`: Text message.
        ///
        /// Parameter `locale`: NSLocale object.  IANA language code specified by the locale will be saved with the payload.
        #[unsafe(method(wellKnownTypeTextPayloadWithString:locale:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnownTypeTextPayloadWithString_locale(
            text: &NSString,
            locale: &NSLocale,
        ) -> Option<Retained<Self>>;

        #[deprecated]
        #[unsafe(method(wellKnowTypeTextPayloadWithString:locale:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnowTypeTextPayloadWithString_locale(
            text: &NSString,
            locale: &NSLocale,
        ) -> Option<Retained<Self>>;

        /// Returns: NSURL object base on a valid Well Known Type URI payload. nil if payload is not a URI.
        #[unsafe(method(wellKnownTypeURIPayload))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnownTypeURIPayload(&self) -> Option<Retained<NSURL>>;

        /// Parameter `locale`: Returns NSLocale object that is constructed from the IANA language code stored with the text payload.
        ///
        /// Returns: NSString object base on a valid Well Known Type Text payload.  nil if payload is not a text.
        #[unsafe(method(wellKnownTypeTextPayloadWithLocale:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wellKnownTypeTextPayloadWithLocale(
            &self,
            locale: &mut Option<Retained<NSLocale>>,
        ) -> Option<Retained<NSString>>;
    );
}

extern_class!(
    /// A NDEF message consists of payload records.  The maximum size of the NDEF message is limited to 128KB.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcndefmessage?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCNDEFMessage;
);

extern_conformance!(
    unsafe impl NSCoding for NFCNDEFMessage {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCNDEFMessage {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for NFCNDEFMessage {}
);

impl NFCNDEFMessage {
    extern_methods!(
        /// Array of NFCNDEFPayload records contained in this message.
        #[unsafe(method(records))]
        #[unsafe(method_family = none)]
        pub unsafe fn records(&self) -> Retained<NSArray<NFCNDEFPayload>>;

        /// Setter for [`records`][Self::records].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setRecords:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRecords(&self, records: &NSArray<NFCNDEFPayload>);

        /// Length of the resulting NDEF message in bytes as it would be stored on a NFC tag.
        #[unsafe(method(length))]
        #[unsafe(method_family = none)]
        pub unsafe fn length(&self) -> NSUInteger;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Parameter `records`: NSArray of NFCNDEFPayload object.  An empty array will create an empty NDEF message.
        #[unsafe(method(initWithNDEFRecords:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNDEFRecords(
            this: Allocated<Self>,
            records: &NSArray<NFCNDEFPayload>,
        ) -> Retained<Self>;

        /// Parameter `data`: NSData storing raw bytes of a complete NDEF message.  The data content will be validated; all NDEF payloads must
        /// be valid according to the NFC Forum NDEF RTD specification and it shall only contain a single NDEF message.
        #[unsafe(method(ndefMessageWithData:))]
        #[unsafe(method_family = none)]
        pub unsafe fn ndefMessageWithData(data: &NSData) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCNDEFMessage {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvasmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCVASMode(pub NSInteger);
impl NFCVASMode {
    #[doc(alias = "NFCVASModeURLOnly")]
    pub const URLOnly: Self = Self(0);
    #[doc(alias = "NFCVASModeNormal")]
    pub const Normal: Self = Self(1);
    #[deprecated]
    pub const VASModeURLOnly: Self = Self(NFCVASMode::URLOnly.0);
    #[deprecated]
    pub const VASModeNormal: Self = Self(NFCVASMode::Normal.0);
}

unsafe impl Encode for NFCVASMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCVASMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/vasmode?language=objc)
#[deprecated]
pub type VASMode = NFCVASMode;

extern_class!(
    /// Configuration for one GET VAS DATA command.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvascommandconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCVASCommandConfiguration;
);

extern_conformance!(
    unsafe impl NSCopying for NFCVASCommandConfiguration {}
);

unsafe impl CopyingHelper for NFCVASCommandConfiguration {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCVASCommandConfiguration {}
);

impl NFCVASCommandConfiguration {
    extern_methods!(
        /// VAS protocol mode.
        #[unsafe(method(mode))]
        #[unsafe(method_family = none)]
        pub unsafe fn mode(&self) -> NFCVASMode;

        /// Setter for [`mode`][Self::mode].
        #[unsafe(method(setMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMode(&self, mode: NFCVASMode);

        /// Wallet Pass Type Identifier of the Wallet Pass.  The string value will be used to calculate the
        /// Merchant ID value for the GET VAS DATA command.
        #[unsafe(method(passTypeIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn passTypeIdentifier(&self) -> Retained<NSString>;

        /// Setter for [`passTypeIdentifier`][Self::passTypeIdentifier].
        #[unsafe(method(setPassTypeIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPassTypeIdentifier(&self, pass_type_identifier: &NSString);

        /// Merchant URL object.  Maximum length of the URL is 64 characters, including the schema.
        /// Set to nil to disable the merchant URL.
        #[unsafe(method(url))]
        #[unsafe(method_family = none)]
        pub unsafe fn url(&self) -> Option<Retained<NSURL>>;

        /// Setter for [`url`][Self::url].
        #[unsafe(method(setUrl:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUrl(&self, url: Option<&NSURL>);

        /// Parameter `mode`: VAS operation mode
        ///
        /// Parameter `passTypeIdentifier`: Pass type identifier of the Wallet pass.
        ///
        /// Parameter `url`: URL for VAR URL Only mode.  Set to
        /// <i>
        /// nil
        /// </i>
        /// for VAS normal mode.
        #[unsafe(method(initWithVASMode:passTypeIdentifier:url:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithVASMode_passTypeIdentifier_url(
            this: Allocated<Self>,
            mode: NFCVASMode,
            pass_type_identifier: &NSString,
            url: Option<&NSURL>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCVASCommandConfiguration {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// Response APDU status word.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvaserrorcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NFCVASErrorCode(pub NSInteger);
impl NFCVASErrorCode {
    #[doc(alias = "NFCVASErrorCodeSuccess")]
    pub const Success: Self = Self(0x9000);
    #[doc(alias = "NFCVASErrorCodeDataNotFound")]
    pub const DataNotFound: Self = Self(0x6A83);
    #[doc(alias = "NFCVASErrorCodeDataNotActivated")]
    pub const DataNotActivated: Self = Self(0x6287);
    #[doc(alias = "NFCVASErrorCodeWrongParameters")]
    pub const WrongParameters: Self = Self(0x6B00);
    #[doc(alias = "NFCVASErrorCodeWrongLCField")]
    pub const WrongLCField: Self = Self(0x6700);
    #[doc(alias = "NFCVASErrorCodeUserIntervention")]
    pub const UserIntervention: Self = Self(0x6984);
    #[doc(alias = "NFCVASErrorCodeIncorrectData")]
    pub const IncorrectData: Self = Self(0x6A80);
    #[doc(alias = "NFCVASErrorCodeUnsupportedApplicationVersion")]
    pub const UnsupportedApplicationVersion: Self = Self(0x6340);
    #[deprecated]
    pub const VASErrorCodeSuccess: Self = Self(NFCVASErrorCode::Success.0);
    #[deprecated]
    pub const VASErrorCodeDataNotFound: Self = Self(NFCVASErrorCode::DataNotFound.0);
    #[deprecated]
    pub const VASErrorCodeDataNotActivated: Self = Self(NFCVASErrorCode::DataNotActivated.0);
    #[deprecated]
    pub const VASErrorCodeWrongParameters: Self = Self(NFCVASErrorCode::WrongParameters.0);
    #[deprecated]
    pub const VASErrorCodeWrongLCField: Self = Self(NFCVASErrorCode::WrongLCField.0);
    #[deprecated]
    pub const VASErrorCodeUserIntervention: Self = Self(NFCVASErrorCode::UserIntervention.0);
    #[deprecated]
    pub const VASErrorCodeIncorrectData: Self = Self(NFCVASErrorCode::IncorrectData.0);
    #[deprecated]
    pub const VASErrorCodeUnsupportedApplicationVersion: Self =
        Self(NFCVASErrorCode::UnsupportedApplicationVersion.0);
}

unsafe impl Encode for NFCVASErrorCode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NFCVASErrorCode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/corenfc/vaserrorcode?language=objc)
#[deprecated]
pub type VASErrorCode = NFCVASErrorCode;

extern_class!(
    /// Response from one GET VAS DATA command.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvasresponse?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCVASResponse;
);

extern_conformance!(
    unsafe impl NSCopying for NFCVASResponse {}
);

unsafe impl CopyingHelper for NFCVASResponse {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCVASResponse {}
);

impl NFCVASResponse {
    extern_methods!(
        /// Response APDU status.
        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> NFCVASErrorCode;

        /// VAS data.
        #[unsafe(method(vasData))]
        #[unsafe(method_family = none)]
        pub unsafe fn vasData(&self) -> Retained<NSData>;

        /// Mobile token value.
        #[unsafe(method(mobileToken))]
        #[unsafe(method_family = none)]
        pub unsafe fn mobileToken(&self) -> Retained<NSData>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCVASResponse {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// Value Added Service (VAS) reader session callbacks.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvasreadersessiondelegate?language=objc)
    pub unsafe trait NFCVASReaderSessionDelegate: NSObjectProtocol {
        /// Parameter `session`: The session object in the active state.
        ///
        ///
        /// Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for VAS tags.
        /// The
        ///
        /// ```text
        ///  readerSession:didReceiveVASResponses: @link/ will be called when a VAS transaction is completed.
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(readerSessionDidBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSessionDidBecomeActive(&self, session: &NFCVASReaderSession);

        /// Parameter `session`: The session object that is invalidated.
        ///
        /// Parameter `error`: The error indicates the invalidation reason.
        ///
        ///
        /// Gets called when a session becomes invalid.  At this point the client is expected to discard
        /// the returned session object.
        #[unsafe(method(readerSession:didInvalidateWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didInvalidateWithError(
            &self,
            session: &NFCVASReaderSession,
            error: &NSError,
        );

        /// Parameter `session`: The session object used for tag detection.
        ///
        /// Parameter `responses`: Array of
        ///
        /// ```text
        ///  NFCVASResponse @link/ objects.  The order of the response objects follows the
        ///                   sequence of GET VAS DATA sent by the reader session.
        ///
        ///  @discussion      Gets called when the reader completes the requested VAS transaction.  Polling
        ///                   is automatically restarted once the detected tag is removed from the reader's read range.
        ///  
        ///
        /// ```
        #[unsafe(method(readerSession:didReceiveVASResponses:))]
        #[unsafe(method_family = none)]
        unsafe fn readerSession_didReceiveVASResponses(
            &self,
            session: &NFCVASReaderSession,
            responses: &NSArray<NFCVASResponse>,
        );
    }
);

extern_class!(
    /// Reader session for processing Value Added Service (VAS) tags.  This session requires the "com.apple.developer.nfc.readersession.formats"
    /// entitlement in your process.  In addition your application's Info.plist must contain a non-empty usage description string.
    ///
    /// ```text
    ///  NFCReaderErrorSecurityViolation @link/ will be returned from @link [NFCVASReaderSessionDelegate readerSession:didInvalidateWithError:] @link/
    ///              if the required entitlement is missing when session is started.
    ///
    ///  NOTE:
    ///  Only one NFCReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcvasreadersession?language=objc)
    #[unsafe(super(NFCReaderSession, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCVASReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCVASReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCVASReaderSession {}
);

impl NFCVASReaderSession {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `commandConfigurations`: NSArray of NFCVASCommandConfiguration objects.  Each NFCVASCommandConfiguration defines one GET VAS DATA command send to
        /// a compatible tag when discovered.  The order of elements in the array defines the order of the command execution.
        ///
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCVASReaderSessionDelegate @link/ object.
        ///  @param queue     A dispatch queue where NFCVASReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                   cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///
        ///  @return          A new NFCVASReaderSession instance.
        ///
        ///  @discussion      A VAS reader session will automatically scan and detect tag that is compatible with the VAS protocol.  The session will advertise as a
        ///                   VAS App Only terminal.  A modal system UI will present once -beginSession is called to inform the start of the session; the UI sheet
        ///                   is automatically dismissed when the session is invalidated either by the user or by calling -invalidateSession.  The alertMessage property shall be set
        ///                   prior to -beginSession to display a message on the action sheet UI for the tag scanning operation.
        ///
        ///                   The reader session has the following properties:
        ///                   + An opened session has a 60 seconds time limit restriction after -beginSession is called; -readerSession:didInvalidateWithError: will return
        ///                   NFCReaderSessionInvalidationErrorSessionTimeout error when the time limit is reached.
        ///                   + Only 1 active reader session is allowed in the system; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSystemIsBusy
        ///                   when a new reader session is initiated by -beginSession when there is an active reader session.
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorUserCanceled when user clicks on the done button on the UI.
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly when the client application enters
        ///                   the background state.
        ///                   + -readerSession:didInvalidateWithError: will return NFCReaderErrorUnsupportedFeature when 1) reader mode feature is not available on the hardware,
        ///                   2) client application does not have the required entitlement.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithVASCommandConfigurations:delegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithVASCommandConfigurations_delegate_queue(
            this: Allocated<Self>,
            command_configurations: &NSArray<NFCVASCommandConfiguration>,
            delegate: &ProtocolObject<dyn NFCVASReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCVASReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Reader session for processing NFC payment tags supporting the
    ///
    /// ```text
    ///  NFCTagTypeISO7816Compatible @link/ type.
    ///               @link [NFCTagReaderSessionDelegate readerSession:didDetectTags:] @link/ will return a @link NFCISO7816Tag @link /. object.
    ///               This session requires the "com.apple.developer.nfc.readersession.formats" entitlement in your process.
    ///               In addition your application's Info.plist must contain a non-empty usage description string.  @link NFCReaderErrorSecurityViolation @link/ will be
    ///               returned from @link [NFCTagReaderSessionDelegate tagReaderSession:didInvalidateWithError:] @link/ if the required entitlement is missing when session is started.
    ///
    ///               When the reader discovers a compatible ISO7816 tag it automatically performs a SELECT command (by DF name) using the values provided in
    ///               "com.apple.developer.nfc.readersession.iso7816.select-identifiers" in the specified array order.  The tag is
    ///               returned from the [NFCTagReaderSessionDelegate readerSession:didDetectTags:] call on the first successful SELECT command.
    ///               The initialSelectedAID property returns the application identifier of the selected application.  Tag will not be returned
    ///               to the NFCTagReaderSessionDelegate if no application described in "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
    ///               is found.
    ///
    ///  NOTE:
    ///  - Only one NFCReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corenfc/nfcpaymenttagreadersession?language=objc)
    #[unsafe(super(NFCTagReaderSession, NFCReaderSession, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NFCPaymentTagReaderSession;
);

extern_conformance!(
    unsafe impl NFCReaderSessionProtocol for NFCPaymentTagReaderSession {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NFCPaymentTagReaderSession {}
);

impl NFCPaymentTagReaderSession {
    extern_methods!(
        #[cfg(feature = "dispatch2")]
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCTagReaderSessionDelegate @link/ object.
        ///  @param queue         A dispatch queue where NFCTagReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                       cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///
        ///  @return              A new NFCPaymentTagReaderSession instance.
        ///
        ///  NOTE:
        ///  The super class `-initWithPollingOption:delegate:queue:` initializer would only accept NFCPollingOption.NFCPollingISO14443; all other options will be ignored.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithDelegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate_queue(
            this: Allocated<Self>,
            delegate: &ProtocolObject<dyn NFCTagReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NFCTagReaderSession`.
impl NFCPaymentTagReaderSession {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `pollingOption`: Configures the RF polling of the reader session; multiple options can be OR'ed together.  This option affects the possible NFC tag type discover.
        ///
        /// Parameter `delegate`: The session will hold a weak ARC reference to this
        ///
        /// ```text
        ///  NFCTagReaderSessionDelegate @link/ object.
        ///  @param queue         A dispatch queue where NFCTagReaderSessionDelegate delegate callbacks will be dispatched to.  A <i>nil</i> value will
        ///                       cause the creation of a serial dispatch queue internally for the session.  The session object will retain the provided dispatch queue.
        ///
        ///  @return              A new NFCTagReaderSession instance.
        ///  
        ///
        /// ```
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithPollingOption:delegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPollingOption_delegate_queue(
            this: Allocated<Self>,
            polling_option: NFCPollingOption,
            delegate: &ProtocolObject<dyn NFCTagReaderSessionDelegate>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NFCPaymentTagReaderSession {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}