[−][src]Module robusta_jni::convert
Conversion facilities. This module provides two trait families: FromJavaValue/IntoJavaValue (infallible conversions) and TryFromJavaValue/TryIntoJavaValue (fallible conversions), similar to the ones found in the standard library.
The call_type
attribute controls which of the two conversion families is selected during code generation.
call_type
is a per-function attribute.
Specific parameters that can be given to call_type
can be found in the module documentation relative to the trait family (safe module for fallible conversions and unchecked module for infallible conversions)
If the call_type
attribute is omitted, the fallible conversion trait family is chosen.
Example usage:
use robusta_jni::bridge; #[bridge] mod jni { #[package(com.example.robusta)] struct HelloWorld; impl HelloWorld { #[call_type(unchecked)] fn special(mut input1: Vec<i32>, input2: i32) -> Vec<String> { input1.push(input2); input1.iter().map(ToString::to_string).collect() } #[call_type(safe(exception_class = "java.lang.IllegalArgumentException", message = "invalid value"))] fn bar(foo: i32) -> i32 { foo } } }
Re-exports
pub use safe::*; |
pub use unchecked::*; |
Modules
safe | Fallible conversions traits. |
unchecked | Infallible conversion traits. |
Traits
JavaValue | A trait for types that are ffi-safe to use with JNI. It is implemented for primitives, JOBject and jobject. Users that want automatic conversion should instead implement FromJavaValue, IntoJavaValue and/or TryFromJavaValue, TryIntoJavaValue |