Module robusta_jni::convert::safe
source · [−]Expand description
Fallible conversions traits.
These are the traits selected if call_type
is omitted or if specified with a safe
parameter.
ⓘ
#[call_type(safe)]
If any conversion fails, e.g. while converting input parameters or return arguments a Java exception is thrown.
Exception class and exception message can be customized with the exception_class
and message
parameters of the safe
option, as such:
ⓘ
#[call_type(safe(exception_class = "java.io.IOException", message = "Error while calling JNI function!"))]
Both of these parameters are optional. By default, the exception class is java.lang.RuntimeException
.
Traits
Conversion trait from Java values to Rust values, analogous to TryFrom. Used when converting types that are input to JNI-available functions.
Conversion trait from Rust values to Java values, analogous to TryInto. Used when converting types returned from JNI-available functions.