1 /*
2  Copyright 2023 Google LLC
3  Licensed under the Apache License, Version 2.0 (the "License");
4  you may not use this file except in compliance with the License.
5  You may obtain a copy of the License at
6 
7       http://www.apache.org/licenses/LICENSE-2.0
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 */
15 
16 // clang-format off
17 
18 
19 #pragma once
20 
21 /* Generated with cbindgen:0.26.0 */
22 
23 /*
24  WARNING: this file is autogenerated by cbindgen. Don't modify this manually.
25  Additionally, you should _not_ rely upon the layouts of the generated
26  structs and unions if you want your code to be forward-compatible,
27  unless a given type explicitly states in its documentation that it has
28  a guaranteed forward-compatible layout.
29  Instead, you should use _only_ the provided exported function symbols.
30 */
31 
32 #include <cstdarg>
33 #include <cstdint>
34 #include <cstdlib>
35 #include <ostream>
36 #include <new>
37 #include "np_cpp_ffi_types.h"
38 
39 namespace np_ffi {
40 namespace internal {
41 
42 extern "C" {
43 
44 /// Overrides the global panic handler to be used when NP C FFI calls panic.
45 /// This method will only have an effect on the global panic-handler
46 /// the first time it's called, and this method will return `true`
47 /// to indicate that the panic handler was successfully set.
48 /// All subsequent calls to this method
49 /// will simply ignore the argument and return `false`.
50 ///
51 /// If the passed function pointer is non-null,
52 /// then we will call it upon every panic,
53 /// followed by the default panicking behavior for
54 /// the platform (in the case where the user-specified
55 /// function does not terminate or hang the running process.)
56 ///
57 /// Otherwise, we will resort to the
58 /// default panicking behavior for the system, which
59 /// is a printed stack trace followed by an abort
60 /// when this crate is compiled with `std`,
61 /// but a bare `loop { }` when this crate is compiled without.
62 bool np_ffi_global_config_panic_handler(void (*handler)(PanicReason));
63 
64 /// Checks the current count of all outstanding handle allocations, useful for debugging,
65 /// logging, and testing
66 CurrentHandleAllocations np_ffi_global_config_get_current_allocation_count();
67 
68 /// Sets an override to the number of shards to employ in the NP FFI's
69 /// internal handle-maps, which places an upper bound on the number
70 /// of writing threads which may make progress at any one time
71 /// when concurrently accessing handles of the same type.
72 ///
73 /// By default, this value will be set to 16, or in `std` environments,
74 /// the minimum of 16 and the number of available hardware threads.
75 /// A shard value override of zero will be interpreted the same
76 /// as this default.
77 ///
78 /// Setting this value will have no effect if the handle-maps for the
79 /// API have already begun being used by the client code, and any
80 /// values set will take effect upon the first usage of _any_ non-`np_ffi_global_config_set`
81 /// API call.
82 void np_ffi_global_config_set_num_shards(uint8_t num_shards);
83 
84 /// Allocates a new credential-book from the given slab, returning a handle
85 /// to the created object. The slab will be deallocated by this call.
86 CreateCredentialBookResult np_ffi_create_credential_book_from_slab(CredentialSlab slab);
87 
88 /// Gets the tag of a `CreateCredentialBookResult` tagged enum.
89 CreateCredentialBookResultKind np_ffi_CreateCredentialBookResult_kind(CreateCredentialBookResult result);
90 
91 /// Casts a `CreateCredentialBookResult` to the `SUCCESS` variant, panicking in the
92 /// case where the passed value is of a different enum variant.
93 CredentialBook np_ffi_CreateCredentialBookResult_into_SUCCESS(CreateCredentialBookResult result);
94 
95 /// Deallocates a credential-slab by its handle.
96 DeallocateResult np_ffi_deallocate_credential_slab(CredentialSlab credential_slab);
97 
98 /// Deallocates a credential-book by its handle
99 DeallocateResult np_ffi_deallocate_credential_book(CredentialBook credential_book);
100 
101 /// Allocates a new credential-slab, returning a handle to the created object
102 CredentialSlab np_ffi_create_credential_slab();
103 
104 /// Adds the given V0 discovery credential with some associated
105 /// match-data to this credential slab.
106 ///
107 /// Safety: this is safe if the provided pointer points to a valid memory address
108 /// which contains the correct len amount of bytes. The copy from the memory address isn't atomic,
109 /// so concurrent modification of the array from another thread would cause undefined behavior.
110 AddV0CredentialToSlabResult np_ffi_CredentialSlab_add_v0_credential(CredentialSlab credential_slab,
111                                                                     V0MatchableCredential v0_cred);
112 
113 /// Adds the given V1 discovery credential with some associated
114 /// match-data to this credential slab.
115 ///
116 /// Safety: this is safe if the provided pointer points to a valid memory address
117 /// which contains the correct len amount of bytes. The copy from the memory address isn't atomic,
118 /// so concurrent modification of the array from another thread would cause undefined behavior.
119 AddV1CredentialToSlabResult np_ffi_CredentialSlab_add_v1_credential(CredentialSlab credential_slab,
120                                                                     V1MatchableCredential v1_cred);
121 
122 /// Frees the underlying resources of the decrypted metadata buffer
123 DeallocateResult np_ffi_deallocate_DecryptedMetadata(DecryptedMetadata metadata);
124 
125 /// Gets the tag of a `DecryptMetadataResult` tagged-union. On success the wrapped identity
126 /// details may be obtained via `DecryptMetadataResult#into_success`.
127 DecryptMetadataResultKind np_ffi_DecryptMetadataResult_kind(DecryptMetadataResult result);
128 
129 /// Casts a `DecryptMetadataResult` to the `Success` variant, panicking in the
130 /// case where the passed value is of a different enum variant.
131 DecryptedMetadata np_ffi_DecryptMetadataResult_into_SUCCESS(DecryptMetadataResult result);
132 
133 /// Gets the pointer and length of the heap allocated byte buffer of decrypted metadata
134 GetMetadataBufferPartsResult np_ffi_DecryptedMetadata_get_metadata_buffer_parts(DecryptedMetadata metadata);
135 
136 /// Gets the tag of a `GetMetadataBufferPartsResult` tagged-union. On success the wrapped identity
137 /// details may be obtained via `GetMetadataBufferPartsResult#into_success`.
138 GetMetadataBufferPartsResultKind np_ffi_GetMetadataBufferPartsResult_kind(GetMetadataBufferPartsResult result);
139 
140 /// Casts a `GetMetadataBufferPartsResult` to the `Success` variant, panicking in the
141 /// case where the passed value is of a different enum variant. This returns the pointer and length
142 /// of the byte buffer containing the decrypted metadata.  There can be a data-race between attempts
143 /// to access the contents of the buffer and attempts to free the handle from different threads.
144 MetadataBufferParts np_ffi_GetMetadataBufferPartsResult_into_SUCCESS(GetMetadataBufferPartsResult result);
145 
146 /// Attempts to deserialize an advertisement with the given service-data
147 /// payload (presumed to be under the NP service UUID) using credentials
148 /// pulled from the given credential-book.
149 DeserializeAdvertisementResult np_ffi_deserialize_advertisement(RawAdvertisementPayload adv_payload,
150                                                                 CredentialBook credential_book);
151 
152 /// Gets the tag of a `DeserializeAdvertisementResult` tagged-union.
153 DeserializeAdvertisementResultKind np_ffi_DeserializeAdvertisementResult_kind(DeserializeAdvertisementResult result);
154 
155 /// Casts a `DeserializeAdvertisementResult` to the `V0` variant, panicking in the
156 /// case where the passed value is of a different enum variant.
157 DeserializedV0Advertisement np_ffi_DeserializeAdvertisementResult_into_V0(DeserializeAdvertisementResult result);
158 
159 /// Casts a `DeserializeAdvertisementResult` to the `V1` variant, panicking in the
160 /// case where the passed value is of a different enum variant.
161 DeserializedV1Advertisement np_ffi_DeserializeAdvertisementResult_into_V1(DeserializeAdvertisementResult result);
162 
163 /// Deallocates any internal data referenced by a `DeserializeAdvertisementResult`. This should only
164 /// be used if into_V0 or into_V1, have not been called yet as it shares the same underlying
165 /// resource.
166 DeallocateResult np_ffi_deallocate_deserialize_advertisement_result(DeserializeAdvertisementResult result);
167 
168 /// Deallocates any internal data referenced by a `DeserializedV0Advertisement`
169 DeallocateResult np_ffi_deallocate_deserialized_V0_advertisement(DeserializedV0Advertisement adv);
170 
171 /// Deallocates any internal data referenced by a `DeserializedV1Advertisement`
172 DeallocateResult np_ffi_deallocate_deserialized_V1_advertisement(DeserializedV1Advertisement adv);
173 
174 /// Gets the tag of a `DeserializedV0Advertisement` tagged-union.
175 DeserializedV0AdvertisementKind np_ffi_DeserializedV0Advertisement_kind(DeserializedV0Advertisement result);
176 
177 /// Casts a `DeserializedV0Advertisement` to the `Legible` variant, panicking in the
178 /// case where the passed value is of a different enum variant.
179 LegibleDeserializedV0Advertisement np_ffi_DeserializedV0Advertisement_into_LEGIBLE(DeserializedV0Advertisement adv);
180 
181 /// Gets the number of DEs in a legible deserialized advertisement.
182 /// Suitable as an iteration bound for `V0Payload#get_de`.
183 uint8_t np_ffi_LegibleDeserializedV0Advertisement_get_num_des(LegibleDeserializedV0Advertisement adv);
184 
185 /// Gets just the data-element payload of a `LegibleDeserializedV0Advertisement`.
186 V0Payload np_ffi_LegibleDeserializedV0Advertisement_into_payload(LegibleDeserializedV0Advertisement adv);
187 
188 /// Gets just the identity kind associated with a `LegibleDeserializedV0Advertisement`.
189 DeserializedV0IdentityKind np_ffi_LegibleDeserializedV0Advertisement_get_identity_kind(LegibleDeserializedV0Advertisement adv);
190 
191 /// Deallocates any internal data of a `LegibleDeserializedV0Advertisement`
192 DeallocateResult np_ffi_deallocate_legible_v0_advertisement(LegibleDeserializedV0Advertisement adv);
193 
194 /// Attempts to get the data-element with the given index in the passed v0 adv payload
195 GetV0DEResult np_ffi_V0Payload_get_de(V0Payload payload, uint8_t index);
196 
197 /// Attempts to decrypt the metadata for the matched credential for this V0 payload (if any)
198 DecryptMetadataResult np_ffi_V0Payload_decrypt_metadata(V0Payload payload);
199 
200 /// Gets the identity details for this V0 payload, or returns an error if this payload does not have
201 /// any associated identity (public advertisement)
202 GetV0IdentityDetailsResult np_ffi_V0Payload_get_identity_details(V0Payload payload);
203 
204 /// Gets the tag of a `GetV0IdentityDetailsResult` tagged-union. On success the wrapped identity
205 /// details may be obtained via `GetV0IdentityDetailsResult#into_success`.
206 GetV0IdentityDetailsResultKind np_ffi_GetV0IdentityDetailsResult_kind(GetV0IdentityDetailsResult result);
207 
208 /// Casts a `GetV0IdentityDetailsResult` to the `Success` variant, panicking in the
209 /// case where the passed value is of a different enum variant.
210 DeserializedV0IdentityDetails np_ffi_GetV0IdentityDetailsResult_into_SUCCESS(GetV0IdentityDetailsResult result);
211 
212 /// Deallocates any internal data of a `V0Payload`
213 DeallocateResult np_ffi_deallocate_v0_payload(V0Payload payload);
214 
215 /// Gets the tag of a `GetV0DEResult` tagged-union.
216 GetV0DEResultKind np_ffi_GetV0DEResult_kind(GetV0DEResult result);
217 
218 /// Casts a `GetV0DEResult` to the `Success` variant, panicking in the
219 /// case where the passed value is of a different enum variant.
220 V0DataElement np_ffi_GetV0DEResult_into_SUCCESS(GetV0DEResult result);
221 
222 /// Gets the number of legible sections on a deserialized V1 advertisement.
223 /// Suitable as an index bound for the second argument of
224 /// `np_ffi_DeserializedV1Advertisement#get_section`.
225 uint8_t np_ffi_DeserializedV1Advertisement_get_num_legible_sections(DeserializedV1Advertisement adv);
226 
227 /// Gets the number of sections on a deserialized V1 advertisement which
228 /// were unable to be decrypted with the credentials that the receiver possesses.
229 uint8_t np_ffi_DeserializedV1Advertisement_get_num_undecryptable_sections(DeserializedV1Advertisement adv);
230 
231 /// Gets the legible section with the given index in a deserialized V1 advertisement.
232 GetV1SectionResult np_ffi_DeserializedV1Advertisement_get_section(DeserializedV1Advertisement adv,
233                                                                   uint8_t legible_section_index);
234 
235 /// Gets the tag of the `GetV1SectionResult` tagged-union.
236 GetV1SectionResultKind np_ffi_GetV1SectionResult_kind(GetV1SectionResult result);
237 
238 /// Casts a `GetV1SectionResult` to the `Success` variant, panicking in the
239 /// case where the passed value is of a different enum variant.
240 DeserializedV1Section np_ffi_GetV1SectionResult_into_SUCCESS(GetV1SectionResult result);
241 
242 /// Gets the number of data elements in a deserialized v1 section.
243 /// Suitable as an iteration bound for the second argument of
244 /// `np_ffi_DeserializedV1Section_get_de`.
245 uint8_t np_ffi_DeserializedV1Section_get_num_des(DeserializedV1Section section);
246 
247 /// Gets the tag of the identity tagged-union used for the passed section.
248 DeserializedV1IdentityKind np_ffi_DeserializedV1Section_get_identity_kind(DeserializedV1Section section);
249 
250 /// Gets the data-element with the given index in the passed section.
251 GetV1DEResult np_ffi_DeserializedV1Section_get_de(DeserializedV1Section section, uint8_t de_index);
252 
253 /// Gets the identity details used to decrypt this V1 section, or returns an error if this payload
254 /// does not have any associated identity (public advertisement)
255 GetV1IdentityDetailsResult np_ffi_DeserializedV1Section_get_identity_details(DeserializedV1Section section);
256 
257 /// Gets the tag of a `GetV1IdentityDetailsResult` tagged-union. On success the wrapped identity
258 /// details may be obtained via `GetV0IdentityDetailsResult#into_success`.
259 GetV1IdentityDetailsResultKind np_ffi_GetV1IdentityDetailsResult_kind(GetV1IdentityDetailsResult result);
260 
261 /// Casts a `GetV1IdentityDetailsResult` to the `Success` variant, panicking in the
262 /// case where the passed value is of a different enum variant.
263 DeserializedV1IdentityDetails np_ffi_GetV1IdentityDetailsResult_into_SUCCESS(GetV1IdentityDetailsResult result);
264 
265 /// Attempts to decrypt the metadata for the matched credential for this V0 payload (if any)
266 DecryptMetadataResult np_ffi_DeserializedV1Section_decrypt_metadata(DeserializedV1Section section);
267 
268 /// Attempts to derive a 16-byte DE salt for a DE in this section with the given DE offset. This
269 /// operation may fail if the passed offset is 255 (causes overflow) or if the section
270 /// is leveraging a public identity, and hence, doesn't have an associated salt.
271 GetV1DE16ByteSaltResult np_ffi_DeserializedV1Section_derive_16_byte_salt_for_offset(DeserializedV1Section section,
272                                                                                     uint8_t offset);
273 
274 /// Gets the tag of a `GetV1DE16ByteSaltResult` tagged-union. On success the wrapped identity
275 /// details may be obtained via `GetV1DE16ByteSaltResult#into_success`.
276 GetV1DE16ByteSaltResultKind np_ffi_GetV1DE16ByteSaltResult_kind(GetV1DE16ByteSaltResult result);
277 
278 /// Casts a `GetV1DE16ByteSaltResult` to the `Success` variant, panicking in the
279 /// case where the passed value is of a different enum variant.
280 FixedSizeArray<16> np_ffi_GetV1DE16ByteSaltResult_into_SUCCESS(GetV1DE16ByteSaltResult result);
281 
282 /// Gets the tag of the `GetV1DEResult` tagged-union.
283 GetV1DEResultKind np_ffi_GetV1DEResult_kind(GetV1DEResult result);
284 
285 /// Casts a `GetV1DEResult` to the `Success` variant, panicking in the
286 /// case where the passed value is of a different enum variant.
287 V1DataElement np_ffi_GetV1DEResult_into_SUCCESS(GetV1DEResult result);
288 
289 /// Attempts to add the given data element to the V0
290 /// advertisement builder behind the passed handle.
291 ///
292 /// This method may invoke the panic handler if the passed DE
293 /// has an invalid layout, which may indicate that the backing
294 /// data on the stack was somehow tampered with in an unintended way.
295 AddV0DEResult np_ffi_V0AdvertisementBuilder_add_de(V0AdvertisementBuilder adv_builder,
296                                                    V0DataElement de);
297 
298 /// Attempts to serialize the contents of the advertisement builder
299 /// behind this handle to bytes. Assuming that the handle is valid,
300 /// this operation will always result in the contents behind the
301 /// advertisement builder handle being deallocated.
302 SerializeV0AdvertisementResult np_ffi_V0AdvertisementBuilder_into_advertisement(V0AdvertisementBuilder adv_builder);
303 
304 /// Attempts to deallocate the v0 advertisement builder behind
305 /// the given handle.
306 DeallocateResult np_ffi_deallocate_v0_advertisement_builder(V0AdvertisementBuilder adv_builder);
307 
308 /// Creates a new V0 advertisement builder for a public advertisement.
309 V0AdvertisementBuilder np_ffi_create_v0_public_advertisement_builder();
310 
311 /// Creates a new V0 advertisement builder for an encrypted advertisement.
312 V0AdvertisementBuilder np_ffi_create_v0_encrypted_advertisement_builder(V0BroadcastCredential broadcast_cred,
313                                                                         FixedSizeArray<2> salt);
314 
315 /// Gets the tag of a `SerializeV0AdvertisementResult` tagged-union.
316 SerializeV0AdvertisementResultKind np_ffi_SerializeV0AdvertisementResult_kind(SerializeV0AdvertisementResult result);
317 
318 /// Casts a `SerializeV0AdvertisementResult` to the `Success` variant,
319 /// panicking in the case where the passed value is of a different enum variant.
320 ByteBuffer<24> np_ffi_SerializeV0AdvertisementResult_into_SUCCESS(SerializeV0AdvertisementResult result);
321 
322 /// Attempts to create a builder for a new public section within
323 /// the advertisement builder behind this handle,
324 /// returning a handle to the newly-created section builder if successful.
325 ///
326 /// This method may fail if there is another currently-active
327 /// section builder for the same advertisement builder, if the
328 /// kind of section being added does not match the advertisement
329 /// type (public/encrypted), or if the section would not manage
330 /// to fit within the enclosing advertisement.
331 CreateV1SectionBuilderResult np_ffi_V1AdvertisementBuilder_public_section_builder(V1AdvertisementBuilder adv_builder);
332 
333 /// Attempts to create a builder for a new encrypted section within
334 /// the advertisement builder behind the given handle,
335 /// returning a handle to the newly-created section builder if successful.
336 ///
337 /// The identity details for the new section builder may be specified
338 /// via providing the broadcast credential data, the kind of encrypted
339 /// identity being broadcast (private/trusted/provisioned), and the
340 /// verification mode (MIC/Signature) to be used for the encrypted section.
341 ///
342 /// This method may fail if there is another currently-active
343 /// section builder for the same advertisement builder, if the
344 /// kind of section being added does not match the advertisement
345 /// type (public/encrypted), or if the section would not manage
346 /// to fit within the enclosing advertisement.
347 CreateV1SectionBuilderResult np_ffi_V1AdvertisementBuilder_encrypted_section_builder(V1AdvertisementBuilder adv_builder,
348                                                                                      V1BroadcastCredential broadcast_cred,
349                                                                                      V1VerificationMode verification_mode);
350 
351 /// Attempts to serialize the contents of the advertisement builder
352 /// behind this handle to bytes. Assuming that the handle is valid,
353 /// this operation will always result in the contents behind the
354 /// advertisement builder handle being deallocated.
355 SerializeV1AdvertisementResult np_ffi_V1AdvertisementBuilder_into_advertisement(V1AdvertisementBuilder adv_builder);
356 
357 /// Creates a new V1 advertisement builder for the given advertisement
358 /// kind (public/encrypted).
359 V1AdvertisementBuilder np_ffi_create_v1_advertisement_builder(AdvertisementBuilderKind kind);
360 
361 /// Gets the tag of a `SerializeV1AdvertisementResult` tagged-union.
362 SerializeV1AdvertisementResultKind np_ffi_SerializeV1AdvertisementResult_kind(SerializeV1AdvertisementResult result);
363 
364 /// Casts a `SerializeV1AdvertisementResult` to the `Success` variant,
365 /// panicking in the case where the passed value is of a different enum variant.
366 ByteBuffer<250> np_ffi_SerializeV1AdvertisementResult_into_SUCCESS(SerializeV1AdvertisementResult result);
367 
368 /// Gets the tag of a `CreateV1SectionBuilderResult` tagged-union.
369 CreateV1SectionBuilderResultKind np_ffi_CreateV1SectionBuilderResult_kind(CreateV1SectionBuilderResult result);
370 
371 /// Casts a `CreateV1SectionBuilderResult` to the `Success` variant,
372 /// panicking in the case where the passed value is of a different enum variant.
373 V1SectionBuilder np_ffi_CreateV1SectionBuilderResult_into_SUCCESS(CreateV1SectionBuilderResult result);
374 
375 /// Gets the tag of a `NextV1DE16ByteSaltResult` tagged-union.
376 NextV1DE16ByteSaltResultKind np_ffi_NextV1DE16ByteSaltResult_kind(NextV1DE16ByteSaltResult result);
377 
378 /// Casts a `NextV1DE16ByteSaltResult` to the `Success` variant,
379 /// panicking in the case where the passed value is of a different enum variant.
380 FixedSizeArray<16> np_ffi_NextV1DE16ByteSaltResult_into_SUCCESS(NextV1DE16ByteSaltResult result);
381 
382 /// Adds the section constructed behind the given handle to
383 /// a section builder to the containing advertisement it originated from.
384 /// After this call, the section builder handle will become invalid.
385 AddV1SectionToAdvertisementResult np_ffi_V1SectionBuilder_add_to_advertisement(V1SectionBuilder section_builder);
386 
387 /// Attempts to get the derived 16-byte V1 DE salt for the next
388 /// DE to be added to the passed section builder. May fail if this
389 /// section builder handle is invalid, or if the section
390 /// is a public section.
391 NextV1DE16ByteSaltResult np_ffi_V1SectionBuilder_next_de_salt(V1SectionBuilder section_builder);
392 
393 /// Attempts to add the given DE to the section builder behind
394 /// this handle. The passed DE may have a payload of up to 127
395 /// bytes, the maximum for a V1 DE.
396 AddV1DEResult np_ffi_V1SectionBuilder_add_127_byte_buffer_de(V1SectionBuilder section_builder,
397                                                              V1DE127ByteBuffer de);
398 
399 /// Gets the tag of a `V0DataElement` tagged-union.
400 V0DataElementKind np_ffi_V0DataElement_kind(V0DataElement de);
401 
402 /// Casts a `V0DataElement` to the `TxPower` variant, panicking in the
403 /// case where the passed value is of a different enum variant.
404 TxPower np_ffi_V0DataElement_into_TX_POWER(V0DataElement de);
405 
406 /// Upcasts a Tx power DE to a generic V0 data-element.
407 V0DataElement np_ffi_TxPower_into_V0DataElement(TxPower tx_power);
408 
409 /// Casts a `V0DataElement` to the `Actions` variant, panicking in the
410 /// case where the passed value is of a different enum variant.
411 V0Actions np_ffi_V0DataElement_into_ACTIONS(V0DataElement de);
412 
413 /// Upcasts a V0 actions DE to a generic V0 data-element.
414 V0DataElement np_ffi_V0Actions_into_V0DataElement(V0Actions actions);
415 
416 /// Gets the tag of a `BuildTxPowerResult` tagged-union.
417 BuildTxPowerResultKind np_ffi_BuildTxPowerResult_kind(BuildTxPowerResult result);
418 
419 /// Casts a `BuildTxPowerResult` to the `Success` variant, panicking in the
420 /// case where the passed value is of a different enum variant.
421 TxPower np_ffi_BuildTxPowerResult_into_SUCCESS(BuildTxPowerResult result);
422 
423 /// Attempts to construct a new TxPower from
424 /// the given signed-byte value.
425 BuildTxPowerResult np_ffi_TxPower_build_from_signed_byte(int8_t tx_power);
426 
427 /// Gets the value of the given TxPower as a signed byte.
428 int8_t np_ffi_TxPower_as_signed_byte(TxPower tx_power);
429 
430 /// Gets the discriminant of the `SetV0ActionResult` tagged-union.
431 SetV0ActionResultKind np_ffi_SetV0ActionResult_kind(SetV0ActionResult result);
432 
433 /// Attempts to cast a `SetV0ActionResult` tagged-union into the `Success` variant.
434 V0Actions np_ffi_SetV0ActionResult_into_SUCCESS(SetV0ActionResult result);
435 
436 /// Attempts to cast a `SetV0ActionResult` tagged-union into the `Error` variant.
437 V0Actions np_ffi_SetV0ActionResult_into_ERROR(SetV0ActionResult result);
438 
439 /// Constructs a new V0 actions DE with no declared boolean
440 /// actions and a zeroed context sync sequence number,
441 /// where the DE is intended for the given advertisement
442 /// kind (plaintext/encrypted).
443 V0Actions np_ffi_build_new_zeroed_V0Actions(AdvertisementBuilderKind kind);
444 
445 /// Return whether a boolean action type is set in this data element
446 bool np_ffi_V0Actions_has_action(V0Actions actions, ActionType action_type);
447 
448 /// Attempts to set the given action bit to the given boolean value.
449 /// This operation may fail if the requested action bit may not be
450 /// set for the kind of containing advertisement (public/encrypted)
451 /// that this action DE is intended to belong to. In this case,
452 /// the original action bits will be yielded back to the caller,
453 /// unaltered.
454 SetV0ActionResult np_ffi_V0Actions_set_action(V0Actions actions,
455                                               ActionType action_type,
456                                               bool value);
457 
458 /// Returns the representation of the passed `V0Actions` as an unsigned
459 /// integer, where the bit-positions correspond to individual actions.
460 uint32_t np_ffi_V0Actions_as_u32(V0Actions actions);
461 
462 /// Converts a `V1DataElement` to a `GenericV1DataElement` which
463 /// only maintains information about the DE's type-code and payload.
464 GenericV1DataElement np_ffi_V1DataElement_to_generic(V1DataElement de);
465 
466 /// Extracts the numerical value of the given V1 DE type code as
467 /// an unsigned 32-bit integer.
468 uint32_t np_ffi_V1DEType_to_uint32_t(V1DEType de_type);
469 
470 } // extern "C"
471 
472 } // namespace internal
473 } // namespace np_ffi
474 
475 // clang-format on
476