aboutsummaryrefslogtreecommitdiff
path: root/nearby/presence/np_c_ffi/include/c/np_c_ffi.h
blob: aab2a30f47c85c70c8d5f539c55a9683cf1f6009 (plain)
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
/*
 Copyright 2023 Google LLC
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/


#pragma once

/* Generated with cbindgen:0.24.5 */

/*
 WARNING: this file is autogenerated by cbindgen. Don't modify this manually.
 Additionally, you should _not_ rely upon the layouts of the generated
 structs and unions if you want your code to be forward-compatible,
 unless a given type explicitly states in its documentation that it has
 a guaranteed forward-compatible layout.
 Instead, you should use _only_ the provided exported function symbols.
*/

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

/**
 * Result type for trying to add a credential to a credential-slab.
 */
enum np_ffi_AddCredentialToSlabResult {
  /**
   * We succeeded in adding the credential to the slab.
   */
  NP_FFI_ADD_CREDENTIAL_TO_SLAB_RESULT_SUCCESS = 0,
  /**
   * The handle to the slab was actually invalid.
   */
  NP_FFI_ADD_CREDENTIAL_TO_SLAB_RESULT_INVALID_HANDLE = 1,
};
typedef uint8_t np_ffi_AddCredentialToSlabResult;

/**
 * The possible boolean action types which can be present in an Actions data element
 */
enum np_ffi_BooleanActionType {
  NP_FFI_BOOLEAN_ACTION_TYPE_ACTIVE_UNLOCK = 8,
  NP_FFI_BOOLEAN_ACTION_TYPE_NEARBY_SHARE = 9,
  NP_FFI_BOOLEAN_ACTION_TYPE_INSTANT_TETHERING = 10,
  NP_FFI_BOOLEAN_ACTION_TYPE_PHONE_HUB = 11,
  NP_FFI_BOOLEAN_ACTION_TYPE_PRESENCE_MANAGER = 12,
  NP_FFI_BOOLEAN_ACTION_TYPE_FINDER = 13,
  NP_FFI_BOOLEAN_ACTION_TYPE_FAST_PAIR_SASS = 14,
};
typedef uint8_t np_ffi_BooleanActionType;

/**
 * Discriminant for `CreateCredentialBookResult`
 */
enum np_ffi_CreateCredentialBookResultKind {
  /**
   * We created a new credential book behind the given handle.
   * The associated payload may be obtained via
   * `CreateCredentialBookResult#into_success()`.
   */
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_KIND_SUCCESS = 0,
  /**
   * There was no space left to create a new credential book
   */
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_KIND_NO_SPACE_LEFT = 1,
  /**
   * The slab that we tried to create a credential-book from
   * actually was an invalid handle.
   */
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_KIND_INVALID_SLAB_HANDLE = 2,
};
typedef uint8_t np_ffi_CreateCredentialBookResultKind;

/**
 * Discriminant for `CreateCredentialSlabResult`
 */
enum np_ffi_CreateCredentialSlabResultKind {
  /**
   * There was no space left to create a new credential slab
   */
  NP_FFI_CREATE_CREDENTIAL_SLAB_RESULT_KIND_NO_SPACE_LEFT = 0,
  /**
   * We created a new credential slab behind the given handle.
   * The associated payload may be obtained via
   * `CreateCredentialSlabResult#into_success()`.
   */
  NP_FFI_CREATE_CREDENTIAL_SLAB_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_CreateCredentialSlabResultKind;

/**
 * A result-type enum which tells the caller whether/not a deallocation
 * succeeded or failed due to the requested handle not being present.
 */
typedef enum {
  /**
   * The requested handle to deallocate was not present in the map
   */
  NP_FFI_DEALLOCATE_RESULT_NOT_PRESENT = 0,
  /**
   * The object behind the handle was successfully deallocated
   */
  NP_FFI_DEALLOCATE_RESULT_SUCCESS = 1,
} np_ffi_DeallocateResult;

/**
 * Discriminant for `DecryptMetadataResult`.
 */
enum np_ffi_DecryptMetadataResultKind {
  /**
   * The attempt to decrypt the metadata of the associated credential succeeded
   * The associated payload may be obtained via
   * `DecryptMetadataResult#into_success`.
   */
  NP_FFI_DECRYPT_METADATA_RESULT_KIND_SUCCESS,
  /**
   * The attempt to decrypt the metadata failed, either the payload had no matching identity
   * ie it was a public advertisement OR the decrypt attempt itself was unsuccessful
   */
  NP_FFI_DECRYPT_METADATA_RESULT_KIND_ERROR,
};
typedef uint8_t np_ffi_DecryptMetadataResultKind;

/**
 * Discriminant for `DeserializeAdvertisementResult`.
 */
enum np_ffi_DeserializeAdvertisementResultKind {
  /**
   * Deserializing the advertisement failed, for some reason or another.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_KIND_ERROR = 0,
  /**
   * The advertisement was correctly deserialized, and it's a V0 advertisement.
   * `DeserializeAdvertisementResult#into_v0()` is the corresponding cast
   * to the associated enum variant.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_KIND_V0 = 1,
  /**
   * The advertisement was correctly deserialized, and it's a V1 advertisement.
   * `DeserializeAdvertisementResult#into_v1()` is the corresponding cast
   * to the associated enum variant.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_KIND_V1 = 2,
};
typedef uint8_t np_ffi_DeserializeAdvertisementResultKind;

/**
 * Discriminant for possible results of V0 advertisement deserialization
 */
enum np_ffi_DeserializedV0AdvertisementKind {
  /**
   * The deserialized V0 advertisement was legible.
   * The associated payload may be obtained via
   * `DeserializedV0Advertisement#into_legible`.
   */
  NP_FFI_DESERIALIZED_V0_ADVERTISEMENT_KIND_LEGIBLE = 0,
  /**
   * The deserialized V0 advertisement is illegible,
   * likely meaning that the receiver does not hold
   * the proper credentials to be able to read
   * the received advertisement.
   */
  NP_FFI_DESERIALIZED_V0_ADVERTISEMENT_KIND_NO_MATCHING_CREDENTIALS = 1,
};
typedef uint8_t np_ffi_DeserializedV0AdvertisementKind;

/**
 * Discriminant for deserialized information about the V0
 * identity utilized by a deserialized V0 advertisement.
 */
enum np_ffi_DeserializedV0IdentityKind {
  /**
   * The deserialized identity was a plaintext identity.
   */
  NP_FFI_DESERIALIZED_V0_IDENTITY_KIND_PLAINTEXT = 0,
  /**
   * The deserialized identity was some decrypted identity.
   */
  NP_FFI_DESERIALIZED_V0_IDENTITY_KIND_DECRYPTED = 1,
};
typedef uint8_t np_ffi_DeserializedV0IdentityKind;

/**
 * Discriminant for `DeserializedV1Identity`.
 */
enum np_ffi_DeserializedV1IdentityKind {
  /**
   * The deserialized v1 identity was plaintext
   */
  NP_FFI_DESERIALIZED_V1_IDENTITY_KIND_PLAINTEXT = 0,
  /**
   * The deserialized v1 identity corresponded
   * to some kind of decrypted identity.
   */
  NP_FFI_DESERIALIZED_V1_IDENTITY_KIND_DECRYPTED = 1,
};
typedef uint8_t np_ffi_DeserializedV1IdentityKind;

/**
 * The DE type for an encrypted identity
 */
enum np_ffi_EncryptedIdentityType {
  /**
   * Identity for broadcasts to nearby devices with the same
   * logged-in-account (for some account).
   */
  NP_FFI_ENCRYPTED_IDENTITY_TYPE_PRIVATE = 1,
  /**
   * Identity for broadcasts to nearby devices which this
   * device has declared to trust.
   */
  NP_FFI_ENCRYPTED_IDENTITY_TYPE_TRUSTED = 2,
  /**
   * Identity for broadcasts to devices which have been provisioned
   * offline with this device.
   */
  NP_FFI_ENCRYPTED_IDENTITY_TYPE_PROVISIONED = 4,
};
typedef uint8_t np_ffi_EncryptedIdentityType;

enum np_ffi_GetMetadataBufferPartsResultKind {
  NP_FFI_GET_METADATA_BUFFER_PARTS_RESULT_KIND_SUCCESS = 0,
  NP_FFI_GET_METADATA_BUFFER_PARTS_RESULT_KIND_ERROR = 1,
};
typedef uint8_t np_ffi_GetMetadataBufferPartsResultKind;

/**
 * Discriminant of `GetV0DEResult`.
 */
enum np_ffi_GetV0DEResultKind {
  /**
   * The attempt to get the DE succeeded.
   * The associated payload may be obtained via
   * `GetV0DEResult#into_success`.
   */
  NP_FFI_GET_V0DE_RESULT_KIND_SUCCESS = 0,
  /**
   * The attempt to get the DE failed,
   * possibly due to the requested index being
   * out-of-bounds or due to the advertisement
   * having been previously deallocated.
   */
  NP_FFI_GET_V0DE_RESULT_KIND_ERROR = 1,
};
typedef uint8_t np_ffi_GetV0DEResultKind;

/**
 * Discriminant for `GetV0IdentityDetailsResult`
 */
enum np_ffi_GetV0IdentityDetailsResultKind {
  /**
   * The attempt to get the identity details
   * for the advertisement failed, possibly
   * due to the advertisement being a public
   * advertisement, or the underlying
   * advertisement has already been deallocated.
   */
  NP_FFI_GET_V0_IDENTITY_DETAILS_RESULT_KIND_ERROR = 0,
  /**
   * The attempt to get the identity details succeeded.
   * The wrapped identity details may be obtained via
   * `GetV0IdentityDetailsResult#into_success`.
   */
  NP_FFI_GET_V0_IDENTITY_DETAILS_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_GetV0IdentityDetailsResultKind;

/**
 * Discriminant for `GetV1DE16ByteSaltResult`.
 */
enum np_ffi_GetV1DE16ByteSaltResultKind {
  /**
   * The attempt to get the derived salt failed, possibly
   * because the passed DE offset was invalid (==255),
   * or because there was no salt included for the
   * referenced advertisement section (i.e: it was
   * a public advertisement section, or it was deallocated.)
   */
  NP_FFI_GET_V1DE16_BYTE_SALT_RESULT_KIND_ERROR = 0,
  /**
   * A 16-byte salt for the given DE offset was successfully
   * derived.
   */
  NP_FFI_GET_V1DE16_BYTE_SALT_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_GetV1DE16ByteSaltResultKind;

/**
 * Discriminant for the `GetV1DEResult` enum.
 */
enum np_ffi_GetV1DEResultKind {
  /**
   * Attempting to get the DE at the given position failed,
   * possibly due to the index being out-of-bounds or due
   * to the whole advertisement having been previously deallocated.
   */
  NP_FFI_GET_V1DE_RESULT_KIND_ERROR = 0,
  /**
   * Attempting to get the DE at the given position succeeded.
   * The underlying DE may be extracted with `GetV1DEResult#into_success`.
   */
  NP_FFI_GET_V1DE_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_GetV1DEResultKind;

/**
 * Discriminant for `GetV1IdentityDetailsResult`
 */
enum np_ffi_GetV1IdentityDetailsResultKind {
  /**
   * The attempt to get the identity details
   * for the section failed, possibly
   * due to the section being a public
   * section, or the underlying
   * advertisement has already been deallocated.
   */
  NP_FFI_GET_V1_IDENTITY_DETAILS_RESULT_KIND_ERROR = 0,
  /**
   * The attempt to get the identity details succeeded.
   * The wrapped identity details may be obtained via
   * `GetV1IdentityDetailsResult#into_success`.
   */
  NP_FFI_GET_V1_IDENTITY_DETAILS_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_GetV1IdentityDetailsResultKind;

/**
 * Discriminant for `GetV1SectionResult`
 */
enum np_ffi_GetV1SectionResultKind {
  /**
   * The attempt to get the section failed,
   * possibly due to the section index being
   * out-of-bounds or due to the underlying
   * advertisement having already been deallocated.
   */
  NP_FFI_GET_V1_SECTION_RESULT_KIND_ERROR = 0,
  /**
   * The attempt to get the section succeeded.
   * The wrapped section may be obtained via
   * `GetV1SectionResult#into_success`.
   */
  NP_FFI_GET_V1_SECTION_RESULT_KIND_SUCCESS = 1,
};
typedef uint8_t np_ffi_GetV1SectionResultKind;

/**
 * Structure for categorized reasons for why a NP C FFI call may
 * be panicking.
 */
enum np_ffi_PanicReason {
  /**
   * Some enum cast to a variant failed. Utilized
   * for failed enum casts of all enums.
   *
   * (That is, this is the catch-all panic reason for enum
   * casts where there is not a more specific reason
   * in some other variant of this enum.)
   */
  NP_FFI_PANIC_REASON_ENUM_CAST_FAILED = 0,
  /**
   * The panic handler is used to assert conditions are true to avoid programmer errors.
   * If a failed assert condition is hit, this panic handler is invoked with this reason.
   */
  NP_FFI_PANIC_REASON_ASSERT_FAILED = 1,
  /**
   * Error returned if action bits inside of a V0Actions struct are invalid. If the struct was
   * created by this deserializer, the bits will always be valid, they are only invalid if
   * a user reaches in and changes them to something invalid.
   */
  NP_FFI_PANIC_REASON_INVALID_ACTION_BITS = 2,
};
typedef uint8_t np_ffi_PanicReason;

/**
 * Discriminant for `V0DataElement`.
 */
enum np_ffi_V0DataElementKind {
  /**
   * A transmission Power (Tx Power) data-element.
   * The associated payload may be obtained via
   * `V0DataElement#into_tx_power`.
   */
  NP_FFI_V0_DATA_ELEMENT_KIND_TX_POWER = 0,
  /**
   * The Actions data-element.
   * The associated payload may be obtained via
   * `V0DataElement#into_actions`.
   */
  NP_FFI_V0_DATA_ELEMENT_KIND_ACTIONS = 1,
};
typedef uint8_t np_ffi_V0DataElementKind;

/**
 * Information about the verification scheme used
 * for verifying the integrity of the contents
 * of a decrypted section.
 */
enum np_ffi_V1VerificationMode {
  /**
   * Message integrity code verification.
   */
  NP_FFI_V1_VERIFICATION_MODE_MIC = 0,
  /**
   * Signature verification.
   */
  NP_FFI_V1_VERIFICATION_MODE_SIGNATURE = 1,
};
typedef uint8_t np_ffi_V1VerificationMode;

/**
 *A `#[repr(C)]` handle to a value of type `super::CredentialBookInternals`.
 */
typedef struct {
  uint64_t handle_id;
} np_ffi_CredentialBook;

/**
 * Result type for `create_credential_book`
 */
enum np_ffi_CreateCredentialBookResult_Tag {
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_SUCCESS = 0,
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_NO_SPACE_LEFT = 1,
  NP_FFI_CREATE_CREDENTIAL_BOOK_RESULT_INVALID_SLAB_HANDLE = 2,
};
typedef uint8_t np_ffi_CreateCredentialBookResult_Tag;

typedef union {
  np_ffi_CreateCredentialBookResult_Tag tag;
  struct {
    np_ffi_CreateCredentialBookResult_Tag success_tag;
    np_ffi_CredentialBook success;
  };
} np_ffi_CreateCredentialBookResult;

/**
 *A `#[repr(C)]` handle to a value of type `super::CredentialSlabInternals`.
 */
typedef struct {
  uint64_t handle_id;
} np_ffi_CredentialSlab;

/**
 * Result type for `create_credential_slab`
 */
typedef enum {
  NP_FFI_CREATE_CREDENTIAL_SLAB_RESULT_NO_SPACE_LEFT,
  NP_FFI_CREATE_CREDENTIAL_SLAB_RESULT_SUCCESS,
} np_ffi_CreateCredentialSlabResult_Tag;

typedef struct {
  np_ffi_CreateCredentialSlabResult_Tag tag;
  union {
    struct {
      np_ffi_CredentialSlab success;
    };
  };
} np_ffi_CreateCredentialSlabResult;

/**
 * Cryptographic information about a particular V0 discovery credential
 * necessary to match and decrypt encrypted V0 advertisements.
 */
typedef struct {
  uint8_t key_seed[32];
  uint8_t legacy_metadata_key_hmac[32];
} np_ffi_V0DiscoveryCredential;

/**
 * A representation of a MatchedCredential which is passable across the FFI boundary
 */
typedef struct {
  uint32_t cred_id;
  const uint8_t *encrypted_metadata_bytes_buffer;
  uintptr_t encrypted_metadata_bytes_len;
} np_ffi_FfiMatchedCredential;

/**
 * Representation of a V0 credential that contains additional data to provide back to caller once it
 * is matched. The credential_id can be used by the caller to correlate it back to the full
 * credentials details.
 */
typedef struct {
  np_ffi_V0DiscoveryCredential discovery_cred;
  np_ffi_FfiMatchedCredential matched_cred;
} np_ffi_V0MatchableCredential;

/**
 * Cryptographic information about a particular V1 discovery credential
 * necessary to match and decrypt encrypted V1 advertisement sections.
 */
typedef struct {
  uint8_t key_seed[32];
  uint8_t expected_unsigned_metadata_key_hmac[32];
  uint8_t expected_signed_metadata_key_hmac[32];
  uint8_t pub_key[32];
} np_ffi_V1DiscoveryCredential;

/**
 * Representation of a V1 credential that contains additional data to provide back to caller once it
 * is matched. The credential_id can be used by the caller to correlate it back to the full
 * credentials details.
 */
typedef struct {
  np_ffi_V1DiscoveryCredential discovery_cred;
  np_ffi_FfiMatchedCredential matched_cred;
} np_ffi_V1MatchableCredential;

/**
 *A `#[repr(C)]` handle to a value of type `super::DecryptedMetadataInternals`.
 */
typedef struct {
  uint64_t handle_id;
} np_ffi_DecryptedMetadata;

/**
 * The result of decrypting metadata from either a V0Payload or DeserializedV1Section
 */
typedef enum {
  NP_FFI_DECRYPT_METADATA_RESULT_SUCCESS,
  NP_FFI_DECRYPT_METADATA_RESULT_ERROR,
} np_ffi_DecryptMetadataResult_Tag;

typedef struct {
  np_ffi_DecryptMetadataResult_Tag tag;
  union {
    struct {
      np_ffi_DecryptedMetadata success;
    };
  };
} np_ffi_DecryptMetadataResult;

/**
 * The pointer and length of the decrypted metadata byte buffer
 */
typedef struct {
  const uint8_t *ptr;
  uintptr_t len;
} np_ffi_MetadataBufferParts;

typedef enum {
  NP_FFI_GET_METADATA_BUFFER_PARTS_RESULT_SUCCESS,
  NP_FFI_GET_METADATA_BUFFER_PARTS_RESULT_ERROR,
} np_ffi_GetMetadataBufferPartsResult_Tag;

typedef struct {
  np_ffi_GetMetadataBufferPartsResult_Tag tag;
  union {
    struct {
      np_ffi_MetadataBufferParts success;
    };
  };
} np_ffi_GetMetadataBufferPartsResult;

/**
 *A `#[repr(C)]` handle to a value of type `super::V0PayloadInternals`.
 */
typedef struct {
  uint64_t handle_id;
} np_ffi_V0Payload;

/**
 * Represents a deserialized V0 advertisement whose DE contents may be read
 */
typedef struct {
  uint8_t num_des;
  np_ffi_V0Payload payload;
  np_ffi_DeserializedV0IdentityKind identity_kind;
} np_ffi_LegibleDeserializedV0Advertisement;

/**
 * Represents a deserialized V0 advertisement
 */
typedef enum {
  NP_FFI_DESERIALIZED_V0_ADVERTISEMENT_LEGIBLE,
  NP_FFI_DESERIALIZED_V0_ADVERTISEMENT_NO_MATCHING_CREDENTIALS,
} np_ffi_DeserializedV0Advertisement_Tag;

typedef struct {
  np_ffi_DeserializedV0Advertisement_Tag tag;
  union {
    struct {
      np_ffi_LegibleDeserializedV0Advertisement legible;
    };
  };
} np_ffi_DeserializedV0Advertisement;

/**
 *A `#[repr(C)]` handle to a value of type `super::LegibleV1SectionsInternals`.
 */
typedef struct {
  uint64_t handle_id;
} np_ffi_LegibleV1Sections;

/**
 * Representation of a deserialized V1 advertisement
 */
typedef struct {
  uint8_t num_legible_sections;
  uint8_t num_undecryptable_sections;
  np_ffi_LegibleV1Sections legible_sections;
} np_ffi_DeserializedV1Advertisement;

/**
 * The result of calling `np_ffi_deserialize_advertisement`.
 * Must be explicitly deallocated after use with
 * a corresponding `np_ffi_deallocate_deserialize_advertisement_result`
 */
enum np_ffi_DeserializeAdvertisementResult_Tag {
  /**
   * Deserializing the advertisement failed, for some reason or another.
   * `DeserializeAdvertisementResultKind::Error` is the associated enum tag.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_ERROR,
  /**
   * The advertisement was correctly deserialized, and it's a V0 advertisement.
   * `DeserializeAdvertisementResultKind::V0` is the associated enum tag.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_V0,
  /**
   * The advertisement was correctly deserialized, and it's a V1 advertisement.
   * `DeserializeAdvertisementResultKind::V1` is the associated enum tag.
   */
  NP_FFI_DESERIALIZE_ADVERTISEMENT_RESULT_V1,
};
typedef uint8_t np_ffi_DeserializeAdvertisementResult_Tag;

typedef union {
  np_ffi_DeserializeAdvertisementResult_Tag tag;
  struct {
    np_ffi_DeserializeAdvertisementResult_Tag v0_tag;
    np_ffi_DeserializedV0Advertisement v0;
  };
  struct {
    np_ffi_DeserializeAdvertisementResult_Tag v1_tag;
    np_ffi_DeserializedV1Advertisement v1;
  };
} np_ffi_DeserializeAdvertisementResult;

/**
 * A byte-string with a maximum size of N,
 * where only the first `len` bytes are considered
 * to contain the actual payload. N is only
 * permitted to be between 0 and 255.
 */
typedef struct {
  uint8_t len;
  uint8_t bytes[255];
} np_ffi_ByteBuffer_255;

/**
 * Represents the raw contents of the service payload data
 * under the Nearby Presence service UUID
 */
typedef struct {
  np_ffi_ByteBuffer_255 bytes;
} np_ffi_RawAdvertisementPayload;

/**
 * Representation of a transmission power,
 * as used for the Tx Power DE in V0 and V1.
 */
typedef struct {
  int8_t tx_power;
} np_ffi_TxPower;

/**
 * The bitfield data of a VOActions data element
 */
typedef struct {
  uint32_t bitfield;
} np_ffi_V0ActionBits;

/**
 * Representation of the Actions DE in V0.
 */
typedef enum {
  /**
   * A set of action bits which were present in a plaintext identity advertisement
   */
  NP_FFI_V0_ACTIONS_PLAINTEXT,
  /**
   * A set of action bits which were present in a encrypted identity advertisement
   */
  NP_FFI_V0_ACTIONS_ENCRYPTED,
} np_ffi_V0Actions_Tag;

typedef struct {
  np_ffi_V0Actions_Tag tag;
  union {
    struct {
      np_ffi_V0ActionBits plaintext;
    };
    struct {
      np_ffi_V0ActionBits encrypted;
    };
  };
} np_ffi_V0Actions;

/**
 * Representation of a V0 data element.
 */
typedef enum {
  NP_FFI_V0_DATA_ELEMENT_TX_POWER,
  NP_FFI_V0_DATA_ELEMENT_ACTIONS,
} np_ffi_V0DataElement_Tag;

typedef struct {
  np_ffi_V0DataElement_Tag tag;
  union {
    struct {
      np_ffi_TxPower tx_power;
    };
    struct {
      np_ffi_V0Actions actions;
    };
  };
} np_ffi_V0DataElement;

/**
 * The result of `V0Payload#get_de`.
 */
typedef enum {
  NP_FFI_GET_V0DE_RESULT_SUCCESS,
  NP_FFI_GET_V0DE_RESULT_ERROR,
} np_ffi_GetV0DEResult_Tag;

typedef struct {
  np_ffi_GetV0DEResult_Tag tag;
  union {
    struct {
      np_ffi_V0DataElement success;
    };
  };
} np_ffi_GetV0DEResult;

/**
 * Information about the identity which matched a
 * decrypted V0 advertisement.
 */
typedef struct {
  /**
   * The identity type (private/provisioned/trusted)
   */
  np_ffi_EncryptedIdentityType identity_type;
  /**
   * The ID of the credential which
   * matched the deserialized adv
   */
  uint32_t cred_id;
  /**
   * The 14-byte legacy metadata key
   */
  uint8_t metadata_key[14];
  /**
   * The 2-byte advertisement salt
   */
  uint8_t salt[2];
} np_ffi_DeserializedV0IdentityDetails;

/**
 * The result of attempting to get the identity details
 * for a V0 advertisement via
 * `DeserializedV0Advertisement#get_identity_details`.
 */
typedef enum {
  NP_FFI_GET_V0_IDENTITY_DETAILS_RESULT_ERROR,
  NP_FFI_GET_V0_IDENTITY_DETAILS_RESULT_SUCCESS,
} np_ffi_GetV0IdentityDetailsResult_Tag;

typedef struct {
  np_ffi_GetV0IdentityDetailsResult_Tag tag;
  union {
    struct {
      np_ffi_DeserializedV0IdentityDetails success;
    };
  };
} np_ffi_GetV0IdentityDetailsResult;

/**
 * Handle to a deserialized V1 section
 */
typedef struct {
  np_ffi_LegibleV1Sections legible_sections_handle;
  uint8_t legible_section_index;
  uint8_t num_des;
  np_ffi_DeserializedV1IdentityKind identity_tag;
} np_ffi_DeserializedV1Section;

/**
 * The result of attempting to get a particular V1 section
 * from its' index within the list of legible sections
 * via `DeserializedV1Advertisement::get_section`.
 */
typedef enum {
  NP_FFI_GET_V1_SECTION_RESULT_ERROR,
  NP_FFI_GET_V1_SECTION_RESULT_SUCCESS,
} np_ffi_GetV1SectionResult_Tag;

typedef struct {
  np_ffi_GetV1SectionResult_Tag tag;
  union {
    struct {
      np_ffi_DeserializedV1Section success;
    };
  };
} np_ffi_GetV1SectionResult;

/**
 * Representation of the data-element type tag
 * of a V1 data element.
 */
typedef struct {
  uint32_t code;
} np_ffi_V1DEType;

/**
 * A byte-string with a maximum size of N,
 * where only the first `len` bytes are considered
 * to contain the actual payload. N is only
 * permitted to be between 0 and 255.
 */
typedef struct {
  uint8_t len;
  uint8_t bytes[127];
} np_ffi_ByteBuffer_127;

/**
 * FFI-transmissible representation of a generic V1 data-element.
 * This representation is stable, and so you may directly
 * reference this struct's fields if you wish.
 */
typedef struct {
  /**
   * The offset of this generic data-element.
   */
  uint8_t offset;
  /**
   * The DE type code of this generic data-element.
   */
  np_ffi_V1DEType de_type;
  /**
   * The raw data-element byte payload, up to
   * 127 bytes in length.
   */
  np_ffi_ByteBuffer_127 payload;
} np_ffi_GenericV1DataElement;

/**
 * FFI-transmissible representation of a V1 data-element
 */
typedef enum {
  /**
   * A "generic" V1 data-element, for which we have no
   * particular information about its schema (just
   * a DE type code and a byte payload.)
   */
  NP_FFI_V1_DATA_ELEMENT_GENERIC,
} np_ffi_V1DataElement_Tag;

typedef struct {
  np_ffi_V1DataElement_Tag tag;
  union {
    struct {
      np_ffi_GenericV1DataElement generic;
    };
  };
} np_ffi_V1DataElement;

/**
 * Represents the result of the `DeserializedV1Section#get_de` operation.
 */
typedef enum {
  NP_FFI_GET_V1DE_RESULT_ERROR,
  NP_FFI_GET_V1DE_RESULT_SUCCESS,
} np_ffi_GetV1DEResult_Tag;

typedef struct {
  np_ffi_GetV1DEResult_Tag tag;
  union {
    struct {
      np_ffi_V1DataElement success;
    };
  };
} np_ffi_GetV1DEResult;

/**
 * Information about the identity which matched
 * a decrypted V1 section.
 */
typedef struct {
  /**
   * The identity type (private/provisioned/trusted)
   */
  np_ffi_EncryptedIdentityType identity_type;
  /**
   * The verification mode (MIC/Signature) which
   * was used to verify the decrypted adv contents.
   */
  np_ffi_V1VerificationMode verification_mode;
  /**
   * The ID of the credential which
   * matched the deserialized section.
   */
  uint32_t cred_id;
  /**
   * The 16-byte metadata key.
   */
  uint8_t metadata_key[16];
} np_ffi_DeserializedV1IdentityDetails;

/**
 * The result of attempting to get the identity details
 * for a V1 advertisement section via
 * `DeserializedV1Advertisement#get_identity_details`.
 */
typedef enum {
  NP_FFI_GET_V1_IDENTITY_DETAILS_RESULT_ERROR,
  NP_FFI_GET_V1_IDENTITY_DETAILS_RESULT_SUCCESS,
} np_ffi_GetV1IdentityDetailsResult_Tag;

typedef struct {
  np_ffi_GetV1IdentityDetailsResult_Tag tag;
  union {
    struct {
      np_ffi_DeserializedV1IdentityDetails success;
    };
  };
} np_ffi_GetV1IdentityDetailsResult;

/**
 * A FFI safe wrapper of a fixed size array
 */
typedef struct {
  uint8_t _0[16];
} np_ffi_FixedSizeArray_16;

/**
 * The result of attempting to get a derived 16-byte salt
 * for a given DE within a section.
 */
typedef enum {
  NP_FFI_GET_V1DE16_BYTE_SALT_RESULT_ERROR,
  NP_FFI_GET_V1DE16_BYTE_SALT_RESULT_SUCCESS,
} np_ffi_GetV1DE16ByteSaltResult_Tag;

typedef struct {
  np_ffi_GetV1DE16ByteSaltResult_Tag tag;
  union {
    struct {
      np_ffi_FixedSizeArray_16 success;
    };
  };
} np_ffi_GetV1DE16ByteSaltResult;

/**
 * Overrides the global panic handler to be used when NP C FFI calls panic.
 * This method will only have an effect on the global panic-handler
 * the first time it's called, and this method will return `true`
 * to indicate that the panic handler was successfully set.
 * All subsequent calls to this method
 * will simply ignore the argument and return `false`.
 *
 * If the passed function pointer is non-null,
 * then we will call it upon every panic,
 * followed by the default panicking behavior for
 * the platform (in the case where the user-specified
 * function does not terminate or hang the running process.)
 *
 * Otherwise, we will resort to the
 * default panicking behavior for the system, which
 * is a printed stack trace followed by an abort
 * when this crate is compiled with `std`,
 * but a bare `loop { }` when this crate is compiled without.
 */
bool np_ffi_global_config_panic_handler(void (*handler)(np_ffi_PanicReason));

/**
 * Sets an override to the number of shards to employ in the NP FFI's
 * internal handle-maps, which places an upper bound on the number
 * of writing threads which may make progress at any one time
 * when concurrently accessing handles of the same type.
 *
 * By default, this value will be set to 16, or in `std` environments,
 * the minimum of 16 and the number of available hardware threads.
 * A shard value override of zero will be interpreted the same
 * as this default.
 *
 * Setting this value will have no effect if the handle-maps for the
 * API have already begun being used by the client code, and any
 * values set will take effect upon the first usage of _any_ non-`np_ffi_global_config_set`
 * API call.
 */
void np_ffi_global_config_set_num_shards(uint8_t num_shards);

/**
 * Sets the maximum number of active handles to credential slabs
 * which may be active at any one time.
 * Default value: Max value.
 * Max value: `u32::MAX - 1`.
 *
 * Useful for bounding the maximum memory used by the client application
 * on credential slabs in constrained-memory environments.
 *
 * Setting this value will have no effect if the handle-maps for the
 * API have already begun being used by the client code, and any
 * values set will take effect upon the first usage of any API
 * call utilizing credential slabs.
 */
void np_ffi_global_config_set_max_num_credential_slabs(uint32_t max_num_credential_slabs);

/**
 * Sets the maximum number of active handles to credential books
 * which may be active at any one time.
 * Default value: Max value.
 * Max value: `u32::MAX - 1`.
 *
 * Useful for bounding the maximum memory used by the client application
 * on credential books in constrained-memory environments.
 *
 * Setting this value will have no effect if the handle-maps for the
 * API have already begun being used by the client code, and any
 * values set will take effect upon the first usage of any API
 * call utilizing credential books.
 */
void np_ffi_global_config_set_max_num_credential_books(uint32_t max_num_credential_books);

/**
 * Sets the maximum number of active handles to deserialized v0
 * advertisements which may be active at any one time.
 *
 * Useful for bounding the maximum memory used by the client application
 * on v0 advertisements in constrained-memory environments.
 *
 * Default value: Max value.
 * Max value: `u32::MAX - 1`.
 *
 * Setting this value will have no effect if the handle-maps for the
 * API have already begun being used by the client code, and any
 * values set will take effect upon the first usage of any API
 * call which references or returns a deserialized V0 advertisement.
 */
void np_ffi_global_config_set_max_num_deserialized_v0_advertisements(uint32_t max_num_deserialized_v0_advertisements);

/**
 * Sets the maximum number of active handles to deserialized v1
 * advertisements which may be active at any one time.
 *
 * Useful for bounding the maximum memory used by the client application
 * on v1 advertisements in constrained-memory environments.
 *
 * Default value: Max value.
 * Max value: `u32::MAX - 1`.
 *
 * Setting this value will have no effect if the handle-maps for the
 * API have already begun being used by the client code, and any
 * values set will take effect upon the first usage of any API
 * call which references or returns a deserialized V1 advertisement.
 */
void np_ffi_global_config_set_max_num_deserialized_v1_advertisements(uint32_t max_num_deserialized_v1_advertisements);

/**
 * Allocates a new credential-book from the given slab, returning a handle
 * to the created object. The slab will be deallocated by this call.
 */
np_ffi_CreateCredentialBookResult np_ffi_create_credential_book_from_slab(np_ffi_CredentialSlab slab);

/**
 * Gets the tag of a `CreateCredentialBookResult` tagged enum.
 */
np_ffi_CreateCredentialBookResultKind np_ffi_CreateCredentialBookResult_kind(np_ffi_CreateCredentialBookResult result);

/**
 * Casts a `CreateCredentialBookResult` to the `SUCCESS` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_CredentialBook np_ffi_CreateCredentialBookResult_into_SUCCESS(np_ffi_CreateCredentialBookResult result);

/**
 * Deallocates a credential-slab by its handle.
 */
np_ffi_DeallocateResult np_ffi_deallocate_credential_slab(np_ffi_CredentialSlab credential_slab);

/**
 * Deallocates a credential-book by its handle
 */
np_ffi_DeallocateResult np_ffi_deallocate_credential_book(np_ffi_CredentialBook credential_book);

/**
 * Allocates a new credential-slab, returning a handle to the created object
 */
np_ffi_CreateCredentialSlabResult np_ffi_create_credential_slab(void);

/**
 * Gets the tag of a `CreateCredentialSlabResult` tagged enum.
 */
np_ffi_CreateCredentialSlabResultKind np_ffi_CreateCredentialSlabResult_kind(np_ffi_CreateCredentialSlabResult result);

/**
 * Casts a `CreateCredentialSlabResult` to the `SUCCESS` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_CredentialSlab np_ffi_CreateCredentialSlabResult_into_SUCCESS(np_ffi_CreateCredentialSlabResult result);

/**
 * Adds the given V0 discovery credential with some associated
 * match-data to this credential slab.
 *
 * Safety: this is safe if the provided pointer points to a valid memory address
 * which contains the correct len amount of bytes. The copy from the memory address isn't atomic,
 * so concurrent modification of the array from another thread would cause undefined behavior.
 */
np_ffi_AddCredentialToSlabResult np_ffi_CredentialSlab_add_v0_credential(np_ffi_CredentialSlab credential_slab,
                                                                         np_ffi_V0MatchableCredential v0_cred);

/**
 * Adds the given V1 discovery credential with some associated
 * match-data to this credential slab.
 *
 * Safety: this is safe if the provided pointer points to a valid memory address
 * which contains the correct len amount of bytes. The copy from the memory address isn't atomic,
 * so concurrent modification of the array from another thread would cause undefined behavior.
 */
np_ffi_AddCredentialToSlabResult np_ffi_CredentialSlab_add_v1_credential(np_ffi_CredentialSlab credential_slab,
                                                                         np_ffi_V1MatchableCredential v1_cred);

/**
 * Frees the underlying resources of the decrypted metadata buffer
 */
np_ffi_DeallocateResult np_ffi_deallocate_DecryptedMetadata(np_ffi_DecryptedMetadata metadata);

/**
 * Gets the tag of a `DecryptMetadataResult` tagged-union. On success the wrapped identity
 * details may be obtained via `DecryptMetadataResult#into_success`.
 */
np_ffi_DecryptMetadataResultKind np_ffi_DecryptMetadataResult_kind(np_ffi_DecryptMetadataResult result);

/**
 * Casts a `DecryptMetadataResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DecryptedMetadata np_ffi_DecryptMetadataResult_into_SUCCESS(np_ffi_DecryptMetadataResult result);

/**
 * Gets the pointer and length of the heap allocated byte buffer of decrypted metadata
 */
np_ffi_GetMetadataBufferPartsResult np_ffi_DecryptedMetadata_get_metadata_buffer_parts(np_ffi_DecryptedMetadata metadata);

/**
 * Gets the tag of a `GetMetadataBufferPartsResult` tagged-union. On success the wrapped identity
 * details may be obtained via `GetMetadataBufferPartsResult#into_success`.
 */
np_ffi_GetMetadataBufferPartsResultKind np_ffi_GetMetadataBufferPartsResult_kind(np_ffi_GetMetadataBufferPartsResult result);

/**
 * Casts a `GetMetadataBufferPartsResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant. This returns the pointer and length
 * of the byte buffer containing the decrypted metadata.  There can be a data-race between attempts
 * to access the contents of the buffer and attempts to free the handle from different threads.
 */
np_ffi_MetadataBufferParts np_ffi_GetMetadataBufferPartsResult_into_SUCCESS(np_ffi_GetMetadataBufferPartsResult result);

/**
 * Attempts to deserialize an advertisement with the given service-data
 * payload (presumed to be under the NP service UUID) using credentials
 * pulled from the given credential-book.
 */
np_ffi_DeserializeAdvertisementResult np_ffi_deserialize_advertisement(np_ffi_RawAdvertisementPayload adv_payload,
                                                                       np_ffi_CredentialBook credential_book);

/**
 * Gets the tag of a `DeserializeAdvertisementResult` tagged-union.
 */
np_ffi_DeserializeAdvertisementResultKind np_ffi_DeserializeAdvertisementResult_kind(np_ffi_DeserializeAdvertisementResult result);

/**
 * Casts a `DeserializeAdvertisementResult` to the `V0` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DeserializedV0Advertisement np_ffi_DeserializeAdvertisementResult_into_V0(np_ffi_DeserializeAdvertisementResult result);

/**
 * Casts a `DeserializeAdvertisementResult` to the `V1` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DeserializedV1Advertisement np_ffi_DeserializeAdvertisementResult_into_V1(np_ffi_DeserializeAdvertisementResult result);

/**
 * Deallocates any internal data referenced by a `DeserializeAdvertisementResult`. This should only
 * be used if into_V0 or into_V1, have not been called yet as it shares the same underlying
 * resource.
 */
np_ffi_DeallocateResult np_ffi_deallocate_deserialize_advertisement_result(np_ffi_DeserializeAdvertisementResult result);

/**
 * Deallocates any internal data referenced by a `DeserializedV0Advertisement`
 */
np_ffi_DeallocateResult np_ffi_deallocate_deserialized_V0_advertisement(np_ffi_DeserializedV0Advertisement adv);

/**
 * Deallocates any internal data referenced by a `DeserializedV1Advertisement`
 */
np_ffi_DeallocateResult np_ffi_deallocate_deserialized_V1_advertisement(np_ffi_DeserializedV1Advertisement adv);

/**
 * Gets the tag of a `DeserializedV0Advertisement` tagged-union.
 */
np_ffi_DeserializedV0AdvertisementKind np_ffi_DeserializedV0Advertisement_kind(np_ffi_DeserializedV0Advertisement result);

/**
 * Casts a `DeserializedV0Advertisement` to the `Legible` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_LegibleDeserializedV0Advertisement np_ffi_DeserializedV0Advertisement_into_LEGIBLE(np_ffi_DeserializedV0Advertisement adv);

/**
 * Gets the number of DEs in a legible deserialized advertisement.
 * Suitable as an iteration bound for `V0Payload#get_de`.
 */
uint8_t np_ffi_LegibleDeserializedV0Advertisement_get_num_des(np_ffi_LegibleDeserializedV0Advertisement adv);

/**
 * Gets just the data-element payload of a `LegibleDeserializedV0Advertisement`.
 */
np_ffi_V0Payload np_ffi_LegibleDeserializedV0Advertisement_into_payload(np_ffi_LegibleDeserializedV0Advertisement adv);

/**
 * Gets just the identity kind associated with a `LegibleDeserializedV0Advertisement`.
 */
np_ffi_DeserializedV0IdentityKind np_ffi_LegibleDeserializedV0Advertisement_get_identity_kind(np_ffi_LegibleDeserializedV0Advertisement adv);

/**
 * Deallocates any internal data of a `LegibleDeserializedV0Advertisement`
 */
np_ffi_DeallocateResult np_ffi_deallocate_legible_v0_advertisement(np_ffi_LegibleDeserializedV0Advertisement adv);

/**
 * Attempts to get the data-element with the given index in the passed v0 adv payload
 */
np_ffi_GetV0DEResult np_ffi_V0Payload_get_de(np_ffi_V0Payload payload, uint8_t index);

/**
 * Attempts to decrypt the metadata for the matched credential for this V0 payload (if any)
 */
np_ffi_DecryptMetadataResult np_ffi_V0Payload_decrypt_metadata(np_ffi_V0Payload payload);

/**
 * Gets the identity details for this V0 payload, or returns an error if this payload does not have
 * any associated identity (public advertisement)
 */
np_ffi_GetV0IdentityDetailsResult np_ffi_V0Payload_get_identity_details(np_ffi_V0Payload payload);

/**
 * Gets the tag of a `GetV0IdentityDetailsResult` tagged-union. On success the wrapped identity
 * details may be obtained via `GetV0IdentityDetailsResult#into_success`.
 */
np_ffi_GetV0IdentityDetailsResultKind np_ffi_GetV0IdentityDetailsResult_kind(np_ffi_GetV0IdentityDetailsResult result);

/**
 * Casts a `GetV0IdentityDetailsResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DeserializedV0IdentityDetails np_ffi_GetV0IdentityDetailsResult_into_SUCCESS(np_ffi_GetV0IdentityDetailsResult result);

/**
 * Deallocates any internal data of a `V0Payload`
 */
np_ffi_DeallocateResult np_ffi_deallocate_v0_payload(np_ffi_V0Payload payload);

/**
 * Gets the tag of a `GetV0DEResult` tagged-union.
 */
np_ffi_GetV0DEResultKind np_ffi_GetV0DEResult_kind(np_ffi_GetV0DEResult result);

/**
 * Casts a `GetV0DEResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_V0DataElement np_ffi_GetV0DEResult_into_SUCCESS(np_ffi_GetV0DEResult result);

/**
 * Gets the tag of a `V0DataElement` tagged-union.
 */
np_ffi_V0DataElementKind np_ffi_V0DataElement_kind(np_ffi_V0DataElement de);

/**
 * Casts a `V0DataElement` to the `TxPower` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_TxPower np_ffi_V0DataElement_into_TX_POWER(np_ffi_V0DataElement de);

/**
 * Casts a `V0DataElement` to the `Actions` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_V0Actions np_ffi_V0DataElement_into_ACTIONS(np_ffi_V0DataElement de);

/**
 * Return whether a boolean action type is set in this data element
 */
bool np_ffi_V0Actions_has_action(np_ffi_V0Actions actions, np_ffi_BooleanActionType action_type);

/**
 * Gets the 4 bit context sync sequence number as a u8 from this data element
 */
uint8_t np_ffi_V0Actions_get_context_sync_sequence_number(np_ffi_V0Actions actions);

/**
 * Return whether a boolean action type is set in this data element
 */
uint32_t np_ffi_V0Actions_as_u32(np_ffi_V0Actions actions);

/**
 * Gets the number of legible sections on a deserialized V1 advertisement.
 * Suitable as an index bound for the second argument of
 * `np_ffi_DeserializedV1Advertisement#get_section`.
 */
uint8_t np_ffi_DeserializedV1Advertisement_get_num_legible_sections(np_ffi_DeserializedV1Advertisement adv);

/**
 * Gets the number of sections on a deserialized V1 advertisement which
 * were unable to be decrypted with the credentials that the receiver possesses.
 */
uint8_t np_ffi_DeserializedV1Advertisement_get_num_undecryptable_sections(np_ffi_DeserializedV1Advertisement adv);

/**
 * Gets the legible section with the given index in a deserialized V1 advertisement.
 */
np_ffi_GetV1SectionResult np_ffi_DeserializedV1Advertisement_get_section(np_ffi_DeserializedV1Advertisement adv,
                                                                         uint8_t legible_section_index);

/**
 * Gets the tag of the `GetV1SectionResult` tagged-union.
 */
np_ffi_GetV1SectionResultKind np_ffi_GetV1SectionResult_kind(np_ffi_GetV1SectionResult result);

/**
 * Casts a `GetV1SectionResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DeserializedV1Section np_ffi_GetV1SectionResult_into_SUCCESS(np_ffi_GetV1SectionResult result);

/**
 * Gets the number of data elements in a deserialized v1 section.
 * Suitable as an iteration bound for the second argument of
 * `np_ffi_DeserializedV1Section_get_de`.
 */
uint8_t np_ffi_DeserializedV1Section_get_num_des(np_ffi_DeserializedV1Section section);

/**
 * Gets the tag of the identity tagged-union used for the passed section.
 */
np_ffi_DeserializedV1IdentityKind np_ffi_DeserializedV1Section_get_identity_kind(np_ffi_DeserializedV1Section section);

/**
 * Gets the data-element with the given index in the passed section.
 */
np_ffi_GetV1DEResult np_ffi_DeserializedV1Section_get_de(np_ffi_DeserializedV1Section section,
                                                         uint8_t de_index);

/**
 * Gets the identity details used to decrypt this V1 section, or returns an error if this payload
 * does not have any associated identity (public advertisement)
 */
np_ffi_GetV1IdentityDetailsResult np_ffi_DeserializedV1Section_get_identity_details(np_ffi_DeserializedV1Section section);

/**
 * Gets the tag of a `GetV1IdentityDetailsResult` tagged-union. On success the wrapped identity
 * details may be obtained via `GetV0IdentityDetailsResult#into_success`.
 */
np_ffi_GetV1IdentityDetailsResultKind np_ffi_GetV1IdentityDetailsResult_kind(np_ffi_GetV1IdentityDetailsResult result);

/**
 * Casts a `GetV1IdentityDetailsResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_DeserializedV1IdentityDetails np_ffi_GetV1IdentityDetailsResult_into_SUCCESS(np_ffi_GetV1IdentityDetailsResult result);

/**
 * Attempts to decrypt the metadata for the matched credential for this V0 payload (if any)
 */
np_ffi_DecryptMetadataResult np_ffi_DeserializedV1Section_decrypt_metadata(np_ffi_DeserializedV1Section section);

/**
 * Attempts to derive a 16-byte DE salt for a DE in this section with the given DE offset. This
 * operation may fail if the passed offset is 255 (causes overflow) or if the section
 * is leveraging a public identity, and hence, doesn't have an associated salt.
 */
np_ffi_GetV1DE16ByteSaltResult np_ffi_DeserializedV1Section_derive_16_byte_salt_for_offset(np_ffi_DeserializedV1Section section,
                                                                                           uint8_t offset);

/**
 * Gets the tag of a `GetV1DE16ByteSaltResult` tagged-union. On success the wrapped identity
 * details may be obtained via `GetV1DE16ByteSaltResult#into_success`.
 */
np_ffi_GetV1DE16ByteSaltResultKind np_ffi_GetV1DE16ByteSaltResult_kind(np_ffi_GetV1DE16ByteSaltResult result);

/**
 * Casts a `GetV1DE16ByteSaltResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_FixedSizeArray_16 np_ffi_GetV1DE16ByteSaltResult_into_SUCCESS(np_ffi_GetV1DE16ByteSaltResult result);

/**
 * Gets the tag of the `GetV1DEResult` tagged-union.
 */
np_ffi_GetV1DEResultKind np_ffi_GetV1DEResult_kind(np_ffi_GetV1DEResult result);

/**
 * Casts a `GetV1DEResult` to the `Success` variant, panicking in the
 * case where the passed value is of a different enum variant.
 */
np_ffi_V1DataElement np_ffi_GetV1DEResult_into_SUCCESS(np_ffi_GetV1DEResult result);

/**
 * Converts a `V1DataElement` to a `GenericV1DataElement` which
 * only maintains information about the DE's type-code and payload.
 */
np_ffi_GenericV1DataElement np_ffi_V1DataElement_to_generic(np_ffi_V1DataElement de);

/**
 * Extracts the numerical value of the given V1 DE type code as
 * an unsigned 32-bit integer.
 */
uint32_t np_ffi_V1DEType_to_uint32_t(np_ffi_V1DEType de_type);