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 //! Rust wrappers for Java classes. 16 //! 17 //! The pattern being used here it to create a new wrapper type for each Java class being used by 18 //! this library. Each wrapper type will implement the required accessors for its members so that 19 //! JNI code using a member can be easily found in case that member is changed. Native methods will 20 //! also be implemented along side the wrapper of the class they are implementing. 21 //! 22 //! This library is primarily meant to be used from Java. The Java entrypoint to this library is 23 //! `class NpAdv`. 24 25 use jni::JNIEnv; 26 27 /// Trait to allow Java exceptions to be thrown from rust Errors 28 pub trait ToJavaException { 29 /// Convert this error to a Java exception and throw it. throw_java_exception<'env>(&self, env: &mut JNIEnv<'env>) -> jni::errors::Result<()>30 fn throw_java_exception<'env>(&self, env: &mut JNIEnv<'env>) -> jni::errors::Result<()>; 31 } 32 33 mod credential_book; 34 mod credential_slab; 35 mod deserialization_exception; 36 mod deserialize_result; 37 mod deserialized_v0_advertisement; 38 mod deserialized_v1_advertisement; 39 mod deserialized_v1_section; 40 mod handle; 41 mod identity_kind; 42 mod legible_v1_sections; 43 mod np_adv; 44 mod owned_handle; 45 mod v0_discovery_credential; 46 mod v0_payload; 47 mod v1_discovery_credential; 48 49 pub mod v0_data_element; 50 pub mod v1_data_element; 51 52 pub use deserialization_exception::{InvalidFormatException, InvalidHeaderException}; 53 pub use deserialize_result::{DeserializeResult, DeserializeResultError}; 54 pub use deserialized_v0_advertisement::{DeserializedV0Advertisement, V0AdvertisementError}; 55 pub use deserialized_v1_advertisement::DeserializedV1Advertisement; 56 pub use deserialized_v1_section::DeserializedV1Section; 57 pub use handle::InvalidHandleException; 58 pub use identity_kind::IdentityKind; 59 pub use legible_v1_sections::LegibleV1Sections; 60 pub use owned_handle::NoSpaceLeftException; 61 pub use v0_discovery_credential::V0DiscoveryCredential; 62 pub use v1_discovery_credential::V1DiscoveryCredential; 63