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 15 //! NP Rust C FFI functionality common to V1 ser/deser flows. 16 17 use np_ffi_core::deserialize::v1::*; 18 19 /// Converts a `V1DataElement` to a `GenericV1DataElement` which 20 /// only maintains information about the DE's type-code and payload. 21 #[no_mangle] np_ffi_V1DataElement_to_generic(de: V1DataElement) -> GenericV1DataElement22pub extern "C" fn np_ffi_V1DataElement_to_generic(de: V1DataElement) -> GenericV1DataElement { 23 de.to_generic() 24 } 25 26 /// Extracts the numerical value of the given V1 DE type code as 27 /// an unsigned 32-bit integer. 28 #[no_mangle] np_ffi_V1DEType_to_uint32_t(de_type: V1DEType) -> u3229pub extern "C" fn np_ffi_V1DEType_to_uint32_t(de_type: V1DEType) -> u32 { 30 de_type.to_u32() 31 } 32