1 // Copyright 2023 Google LLC
2 //
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 //! Core NP Rust FFI structures and methods for advertisement serialization.
15 
16 pub mod v0;
17 pub mod v1;
18 
19 /// Enum common to V0 and V1 serialization expressing
20 /// what kind of advertisement builder (public/encrypted)
21 /// is in use.
22 #[derive(Clone, Copy)]
23 #[repr(u8)]
24 pub enum AdvertisementBuilderKind {
25     /// The builder is for a public advertisement.
26     Public = 0,
27     /// The builder is for an encrypted advertisement.
28     Encrypted = 1,
29 }
30 
31 impl AdvertisementBuilderKind {
as_internal_v1(&self) -> np_adv::extended::serialize::AdvertisementType32     pub(crate) fn as_internal_v1(&self) -> np_adv::extended::serialize::AdvertisementType {
33         use np_adv::extended::serialize::AdvertisementType;
34         match self {
35             Self::Public => AdvertisementType::Plaintext,
36             Self::Encrypted => AdvertisementType::Encrypted,
37         }
38     }
39 }
40