pub trait TryIntoJavaValue<'env>: Signature {
    type Target: JavaValue<'env>;

    const SIG_TYPE: &'static str = <Self as Signature>::SIG_TYPE;

    // Required method
    fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>;
}
Expand description

Conversion trait from Rust values to Java values, analogous to TryInto. Used when converting types returned from JNI-available functions.

This is the default trait used when converting values from Rust to Java.

Notes on derive macro

The same notes on TryFromJavaValue apply.

Note that when autoderiving TryIntoJavaValue for T, an implementation for all of T, &T and &mut T is generated (for ergonomics).

Required Associated Types§

source

type Target: JavaValue<'env>

Conversion target type.

Provided Associated Constants§

source

const SIG_TYPE: &'static str = <Self as Signature>::SIG_TYPE

Signature of the source type. By default, use the one defined on the Signature trait for the implementing type.

Required Methods§

source

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

Perform the conversion.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'env> TryIntoJavaValue<'env> for bool

§

type Target = u8

source§

fn try_into(self, _env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env> TryIntoJavaValue<'env> for char

§

type Target = u16

source§

fn try_into(self, _env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env> TryIntoJavaValue<'env> for Box<[bool]>

§

type Target = *mut _jobject

source§

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env> TryIntoJavaValue<'env> for Box<[u8]>

§

type Target = *mut _jobject

source§

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env> TryIntoJavaValue<'env> for String

§

type Target = JString<'env>

source§

const SIG_TYPE: &'static str = "Ljava/lang/String;"

source§

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env, T> TryIntoJavaValue<'env> for Vec<T>where T: TryIntoJavaValue<'env>,

§

type Target = *mut _jobject

source§

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

source§

impl<'env, T> TryIntoJavaValue<'env> for Result<T>where T: TryIntoJavaValue<'env>,

When returning a jni::errors::Result, if the returned variant is Ok(v) then the value v is returned as usual.

If the returned value is Err, the Java exception specified in the #[call_type(safe)] attribute is thrown (by default java.lang.RuntimeException)

§

type Target = <T as TryIntoJavaValue<'env>>::Target

source§

fn try_into(self, env: &JNIEnv<'env>) -> Result<Self::Target>

Implementors§

source§

impl<'env, T> TryIntoJavaValue<'env> for Twhere T: JavaValue<'env> + Signature,

§

type Target = T