nwep-rs 0.1.8

Rust bindings for the NWEP (WEB/1) protocol library
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
/* automatically generated by rust-bindgen 0.71.1 */

pub const NWEP_VERSION_MAJOR: u32 = 0;
pub const NWEP_VERSION_MINOR: u32 = 1;
pub const NWEP_VERSION_PATCH: u32 = 0;
pub const NWEP_VERSION: &[u8; 6] = b"0.1.0\0";
pub const NWEP_PROTO_VER: &[u8; 6] = b"WEB/1\0";
pub const NWEP_ALPN: &[u8; 6] = b"WEB/1\0";
pub const NWEP_ALPN_LEN: u32 = 5;
pub const NWEP_DEFAULT_PORT: u32 = 4433;
pub const NWEP_MAX_HEADERS: u32 = 128;
pub const NWEP_DEFAULT_MAX_STREAMS: u32 = 100;
pub const NWEP_ED25519_PUBKEY_LEN: u32 = 32;
pub const NWEP_ED25519_PRIVKEY_LEN: u32 = 32;
pub const NWEP_ED25519_SIG_LEN: u32 = 64;
pub const NWEP_NODEID_LEN: u32 = 32;
pub const NWEP_CHALLENGE_LEN: u32 = 32;
pub const NWEP_REQUEST_ID_LEN: u32 = 16;
pub const NWEP_TRACE_ID_LEN: u32 = 16;
pub const NWEP_MSG_REQUEST: u32 = 0;
pub const NWEP_MSG_RESPONSE: u32 = 1;
pub const NWEP_MSG_STREAM: u32 = 2;
pub const NWEP_MSG_NOTIFY: u32 = 3;
pub const NWEP_METHOD_READ: &[u8; 5] = b"read\0";
pub const NWEP_METHOD_WRITE: &[u8; 6] = b"write\0";
pub const NWEP_METHOD_UPDATE: &[u8; 7] = b"update\0";
pub const NWEP_METHOD_DELETE: &[u8; 7] = b"delete\0";
pub const NWEP_METHOD_CONNECT: &[u8; 8] = b"connect\0";
pub const NWEP_METHOD_AUTHENTICATE: &[u8; 13] = b"authenticate\0";
pub const NWEP_METHOD_HEARTBEAT: &[u8; 10] = b"heartbeat\0";
pub const NWEP_STATUS_OK: &[u8; 3] = b"ok\0";
pub const NWEP_STATUS_CREATED: &[u8; 8] = b"created\0";
pub const NWEP_STATUS_ACCEPTED: &[u8; 9] = b"accepted\0";
pub const NWEP_STATUS_NO_CONTENT: &[u8; 11] = b"no_content\0";
pub const NWEP_STATUS_BAD_REQUEST: &[u8; 12] = b"bad_request\0";
pub const NWEP_STATUS_UNAUTHORIZED: &[u8; 13] = b"unauthorized\0";
pub const NWEP_STATUS_FORBIDDEN: &[u8; 10] = b"forbidden\0";
pub const NWEP_STATUS_NOT_FOUND: &[u8; 10] = b"not_found\0";
pub const NWEP_STATUS_CONFLICT: &[u8; 9] = b"conflict\0";
pub const NWEP_STATUS_RATE_LIMITED: &[u8; 13] = b"rate_limited\0";
pub const NWEP_STATUS_INTERNAL_ERROR: &[u8; 15] = b"internal_error\0";
pub const NWEP_STATUS_UNAVAILABLE: &[u8; 12] = b"unavailable\0";
pub const NWEP_ERR_CONFIG_FILE_NOT_FOUND: i32 = -101;
pub const NWEP_ERR_CONFIG_PARSE_ERROR: i32 = -102;
pub const NWEP_ERR_CONFIG_INVALID_VALUE: i32 = -103;
pub const NWEP_ERR_CONFIG_MISSING_REQUIRED: i32 = -104;
pub const NWEP_ERR_CONFIG_VALIDATION_FAILED: i32 = -105;
pub const NWEP_ERR_NETWORK_CONN_FAILED: i32 = -201;
pub const NWEP_ERR_NETWORK_CONN_CLOSED: i32 = -202;
pub const NWEP_ERR_NETWORK_TIMEOUT: i32 = -203;
pub const NWEP_ERR_NETWORK_ADDR_IN_USE: i32 = -204;
pub const NWEP_ERR_NETWORK_ADDR_INVALID: i32 = -205;
pub const NWEP_ERR_NETWORK_SOCKET: i32 = -206;
pub const NWEP_ERR_NETWORK_TLS: i32 = -207;
pub const NWEP_ERR_NETWORK_QUIC: i32 = -208;
pub const NWEP_ERR_NETWORK_NO_SERVERS: i32 = -209;
pub const NWEP_ERR_CRYPTO_KEY_GEN_FAILED: i32 = -301;
pub const NWEP_ERR_CRYPTO_SIGN_FAILED: i32 = -302;
pub const NWEP_ERR_CRYPTO_VERIFY_FAILED: i32 = -303;
pub const NWEP_ERR_CRYPTO_HASH_FAILED: i32 = -304;
pub const NWEP_ERR_CRYPTO_INVALID_KEY: i32 = -305;
pub const NWEP_ERR_CRYPTO_INVALID_SIG: i32 = -306;
pub const NWEP_ERR_CRYPTO_ENCRYPT_FAILED: i32 = -307;
pub const NWEP_ERR_CRYPTO_DECRYPT_FAILED: i32 = -308;
pub const NWEP_ERR_CRYPTO_KEY_LOAD_FAILED: i32 = -309;
pub const NWEP_ERR_CRYPTO_KEY_SAVE_FAILED: i32 = -310;
pub const NWEP_ERR_CRYPTO_CERT_ERROR: i32 = -311;
pub const NWEP_ERR_CRYPTO_PUBKEY_MISMATCH: i32 = -381;
pub const NWEP_ERR_CRYPTO_NODEID_MISMATCH: i32 = -382;
pub const NWEP_ERR_CRYPTO_CHALLENGE_FAILED: i32 = -383;
pub const NWEP_ERR_CRYPTO_SERVER_SIG_INVALID: i32 = -384;
pub const NWEP_ERR_CRYPTO_CLIENT_SIG_INVALID: i32 = -385;
pub const NWEP_ERR_CRYPTO_AUTH_TIMEOUT: i32 = -320;
pub const NWEP_ERR_PROTO_INVALID_MESSAGE: i32 = -401;
pub const NWEP_ERR_PROTO_INVALID_METHOD: i32 = -402;
pub const NWEP_ERR_PROTO_INVALID_HEADER: i32 = -403;
pub const NWEP_ERR_PROTO_MSG_TOO_LARGE: i32 = -404;
pub const NWEP_ERR_PROTO_STREAM_ERROR: i32 = -405;
pub const NWEP_ERR_PROTO_INVALID_STATUS: i32 = -406;
pub const NWEP_ERR_PROTO_CONNECT_REQUIRED: i32 = -407;
pub const NWEP_ERR_PROTO_TOO_MANY_HEADERS: i32 = -408;
pub const NWEP_ERR_PROTO_HEADER_TOO_LARGE: i32 = -409;
pub const NWEP_ERR_PROTO_0RTT_REJECTED: i32 = -410;
pub const NWEP_ERR_PROTO_MISSING_HEADER: i32 = -411;
pub const NWEP_ERR_PROTO_ROLE_MISMATCH: i32 = -412;
pub const NWEP_ERR_PROTO_UNAUTHORIZED: i32 = -413;
pub const NWEP_ERR_PROTO_PATH_NOT_FOUND: i32 = -414;
pub const NWEP_ERR_PROTO_VERSION_MISMATCH: i32 = -481;
pub const NWEP_ERR_IDENTITY_INVALID_NODEID: i32 = -501;
pub const NWEP_ERR_IDENTITY_INVALID_ADDR: i32 = -502;
pub const NWEP_ERR_IDENTITY_AUTH_FAILED: i32 = -503;
pub const NWEP_ERR_IDENTITY_CHALLENGE_EXPIRED: i32 = -504;
pub const NWEP_ERR_IDENTITY_NO_RECOVERY: i32 = -505;
pub const NWEP_ERR_IDENTITY_RECOVERY_MISMATCH: i32 = -506;
pub const NWEP_ERR_IDENTITY_INVALID_SHARE: i32 = -507;
pub const NWEP_ERR_IDENTITY_SHARE_COMBINE: i32 = -508;
pub const NWEP_ERR_IDENTITY_INVALID_THRESHOLD: i32 = -509;
pub const NWEP_ERR_IDENTITY_ROTATION_IN_PROGRESS: i32 = -510;
pub const NWEP_ERR_IDENTITY_KEY_MISMATCH: i32 = -581;
pub const NWEP_ERR_IDENTITY_REVOKED: i32 = -582;
pub const NWEP_ERR_STORAGE_FILE_NOT_FOUND: i32 = -601;
pub const NWEP_ERR_STORAGE_READ_ERROR: i32 = -602;
pub const NWEP_ERR_STORAGE_WRITE_ERROR: i32 = -603;
pub const NWEP_ERR_STORAGE_PERMISSION: i32 = -604;
pub const NWEP_ERR_STORAGE_DISK_FULL: i32 = -605;
pub const NWEP_ERR_STORAGE_KEY_NOT_FOUND: i32 = -606;
pub const NWEP_ERR_STORAGE_INDEX_OUT_OF_RANGE: i32 = -607;
pub const NWEP_ERR_STORAGE_CORRUPTED: i32 = -681;
pub const NWEP_ERR_TRUST_PARSE_ERROR: i32 = -701;
pub const NWEP_ERR_TRUST_INVALID_ENTRY: i32 = -702;
pub const NWEP_ERR_TRUST_INVALID_SIG: i32 = -703;
pub const NWEP_ERR_TRUST_QUORUM_NOT_REACHED: i32 = -704;
pub const NWEP_ERR_TRUST_INVALID_PROOF: i32 = -705;
pub const NWEP_ERR_TRUST_ENTRY_NOT_FOUND: i32 = -706;
pub const NWEP_ERR_TRUST_CHECKPOINT_STALE: i32 = -708;
pub const NWEP_ERR_TRUST_ANCHOR_UNKNOWN: i32 = -709;
pub const NWEP_ERR_TRUST_DUPLICATE_BINDING: i32 = -711;
pub const NWEP_ERR_TRUST_NODE_NOT_FOUND: i32 = -712;
pub const NWEP_ERR_TRUST_ALREADY_REVOKED: i32 = -713;
pub const NWEP_ERR_TRUST_INVALID_AUTH: i32 = -714;
pub const NWEP_ERR_TRUST_UNAUTHORIZED: i32 = -715;
pub const NWEP_ERR_TRUST_TYPE_NOT_ALLOWED: i32 = -716;
pub const NWEP_ERR_TRUST_KEY_MISMATCH: i32 = -717;
pub const NWEP_ERR_TRUST_STORAGE: i32 = -718;
pub const NWEP_ERR_TRUST_LOG_CORRUPTED: i32 = -781;
pub const NWEP_ERR_TRUST_EQUIVOCATION: i32 = -782;
pub const NWEP_ERR_INTERNAL_UNKNOWN: i32 = -801;
pub const NWEP_ERR_INTERNAL_NOT_IMPLEMENTED: i32 = -802;
pub const NWEP_ERR_INTERNAL_INVALID_STATE: i32 = -803;
pub const NWEP_ERR_INTERNAL_NULL_PTR: i32 = -804;
pub const NWEP_ERR_INTERNAL_NOMEM: i32 = -805;
pub const NWEP_ERR_INTERNAL_INVALID_ARG: i32 = -806;
pub const NWEP_ERR_INTERNAL_CALLBACK_FAILURE: i32 = -807;
pub const NWEP_ERR_INTERNAL_NOBUF: i32 = -808;
pub const NWEP_ERR_FATAL_THRESHOLD: u32 = 80;
pub const NWEP_ERR_CONTEXT_MAX: u32 = 8;
pub const NWEP_BASE58_ADDR_LEN: u32 = 66;
pub const NWEP_SHAMIR_MAX_SHARES: u32 = 255;
pub const NWEP_SHAMIR_MIN_THRESHOLD: u32 = 2;
pub const NWEP_KEY_OVERLAP_SECONDS: u32 = 300;
pub const NWEP_MAX_ACTIVE_KEYS: u32 = 2;
pub const NWEP_LOG_ENTRY_MAX_SIZE: u32 = 256;
pub const NWEP_MERKLE_PROOF_MAX_DEPTH: u32 = 64;
pub const NWEP_MERKLE_PROOF_MAX_SIZE: u32 = 2100;
pub const NWEP_URL_MAX_LEN: u32 = 512;
pub const NWEP_FRAME_HEADER_SIZE: u32 = 4;
pub const NWEP_MSG_TYPE_SIZE: u32 = 1;
pub const NWEP_HDR_METHOD: &[u8; 8] = b":method\0";
pub const NWEP_HDR_PATH: &[u8; 6] = b":path\0";
pub const NWEP_HDR_VERSION: &[u8; 9] = b":version\0";
pub const NWEP_HDR_STATUS: &[u8; 8] = b":status\0";
pub const NWEP_HDR_REQUEST_ID: &[u8; 11] = b"request-id\0";
pub const NWEP_HDR_CLIENT_ID: &[u8; 10] = b"client-id\0";
pub const NWEP_HDR_SERVER_ID: &[u8; 10] = b"server-id\0";
pub const NWEP_HDR_CHALLENGE: &[u8; 10] = b"challenge\0";
pub const NWEP_HDR_CHALLENGE_RESPONSE: &[u8; 19] = b"challenge-response\0";
pub const NWEP_HDR_SERVER_CHALLENGE: &[u8; 17] = b"server-challenge\0";
pub const NWEP_HDR_AUTH_RESPONSE: &[u8; 14] = b"auth-response\0";
pub const NWEP_HDR_MAX_STREAMS: &[u8; 12] = b"max-streams\0";
pub const NWEP_HDR_MAX_MESSAGE_SIZE: &[u8; 17] = b"max-message-size\0";
pub const NWEP_HDR_COMPRESSION: &[u8; 12] = b"compression\0";
pub const NWEP_HDR_ROLES: &[u8; 6] = b"roles\0";
pub const NWEP_HDR_TRANSCRIPT_SIG: &[u8; 21] = b"transcript-signature\0";
pub const NWEP_HDR_STATUS_DETAILS: &[u8; 15] = b"status-details\0";
pub const NWEP_HDR_RETRY_AFTER: &[u8; 12] = b"retry-after\0";
pub const NWEP_HDR_TRACE_ID: &[u8; 9] = b"trace-id\0";
pub const NWEP_HDR_EVENT: &[u8; 7] = b":event\0";
pub const NWEP_HDR_NOTIFY_ID: &[u8; 10] = b"notify-id\0";
pub const NWEP_NOTIFY_ID_LEN: u32 = 16;
pub const NWEP_BLS_PUBKEY_LEN: u32 = 48;
pub const NWEP_BLS_PRIVKEY_LEN: u32 = 32;
pub const NWEP_BLS_SIG_LEN: u32 = 96;
pub const NWEP_CHECKPOINT_DST: &[u8; 17] = b"WEB/1-CHECKPOINT\0";
pub const NWEP_DEFAULT_ANCHOR_THRESHOLD: u32 = 5;
pub const NWEP_MAX_ANCHORS: u32 = 32;
pub const NWEP_MAX_CHECKPOINTS: u32 = 168;
pub const NWEP_ROLE_STR_REGULAR: &[u8; 8] = b"regular\0";
pub const NWEP_ROLE_STR_LOG_SERVER: &[u8; 11] = b"log_server\0";
pub const NWEP_ROLE_STR_ANCHOR: &[u8; 7] = b"anchor\0";
pub const NWEP_CACHE_DEFAULT_CAPACITY: u32 = 10000;
pub const NWEP_POOL_MAX_SERVERS: u32 = 32;
pub const NWEP_POOL_HEALTH_CHECK_FAILURES: u32 = 3;
pub type sa_family_t = ::std::os::raw::c_ushort;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sockaddr {
    pub sa_family: sa_family_t,
    pub sa_data: [::std::os::raw::c_char; 14usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of sockaddr"][::std::mem::size_of::<sockaddr>() - 16usize];
    ["Alignment of sockaddr"][::std::mem::align_of::<sockaddr>() - 2usize];
    ["Offset of field: sockaddr::sa_family"][::std::mem::offset_of!(sockaddr, sa_family) - 0usize];
    ["Offset of field: sockaddr::sa_data"][::std::mem::offset_of!(sockaddr, sa_data) - 2usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sockaddr_storage {
    pub ss_family: sa_family_t,
    pub __ss_padding: [::std::os::raw::c_char; 118usize],
    pub __ss_align: ::std::os::raw::c_ulong,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of sockaddr_storage"][::std::mem::size_of::<sockaddr_storage>() - 128usize];
    ["Alignment of sockaddr_storage"][::std::mem::align_of::<sockaddr_storage>() - 8usize];
    ["Offset of field: sockaddr_storage::ss_family"]
        [::std::mem::offset_of!(sockaddr_storage, ss_family) - 0usize];
    ["Offset of field: sockaddr_storage::__ss_padding"]
        [::std::mem::offset_of!(sockaddr_storage, __ss_padding) - 2usize];
    ["Offset of field: sockaddr_storage::__ss_align"]
        [::std::mem::offset_of!(sockaddr_storage, __ss_align) - 120usize];
};
#[doc = " @typedef\n\n :type:`nwep_ssize` is signed counterpart of size_t."]
pub type nwep_ssize = isize;
#[doc = " @typedef\n\n :type:`nwep_tstamp` is a timestamp in nanoseconds."]
pub type nwep_tstamp = u64;
#[doc = " @typedef\n\n :type:`nwep_duration` is a duration in nanoseconds."]
pub type nwep_duration = u64;
pub const nwep_error_category_NWEP_ERR_CAT_NONE: nwep_error_category = 0;
pub const nwep_error_category_NWEP_ERR_CAT_CONFIG: nwep_error_category = 1;
pub const nwep_error_category_NWEP_ERR_CAT_NETWORK: nwep_error_category = 2;
pub const nwep_error_category_NWEP_ERR_CAT_CRYPTO: nwep_error_category = 3;
pub const nwep_error_category_NWEP_ERR_CAT_PROTOCOL: nwep_error_category = 4;
pub const nwep_error_category_NWEP_ERR_CAT_IDENTITY: nwep_error_category = 5;
pub const nwep_error_category_NWEP_ERR_CAT_STORAGE: nwep_error_category = 6;
pub const nwep_error_category_NWEP_ERR_CAT_TRUST: nwep_error_category = 7;
pub const nwep_error_category_NWEP_ERR_CAT_INTERNAL: nwep_error_category = 8;
#[doc = " @enum\n\n :type:`nwep_error_category` defines the error category values."]
pub type nwep_error_category = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_error` represents an error with context chain for debugging."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_error {
    #[doc = " :member:`code` is the error code."]
    pub code: ::std::os::raw::c_int,
    #[doc = " :member:`context` is an array of context strings (most recent first)."]
    pub context: [*const ::std::os::raw::c_char; 8usize],
    #[doc = " :member:`context_count` is the number of context entries."]
    pub context_count: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_error"][::std::mem::size_of::<nwep_error>() - 80usize];
    ["Alignment of nwep_error"][::std::mem::align_of::<nwep_error>() - 8usize];
    ["Offset of field: nwep_error::code"][::std::mem::offset_of!(nwep_error, code) - 0usize];
    ["Offset of field: nwep_error::context"][::std::mem::offset_of!(nwep_error, context) - 8usize];
    ["Offset of field: nwep_error::context_count"]
        [::std::mem::offset_of!(nwep_error, context_count) - 72usize];
};
#[doc = " @functypedef\n\n :type:`nwep_malloc` is a custom memory allocator to replace malloc(3)."]
pub type nwep_malloc = ::std::option::Option<
    unsafe extern "C" fn(
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @functypedef\n\n :type:`nwep_free` is a custom memory allocator to replace free(3)."]
pub type nwep_free = ::std::option::Option<
    unsafe extern "C" fn(ptr: *mut ::std::os::raw::c_void, user_data: *mut ::std::os::raw::c_void),
>;
#[doc = " @functypedef\n\n :type:`nwep_calloc` is a custom memory allocator to replace calloc(3)."]
pub type nwep_calloc = ::std::option::Option<
    unsafe extern "C" fn(
        nmemb: usize,
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @functypedef\n\n :type:`nwep_realloc` is a custom memory allocator to replace realloc(3)."]
pub type nwep_realloc = ::std::option::Option<
    unsafe extern "C" fn(
        ptr: *mut ::std::os::raw::c_void,
        size: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
>;
#[doc = " @struct\n\n :type:`nwep_mem` is a custom memory allocator."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_mem {
    #[doc = " :member:`user_data` is an arbitrary user supplied data passed to each\n allocator function."]
    pub user_data: *mut ::std::os::raw::c_void,
    #[doc = " :member:`malloc` is a custom allocator function to replace malloc(3)."]
    pub malloc: nwep_malloc,
    #[doc = " :member:`free` is a custom allocator function to replace free(3)."]
    pub free: nwep_free,
    #[doc = " :member:`calloc` is a custom allocator function to replace calloc(3)."]
    pub calloc: nwep_calloc,
    #[doc = " :member:`realloc` is a custom allocator function to replace realloc(3)."]
    pub realloc: nwep_realloc,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_mem"][::std::mem::size_of::<nwep_mem>() - 40usize];
    ["Alignment of nwep_mem"][::std::mem::align_of::<nwep_mem>() - 8usize];
    ["Offset of field: nwep_mem::user_data"][::std::mem::offset_of!(nwep_mem, user_data) - 0usize];
    ["Offset of field: nwep_mem::malloc"][::std::mem::offset_of!(nwep_mem, malloc) - 8usize];
    ["Offset of field: nwep_mem::free"][::std::mem::offset_of!(nwep_mem, free) - 16usize];
    ["Offset of field: nwep_mem::calloc"][::std::mem::offset_of!(nwep_mem, calloc) - 24usize];
    ["Offset of field: nwep_mem::realloc"][::std::mem::offset_of!(nwep_mem, realloc) - 32usize];
};
#[doc = " @struct\n\n :type:`nwep_vec` is a buffer with a pointer and length."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_vec {
    #[doc = " :member:`base` points to the buffer."]
    pub base: *mut u8,
    #[doc = " :member:`len` is the length of the buffer."]
    pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_vec"][::std::mem::size_of::<nwep_vec>() - 16usize];
    ["Alignment of nwep_vec"][::std::mem::align_of::<nwep_vec>() - 8usize];
    ["Offset of field: nwep_vec::base"][::std::mem::offset_of!(nwep_vec, base) - 0usize];
    ["Offset of field: nwep_vec::len"][::std::mem::offset_of!(nwep_vec, len) - 8usize];
};
#[doc = " @struct\n\n :type:`nwep_nodeid` is a 32-byte NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_nodeid {
    #[doc = " :member:`data` contains the NodeID bytes."]
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_nodeid"][::std::mem::size_of::<nwep_nodeid>() - 32usize];
    ["Alignment of nwep_nodeid"][::std::mem::align_of::<nwep_nodeid>() - 1usize];
    ["Offset of field: nwep_nodeid::data"][::std::mem::offset_of!(nwep_nodeid, data) - 0usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_version` returns the version string of the nwep library."]
    pub fn nwep_version() -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_strerror` returns the error string for the given error code |liberr|."]
    pub fn nwep_strerror(liberr: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_is_fatal` returns nonzero if |liberr| is a fatal error that\n requires immediate connection termination. Fatal errors are those with\n codes ending in 81-99 within their category."]
    pub fn nwep_err_is_fatal(liberr: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_category` returns the error category for the given error code.\n Returns :enum:`NWEP_ERR_CAT_NONE` for success (0) or unknown errors."]
    pub fn nwep_err_category(liberr: ::std::os::raw::c_int) -> nwep_error_category;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_category_str` returns the category name string for the given\n category."]
    pub fn nwep_err_category_str(cat: nwep_error_category) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_err_to_status` returns the WEB/1 status token string appropriate\n for the given error code. This is used when generating error responses."]
    pub fn nwep_err_to_status(liberr: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_init` initializes an error struct with the given code."]
    pub fn nwep_error_init(err: *mut nwep_error, code: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_set_context` adds a context string to the error. Context\n strings are stored most-recent-first, up to :macro:`NWEP_ERR_CONTEXT_MAX`.\n Returns the error struct for chaining."]
    pub fn nwep_error_set_context(
        err: *mut nwep_error,
        context: *const ::std::os::raw::c_char,
    ) -> *mut nwep_error;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_error_format` formats the error with its context chain into a\n human-readable string. The format is:\n   [category:code] context1\n     caused by: context2\n     caused by: context3\n\n |buf| is the buffer to write to, |buflen| is the buffer size.\n Returns the number of bytes written (excluding null terminator), or\n the number of bytes that would have been written if the buffer was\n large enough."]
    pub fn nwep_error_format(
        err: *const nwep_error,
        buf: *mut ::std::os::raw::c_char,
        buflen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_encode` encodes |srclen| bytes from |src| into Base58.\n |dest| must have space for at least |destlen| bytes. The output is\n null-terminated.\n\n Returns the number of characters written (excluding null terminator),\n or 0 on error."]
    pub fn nwep_base58_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        src: *const u8,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_decode` decodes Base58 string |src| into |dest|.\n |dest| must have space for at least |destlen| bytes.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base58_decode(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_encode_len` returns the buffer size needed to encode\n |srclen| bytes as Base58 (including null terminator)."]
    pub fn nwep_base58_encode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base58_decode_len` returns the maximum buffer size needed to\n decode a Base58 string of |srclen| characters."]
    pub fn nwep_base58_decode_len(srclen: usize) -> usize;
}
#[doc = " @struct\n\n :type:`nwep_keypair` holds an Ed25519 keypair. The private key is stored\n in a form suitable for signing operations."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_keypair {
    #[doc = " :member:`pubkey` is the 32-byte public key."]
    pub pubkey: [u8; 32usize],
    #[doc = " :member:`privkey` is the 64-byte expanded private key (seed + pubkey)."]
    pub privkey: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_keypair"][::std::mem::size_of::<nwep_keypair>() - 96usize];
    ["Alignment of nwep_keypair"][::std::mem::align_of::<nwep_keypair>() - 1usize];
    ["Offset of field: nwep_keypair::pubkey"]
        [::std::mem::offset_of!(nwep_keypair, pubkey) - 0usize];
    ["Offset of field: nwep_keypair::privkey"]
        [::std::mem::offset_of!(nwep_keypair, privkey) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_generate` generates a new Ed25519 keypair using the\n system's secure random number generator.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_generate(kp: *mut nwep_keypair) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_from_seed` derives an Ed25519 keypair from a 32-byte seed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_from_seed(kp: *mut nwep_keypair, seed: *const u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_from_privkey` loads a keypair from a 64-byte private key\n (as returned by OpenSSL's Ed25519 routines or stored previously).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_keypair_from_privkey(
        kp: *mut nwep_keypair,
        privkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_keypair_clear` securely zeros the keypair memory."]
    pub fn nwep_keypair_clear(kp: *mut nwep_keypair);
}
#[doc = " @struct\n\n :type:`nwep_shamir_share` holds a single share of a split secret."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_shamir_share {
    pub index: u8,
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_shamir_share"][::std::mem::size_of::<nwep_shamir_share>() - 33usize];
    ["Alignment of nwep_shamir_share"][::std::mem::align_of::<nwep_shamir_share>() - 1usize];
    ["Offset of field: nwep_shamir_share::index"]
        [::std::mem::offset_of!(nwep_shamir_share, index) - 0usize];
    ["Offset of field: nwep_shamir_share::data"]
        [::std::mem::offset_of!(nwep_shamir_share, data) - 1usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_shamir_split` splits a 32-byte secret into n shares with threshold t.\n Any t shares can reconstruct the original secret.\n\n |secret| is the 32-byte secret to split.\n |shares| is an array of at least n nwep_shamir_share structs.\n |n| is the total number of shares to create (2-255).\n |t| is the threshold (2-n).\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_CRYPTO_INVALID_KEY`\n     Invalid parameters (n < t, t < 2, n > 255)."]
    pub fn nwep_shamir_split(
        secret: *const u8,
        shares: *mut nwep_shamir_share,
        n: usize,
        t: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_shamir_combine` reconstructs a secret from t or more shares.\n\n |secret| receives the reconstructed 32-byte secret.\n |shares| is an array of at least t shares.\n |num_shares| is the number of shares provided (must be >= threshold used in split).\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_CRYPTO_INVALID_KEY`\n     Invalid parameters or duplicate share indices."]
    pub fn nwep_shamir_combine(
        secret: *mut u8,
        shares: *const nwep_shamir_share,
        num_shares: usize,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_recovery_authority` holds the recovery authority keypair\n which can revoke the primary identity key."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_recovery_authority {
    pub keypair: nwep_keypair,
    pub initialized: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_recovery_authority"]
        [::std::mem::size_of::<nwep_recovery_authority>() - 100usize];
    ["Alignment of nwep_recovery_authority"]
        [::std::mem::align_of::<nwep_recovery_authority>() - 4usize];
    ["Offset of field: nwep_recovery_authority::keypair"]
        [::std::mem::offset_of!(nwep_recovery_authority, keypair) - 0usize];
    ["Offset of field: nwep_recovery_authority::initialized"]
        [::std::mem::offset_of!(nwep_recovery_authority, initialized) - 96usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_new` generates a new recovery authority keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_recovery_authority_new(ra: *mut nwep_recovery_authority) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_from_keypair` initializes a recovery authority\n from an existing keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_recovery_authority_from_keypair(
        ra: *mut nwep_recovery_authority,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_clear` securely zeros the recovery authority."]
    pub fn nwep_recovery_authority_clear(ra: *mut nwep_recovery_authority);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_recovery_authority_get_pubkey` returns the public key of the\n recovery authority.\n\n Returns pointer to the 32-byte public key, or NULL if not initialized."]
    pub fn nwep_recovery_authority_get_pubkey(ra: *const nwep_recovery_authority) -> *const u8;
}
#[doc = " @struct\n\n :type:`nwep_timed_keypair` holds a keypair with rotation timestamps."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_timed_keypair {
    pub keypair: nwep_keypair,
    pub activated_at: nwep_tstamp,
    pub expires_at: nwep_tstamp,
    pub active: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_timed_keypair"][::std::mem::size_of::<nwep_timed_keypair>() - 120usize];
    ["Alignment of nwep_timed_keypair"][::std::mem::align_of::<nwep_timed_keypair>() - 8usize];
    ["Offset of field: nwep_timed_keypair::keypair"]
        [::std::mem::offset_of!(nwep_timed_keypair, keypair) - 0usize];
    ["Offset of field: nwep_timed_keypair::activated_at"]
        [::std::mem::offset_of!(nwep_timed_keypair, activated_at) - 96usize];
    ["Offset of field: nwep_timed_keypair::expires_at"]
        [::std::mem::offset_of!(nwep_timed_keypair, expires_at) - 104usize];
    ["Offset of field: nwep_timed_keypair::active"]
        [::std::mem::offset_of!(nwep_timed_keypair, active) - 112usize];
};
#[doc = " @struct\n\n :type:`nwep_revocation` holds a signed revocation record."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_revocation {
    pub nodeid: nwep_nodeid,
    pub timestamp: nwep_tstamp,
    pub recovery_pubkey: [u8; 32usize],
    pub signature: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_revocation"][::std::mem::size_of::<nwep_revocation>() - 136usize];
    ["Alignment of nwep_revocation"][::std::mem::align_of::<nwep_revocation>() - 8usize];
    ["Offset of field: nwep_revocation::nodeid"]
        [::std::mem::offset_of!(nwep_revocation, nodeid) - 0usize];
    ["Offset of field: nwep_revocation::timestamp"]
        [::std::mem::offset_of!(nwep_revocation, timestamp) - 32usize];
    ["Offset of field: nwep_revocation::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_revocation, recovery_pubkey) - 40usize];
    ["Offset of field: nwep_revocation::signature"]
        [::std::mem::offset_of!(nwep_revocation, signature) - 72usize];
};
#[doc = " @struct\n\n :type:`nwep_managed_identity` holds an identity with key rotation\n and recovery support."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_managed_identity {
    pub nodeid: nwep_nodeid,
    pub keys: [nwep_timed_keypair; 2usize],
    pub key_count: usize,
    pub recovery_pubkey: [u8; 32usize],
    pub has_recovery: ::std::os::raw::c_int,
    pub revoked: ::std::os::raw::c_int,
    pub revocation: nwep_revocation,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_managed_identity"][::std::mem::size_of::<nwep_managed_identity>() - 456usize];
    ["Alignment of nwep_managed_identity"]
        [::std::mem::align_of::<nwep_managed_identity>() - 8usize];
    ["Offset of field: nwep_managed_identity::nodeid"]
        [::std::mem::offset_of!(nwep_managed_identity, nodeid) - 0usize];
    ["Offset of field: nwep_managed_identity::keys"]
        [::std::mem::offset_of!(nwep_managed_identity, keys) - 32usize];
    ["Offset of field: nwep_managed_identity::key_count"]
        [::std::mem::offset_of!(nwep_managed_identity, key_count) - 272usize];
    ["Offset of field: nwep_managed_identity::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_managed_identity, recovery_pubkey) - 280usize];
    ["Offset of field: nwep_managed_identity::has_recovery"]
        [::std::mem::offset_of!(nwep_managed_identity, has_recovery) - 312usize];
    ["Offset of field: nwep_managed_identity::revoked"]
        [::std::mem::offset_of!(nwep_managed_identity, revoked) - 316usize];
    ["Offset of field: nwep_managed_identity::revocation"]
        [::std::mem::offset_of!(nwep_managed_identity, revocation) - 320usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_new` creates a new managed identity with\n the given keypair and optional recovery authority.\n\n |identity| receives the initialized managed identity.\n |kp| is the initial keypair.\n |ra| is the recovery authority (may be NULL for no recovery support).\n |now| is the current timestamp.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_managed_identity_new(
        identity: *mut nwep_managed_identity,
        kp: *const nwep_keypair,
        ra: *const nwep_recovery_authority,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_rotate` generates a new keypair and begins\n the rotation process. The old key remains active for the overlap period.\n\n |identity| is the managed identity.\n |now| is the current timestamp.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_IDENTITY_REVOKED`\n     Identity has been revoked.\n :macro:`NWEP_ERR_IDENTITY_ROTATION_IN_PROGRESS`\n     Maximum active keys reached (rotation in progress)."]
    pub fn nwep_managed_identity_rotate(
        identity: *mut nwep_managed_identity,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_update` expires old keys based on current time.\n Should be called periodically.\n\n |identity| is the managed identity.\n |now| is the current timestamp."]
    pub fn nwep_managed_identity_update(identity: *mut nwep_managed_identity, now: nwep_tstamp);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_get_active` returns the currently active keypair\n for signing. Returns the newest active key.\n\n Returns pointer to the active keypair, or NULL if revoked or no active key."]
    pub fn nwep_managed_identity_get_active(
        identity: *const nwep_managed_identity,
    ) -> *const nwep_keypair;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_get_active_keys` returns all currently active\n keypairs. Used for verification (accept signatures from any active key).\n\n |keys| receives pointers to active keypairs.\n |max_keys| is the size of the keys array.\n\n Returns the number of active keys written to the array."]
    pub fn nwep_managed_identity_get_active_keys(
        identity: *const nwep_managed_identity,
        keys: *mut *const nwep_keypair,
        max_keys: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_is_revoked` returns nonzero if the identity\n has been revoked."]
    pub fn nwep_managed_identity_is_revoked(
        identity: *const nwep_managed_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_revoke` revokes the identity using the\n recovery authority. After revocation, no keys are active.\n\n |identity| is the managed identity to revoke.\n |ra| is the recovery authority (must match identity's recovery pubkey).\n |now| is the current timestamp.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_IDENTITY_NO_RECOVERY`\n     Identity has no recovery authority configured.\n :macro:`NWEP_ERR_IDENTITY_RECOVERY_MISMATCH`\n     Recovery authority does not match.\n :macro:`NWEP_ERR_IDENTITY_REVOKED`\n     Identity is already revoked."]
    pub fn nwep_managed_identity_revoke(
        identity: *mut nwep_managed_identity,
        ra: *const nwep_recovery_authority,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_verify_revocation` verifies a revocation record.\n\n |revocation| is the revocation record to verify.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_managed_identity_verify_revocation(
        revocation: *const nwep_revocation,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_managed_identity_clear` securely zeros the managed identity."]
    pub fn nwep_managed_identity_clear(identity: *mut nwep_managed_identity);
}
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_KEY_BINDING: nwep_merkle_entry_type = 1;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_KEY_ROTATION: nwep_merkle_entry_type = 2;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_REVOCATION: nwep_merkle_entry_type = 3;
pub const nwep_merkle_entry_type_NWEP_LOG_ENTRY_ANCHOR_CHANGE: nwep_merkle_entry_type = 4;
#[doc = " @enum\n\n :type:`nwep_merkle_entry_type` defines the types of log entries."]
pub type nwep_merkle_entry_type = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_merkle_entry` represents an entry in the Merkle log."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_entry {
    pub type_: nwep_merkle_entry_type,
    pub timestamp: nwep_tstamp,
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub prev_pubkey: [u8; 32usize],
    pub recovery_pubkey: [u8; 32usize],
    pub signature: [u8; 64usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_entry"][::std::mem::size_of::<nwep_merkle_entry>() - 208usize];
    ["Alignment of nwep_merkle_entry"][::std::mem::align_of::<nwep_merkle_entry>() - 8usize];
    ["Offset of field: nwep_merkle_entry::type_"]
        [::std::mem::offset_of!(nwep_merkle_entry, type_) - 0usize];
    ["Offset of field: nwep_merkle_entry::timestamp"]
        [::std::mem::offset_of!(nwep_merkle_entry, timestamp) - 8usize];
    ["Offset of field: nwep_merkle_entry::nodeid"]
        [::std::mem::offset_of!(nwep_merkle_entry, nodeid) - 16usize];
    ["Offset of field: nwep_merkle_entry::pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, pubkey) - 48usize];
    ["Offset of field: nwep_merkle_entry::prev_pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, prev_pubkey) - 80usize];
    ["Offset of field: nwep_merkle_entry::recovery_pubkey"]
        [::std::mem::offset_of!(nwep_merkle_entry, recovery_pubkey) - 112usize];
    ["Offset of field: nwep_merkle_entry::signature"]
        [::std::mem::offset_of!(nwep_merkle_entry, signature) - 144usize];
};
#[doc = " @struct\n\n :type:`nwep_merkle_hash` holds a 32-byte Merkle tree hash."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_hash {
    pub data: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_hash"][::std::mem::size_of::<nwep_merkle_hash>() - 32usize];
    ["Alignment of nwep_merkle_hash"][::std::mem::align_of::<nwep_merkle_hash>() - 1usize];
    ["Offset of field: nwep_merkle_hash::data"]
        [::std::mem::offset_of!(nwep_merkle_hash, data) - 0usize];
};
#[doc = " @struct\n\n :type:`nwep_merkle_proof` holds an inclusion proof for a log entry."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_proof {
    pub index: u64,
    pub log_size: u64,
    pub leaf_hash: nwep_merkle_hash,
    pub siblings: [nwep_merkle_hash; 64usize],
    pub depth: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_merkle_proof"][::std::mem::size_of::<nwep_merkle_proof>() - 2104usize];
    ["Alignment of nwep_merkle_proof"][::std::mem::align_of::<nwep_merkle_proof>() - 8usize];
    ["Offset of field: nwep_merkle_proof::index"]
        [::std::mem::offset_of!(nwep_merkle_proof, index) - 0usize];
    ["Offset of field: nwep_merkle_proof::log_size"]
        [::std::mem::offset_of!(nwep_merkle_proof, log_size) - 8usize];
    ["Offset of field: nwep_merkle_proof::leaf_hash"]
        [::std::mem::offset_of!(nwep_merkle_proof, leaf_hash) - 16usize];
    ["Offset of field: nwep_merkle_proof::siblings"]
        [::std::mem::offset_of!(nwep_merkle_proof, siblings) - 48usize];
    ["Offset of field: nwep_merkle_proof::depth"]
        [::std::mem::offset_of!(nwep_merkle_proof, depth) - 2096usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_entry_encode` serializes a Merkle log entry.\n\n |buf| receives the serialized data.\n |buflen| is the buffer size.\n |entry| is the entry to serialize.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_merkle_entry_encode(
        buf: *mut u8,
        buflen: usize,
        entry: *const nwep_merkle_entry,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_entry_decode` deserializes a Merkle log entry.\n\n |entry| receives the deserialized entry.\n |data| is the serialized data.\n |datalen| is the data length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_entry_decode(
        entry: *mut nwep_merkle_entry,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_leaf_hash` computes the leaf hash for a Merkle log entry.\n Hash = SHA-256(0x00 || entry_bytes)\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_leaf_hash(
        hash: *mut nwep_merkle_hash,
        entry: *const nwep_merkle_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_node_hash` computes an internal node hash.\n Hash = SHA-256(0x01 || left || right)\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_node_hash(
        hash: *mut nwep_merkle_hash,
        left: *const nwep_merkle_hash,
        right: *const nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_verify` verifies an inclusion proof against a root hash.\n\n |proof| is the inclusion proof.\n |root| is the expected root hash.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_merkle_proof_verify(
        proof: *const nwep_merkle_proof,
        root: *const nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_encode` serializes an inclusion proof.\n\n |buf| receives the serialized data.\n |buflen| is the buffer size.\n |proof| is the proof to serialize.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_merkle_proof_encode(
        buf: *mut u8,
        buflen: usize,
        proof: *const nwep_merkle_proof,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_proof_decode` deserializes an inclusion proof.\n\n |proof| receives the deserialized proof.\n |data| is the serialized data.\n |datalen| is the data length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_proof_decode(
        proof: *mut nwep_merkle_proof,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @callback\n\n `nwep_log_append_cb` appends an entry to storage.\n Returns 0 on success, or negative error code."]
pub type nwep_log_append_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        index: u64,
        entry: *const u8,
        entry_len: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_log_get_cb` retrieves an entry from storage.\n Returns entry length on success, or negative error code."]
pub type nwep_log_get_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        index: u64,
        buf: *mut u8,
        buflen: usize,
    ) -> nwep_ssize,
>;
#[doc = " @callback\n\n `nwep_log_size_cb` returns the current log size (number of entries)."]
pub type nwep_log_size_cb =
    ::std::option::Option<unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void) -> u64>;
#[doc = " @struct\n\n :type:`nwep_log_storage` holds storage callbacks for the Merkle log."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_storage {
    pub append: nwep_log_append_cb,
    pub get: nwep_log_get_cb,
    pub size: nwep_log_size_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_storage"][::std::mem::size_of::<nwep_log_storage>() - 32usize];
    ["Alignment of nwep_log_storage"][::std::mem::align_of::<nwep_log_storage>() - 8usize];
    ["Offset of field: nwep_log_storage::append"]
        [::std::mem::offset_of!(nwep_log_storage, append) - 0usize];
    ["Offset of field: nwep_log_storage::get"]
        [::std::mem::offset_of!(nwep_log_storage, get) - 8usize];
    ["Offset of field: nwep_log_storage::size"]
        [::std::mem::offset_of!(nwep_log_storage, size) - 16usize];
    ["Offset of field: nwep_log_storage::user_data"]
        [::std::mem::offset_of!(nwep_log_storage, user_data) - 24usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_merkle_log {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_new` creates a new Merkle log.\n\n |plog| receives the created log.\n |storage| provides the storage callbacks.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_new(
        plog: *mut *mut nwep_merkle_log,
        storage: *const nwep_log_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_free` frees a Merkle log."]
    pub fn nwep_merkle_log_free(log: *mut nwep_merkle_log);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_append` appends an entry to the log.\n\n |log| is the Merkle log.\n |entry| is the entry to append.\n |pindex| receives the index of the appended entry (may be NULL).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_append(
        log: *mut nwep_merkle_log,
        entry: *const nwep_merkle_entry,
        pindex: *mut u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_get` retrieves an entry from the log.\n\n |log| is the Merkle log.\n |index| is the entry index.\n |entry| receives the entry.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_get(
        log: *mut nwep_merkle_log,
        index: u64,
        entry: *mut nwep_merkle_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_size` returns the number of entries in the log."]
    pub fn nwep_merkle_log_size(log: *const nwep_merkle_log) -> u64;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_root` computes the current root hash.\n\n |log| is the Merkle log.\n |root| receives the root hash.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_root(
        log: *mut nwep_merkle_log,
        root: *mut nwep_merkle_hash,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_merkle_log_prove` generates an inclusion proof for an entry.\n\n |log| is the Merkle log.\n |index| is the entry index.\n |proof| receives the inclusion proof.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_merkle_log_prove(
        log: *mut nwep_merkle_log,
        index: u64,
        proof: *mut nwep_merkle_proof,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_log_index_entry` holds the current state for a NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index_entry {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub revoked: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_index_entry"][::std::mem::size_of::<nwep_log_index_entry>() - 80usize];
    ["Alignment of nwep_log_index_entry"][::std::mem::align_of::<nwep_log_index_entry>() - 8usize];
    ["Offset of field: nwep_log_index_entry::nodeid"]
        [::std::mem::offset_of!(nwep_log_index_entry, nodeid) - 0usize];
    ["Offset of field: nwep_log_index_entry::pubkey"]
        [::std::mem::offset_of!(nwep_log_index_entry, pubkey) - 32usize];
    ["Offset of field: nwep_log_index_entry::log_index"]
        [::std::mem::offset_of!(nwep_log_index_entry, log_index) - 64usize];
    ["Offset of field: nwep_log_index_entry::revoked"]
        [::std::mem::offset_of!(nwep_log_index_entry, revoked) - 72usize];
};
#[doc = " @callback\n\n `nwep_index_get_cb` retrieves an index entry by NodeID.\n Returns 0 on success, NWEP_ERR_STORAGE_KEY_NOT_FOUND if not found."]
pub type nwep_index_get_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        nodeid: *const nwep_nodeid,
        entry: *mut nwep_log_index_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_index_put_cb` stores an index entry.\n Returns 0 on success, or negative error code."]
pub type nwep_index_put_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        entry: *const nwep_log_index_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_log_index_storage` holds storage callbacks for the log index."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index_storage {
    pub get: nwep_index_get_cb,
    pub put: nwep_index_put_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_index_storage"][::std::mem::size_of::<nwep_log_index_storage>() - 24usize];
    ["Alignment of nwep_log_index_storage"]
        [::std::mem::align_of::<nwep_log_index_storage>() - 8usize];
    ["Offset of field: nwep_log_index_storage::get"]
        [::std::mem::offset_of!(nwep_log_index_storage, get) - 0usize];
    ["Offset of field: nwep_log_index_storage::put"]
        [::std::mem::offset_of!(nwep_log_index_storage, put) - 8usize];
    ["Offset of field: nwep_log_index_storage::user_data"]
        [::std::mem::offset_of!(nwep_log_index_storage, user_data) - 16usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_index {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_new` creates a new log index.\n\n |pindex| receives the created index.\n |storage| provides the storage callbacks.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_index_new(
        pindex: *mut *mut nwep_log_index,
        storage: *const nwep_log_index_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_free` frees a log index."]
    pub fn nwep_log_index_free(index: *mut nwep_log_index);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_lookup` looks up the current state for a NodeID.\n\n |index| is the log index.\n |nodeid| is the NodeID to look up.\n |entry| receives the index entry.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_STORAGE_KEY_NOT_FOUND`\n     NodeID not found in index."]
    pub fn nwep_log_index_lookup(
        index: *mut nwep_log_index,
        nodeid: *const nwep_nodeid,
        entry: *mut nwep_log_index_entry,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_index_update` updates the index from a Merkle log entry.\n\n |index| is the log index.\n |entry| is the Merkle log entry.\n |log_idx| is the entry's index in the log.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_index_update(
        index: *mut nwep_log_index,
        entry: *const nwep_merkle_entry,
        log_idx: u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_from_pubkey` computes a NodeID from a public key.\n NodeID = SHA-256(pubkey || \"WEB/1\")\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_nodeid_from_pubkey(
        nodeid: *mut nwep_nodeid,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_from_keypair` computes a NodeID from a keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_nodeid_from_keypair(
        nodeid: *mut nwep_nodeid,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_eq` returns nonzero if two NodeIDs are equal."]
    pub fn nwep_nodeid_eq(a: *const nwep_nodeid, b: *const nwep_nodeid) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_nodeid_is_zero` returns nonzero if the NodeID is all zeros."]
    pub fn nwep_nodeid_is_zero(nodeid: *const nwep_nodeid) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_addr` holds an IP address (IPv6 or IPv4-mapped) and NodeID."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_addr {
    #[doc = " :member:`ip` is the IPv6 address (IPv4 mapped as ::ffff:x.x.x.x)."]
    pub ip: [u8; 16usize],
    #[doc = " :member:`nodeid` is the NodeID."]
    pub nodeid: nwep_nodeid,
    #[doc = " :member:`port` is the port number (default 4433)."]
    pub port: u16,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_addr"][::std::mem::size_of::<nwep_addr>() - 50usize];
    ["Alignment of nwep_addr"][::std::mem::align_of::<nwep_addr>() - 2usize];
    ["Offset of field: nwep_addr::ip"][::std::mem::offset_of!(nwep_addr, ip) - 0usize];
    ["Offset of field: nwep_addr::nodeid"][::std::mem::offset_of!(nwep_addr, nodeid) - 16usize];
    ["Offset of field: nwep_addr::port"][::std::mem::offset_of!(nwep_addr, port) - 48usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_encode` encodes an address to Base58.\n |dest| must have space for at least NWEP_BASE58_ADDR_LEN + 1 bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_addr_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        addr: *const nwep_addr,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_decode` decodes a Base58 address string into an nwep_addr.\n This only decodes the address portion, not the full URL.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_addr_decode(
        addr: *mut nwep_addr,
        encoded: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_url` represents a parsed web:// URL."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_url {
    #[doc = " :member:`addr` is the decoded address."]
    pub addr: nwep_addr,
    #[doc = " :member:`path` is the path portion (null-terminated, max 256 chars)."]
    pub path: [::std::os::raw::c_char; 256usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_url"][::std::mem::size_of::<nwep_url>() - 306usize];
    ["Alignment of nwep_url"][::std::mem::align_of::<nwep_url>() - 2usize];
    ["Offset of field: nwep_url::addr"][::std::mem::offset_of!(nwep_url, addr) - 0usize];
    ["Offset of field: nwep_url::path"][::std::mem::offset_of!(nwep_url, path) - 50usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_url_parse` parses a web:// URL string.\n Format: web://[address]:port/path\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_url_parse(
        url: *mut nwep_url,
        str_: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_url_format` formats a URL into a string buffer.\n |dest| must have space for at least NWEP_URL_MAX_LEN bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_url_format(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        url: *const nwep_url,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_set_ipv4` sets an address to an IPv4-mapped IPv6 address."]
    pub fn nwep_addr_set_ipv4(addr: *mut nwep_addr, ipv4: u32);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_addr_set_ipv6` sets an address to an IPv6 address."]
    pub fn nwep_addr_set_ipv6(addr: *mut nwep_addr, ipv6: *const u8);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_sign` signs |msg| of |msglen| bytes using |kp|.\n |sig| must have space for 64 bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_sign(
        sig: *mut u8,
        msg: *const u8,
        msglen: usize,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify` verifies a signature |sig| on |msglen| bytes of |msg|\n using the public key |pubkey|.\n\n Returns 0 if the signature is valid, or a negative error code."]
    pub fn nwep_verify(
        sig: *const u8,
        msg: *const u8,
        msglen: usize,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_generate` generates a 32-byte random challenge nonce.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_challenge_generate(challenge: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_sign` signs a challenge using the keypair.\n |response| must have space for 64 bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_challenge_sign(
        response: *mut u8,
        challenge: *const u8,
        kp: *const nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_challenge_verify` verifies a challenge response signature.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_challenge_verify(
        response: *const u8,
        challenge: *const u8,
        pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_random_bytes` fills |dest| with |len| cryptographically secure\n random bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_random_bytes(dest: *mut u8, len: usize) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_header` represents a single header name-value pair."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_header {
    #[doc = " :member:`name` is the header name (not null-terminated in wire format)."]
    pub name: *const u8,
    #[doc = " :member:`name_len` is the length of the header name."]
    pub name_len: usize,
    #[doc = " :member:`value` is the header value (not null-terminated in wire format)."]
    pub value: *const u8,
    #[doc = " :member:`value_len` is the length of the header value."]
    pub value_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_header"][::std::mem::size_of::<nwep_header>() - 32usize];
    ["Alignment of nwep_header"][::std::mem::align_of::<nwep_header>() - 8usize];
    ["Offset of field: nwep_header::name"][::std::mem::offset_of!(nwep_header, name) - 0usize];
    ["Offset of field: nwep_header::name_len"]
        [::std::mem::offset_of!(nwep_header, name_len) - 8usize];
    ["Offset of field: nwep_header::value"][::std::mem::offset_of!(nwep_header, value) - 16usize];
    ["Offset of field: nwep_header::value_len"]
        [::std::mem::offset_of!(nwep_header, value_len) - 24usize];
};
#[doc = " @struct\n\n :type:`nwep_msg` represents a parsed WEB/1 message."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_msg {
    #[doc = " :member:`type` is the message type (NWEP_MSG_REQUEST, etc.)."]
    pub type_: u8,
    #[doc = " :member:`headers` points to an array of headers."]
    pub headers: *mut nwep_header,
    #[doc = " :member:`header_count` is the number of headers."]
    pub header_count: usize,
    #[doc = " :member:`body` points to the message body."]
    pub body: *const u8,
    #[doc = " :member:`body_len` is the length of the body."]
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_msg"][::std::mem::size_of::<nwep_msg>() - 40usize];
    ["Alignment of nwep_msg"][::std::mem::align_of::<nwep_msg>() - 8usize];
    ["Offset of field: nwep_msg::type_"][::std::mem::offset_of!(nwep_msg, type_) - 0usize];
    ["Offset of field: nwep_msg::headers"][::std::mem::offset_of!(nwep_msg, headers) - 8usize];
    ["Offset of field: nwep_msg::header_count"]
        [::std::mem::offset_of!(nwep_msg, header_count) - 16usize];
    ["Offset of field: nwep_msg::body"][::std::mem::offset_of!(nwep_msg, body) - 24usize];
    ["Offset of field: nwep_msg::body_len"][::std::mem::offset_of!(nwep_msg, body_len) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_init` initializes a message structure."]
    pub fn nwep_msg_init(msg: *mut nwep_msg, type_: u8);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_encode_len` calculates the encoded size of a message.\n This includes the 4-byte length prefix."]
    pub fn nwep_msg_encode_len(msg: *const nwep_msg) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_encode` encodes a message into a buffer.\n |dest| must have space for at least nwep_msg_encode_len() bytes.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_msg_encode(dest: *mut u8, destlen: usize, msg: *const nwep_msg) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_decode_header` decodes just the frame header to get payload size.\n |src| must have at least NWEP_FRAME_HEADER_SIZE (4) bytes.\n |payload_len| receives the payload length (excludes the 4-byte header).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_msg_decode_header(
        payload_len: *mut u32,
        src: *const u8,
        srclen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_decode` decodes a complete message from a buffer.\n |src| must contain the complete message including the 4-byte length prefix.\n |msg| receives the decoded message. Headers point into |src| buffer.\n |headers| is a caller-provided array to store decoded headers.\n |max_headers| is the maximum number of headers to decode.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_msg_decode(
        msg: *mut nwep_msg,
        src: *const u8,
        srclen: usize,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_set` sets a header from C strings (null-terminated)."]
    pub fn nwep_header_set(
        hdr: *mut nwep_header,
        name: *const ::std::os::raw::c_char,
        value: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_set_n` sets a header from byte arrays with lengths."]
    pub fn nwep_header_set_n(
        hdr: *mut nwep_header,
        name: *const u8,
        name_len: usize,
        value: *const u8,
        value_len: usize,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_msg_find_header` finds a header by name in a message.\n Returns a pointer to the header, or NULL if not found."]
    pub fn nwep_msg_find_header(
        msg: *const nwep_msg,
        name: *const ::std::os::raw::c_char,
    ) -> *const nwep_header;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_header_value_eq` returns nonzero if a header's value equals\n the given null-terminated string."]
    pub fn nwep_header_value_eq(
        hdr: *const nwep_header,
        value: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trace_id_generate` generates a 16-byte trace ID.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trace_id_generate(trace_id: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_id_generate` generates a 16-byte request ID.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_request_id_generate(request_id: *mut u8) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_is_valid` checks if |method| is a valid WEB/1 method.\n\n Returns 1 if valid, 0 otherwise."]
    pub fn nwep_method_is_valid(method: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_is_idempotent` checks if |method| is idempotent.\n Idempotent methods: READ, DELETE, HEARTBEAT.\n\n Returns 1 if idempotent, 0 otherwise."]
    pub fn nwep_method_is_idempotent(
        method: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_method_allowed_0rtt` checks if |method| is allowed in 0-RTT.\n Only READ is allowed in 0-RTT for replay safety.\n\n Returns 1 if allowed, 0 otherwise."]
    pub fn nwep_method_allowed_0rtt(method: *const ::std::os::raw::c_char)
        -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_valid` checks if |status| is a valid WEB/1 status token.\n\n Returns 1 if valid, 0 otherwise."]
    pub fn nwep_status_is_valid(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_success` checks if |status| indicates success.\n Success statuses: ok, created, accepted, no_content.\n\n Returns 1 if success, 0 otherwise."]
    pub fn nwep_status_is_success(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_status_is_error` checks if |status| indicates an error.\n\n Returns 1 if error, 0 otherwise."]
    pub fn nwep_status_is_error(status: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_build` builds a request message.\n |headers| must have space for at least 4 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        method: *const ::std::os::raw::c_char,
        path: *const ::std::os::raw::c_char,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_response_build` builds a response message.\n |headers| must have space for at least 2 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        status: *const ::std::os::raw::c_char,
        status_details: *const ::std::os::raw::c_char,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_msg_build` builds a stream message for chunked body data.\n Stream messages have no headers, only body data.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_msg_build(
        msg: *mut nwep_msg,
        data: *const u8,
        data_len: usize,
        is_final: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_heartbeat_build` builds a HEARTBEAT request message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_heartbeat_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_heartbeat_response_build` builds a HEARTBEAT response message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_heartbeat_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_encode_len` returns the buffer size needed to encode\n |srclen| bytes as Base64 (including null terminator)."]
    pub fn nwep_base64_encode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_encode` encodes |srclen| bytes from |src| into Base64.\n |dest| must have space for nwep_base64_encode_len(srclen) bytes.\n\n Returns the number of characters written (excluding null), or 0 on error."]
    pub fn nwep_base64_encode(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        src: *const u8,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode_len` returns the maximum buffer size needed to decode\n a Base64 string of |srclen| characters."]
    pub fn nwep_base64_decode_len(srclen: usize) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode` decodes Base64 string |src| into |dest|.\n |src| must be null-terminated.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base64_decode(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_base64_decode_n` decodes |srclen| bytes of Base64 from |src| into\n |dest|. Unlike `nwep_base64_decode`, this function does not require |src|\n to be null-terminated.\n\n Returns the number of bytes written, or 0 on error."]
    pub fn nwep_base64_decode_n(
        dest: *mut u8,
        destlen: usize,
        src: *const ::std::os::raw::c_char,
        srclen: usize,
    ) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_put_uint32be` writes a 32-bit big-endian value to |p|.\n Returns pointer past written bytes."]
    pub fn nwep_put_uint32be(p: *mut u8, n: u32) -> *mut u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_get_uint32be` reads a 32-bit big-endian value from |p|.\n Returns pointer past read bytes."]
    pub fn nwep_get_uint32be(dest: *mut u32, p: *const u8) -> *const u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_put_uint16be` writes a 16-bit big-endian value to |p|.\n Returns pointer past written bytes."]
    pub fn nwep_put_uint16be(p: *mut u8, n: u16) -> *mut u8;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_get_uint16be` reads a 16-bit big-endian value from |p|.\n Returns pointer past read bytes."]
    pub fn nwep_get_uint16be(dest: *mut u16, p: *const u8) -> *const u8;
}
pub const nwep_client_state_NWEP_CLIENT_STATE_INITIAL: nwep_client_state = 0;
pub const nwep_client_state_NWEP_CLIENT_STATE_TLS_HANDSHAKE: nwep_client_state = 1;
pub const nwep_client_state_NWEP_CLIENT_STATE_SEND_CONNECT: nwep_client_state = 2;
pub const nwep_client_state_NWEP_CLIENT_STATE_WAIT_CONNECT_RESP: nwep_client_state = 3;
pub const nwep_client_state_NWEP_CLIENT_STATE_SEND_AUTHENTICATE: nwep_client_state = 4;
pub const nwep_client_state_NWEP_CLIENT_STATE_WAIT_AUTH_RESP: nwep_client_state = 5;
pub const nwep_client_state_NWEP_CLIENT_STATE_CONNECTED: nwep_client_state = 6;
pub const nwep_client_state_NWEP_CLIENT_STATE_ERROR: nwep_client_state = 7;
#[doc = " @enum\n\n :type:`nwep_client_state` represents the client connection state machine."]
pub type nwep_client_state = ::std::os::raw::c_uint;
pub const nwep_server_state_NWEP_SERVER_STATE_INITIAL: nwep_server_state = 0;
pub const nwep_server_state_NWEP_SERVER_STATE_TLS_HANDSHAKE: nwep_server_state = 1;
pub const nwep_server_state_NWEP_SERVER_STATE_AWAITING_CONNECT: nwep_server_state = 2;
pub const nwep_server_state_NWEP_SERVER_STATE_AWAITING_CLIENT_AUTH: nwep_server_state = 3;
pub const nwep_server_state_NWEP_SERVER_STATE_CONNECTED: nwep_server_state = 4;
pub const nwep_server_state_NWEP_SERVER_STATE_ERROR: nwep_server_state = 5;
#[doc = " @enum\n\n :type:`nwep_server_state` represents the server connection state machine."]
pub type nwep_server_state = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_handshake_params` holds negotiable parameters for the handshake."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_handshake_params {
    pub max_streams: u32,
    pub max_message_size: u32,
    pub compression: *const ::std::os::raw::c_char,
    pub role: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake_params"][::std::mem::size_of::<nwep_handshake_params>() - 24usize];
    ["Alignment of nwep_handshake_params"]
        [::std::mem::align_of::<nwep_handshake_params>() - 8usize];
    ["Offset of field: nwep_handshake_params::max_streams"]
        [::std::mem::offset_of!(nwep_handshake_params, max_streams) - 0usize];
    ["Offset of field: nwep_handshake_params::max_message_size"]
        [::std::mem::offset_of!(nwep_handshake_params, max_message_size) - 4usize];
    ["Offset of field: nwep_handshake_params::compression"]
        [::std::mem::offset_of!(nwep_handshake_params, compression) - 8usize];
    ["Offset of field: nwep_handshake_params::role"]
        [::std::mem::offset_of!(nwep_handshake_params, role) - 16usize];
};
#[doc = " @struct\n\n :type:`nwep_handshake` holds the state for a CONNECT/AUTHENTICATE handshake."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct nwep_handshake {
    pub local_keypair: *mut nwep_keypair,
    pub local_nodeid: nwep_nodeid,
    pub peer_pubkey: [u8; 32usize],
    pub peer_nodeid: nwep_nodeid,
    pub expected_peer_nodeid: nwep_nodeid,
    pub peer_nodeid_verified: ::std::os::raw::c_int,
    pub local_challenge: [u8; 32usize],
    pub peer_challenge: [u8; 32usize],
    pub local_params: nwep_handshake_params,
    pub peer_params: nwep_handshake_params,
    pub negotiated_params: nwep_handshake_params,
    pub transcript: *mut u8,
    pub transcript_len: usize,
    pub transcript_cap: usize,
    pub is_server: ::std::os::raw::c_int,
    pub state: nwep_handshake__bindgen_ty_1,
    pub error_code: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union nwep_handshake__bindgen_ty_1 {
    pub client: nwep_client_state,
    pub server: nwep_server_state,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake__bindgen_ty_1"]
        [::std::mem::size_of::<nwep_handshake__bindgen_ty_1>() - 4usize];
    ["Alignment of nwep_handshake__bindgen_ty_1"]
        [::std::mem::align_of::<nwep_handshake__bindgen_ty_1>() - 4usize];
    ["Offset of field: nwep_handshake__bindgen_ty_1::client"]
        [::std::mem::offset_of!(nwep_handshake__bindgen_ty_1, client) - 0usize];
    ["Offset of field: nwep_handshake__bindgen_ty_1::server"]
        [::std::mem::offset_of!(nwep_handshake__bindgen_ty_1, server) - 0usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_handshake"][::std::mem::size_of::<nwep_handshake>() - 320usize];
    ["Alignment of nwep_handshake"][::std::mem::align_of::<nwep_handshake>() - 8usize];
    ["Offset of field: nwep_handshake::local_keypair"]
        [::std::mem::offset_of!(nwep_handshake, local_keypair) - 0usize];
    ["Offset of field: nwep_handshake::local_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, local_nodeid) - 8usize];
    ["Offset of field: nwep_handshake::peer_pubkey"]
        [::std::mem::offset_of!(nwep_handshake, peer_pubkey) - 40usize];
    ["Offset of field: nwep_handshake::peer_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, peer_nodeid) - 72usize];
    ["Offset of field: nwep_handshake::expected_peer_nodeid"]
        [::std::mem::offset_of!(nwep_handshake, expected_peer_nodeid) - 104usize];
    ["Offset of field: nwep_handshake::peer_nodeid_verified"]
        [::std::mem::offset_of!(nwep_handshake, peer_nodeid_verified) - 136usize];
    ["Offset of field: nwep_handshake::local_challenge"]
        [::std::mem::offset_of!(nwep_handshake, local_challenge) - 140usize];
    ["Offset of field: nwep_handshake::peer_challenge"]
        [::std::mem::offset_of!(nwep_handshake, peer_challenge) - 172usize];
    ["Offset of field: nwep_handshake::local_params"]
        [::std::mem::offset_of!(nwep_handshake, local_params) - 208usize];
    ["Offset of field: nwep_handshake::peer_params"]
        [::std::mem::offset_of!(nwep_handshake, peer_params) - 232usize];
    ["Offset of field: nwep_handshake::negotiated_params"]
        [::std::mem::offset_of!(nwep_handshake, negotiated_params) - 256usize];
    ["Offset of field: nwep_handshake::transcript"]
        [::std::mem::offset_of!(nwep_handshake, transcript) - 280usize];
    ["Offset of field: nwep_handshake::transcript_len"]
        [::std::mem::offset_of!(nwep_handshake, transcript_len) - 288usize];
    ["Offset of field: nwep_handshake::transcript_cap"]
        [::std::mem::offset_of!(nwep_handshake, transcript_cap) - 296usize];
    ["Offset of field: nwep_handshake::is_server"]
        [::std::mem::offset_of!(nwep_handshake, is_server) - 304usize];
    ["Offset of field: nwep_handshake::state"]
        [::std::mem::offset_of!(nwep_handshake, state) - 308usize];
    ["Offset of field: nwep_handshake::error_code"]
        [::std::mem::offset_of!(nwep_handshake, error_code) - 312usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_client_init` initializes a client handshake context.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_handshake_client_init(
        hs: *mut nwep_handshake,
        keypair: *mut nwep_keypair,
        expected_server: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_server_init` initializes a server handshake context.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_handshake_server_init(
        hs: *mut nwep_handshake,
        keypair: *mut nwep_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_free` frees resources allocated for a handshake."]
    pub fn nwep_handshake_free(hs: *mut nwep_handshake);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_handshake_set_params` sets the local handshake parameters."]
    pub fn nwep_handshake_set_params(hs: *mut nwep_handshake, params: *const nwep_handshake_params);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_request_build` builds a CONNECT request message.\n |headers| must have space for at least 6 headers.\n |header_buf| is scratch space for Base64-encoded values.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_request_parse` parses a CONNECT request and updates handshake state.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_request_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_response_build` builds a CONNECT response message.\n |headers| must have space for at least 10 headers.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_connect_response_parse` parses a CONNECT response and verifies server.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_connect_response_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_request_build` builds an AUTHENTICATE request message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_request_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        header_buf: *mut u8,
        header_buf_len: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_request_parse` parses an AUTHENTICATE request and verifies client.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_request_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_response_build` builds an AUTHENTICATE response message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_response_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        hs: *mut nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_auth_response_parse` parses an AUTHENTICATE response.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_auth_response_parse(
        hs: *mut nwep_handshake,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer1` verifies Layer 1: TLS cert pubkey matches peer_pubkey.\n |tls_pubkey| is extracted from the peer's TLS certificate.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_PUBKEY_MISMATCH."]
    pub fn nwep_verify_layer1(
        hs: *const nwep_handshake,
        tls_pubkey: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer2` verifies Layer 2: NodeID derivation is correct.\n Checks that SHA-256(peer_pubkey || \"WEB/1\") == expected_peer_nodeid.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_NODEID_MISMATCH."]
    pub fn nwep_verify_layer2(hs: *const nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_layer3` verifies Layer 3: challenge signature is valid.\n |signature| is the peer's response to our challenge.\n\n Returns 0 if valid, or NWEP_ERR_CRYPTO_CHALLENGE_FAILED."]
    pub fn nwep_verify_layer3(
        hs: *const nwep_handshake,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_verify_all_layers` performs all three verification layers.\n\n Returns 0 if all valid, or the first fatal error encountered."]
    pub fn nwep_verify_all_layers(
        hs: *const nwep_handshake,
        tls_pubkey: *const u8,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_init` initializes the transcript buffer.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_init(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_add_connect_request` adds CONNECT request to transcript.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_add_connect_request(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_add_connect_response` adds CONNECT response to transcript.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_add_connect_response(hs: *mut nwep_handshake) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_sign` signs the transcript and returns the signature.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_transcript_sign(
        signature: *mut u8,
        hs: *const nwep_handshake,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_transcript_verify` verifies a transcript signature from the peer.\n\n Returns 0 if valid, or a negative error code."]
    pub fn nwep_transcript_verify(
        hs: *const nwep_handshake,
        signature: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_state_str` returns a string representation of the client state."]
    pub fn nwep_client_state_str(state: nwep_client_state) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_state_str` returns a string representation of the server state."]
    pub fn nwep_server_state_str(state: nwep_server_state) -> *const ::std::os::raw::c_char;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_server {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_client {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_conn {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_stream {
    _unused: [u8; 0],
}
pub const nwep_log_level_NWEP_LOG_TRACE: nwep_log_level = 0;
pub const nwep_log_level_NWEP_LOG_DEBUG: nwep_log_level = 1;
pub const nwep_log_level_NWEP_LOG_INFO: nwep_log_level = 2;
pub const nwep_log_level_NWEP_LOG_WARN: nwep_log_level = 3;
pub const nwep_log_level_NWEP_LOG_ERROR: nwep_log_level = 4;
#[doc = " @enum\n\n :type:`nwep_log_level` defines logging severity levels."]
pub type nwep_log_level = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_log_entry` represents a structured log entry."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_entry {
    #[doc = " :member:`level` is the log severity level."]
    pub level: nwep_log_level,
    #[doc = " :member:`timestamp_ns` is the timestamp in nanoseconds (optional, 0 if not set)."]
    pub timestamp_ns: u64,
    #[doc = " :member:`trace_id` is the 16-byte trace ID (all zeros if not set)."]
    pub trace_id: [u8; 16usize],
    #[doc = " :member:`component` is the component name (e.g., \"handshake\", \"stream\")."]
    pub component: *const ::std::os::raw::c_char,
    #[doc = " :member:`message` is the log message."]
    pub message: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_entry"][::std::mem::size_of::<nwep_log_entry>() - 48usize];
    ["Alignment of nwep_log_entry"][::std::mem::align_of::<nwep_log_entry>() - 8usize];
    ["Offset of field: nwep_log_entry::level"]
        [::std::mem::offset_of!(nwep_log_entry, level) - 0usize];
    ["Offset of field: nwep_log_entry::timestamp_ns"]
        [::std::mem::offset_of!(nwep_log_entry, timestamp_ns) - 8usize];
    ["Offset of field: nwep_log_entry::trace_id"]
        [::std::mem::offset_of!(nwep_log_entry, trace_id) - 16usize];
    ["Offset of field: nwep_log_entry::component"]
        [::std::mem::offset_of!(nwep_log_entry, component) - 32usize];
    ["Offset of field: nwep_log_entry::message"]
        [::std::mem::offset_of!(nwep_log_entry, message) - 40usize];
};
#[doc = " @callback\n\n `nwep_log_callback` is called for each log entry when using custom logging."]
pub type nwep_log_callback = ::std::option::Option<
    unsafe extern "C" fn(entry: *const nwep_log_entry, user_data: *mut ::std::os::raw::c_void),
>;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_level_str` returns the string representation of a log level."]
    pub fn nwep_log_level_str(level: nwep_log_level) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_level` sets the minimum log level for output.\n Messages below this level are discarded."]
    pub fn nwep_log_set_level(level: nwep_log_level);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_get_level` returns the current minimum log level."]
    pub fn nwep_log_get_level() -> nwep_log_level;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_callback` sets a custom log callback function.\n If set, all log output goes to the callback instead of default output."]
    pub fn nwep_log_set_callback(
        callback: nwep_log_callback,
        user_data: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_json` enables or disables JSON format output.\n Default is plain text format."]
    pub fn nwep_log_set_json(enabled: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_set_stderr` enables or disables stderr output.\n Default is enabled. Disable when using a custom callback."]
    pub fn nwep_log_set_stderr(enabled: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_write` writes a log entry with the specified level, trace ID,\n component, and printf-style message."]
    pub fn nwep_log_write(
        level: nwep_log_level,
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_trace` writes a TRACE level log entry."]
    pub fn nwep_log_trace(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_debug` writes a DEBUG level log entry."]
    pub fn nwep_log_debug(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_info` writes an INFO level log entry."]
    pub fn nwep_log_info(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_warn` writes a WARN level log entry."]
    pub fn nwep_log_warn(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_error` writes an ERROR level log entry."]
    pub fn nwep_log_error(
        trace_id: *const u8,
        component: *const ::std::os::raw::c_char,
        fmt: *const ::std::os::raw::c_char,
        ...
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_format_json` formats a log entry as a JSON string.\n Returns the number of bytes written (excluding null terminator)."]
    pub fn nwep_log_format_json(
        dest: *mut ::std::os::raw::c_char,
        destlen: usize,
        entry: *const nwep_log_entry,
    ) -> usize;
}
#[doc = " @struct\n\n :type:`nwep_identity` holds identity information (pubkey and NodeID)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity {
    pub pubkey: [u8; 32usize],
    pub nodeid: nwep_nodeid,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_identity"][::std::mem::size_of::<nwep_identity>() - 64usize];
    ["Alignment of nwep_identity"][::std::mem::align_of::<nwep_identity>() - 1usize];
    ["Offset of field: nwep_identity::pubkey"]
        [::std::mem::offset_of!(nwep_identity, pubkey) - 0usize];
    ["Offset of field: nwep_identity::nodeid"]
        [::std::mem::offset_of!(nwep_identity, nodeid) - 32usize];
};
#[doc = " @struct\n\n :type:`nwep_request` represents an incoming request."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_request {
    pub method: *const ::std::os::raw::c_char,
    pub method_len: usize,
    pub path: *const ::std::os::raw::c_char,
    pub path_len: usize,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
    pub request_id: [u8; 16usize],
    pub trace_id: [u8; 16usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_request"][::std::mem::size_of::<nwep_request>() - 96usize];
    ["Alignment of nwep_request"][::std::mem::align_of::<nwep_request>() - 8usize];
    ["Offset of field: nwep_request::method"]
        [::std::mem::offset_of!(nwep_request, method) - 0usize];
    ["Offset of field: nwep_request::method_len"]
        [::std::mem::offset_of!(nwep_request, method_len) - 8usize];
    ["Offset of field: nwep_request::path"][::std::mem::offset_of!(nwep_request, path) - 16usize];
    ["Offset of field: nwep_request::path_len"]
        [::std::mem::offset_of!(nwep_request, path_len) - 24usize];
    ["Offset of field: nwep_request::headers"]
        [::std::mem::offset_of!(nwep_request, headers) - 32usize];
    ["Offset of field: nwep_request::header_count"]
        [::std::mem::offset_of!(nwep_request, header_count) - 40usize];
    ["Offset of field: nwep_request::body"][::std::mem::offset_of!(nwep_request, body) - 48usize];
    ["Offset of field: nwep_request::body_len"]
        [::std::mem::offset_of!(nwep_request, body_len) - 56usize];
    ["Offset of field: nwep_request::request_id"]
        [::std::mem::offset_of!(nwep_request, request_id) - 64usize];
    ["Offset of field: nwep_request::trace_id"]
        [::std::mem::offset_of!(nwep_request, trace_id) - 80usize];
};
#[doc = " @struct\n\n :type:`nwep_response` represents an incoming or outgoing response."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_response {
    pub status: *const ::std::os::raw::c_char,
    pub status_len: usize,
    pub status_details: *const ::std::os::raw::c_char,
    pub status_details_len: usize,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_response"][::std::mem::size_of::<nwep_response>() - 64usize];
    ["Alignment of nwep_response"][::std::mem::align_of::<nwep_response>() - 8usize];
    ["Offset of field: nwep_response::status"]
        [::std::mem::offset_of!(nwep_response, status) - 0usize];
    ["Offset of field: nwep_response::status_len"]
        [::std::mem::offset_of!(nwep_response, status_len) - 8usize];
    ["Offset of field: nwep_response::status_details"]
        [::std::mem::offset_of!(nwep_response, status_details) - 16usize];
    ["Offset of field: nwep_response::status_details_len"]
        [::std::mem::offset_of!(nwep_response, status_details_len) - 24usize];
    ["Offset of field: nwep_response::headers"]
        [::std::mem::offset_of!(nwep_response, headers) - 32usize];
    ["Offset of field: nwep_response::header_count"]
        [::std::mem::offset_of!(nwep_response, header_count) - 40usize];
    ["Offset of field: nwep_response::body"][::std::mem::offset_of!(nwep_response, body) - 48usize];
    ["Offset of field: nwep_response::body_len"]
        [::std::mem::offset_of!(nwep_response, body_len) - 56usize];
};
#[doc = " @struct\n\n :type:`nwep_notify` represents a server-initiated notification."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_notify {
    pub event: *const ::std::os::raw::c_char,
    pub event_len: usize,
    pub path: *const ::std::os::raw::c_char,
    pub path_len: usize,
    pub notify_id: [u8; 16usize],
    pub has_notify_id: ::std::os::raw::c_int,
    pub headers: *const nwep_header,
    pub header_count: usize,
    pub body: *const u8,
    pub body_len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_notify"][::std::mem::size_of::<nwep_notify>() - 88usize];
    ["Alignment of nwep_notify"][::std::mem::align_of::<nwep_notify>() - 8usize];
    ["Offset of field: nwep_notify::event"][::std::mem::offset_of!(nwep_notify, event) - 0usize];
    ["Offset of field: nwep_notify::event_len"]
        [::std::mem::offset_of!(nwep_notify, event_len) - 8usize];
    ["Offset of field: nwep_notify::path"][::std::mem::offset_of!(nwep_notify, path) - 16usize];
    ["Offset of field: nwep_notify::path_len"]
        [::std::mem::offset_of!(nwep_notify, path_len) - 24usize];
    ["Offset of field: nwep_notify::notify_id"]
        [::std::mem::offset_of!(nwep_notify, notify_id) - 32usize];
    ["Offset of field: nwep_notify::has_notify_id"]
        [::std::mem::offset_of!(nwep_notify, has_notify_id) - 48usize];
    ["Offset of field: nwep_notify::headers"]
        [::std::mem::offset_of!(nwep_notify, headers) - 56usize];
    ["Offset of field: nwep_notify::header_count"]
        [::std::mem::offset_of!(nwep_notify, header_count) - 64usize];
    ["Offset of field: nwep_notify::body"][::std::mem::offset_of!(nwep_notify, body) - 72usize];
    ["Offset of field: nwep_notify::body_len"]
        [::std::mem::offset_of!(nwep_notify, body_len) - 80usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_request_parse` parses a decoded message into a request structure.\n |msg| must be a NWEP_MSG_REQUEST type message.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_PROTO_INVALID_MESSAGE`\n     Message is not a request.\n :macro:`NWEP_ERR_PROTO_MISSING_HEADER`\n     Required header is missing.\n :macro:`NWEP_ERR_PROTO_INVALID_METHOD`\n     Method is not valid."]
    pub fn nwep_request_parse(
        req: *mut nwep_request,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_response_parse` parses a decoded message into a response structure.\n |msg| must be a NWEP_MSG_RESPONSE type message.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_response_parse(
        resp: *mut nwep_response,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @callback\n\n `nwep_on_connect` is called when a connection is established.\n |peer| contains the peer's identity.\n\n Return 0 to accept the connection, or a negative error code to reject."]
pub type nwep_on_connect = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        peer: *const nwep_identity,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_disconnect` is called when a connection is closed.\n |error| is the error that caused the disconnect (0 for graceful close)."]
pub type nwep_on_disconnect = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        error: ::std::os::raw::c_int,
        user_data: *mut ::std::os::raw::c_void,
    ),
>;
#[doc = " @callback\n\n `nwep_on_request` is called when a request is received (server-side).\n The callback should call nwep_stream_respond() to send a response.\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_request = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        req: *const nwep_request,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_response` is called when a response is received (client-side).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_response = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        resp: *const nwep_response,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_stream_data` is called when stream body data is received.\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_stream_data = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        data: *const u8,
        len: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_stream_end` is called when the stream ends (FIN received).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_stream_end = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_on_notify` is called when a NOTIFY is received (client-side).\n\n Return 0 on success, or a negative error code."]
pub type nwep_on_notify = ::std::option::Option<
    unsafe extern "C" fn(
        conn: *mut nwep_conn,
        stream: *mut nwep_stream,
        notify: *const nwep_notify,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_rand` generates random bytes. If not provided, OpenSSL's\n RAND_bytes will be used.\n\n Return 0 on success, or a negative error code."]
pub type nwep_rand = ::std::option::Option<
    unsafe extern "C" fn(
        dest: *mut u8,
        len: usize,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_callbacks` holds all callback function pointers."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_callbacks {
    pub on_connect: nwep_on_connect,
    pub on_disconnect: nwep_on_disconnect,
    pub on_request: nwep_on_request,
    pub on_response: nwep_on_response,
    pub on_notify: nwep_on_notify,
    pub on_stream_data: nwep_on_stream_data,
    pub on_stream_end: nwep_on_stream_end,
    pub rand: nwep_rand,
    pub log: nwep_log_callback,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_callbacks"][::std::mem::size_of::<nwep_callbacks>() - 72usize];
    ["Alignment of nwep_callbacks"][::std::mem::align_of::<nwep_callbacks>() - 8usize];
    ["Offset of field: nwep_callbacks::on_connect"]
        [::std::mem::offset_of!(nwep_callbacks, on_connect) - 0usize];
    ["Offset of field: nwep_callbacks::on_disconnect"]
        [::std::mem::offset_of!(nwep_callbacks, on_disconnect) - 8usize];
    ["Offset of field: nwep_callbacks::on_request"]
        [::std::mem::offset_of!(nwep_callbacks, on_request) - 16usize];
    ["Offset of field: nwep_callbacks::on_response"]
        [::std::mem::offset_of!(nwep_callbacks, on_response) - 24usize];
    ["Offset of field: nwep_callbacks::on_notify"]
        [::std::mem::offset_of!(nwep_callbacks, on_notify) - 32usize];
    ["Offset of field: nwep_callbacks::on_stream_data"]
        [::std::mem::offset_of!(nwep_callbacks, on_stream_data) - 40usize];
    ["Offset of field: nwep_callbacks::on_stream_end"]
        [::std::mem::offset_of!(nwep_callbacks, on_stream_end) - 48usize];
    ["Offset of field: nwep_callbacks::rand"]
        [::std::mem::offset_of!(nwep_callbacks, rand) - 56usize];
    ["Offset of field: nwep_callbacks::log"][::std::mem::offset_of!(nwep_callbacks, log) - 64usize];
};
#[doc = " @struct\n\n :type:`nwep_settings` holds configuration settings."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_settings {
    #[doc = " :member:`max_streams` is the maximum concurrent streams (default 100)."]
    pub max_streams: u32,
    #[doc = " :member:`max_message_size` is the maximum message size (default 24MB)."]
    pub max_message_size: u32,
    #[doc = " :member:`timeout_ms` is the connection timeout in milliseconds (default 30000)."]
    pub timeout_ms: u32,
    #[doc = " :member:`compression` is the compression algorithm (\"none\" or \"zstd\")."]
    pub compression: *const ::std::os::raw::c_char,
    #[doc = " :member:`role` is the advertised role (server only, e.g., \"regular_node\")."]
    pub role: *const ::std::os::raw::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_settings"][::std::mem::size_of::<nwep_settings>() - 32usize];
    ["Alignment of nwep_settings"][::std::mem::align_of::<nwep_settings>() - 8usize];
    ["Offset of field: nwep_settings::max_streams"]
        [::std::mem::offset_of!(nwep_settings, max_streams) - 0usize];
    ["Offset of field: nwep_settings::max_message_size"]
        [::std::mem::offset_of!(nwep_settings, max_message_size) - 4usize];
    ["Offset of field: nwep_settings::timeout_ms"]
        [::std::mem::offset_of!(nwep_settings, timeout_ms) - 8usize];
    ["Offset of field: nwep_settings::compression"]
        [::std::mem::offset_of!(nwep_settings, compression) - 16usize];
    ["Offset of field: nwep_settings::role"][::std::mem::offset_of!(nwep_settings, role) - 24usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_settings_default` initializes settings with default values."]
    pub fn nwep_settings_default(settings: *mut nwep_settings);
}
#[doc = " @struct\n\n :type:`nwep_path` represents a network path (local and remote addresses)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_path {
    pub local_addr: sockaddr_storage,
    pub local_addrlen: usize,
    pub remote_addr: sockaddr_storage,
    pub remote_addrlen: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_path"][::std::mem::size_of::<nwep_path>() - 272usize];
    ["Alignment of nwep_path"][::std::mem::align_of::<nwep_path>() - 8usize];
    ["Offset of field: nwep_path::local_addr"]
        [::std::mem::offset_of!(nwep_path, local_addr) - 0usize];
    ["Offset of field: nwep_path::local_addrlen"]
        [::std::mem::offset_of!(nwep_path, local_addrlen) - 128usize];
    ["Offset of field: nwep_path::remote_addr"]
        [::std::mem::offset_of!(nwep_path, remote_addr) - 136usize];
    ["Offset of field: nwep_path::remote_addrlen"]
        [::std::mem::offset_of!(nwep_path, remote_addrlen) - 264usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_init` initializes the nwep library.\n Call this function before using any other nwep functions.\n This initializes the underlying TLS/crypto library.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_init() -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_new` creates a new server instance.\n |keypair| is the server's Ed25519 keypair (caller retains ownership).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_new(
        pserver: *mut *mut nwep_server,
        settings: *const nwep_settings,
        callbacks: *const nwep_callbacks,
        keypair: *mut nwep_keypair,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_free` frees a server instance."]
    pub fn nwep_server_free(server: *mut nwep_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_read` processes a received packet.\n |path| identifies the network path the packet arrived on.\n |data| is the packet data, |datalen| is its length.\n |ts| is the current timestamp in nanoseconds.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_read(
        server: *mut nwep_server,
        path: *const nwep_path,
        data: *const u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_write` gets the next packet to send.\n |path| receives the network path to send on.\n |data| is the buffer to write to, |datalen| is its capacity.\n |ts| is the current timestamp in nanoseconds.\n\n Returns the number of bytes written, 0 if no packet to send,\n or a negative error code."]
    pub fn nwep_server_write(
        server: *mut nwep_server,
        path: *mut nwep_path,
        data: *mut u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_handle_expiry` handles timer expiration.\n Call this when the timer returned by nwep_server_get_expiry() fires.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_server_handle_expiry(
        server: *mut nwep_server,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_get_expiry` gets the next timer deadline.\n\n Returns the deadline in nanoseconds, or UINT64_MAX if no timer is set."]
    pub fn nwep_server_get_expiry(server: *const nwep_server) -> nwep_tstamp;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_server_close` initiates graceful shutdown."]
    pub fn nwep_server_close(server: *mut nwep_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_new` creates a new client instance.\n |keypair| is the client's Ed25519 keypair (caller retains ownership).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_new(
        pclient: *mut *mut nwep_client,
        settings: *const nwep_settings,
        callbacks: *const nwep_callbacks,
        keypair: *mut nwep_keypair,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_free` frees a client instance."]
    pub fn nwep_client_free(client: *mut nwep_client);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_connect` initiates a connection to a web:// address.\n |url| is the parsed URL containing address and path.\n |local_addr| is the local address to bind to (can be NULL).\n |ts| is the current timestamp in nanoseconds.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_connect(
        client: *mut nwep_client,
        url: *const nwep_url,
        local_addr: *const sockaddr,
        local_addrlen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_read` processes a received packet.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_read(
        client: *mut nwep_client,
        path: *const nwep_path,
        data: *const u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_write` gets the next packet to send.\n\n Returns the number of bytes written, 0 if no packet to send,\n or a negative error code."]
    pub fn nwep_client_write(
        client: *mut nwep_client,
        path: *mut nwep_path,
        data: *mut u8,
        datalen: usize,
        ts: nwep_tstamp,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_handle_expiry` handles timer expiration.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_client_handle_expiry(
        client: *mut nwep_client,
        ts: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_get_expiry` gets the next timer deadline.\n\n Returns the deadline in nanoseconds, or UINT64_MAX if no timer is set."]
    pub fn nwep_client_get_expiry(client: *const nwep_client) -> nwep_tstamp;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_close` initiates graceful shutdown."]
    pub fn nwep_client_close(client: *mut nwep_client);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_client_get_conn` gets the connection for the client.\n Returns NULL if not connected."]
    pub fn nwep_client_get_conn(client: *mut nwep_client) -> *mut nwep_conn;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_peer_identity` gets the peer's identity."]
    pub fn nwep_conn_get_peer_identity(conn: *const nwep_conn) -> *const nwep_identity;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_local_identity` gets our identity."]
    pub fn nwep_conn_get_local_identity(conn: *const nwep_conn) -> *const nwep_identity;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_role` gets the negotiated role."]
    pub fn nwep_conn_get_role(conn: *const nwep_conn) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_close` closes the connection with an error.\n |error| is the error code (0 for graceful close)."]
    pub fn nwep_conn_close(conn: *mut nwep_conn, error: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_user_data` gets the user data associated with the connection."]
    pub fn nwep_conn_get_user_data(conn: *const nwep_conn) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_set_user_data` sets user data for the connection."]
    pub fn nwep_conn_set_user_data(conn: *mut nwep_conn, user_data: *mut ::std::os::raw::c_void);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_request` sends a request and returns the stream.\n |req| contains the request to send.\n |pstream| receives the stream pointer for response handling.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_request(
        conn: *mut nwep_conn,
        req: *const nwep_request,
        pstream: *mut *mut nwep_stream,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_respond` sends a response on a stream (server-side).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_respond(
        stream: *mut nwep_stream,
        resp: *const nwep_response,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_write` writes body data to a stream.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_stream_write(stream: *mut nwep_stream, data: *const u8, len: usize) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_end` signals the end of the stream (sends FIN).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_stream_end(stream: *mut nwep_stream) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_close` closes the stream with an error (sends RESET)."]
    pub fn nwep_stream_close(stream: *mut nwep_stream, error: ::std::os::raw::c_int);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_id` gets the stream ID."]
    pub fn nwep_stream_get_id(stream: *const nwep_stream) -> i64;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_user_data` gets user data for the stream."]
    pub fn nwep_stream_get_user_data(stream: *const nwep_stream) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_set_user_data` sets user data for the stream."]
    pub fn nwep_stream_set_user_data(
        stream: *mut nwep_stream,
        user_data: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_get_conn` gets the connection for a stream."]
    pub fn nwep_stream_get_conn(stream: *const nwep_stream) -> *mut nwep_conn;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_notify` sends a NOTIFY to client, opening a new stream.\n |conn| must be a server connection. |pstream| receives the stream.\n\n This function returns 0 if it succeeds, or one of the following\n negative error codes:\n\n :macro:`NWEP_ERR_INTERNAL_INVALID_STATE`\n     Connection is not a server or not connected.\n :macro:`NWEP_ERR_INTERNAL_NOMEM`\n     Out of memory.\n :macro:`NWEP_ERR_NETWORK_QUIC`\n     Stream ID blocked."]
    pub fn nwep_conn_notify(
        conn: *mut nwep_conn,
        notify: *const nwep_notify,
        pstream: *mut *mut nwep_stream,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_notify_build` builds a NOTIFY message.\n\n This function returns 0 if it succeeds, or a negative error code."]
    pub fn nwep_notify_build(
        msg: *mut nwep_msg,
        headers: *mut nwep_header,
        max_headers: usize,
        event: *const ::std::os::raw::c_char,
        path: *const ::std::os::raw::c_char,
        notify_id: *const u8,
        body: *const u8,
        body_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_notify_parse` parses a message into a notify structure.\n\n This function returns 0 if it succeeds, or one of the following\n negative error codes:\n\n :macro:`NWEP_ERR_PROTO_INVALID_MESSAGE`\n     Message is not a notify.\n :macro:`NWEP_ERR_PROTO_MISSING_HEADER`\n     Required header is missing."]
    pub fn nwep_notify_parse(
        notify: *mut nwep_notify,
        msg: *const nwep_msg,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_stream_is_server_initiated` returns nonzero if the stream was\n initiated by the server."]
    pub fn nwep_stream_is_server_initiated(stream: *const nwep_stream) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_bls_keypair` holds a BLS12-381 keypair."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_keypair {
    pub pubkey: [u8; 48usize],
    pub privkey: [u8; 32usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_keypair"][::std::mem::size_of::<nwep_bls_keypair>() - 80usize];
    ["Alignment of nwep_bls_keypair"][::std::mem::align_of::<nwep_bls_keypair>() - 1usize];
    ["Offset of field: nwep_bls_keypair::pubkey"]
        [::std::mem::offset_of!(nwep_bls_keypair, pubkey) - 0usize];
    ["Offset of field: nwep_bls_keypair::privkey"]
        [::std::mem::offset_of!(nwep_bls_keypair, privkey) - 48usize];
};
#[doc = " @struct\n\n :type:`nwep_bls_pubkey` holds a BLS12-381 public key."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_pubkey {
    pub data: [u8; 48usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_pubkey"][::std::mem::size_of::<nwep_bls_pubkey>() - 48usize];
    ["Alignment of nwep_bls_pubkey"][::std::mem::align_of::<nwep_bls_pubkey>() - 1usize];
    ["Offset of field: nwep_bls_pubkey::data"]
        [::std::mem::offset_of!(nwep_bls_pubkey, data) - 0usize];
};
#[doc = " @struct\n\n :type:`nwep_bls_sig` holds a BLS12-381 signature."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_bls_sig {
    pub data: [u8; 96usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_bls_sig"][::std::mem::size_of::<nwep_bls_sig>() - 96usize];
    ["Alignment of nwep_bls_sig"][::std::mem::align_of::<nwep_bls_sig>() - 1usize];
    ["Offset of field: nwep_bls_sig::data"][::std::mem::offset_of!(nwep_bls_sig, data) - 0usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_keypair_generate` generates a new BLS12-381 keypair.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_keypair_generate(kp: *mut nwep_bls_keypair) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_keypair_from_seed` generates a BLS keypair deterministically.\n\n |ikm| is the input keying material (at least 32 bytes recommended).\n |ikm_len| is the length of ikm.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_keypair_from_seed(
        kp: *mut nwep_bls_keypair,
        ikm: *const u8,
        ikm_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_pubkey_serialize` serializes a public key to bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_pubkey_serialize(
        out: *mut u8,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_pubkey_deserialize` deserializes a public key from bytes.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_pubkey_deserialize(
        pk: *mut nwep_bls_pubkey,
        in_: *const u8,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_sign` signs a message with a BLS private key.\n\n |sig| receives the signature.\n |kp| is the keypair.\n |msg| is the message to sign.\n |msg_len| is the message length.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_sign(
        sig: *mut nwep_bls_sig,
        kp: *const nwep_bls_keypair,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_verify` verifies a BLS signature.\n\n Returns 0 on success (valid), or a negative error code."]
    pub fn nwep_bls_verify(
        pk: *const nwep_bls_pubkey,
        sig: *const nwep_bls_sig,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_aggregate_sigs` aggregates multiple BLS signatures.\n\n |out| receives the aggregated signature.\n |sigs| is an array of signatures.\n |n| is the number of signatures.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_bls_aggregate_sigs(
        out: *mut nwep_bls_sig,
        sigs: *const nwep_bls_sig,
        n: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_bls_verify_aggregate` verifies an aggregated BLS signature.\n\n All signers must have signed the same message.\n\n |pks| is an array of public keys.\n |n| is the number of public keys.\n |sig| is the aggregated signature.\n |msg| is the message.\n |msg_len| is the message length.\n\n Returns 0 on success (valid), or a negative error code."]
    pub fn nwep_bls_verify_aggregate(
        pks: *const nwep_bls_pubkey,
        n: usize,
        sig: *const nwep_bls_sig,
        msg: *const u8,
        msg_len: usize,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_set {
    _unused: [u8; 0],
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_new` creates a new anchor set.\n\n |threshold| is the number of anchors required for a valid checkpoint.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_new(
        pset: *mut *mut nwep_anchor_set,
        threshold: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_free` frees an anchor set."]
    pub fn nwep_anchor_set_free(set: *mut nwep_anchor_set);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_add` adds an anchor public key to the set.\n\n |builtin| indicates if this is a built-in anchor (cannot be removed).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_add(
        set: *mut nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
        builtin: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_remove` removes an anchor from the set.\n\n Built-in anchors cannot be removed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_remove(
        set: *mut nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_size` returns the number of anchors in the set."]
    pub fn nwep_anchor_set_size(set: *const nwep_anchor_set) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_get` retrieves an anchor by index.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_set_get(
        set: *const nwep_anchor_set,
        idx: usize,
        pk: *mut nwep_bls_pubkey,
        builtin: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_threshold` returns the threshold for the set."]
    pub fn nwep_anchor_set_threshold(set: *const nwep_anchor_set) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_set_contains` checks if a public key is in the set.\n\n Returns 1 if found, 0 if not found."]
    pub fn nwep_anchor_set_contains(
        set: *const nwep_anchor_set,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_checkpoint` represents a signed epoch checkpoint."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_checkpoint {
    pub epoch: u64,
    pub timestamp: nwep_tstamp,
    pub merkle_root: nwep_merkle_hash,
    pub log_size: u64,
    pub signature: nwep_bls_sig,
    pub signers: [nwep_bls_pubkey; 32usize],
    pub num_signers: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_checkpoint"][::std::mem::size_of::<nwep_checkpoint>() - 1696usize];
    ["Alignment of nwep_checkpoint"][::std::mem::align_of::<nwep_checkpoint>() - 8usize];
    ["Offset of field: nwep_checkpoint::epoch"]
        [::std::mem::offset_of!(nwep_checkpoint, epoch) - 0usize];
    ["Offset of field: nwep_checkpoint::timestamp"]
        [::std::mem::offset_of!(nwep_checkpoint, timestamp) - 8usize];
    ["Offset of field: nwep_checkpoint::merkle_root"]
        [::std::mem::offset_of!(nwep_checkpoint, merkle_root) - 16usize];
    ["Offset of field: nwep_checkpoint::log_size"]
        [::std::mem::offset_of!(nwep_checkpoint, log_size) - 48usize];
    ["Offset of field: nwep_checkpoint::signature"]
        [::std::mem::offset_of!(nwep_checkpoint, signature) - 56usize];
    ["Offset of field: nwep_checkpoint::signers"]
        [::std::mem::offset_of!(nwep_checkpoint, signers) - 152usize];
    ["Offset of field: nwep_checkpoint::num_signers"]
        [::std::mem::offset_of!(nwep_checkpoint, num_signers) - 1688usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_new` creates a new checkpoint proposal.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_new(
        cp: *mut nwep_checkpoint,
        epoch: u64,
        timestamp: nwep_tstamp,
        merkle_root: *const nwep_merkle_hash,
        log_size: u64,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_sign` signs a checkpoint with an anchor's key.\n\n Adds the signature to the checkpoint's aggregated signature.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_sign(
        cp: *mut nwep_checkpoint,
        anchor_kp: *const nwep_bls_keypair,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_verify` verifies a checkpoint's signatures.\n\n |anchor_set| is the trusted anchor set.\n\n Returns 0 if valid (threshold reached), or a negative error code."]
    pub fn nwep_checkpoint_verify(
        cp: *const nwep_checkpoint,
        anchor_set: *const nwep_anchor_set,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_encode` serializes a checkpoint.\n\n Returns the number of bytes written, or a negative error code."]
    pub fn nwep_checkpoint_encode(
        buf: *mut u8,
        buflen: usize,
        cp: *const nwep_checkpoint,
    ) -> nwep_ssize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_decode` deserializes a checkpoint.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_checkpoint_decode(
        cp: *mut nwep_checkpoint,
        data: *const u8,
        datalen: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_checkpoint_message` computes the message to be signed.\n\n This is the canonical encoding: epoch || timestamp || merkle_root || log_size\n\n Returns the number of bytes written (always 56), or a negative error code."]
    pub fn nwep_checkpoint_message(
        buf: *mut u8,
        buflen: usize,
        cp: *const nwep_checkpoint,
    ) -> nwep_ssize;
}
#[doc = " @callback\n\n `nwep_trust_anchor_load_cb` loads anchors from persistent storage.\n Returns number of anchors loaded, or negative error code."]
pub type nwep_trust_anchor_load_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        anchors: *mut nwep_bls_pubkey,
        max_anchors: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_anchor_save_cb` saves anchors to persistent storage.\n Returns 0 on success, or negative error code."]
pub type nwep_trust_anchor_save_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        anchors: *const nwep_bls_pubkey,
        count: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_checkpoint_load_cb` loads checkpoints from persistent storage.\n Returns number of checkpoints loaded, or negative error code."]
pub type nwep_trust_checkpoint_load_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        checkpoints: *mut nwep_checkpoint,
        max_checkpoints: usize,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @callback\n\n `nwep_trust_checkpoint_save_cb` saves a checkpoint to persistent storage.\n Returns 0 on success, or negative error code."]
pub type nwep_trust_checkpoint_save_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_trust_storage` holds optional persistence callbacks."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_storage {
    pub anchor_load: nwep_trust_anchor_load_cb,
    pub anchor_save: nwep_trust_anchor_save_cb,
    pub checkpoint_load: nwep_trust_checkpoint_load_cb,
    pub checkpoint_save: nwep_trust_checkpoint_save_cb,
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_trust_storage"][::std::mem::size_of::<nwep_trust_storage>() - 40usize];
    ["Alignment of nwep_trust_storage"][::std::mem::align_of::<nwep_trust_storage>() - 8usize];
    ["Offset of field: nwep_trust_storage::anchor_load"]
        [::std::mem::offset_of!(nwep_trust_storage, anchor_load) - 0usize];
    ["Offset of field: nwep_trust_storage::anchor_save"]
        [::std::mem::offset_of!(nwep_trust_storage, anchor_save) - 8usize];
    ["Offset of field: nwep_trust_storage::checkpoint_load"]
        [::std::mem::offset_of!(nwep_trust_storage, checkpoint_load) - 16usize];
    ["Offset of field: nwep_trust_storage::checkpoint_save"]
        [::std::mem::offset_of!(nwep_trust_storage, checkpoint_save) - 24usize];
    ["Offset of field: nwep_trust_storage::user_data"]
        [::std::mem::offset_of!(nwep_trust_storage, user_data) - 32usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_store {
    _unused: [u8; 0],
}
#[doc = " @struct\n\n :type:`nwep_trust_settings` configures trust store behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_trust_settings {
    #[doc = " :member:`staleness_warning_ns` is the warning threshold in nanoseconds.\n Default: NWEP_STALENESS_WARNING_NS (1 hour)."]
    pub staleness_warning_ns: nwep_duration,
    #[doc = " :member:`staleness_reject_ns` is the rejection threshold in nanoseconds.\n Default: NWEP_STALENESS_REJECT_NS (24 hours)."]
    pub staleness_reject_ns: nwep_duration,
    #[doc = " :member:`identity_cache_ttl` is the identity cache TTL in nanoseconds.\n Default: NWEP_IDENTITY_CACHE_TTL (1 hour)."]
    pub identity_cache_ttl: nwep_duration,
    #[doc = " :member:`anchor_threshold` is the minimum anchors for valid checkpoint.\n Default: NWEP_DEFAULT_ANCHOR_THRESHOLD."]
    pub anchor_threshold: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_trust_settings"][::std::mem::size_of::<nwep_trust_settings>() - 32usize];
    ["Alignment of nwep_trust_settings"][::std::mem::align_of::<nwep_trust_settings>() - 8usize];
    ["Offset of field: nwep_trust_settings::staleness_warning_ns"]
        [::std::mem::offset_of!(nwep_trust_settings, staleness_warning_ns) - 0usize];
    ["Offset of field: nwep_trust_settings::staleness_reject_ns"]
        [::std::mem::offset_of!(nwep_trust_settings, staleness_reject_ns) - 8usize];
    ["Offset of field: nwep_trust_settings::identity_cache_ttl"]
        [::std::mem::offset_of!(nwep_trust_settings, identity_cache_ttl) - 16usize];
    ["Offset of field: nwep_trust_settings::anchor_threshold"]
        [::std::mem::offset_of!(nwep_trust_settings, anchor_threshold) - 24usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_settings_default` initializes settings to defaults."]
    pub fn nwep_trust_settings_default(settings: *mut nwep_trust_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_new` creates a new trust store.\n\n |settings| configures behavior (NULL for defaults).\n |storage| provides optional persistence (NULL for in-memory only).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_new(
        pstore: *mut *mut nwep_trust_store,
        settings: *const nwep_trust_settings,
        storage: *const nwep_trust_storage,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_free` frees a trust store."]
    pub fn nwep_trust_store_free(store: *mut nwep_trust_store);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_add_anchor` adds a trusted anchor.\n\n |builtin| indicates if this is a built-in anchor (cannot be removed).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_add_anchor(
        store: *mut nwep_trust_store,
        pk: *const nwep_bls_pubkey,
        builtin: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_remove_anchor` removes a non-builtin anchor.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_remove_anchor(
        store: *mut nwep_trust_store,
        pk: *const nwep_bls_pubkey,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_anchors` retrieves the anchor set.\n\n The returned anchor set is owned by the trust store; do not free it."]
    pub fn nwep_trust_store_get_anchors(store: *const nwep_trust_store) -> *const nwep_anchor_set;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_add_checkpoint` adds a verified checkpoint.\n\n The checkpoint is verified against the anchor set before storing.\n\n Returns 0 on success, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_TRUST_QUORUM_NOT_REACHED`\n     Checkpoint does not have enough valid signatures.\n :macro:`NWEP_ERR_CRYPTO_SIGN_FAILED`\n     Signature verification failed."]
    pub fn nwep_trust_store_add_checkpoint(
        store: *mut nwep_trust_store,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_latest_checkpoint` retrieves the most recent checkpoint.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if no checkpoints."]
    pub fn nwep_trust_store_get_latest_checkpoint(
        store: *const nwep_trust_store,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_checkpoint` retrieves a checkpoint by epoch.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_trust_store_get_checkpoint(
        store: *const nwep_trust_store,
        epoch: u64,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_checkpoint_count` returns number of stored checkpoints."]
    pub fn nwep_trust_store_checkpoint_count(store: *const nwep_trust_store) -> usize;
}
pub const nwep_staleness_NWEP_STALENESS_FRESH: nwep_staleness = 0;
pub const nwep_staleness_NWEP_STALENESS_WARNING: nwep_staleness = 1;
pub const nwep_staleness_NWEP_STALENESS_REJECT: nwep_staleness = 2;
#[doc = " @enum\n\n :type:`nwep_staleness` indicates checkpoint freshness status."]
pub type nwep_staleness = ::std::os::raw::c_uint;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_check_staleness` checks checkpoint freshness.\n\n |now| is the current timestamp.\n\n Returns staleness status."]
    pub fn nwep_trust_store_check_staleness(
        store: *const nwep_trust_store,
        now: nwep_tstamp,
    ) -> nwep_staleness;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_get_staleness_age` returns age since last checkpoint.\n\n Returns 0 if no checkpoints stored."]
    pub fn nwep_trust_store_get_staleness_age(
        store: *const nwep_trust_store,
        now: nwep_tstamp,
    ) -> nwep_duration;
}
#[doc = " @struct\n\n :type:`nwep_verified_identity` holds a verified identity with proof."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_verified_identity {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub checkpoint_epoch: u64,
    pub verified_at: nwep_tstamp,
    pub revoked: ::std::os::raw::c_int,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_verified_identity"][::std::mem::size_of::<nwep_verified_identity>() - 96usize];
    ["Alignment of nwep_verified_identity"]
        [::std::mem::align_of::<nwep_verified_identity>() - 8usize];
    ["Offset of field: nwep_verified_identity::nodeid"]
        [::std::mem::offset_of!(nwep_verified_identity, nodeid) - 0usize];
    ["Offset of field: nwep_verified_identity::pubkey"]
        [::std::mem::offset_of!(nwep_verified_identity, pubkey) - 32usize];
    ["Offset of field: nwep_verified_identity::log_index"]
        [::std::mem::offset_of!(nwep_verified_identity, log_index) - 64usize];
    ["Offset of field: nwep_verified_identity::checkpoint_epoch"]
        [::std::mem::offset_of!(nwep_verified_identity, checkpoint_epoch) - 72usize];
    ["Offset of field: nwep_verified_identity::verified_at"]
        [::std::mem::offset_of!(nwep_verified_identity, verified_at) - 80usize];
    ["Offset of field: nwep_verified_identity::revoked"]
        [::std::mem::offset_of!(nwep_verified_identity, revoked) - 88usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_verify_identity` verifies an identity against a checkpoint.\n\n |entry| is the log entry claiming the identity.\n |proof| is the inclusion proof for the entry.\n |checkpoint| is the checkpoint to verify against (NULL for latest).\n\n Returns 0 if valid, or one of the following negative error codes:\n\n :macro:`NWEP_ERR_TRUST_INVALID_PROOF`\n     Proof does not verify against checkpoint merkle root.\n :macro:`NWEP_ERR_TRUST_ENTRY_NOT_FOUND`\n     No checkpoints available.\n :macro:`NWEP_ERR_TRUST_CHECKPOINT_STALE`\n     Checkpoint is too old."]
    pub fn nwep_trust_store_verify_identity(
        store: *mut nwep_trust_store,
        entry: *const nwep_merkle_entry,
        proof: *const nwep_merkle_proof,
        checkpoint: *const nwep_checkpoint,
        now: nwep_tstamp,
        result: *mut nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_cache_identity` caches a verified identity.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_trust_store_cache_identity(
        store: *mut nwep_trust_store,
        identity: *const nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_lookup_identity` looks up a cached identity by NodeID.\n\n Returns 0 if found and valid, or NWEP_ERR_TRUST_NODE_NOT_FOUND."]
    pub fn nwep_trust_store_lookup_identity(
        store: *const nwep_trust_store,
        nodeid: *const nwep_nodeid,
        now: nwep_tstamp,
        out: *mut nwep_verified_identity,
    ) -> ::std::os::raw::c_int;
}
#[doc = " @struct\n\n :type:`nwep_equivocation` describes a detected equivocation."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_equivocation {
    pub anchor: nwep_bls_pubkey,
    pub epoch: u64,
    pub root1: nwep_merkle_hash,
    pub root2: nwep_merkle_hash,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_equivocation"][::std::mem::size_of::<nwep_equivocation>() - 120usize];
    ["Alignment of nwep_equivocation"][::std::mem::align_of::<nwep_equivocation>() - 8usize];
    ["Offset of field: nwep_equivocation::anchor"]
        [::std::mem::offset_of!(nwep_equivocation, anchor) - 0usize];
    ["Offset of field: nwep_equivocation::epoch"]
        [::std::mem::offset_of!(nwep_equivocation, epoch) - 48usize];
    ["Offset of field: nwep_equivocation::root1"]
        [::std::mem::offset_of!(nwep_equivocation, root1) - 56usize];
    ["Offset of field: nwep_equivocation::root2"]
        [::std::mem::offset_of!(nwep_equivocation, root2) - 88usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_trust_store_check_equivocation` checks for conflicting checkpoints.\n\n Compares |cp| against stored checkpoints for the same epoch.\n\n Returns 0 if no equivocation, or NWEP_ERR_TRUST_EQUIVOCATION if detected.\n If detected, |out| receives details (if not NULL)."]
    pub fn nwep_trust_store_check_equivocation(
        store: *mut nwep_trust_store,
        cp: *const nwep_checkpoint,
        out: *mut nwep_equivocation,
    ) -> ::std::os::raw::c_int;
}
#[doc = " :enum:`NWEP_ROLE_REGULAR` is a regular node (client connections, forwarding)."]
pub const nwep_server_role_NWEP_ROLE_REGULAR: nwep_server_role = 0;
#[doc = " :enum:`NWEP_ROLE_LOG_SERVER` is a Merkle log server."]
pub const nwep_server_role_NWEP_ROLE_LOG_SERVER: nwep_server_role = 1;
#[doc = " :enum:`NWEP_ROLE_ANCHOR` is an anchor server (checkpoint signing)."]
pub const nwep_server_role_NWEP_ROLE_ANCHOR: nwep_server_role = 2;
#[doc = " @enum\n\n :type:`nwep_server_role` defines the server role types."]
pub type nwep_server_role = ::std::os::raw::c_uint;
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_role_from_str` converts a role string to enum.\n\n Returns the role enum, or NWEP_ROLE_REGULAR if unknown."]
    pub fn nwep_role_from_str(role_str: *const ::std::os::raw::c_char) -> nwep_server_role;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_role_to_str` converts a role enum to string.\n\n Returns the role string."]
    pub fn nwep_role_to_str(role: nwep_server_role) -> *const ::std::os::raw::c_char;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server {
    _unused: [u8; 0],
}
#[doc = " @callback\n\n `nwep_log_authorize_cb` checks if a client is authorized to write entries.\n\n |nodeid| is the client's NodeID.\n |entry| is the entry they want to write.\n\n Returns 0 if authorized, or NWEP_ERR_PROTO_UNAUTHORIZED if not."]
pub type nwep_log_authorize_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        nodeid: *const nwep_nodeid,
        entry: *const nwep_merkle_entry,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_log_server_settings` configures log server behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_settings {
    #[doc = " :member:`authorize` is called before accepting write requests.\n If NULL, only read operations are allowed."]
    pub authorize: nwep_log_authorize_cb,
    #[doc = " :member:`user_data` is passed to callbacks."]
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_server_settings"]
        [::std::mem::size_of::<nwep_log_server_settings>() - 16usize];
    ["Alignment of nwep_log_server_settings"]
        [::std::mem::align_of::<nwep_log_server_settings>() - 8usize];
    ["Offset of field: nwep_log_server_settings::authorize"]
        [::std::mem::offset_of!(nwep_log_server_settings, authorize) - 0usize];
    ["Offset of field: nwep_log_server_settings::user_data"]
        [::std::mem::offset_of!(nwep_log_server_settings, user_data) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_new` creates a new log server.\n\n |log| is the Merkle log to serve.\n |settings| configures server behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_new(
        pserver: *mut *mut nwep_log_server,
        log: *mut nwep_merkle_log,
        settings: *const nwep_log_server_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_free` frees a log server."]
    pub fn nwep_log_server_free(server: *mut nwep_log_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_handle_request` handles a log server request.\n\n Handles paths:\n - READ /log/entry/{index} - returns entry at index\n - READ /log/proof/{index} - returns inclusion proof\n - READ /log/size - returns current log size\n - WRITE /log/entry - appends entry (if authorized)\n\n |stream| is the stream to respond on.\n |request| is the incoming request.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_handle_request(
        server: *mut nwep_log_server,
        stream: *mut nwep_stream,
        request: *const nwep_request,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_get_log` returns the underlying Merkle log."]
    pub fn nwep_log_server_get_log(server: *mut nwep_log_server) -> *mut nwep_merkle_log;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_server {
    _unused: [u8; 0],
}
#[doc = " @callback\n\n `nwep_anchor_proposal_cb` is called when a checkpoint proposal is received.\n\n |cp| is the proposed checkpoint.\n Returns 0 to sign and accept, or a negative error code to reject."]
pub type nwep_anchor_proposal_cb = ::std::option::Option<
    unsafe extern "C" fn(
        user_data: *mut ::std::os::raw::c_void,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int,
>;
#[doc = " @struct\n\n :type:`nwep_anchor_server_settings` configures anchor server behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_anchor_server_settings {
    #[doc = " :member:`on_proposal` is called when receiving checkpoint proposals.\n If NULL, all valid proposals are signed."]
    pub on_proposal: nwep_anchor_proposal_cb,
    #[doc = " :member:`user_data` is passed to callbacks."]
    pub user_data: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_anchor_server_settings"]
        [::std::mem::size_of::<nwep_anchor_server_settings>() - 16usize];
    ["Alignment of nwep_anchor_server_settings"]
        [::std::mem::align_of::<nwep_anchor_server_settings>() - 8usize];
    ["Offset of field: nwep_anchor_server_settings::on_proposal"]
        [::std::mem::offset_of!(nwep_anchor_server_settings, on_proposal) - 0usize];
    ["Offset of field: nwep_anchor_server_settings::user_data"]
        [::std::mem::offset_of!(nwep_anchor_server_settings, user_data) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_new` creates a new anchor server.\n\n |keypair| is the BLS keypair for signing checkpoints.\n |anchors| is the trusted anchor set.\n |settings| configures server behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_new(
        pserver: *mut *mut nwep_anchor_server,
        keypair: *const nwep_bls_keypair,
        anchors: *mut nwep_anchor_set,
        settings: *const nwep_anchor_server_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_free` frees an anchor server."]
    pub fn nwep_anchor_server_free(server: *mut nwep_anchor_server);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_handle_request` handles an anchor server request.\n\n Handles paths:\n - READ /checkpoint/latest - returns latest finalized checkpoint\n - READ /checkpoint/{epoch} - returns checkpoint for specific epoch\n - WRITE /checkpoint/propose - receives checkpoint proposal\n - WRITE /checkpoint/signature - receives signature for proposal\n\n |stream| is the stream to respond on.\n |request| is the incoming request.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_handle_request(
        server: *mut nwep_anchor_server,
        stream: *mut nwep_stream,
        request: *const nwep_request,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_add_checkpoint` adds a finalized checkpoint.\n\n Call this after collecting enough signatures for a checkpoint."]
    pub fn nwep_anchor_server_add_checkpoint(
        server: *mut nwep_anchor_server,
        cp: *const nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_get_latest` gets the latest finalized checkpoint.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if none."]
    pub fn nwep_anchor_server_get_latest(
        server: *const nwep_anchor_server,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_get_checkpoint` gets a checkpoint by epoch.\n\n Returns 0 on success, or NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_anchor_server_get_checkpoint(
        server: *const nwep_anchor_server,
        epoch: u64,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_create_proposal` creates a checkpoint proposal.\n\n |log| is the Merkle log to checkpoint.\n |epoch| is the epoch number.\n |timestamp| is the checkpoint timestamp.\n |cp| receives the unsigned checkpoint proposal.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_create_proposal(
        server: *mut nwep_anchor_server,
        log: *mut nwep_merkle_log,
        epoch: u64,
        timestamp: nwep_tstamp,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_anchor_server_sign_proposal` signs a checkpoint proposal.\n\n |cp| is the checkpoint to sign (modified in place with signature).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_anchor_server_sign_proposal(
        server: *mut nwep_anchor_server,
        cp: *mut nwep_checkpoint,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_get_peer_role` gets the peer's announced server role.\n\n Returns the role enum, or NWEP_ROLE_REGULAR if not specified."]
    pub fn nwep_conn_get_peer_role(conn: *const nwep_conn) -> nwep_server_role;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_conn_set_required_role` sets the required role for the connection.\n\n Call before connecting. The connection will fail if the server\n doesn't have the required role.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_conn_set_required_role(
        conn: *mut nwep_conn,
        role: nwep_server_role,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity_cache {
    _unused: [u8; 0],
}
#[doc = " @struct\n\n :type:`nwep_cached_identity` represents a cached verified identity."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_cached_identity {
    pub nodeid: nwep_nodeid,
    pub pubkey: [u8; 32usize],
    pub log_index: u64,
    pub verified_at: nwep_tstamp,
    pub expires_at: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_cached_identity"][::std::mem::size_of::<nwep_cached_identity>() - 88usize];
    ["Alignment of nwep_cached_identity"][::std::mem::align_of::<nwep_cached_identity>() - 8usize];
    ["Offset of field: nwep_cached_identity::nodeid"]
        [::std::mem::offset_of!(nwep_cached_identity, nodeid) - 0usize];
    ["Offset of field: nwep_cached_identity::pubkey"]
        [::std::mem::offset_of!(nwep_cached_identity, pubkey) - 32usize];
    ["Offset of field: nwep_cached_identity::log_index"]
        [::std::mem::offset_of!(nwep_cached_identity, log_index) - 64usize];
    ["Offset of field: nwep_cached_identity::verified_at"]
        [::std::mem::offset_of!(nwep_cached_identity, verified_at) - 72usize];
    ["Offset of field: nwep_cached_identity::expires_at"]
        [::std::mem::offset_of!(nwep_cached_identity, expires_at) - 80usize];
};
#[doc = " @struct\n\n :type:`nwep_identity_cache_settings` configures cache behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_identity_cache_settings {
    #[doc = " :member:`capacity` is the maximum number of entries.\n Default: NWEP_CACHE_DEFAULT_CAPACITY (10000)"]
    pub capacity: usize,
    #[doc = " :member:`ttl_ns` is the TTL in nanoseconds.\n Default: NWEP_CACHE_DEFAULT_TTL_NS (1 hour)"]
    pub ttl_ns: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_identity_cache_settings"]
        [::std::mem::size_of::<nwep_identity_cache_settings>() - 16usize];
    ["Alignment of nwep_identity_cache_settings"]
        [::std::mem::align_of::<nwep_identity_cache_settings>() - 8usize];
    ["Offset of field: nwep_identity_cache_settings::capacity"]
        [::std::mem::offset_of!(nwep_identity_cache_settings, capacity) - 0usize];
    ["Offset of field: nwep_identity_cache_settings::ttl_ns"]
        [::std::mem::offset_of!(nwep_identity_cache_settings, ttl_ns) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_settings_default` initializes settings to defaults."]
    pub fn nwep_identity_cache_settings_default(settings: *mut nwep_identity_cache_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_new` creates a new identity cache.\n\n |settings| configures cache behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_new(
        pcache: *mut *mut nwep_identity_cache,
        settings: *const nwep_identity_cache_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_free` frees an identity cache."]
    pub fn nwep_identity_cache_free(cache: *mut nwep_identity_cache);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_lookup` looks up an identity by NodeID.\n\n |now| is the current timestamp for TTL checking.\n |identity| receives the cached identity if found and not expired.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found or expired."]
    pub fn nwep_identity_cache_lookup(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        now: nwep_tstamp,
        identity: *mut nwep_cached_identity,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_store` stores a verified identity.\n\n |now| is the current timestamp for setting verified_at and expires_at.\n |nodeid| is the NodeID to cache.\n |pubkey| is the verified public key.\n |log_index| is the log index where the identity was verified.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_store(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        pubkey: *const u8,
        log_index: u64,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_invalidate` invalidates an entry by NodeID.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_identity_cache_invalidate(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_clear` clears all entries from the cache."]
    pub fn nwep_identity_cache_clear(cache: *mut nwep_identity_cache);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_size` returns the number of entries in the cache."]
    pub fn nwep_identity_cache_size(cache: *const nwep_identity_cache) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_capacity` returns the cache capacity."]
    pub fn nwep_identity_cache_capacity(cache: *const nwep_identity_cache) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_on_rotation` handles key rotation notification.\n\n Invalidates the cached identity for |nodeid| since the key has changed.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_on_rotation(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
        new_pubkey: *const u8,
        new_log_index: u64,
        now: nwep_tstamp,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_on_revocation` handles key revocation notification.\n\n Invalidates the cached identity for |nodeid| since the key has been revoked.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_identity_cache_on_revocation(
        cache: *mut nwep_identity_cache,
        nodeid: *const nwep_nodeid,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_pool {
    _unused: [u8; 0],
}
#[doc = " :enum:`NWEP_POOL_ROUND_ROBIN` selects servers in round-robin order."]
pub const nwep_pool_strategy_NWEP_POOL_ROUND_ROBIN: nwep_pool_strategy = 0;
#[doc = " :enum:`NWEP_POOL_RANDOM` selects servers randomly."]
pub const nwep_pool_strategy_NWEP_POOL_RANDOM: nwep_pool_strategy = 1;
#[doc = " @enum\n\n :type:`nwep_pool_strategy` defines the load balancing strategy."]
pub type nwep_pool_strategy = ::std::os::raw::c_uint;
#[doc = " :enum:`NWEP_SERVER_HEALTHY` means the server is responding normally."]
pub const nwep_server_health_NWEP_SERVER_HEALTHY: nwep_server_health = 0;
#[doc = " :enum:`NWEP_SERVER_UNHEALTHY` means the server has failed health checks."]
pub const nwep_server_health_NWEP_SERVER_UNHEALTHY: nwep_server_health = 1;
#[doc = " @enum\n\n :type:`nwep_server_health` indicates server health status."]
pub type nwep_server_health = ::std::os::raw::c_uint;
#[doc = " @struct\n\n :type:`nwep_pool_server` represents a server in the pool."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_pool_server {
    pub url: [::std::os::raw::c_char; 256usize],
    pub health: nwep_server_health,
    pub consecutive_failures: ::std::os::raw::c_int,
    pub last_success: nwep_tstamp,
    pub last_failure: nwep_tstamp,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_pool_server"][::std::mem::size_of::<nwep_pool_server>() - 280usize];
    ["Alignment of nwep_pool_server"][::std::mem::align_of::<nwep_pool_server>() - 8usize];
    ["Offset of field: nwep_pool_server::url"]
        [::std::mem::offset_of!(nwep_pool_server, url) - 0usize];
    ["Offset of field: nwep_pool_server::health"]
        [::std::mem::offset_of!(nwep_pool_server, health) - 256usize];
    ["Offset of field: nwep_pool_server::consecutive_failures"]
        [::std::mem::offset_of!(nwep_pool_server, consecutive_failures) - 260usize];
    ["Offset of field: nwep_pool_server::last_success"]
        [::std::mem::offset_of!(nwep_pool_server, last_success) - 264usize];
    ["Offset of field: nwep_pool_server::last_failure"]
        [::std::mem::offset_of!(nwep_pool_server, last_failure) - 272usize];
};
#[doc = " @struct\n\n :type:`nwep_log_server_pool_settings` configures pool behavior."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_log_server_pool_settings {
    #[doc = " :member:`strategy` is the load balancing strategy."]
    pub strategy: nwep_pool_strategy,
    #[doc = " :member:`max_failures` is failures before marking unhealthy.\n Default: NWEP_POOL_HEALTH_CHECK_FAILURES (3)"]
    pub max_failures: ::std::os::raw::c_int,
    #[doc = " :member:`rand` is the random callback for RANDOM strategy."]
    pub rand: nwep_rand,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_log_server_pool_settings"]
        [::std::mem::size_of::<nwep_log_server_pool_settings>() - 16usize];
    ["Alignment of nwep_log_server_pool_settings"]
        [::std::mem::align_of::<nwep_log_server_pool_settings>() - 8usize];
    ["Offset of field: nwep_log_server_pool_settings::strategy"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, strategy) - 0usize];
    ["Offset of field: nwep_log_server_pool_settings::max_failures"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, max_failures) - 4usize];
    ["Offset of field: nwep_log_server_pool_settings::rand"]
        [::std::mem::offset_of!(nwep_log_server_pool_settings, rand) - 8usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_settings_default` initializes settings to defaults."]
    pub fn nwep_log_server_pool_settings_default(settings: *mut nwep_log_server_pool_settings);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_new` creates a new log server pool.\n\n |settings| configures pool behavior (NULL for defaults).\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_new(
        ppool: *mut *mut nwep_log_server_pool,
        settings: *const nwep_log_server_pool_settings,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_free` frees a log server pool."]
    pub fn nwep_log_server_pool_free(pool: *mut nwep_log_server_pool);
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_add` adds a server to the pool.\n\n |url| is the server URL (e.g., \"web://...\").\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_add(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_remove` removes a server from the pool.\n\n Returns 0 on success, NWEP_ERR_TRUST_ENTRY_NOT_FOUND if not found."]
    pub fn nwep_log_server_pool_remove(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_select` selects a healthy server from the pool.\n\n |server| receives the selected server info.\n\n Returns 0 on success, NWEP_ERR_NETWORK_NO_SERVERS if no healthy servers."]
    pub fn nwep_log_server_pool_select(
        pool: *mut nwep_log_server_pool,
        server: *mut nwep_pool_server,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_mark_success` marks a server as successful.\n\n Resets failure count and updates last_success timestamp."]
    pub fn nwep_log_server_pool_mark_success(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
        now: nwep_tstamp,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_mark_failure` marks a server as failed.\n\n Increments failure count and may mark server unhealthy."]
    pub fn nwep_log_server_pool_mark_failure(
        pool: *mut nwep_log_server_pool,
        url: *const ::std::os::raw::c_char,
        now: nwep_tstamp,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_size` returns the number of servers in the pool."]
    pub fn nwep_log_server_pool_size(pool: *const nwep_log_server_pool) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_healthy_count` returns the number of healthy servers."]
    pub fn nwep_log_server_pool_healthy_count(pool: *const nwep_log_server_pool) -> usize;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_get` gets a server by index.\n\n Returns 0 on success, or a negative error code."]
    pub fn nwep_log_server_pool_get(
        pool: *const nwep_log_server_pool,
        index: usize,
        server: *mut nwep_pool_server,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_log_server_pool_reset_health` resets all servers to healthy."]
    pub fn nwep_log_server_pool_reset_health(pool: *mut nwep_log_server_pool);
}
#[doc = " @struct\n\n :type:`nwep_cache_stats` holds cache statistics."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nwep_cache_stats {
    pub hits: u64,
    pub misses: u64,
    pub evictions: u64,
    pub stores: u64,
    pub invalidations: u64,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
#[cfg(all(target_pointer_width = "64", not(target_os = "windows")))]
const _: () = {
    ["Size of nwep_cache_stats"][::std::mem::size_of::<nwep_cache_stats>() - 40usize];
    ["Alignment of nwep_cache_stats"][::std::mem::align_of::<nwep_cache_stats>() - 8usize];
    ["Offset of field: nwep_cache_stats::hits"]
        [::std::mem::offset_of!(nwep_cache_stats, hits) - 0usize];
    ["Offset of field: nwep_cache_stats::misses"]
        [::std::mem::offset_of!(nwep_cache_stats, misses) - 8usize];
    ["Offset of field: nwep_cache_stats::evictions"]
        [::std::mem::offset_of!(nwep_cache_stats, evictions) - 16usize];
    ["Offset of field: nwep_cache_stats::stores"]
        [::std::mem::offset_of!(nwep_cache_stats, stores) - 24usize];
    ["Offset of field: nwep_cache_stats::invalidations"]
        [::std::mem::offset_of!(nwep_cache_stats, invalidations) - 32usize];
};
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_get_stats` gets cache statistics."]
    pub fn nwep_identity_cache_get_stats(
        cache: *const nwep_identity_cache,
        stats: *mut nwep_cache_stats,
    );
}
unsafe extern "C" {
    #[doc = " @function\n\n `nwep_identity_cache_reset_stats` resets cache statistics."]
    pub fn nwep_identity_cache_reset_stats(cache: *mut nwep_identity_cache);
}