lance_jni::ffi

Trait JNIEnvExt

Source
pub trait JNIEnvExt {
Show 20 methods // Required methods fn get_integers(&mut self, obj: &JObject<'_>) -> Result<Vec<i32>>; fn get_strings(&mut self, obj: &JObject<'_>) -> Result<Vec<String>>; unsafe fn get_strings_array( &mut self, obj: jobjectArray, ) -> Result<Vec<String>>; fn get_string_opt(&mut self, obj: &JObject<'_>) -> Result<Option<String>>; fn get_strings_opt( &mut self, obj: &JObject<'_>, ) -> Result<Option<Vec<String>>>; fn get_int_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i32>>; fn get_ints_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<i32>>>; fn get_long_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i64>>; fn get_u64_opt(&mut self, obj: &JObject<'_>) -> Result<Option<u64>>; fn get_bytes_opt(&mut self, obj: &JObject<'_>) -> Result<Option<&[u8]>>; fn get_string_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<String>; fn get_vec_f32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Vec<f32>>; fn get_int_as_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<usize>; fn get_boolean_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<bool>; fn get_optional_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<usize>>; fn get_optional_i32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<i32>>; fn get_optional_u32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<u32>>; fn get_optional_integer_from_method<T>( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<T>> where T: TryFrom<i32>, <T as TryFrom<i32>>::Error: Debug; fn get_optional_from_method<T, F>( &mut self, obj: &JObject<'_>, method_name: &str, f: F, ) -> Result<Option<T>> where F: FnOnce(&mut JNIEnv<'_>, JObject<'_>) -> Result<T>; fn get_optional<T, F>( &mut self, obj: &JObject<'_>, f: F, ) -> Result<Option<T>> where F: FnOnce(&mut JNIEnv<'_>, &JObject<'_>) -> Result<T>;
}
Expand description

Extend JNIEnv with helper functions.

Required Methods§

Source

fn get_integers(&mut self, obj: &JObject<'_>) -> Result<Vec<i32>>

Get integers from Java List object.

Source

fn get_strings(&mut self, obj: &JObject<'_>) -> Result<Vec<String>>

Get strings from Java List object.

Source

unsafe fn get_strings_array(&mut self, obj: jobjectArray) -> Result<Vec<String>>

Converts a Java String[] array to a Rust Vec<String>.

§Safety

This function is unsafe because it dereferences a raw pointer jobjectArray. The caller must ensure that the jobjectArray is a valid Java string array and that the JNI environment self is correctly initialized and valid. The function assumes that the jobjectArray is not null and that its elements are valid Java strings. If these conditions are not met, the function may exhibit undefined behavior.

Source

fn get_string_opt(&mut self, obj: &JObject<'_>) -> Result<Option<String>>

Get Option from Java Optional.

Source

fn get_strings_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<String>>>

Get Option<Vec> from Java Optional<List>.

Source

fn get_int_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i32>>

Get Option from Java Optional.

Source

fn get_ints_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<i32>>>

Get Option<Vec> from Java Optional<List>.

Source

fn get_long_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i64>>

Get Option from Java Optional.

Source

fn get_u64_opt(&mut self, obj: &JObject<'_>) -> Result<Option<u64>>

Get Option from Java Optional.

Source

fn get_bytes_opt(&mut self, obj: &JObject<'_>) -> Result<Option<&[u8]>>

Get Option<&u8> from Java Optional.

Source

fn get_string_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<String>

Source

fn get_vec_f32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Vec<f32>>

Source

fn get_int_as_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<usize>

Source

fn get_boolean_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<bool>

Source

fn get_optional_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<usize>>

Source

fn get_optional_i32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<i32>>

Source

fn get_optional_u32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<u32>>

Source

fn get_optional_integer_from_method<T>( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<T>>
where T: TryFrom<i32>, <T as TryFrom<i32>>::Error: Debug,

Source

fn get_optional_from_method<T, F>( &mut self, obj: &JObject<'_>, method_name: &str, f: F, ) -> Result<Option<T>>
where F: FnOnce(&mut JNIEnv<'_>, JObject<'_>) -> Result<T>,

Source

fn get_optional<T, F>(&mut self, obj: &JObject<'_>, f: F) -> Result<Option<T>>
where F: FnOnce(&mut JNIEnv<'_>, &JObject<'_>) -> Result<T>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl JNIEnvExt for JNIEnv<'_>

Source§

fn get_integers(&mut self, obj: &JObject<'_>) -> Result<Vec<i32>>

Source§

fn get_strings(&mut self, obj: &JObject<'_>) -> Result<Vec<String>>

Source§

unsafe fn get_strings_array(&mut self, obj: jobjectArray) -> Result<Vec<String>>

Source§

fn get_string_opt(&mut self, obj: &JObject<'_>) -> Result<Option<String>>

Source§

fn get_strings_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<String>>>

Source§

fn get_int_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i32>>

Source§

fn get_ints_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<i32>>>

Source§

fn get_long_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i64>>

Source§

fn get_u64_opt(&mut self, obj: &JObject<'_>) -> Result<Option<u64>>

Source§

fn get_bytes_opt(&mut self, obj: &JObject<'_>) -> Result<Option<&[u8]>>

Source§

fn get_string_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<String>

Source§

fn get_vec_f32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Vec<f32>>

Source§

fn get_int_as_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<usize>

Source§

fn get_boolean_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<bool>

Source§

fn get_optional_i32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<i32>>

Source§

fn get_optional_u32_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<u32>>

Source§

fn get_optional_usize_from_method( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<usize>>

Source§

fn get_optional_integer_from_method<T>( &mut self, obj: &JObject<'_>, method_name: &str, ) -> Result<Option<T>>
where T: TryFrom<i32>, <T as TryFrom<i32>>::Error: Debug,

Source§

fn get_optional_from_method<T, F>( &mut self, obj: &JObject<'_>, method_name: &str, f: F, ) -> Result<Option<T>>
where F: FnOnce(&mut JNIEnv<'_>, JObject<'_>) -> Result<T>,

Source§

fn get_optional<T, F>(&mut self, obj: &JObject<'_>, f: F) -> Result<Option<T>>
where F: FnOnce(&mut JNIEnv<'_>, &JObject<'_>) -> Result<T>,

Implementors§