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§
Sourcefn get_integers(&mut self, obj: &JObject<'_>) -> Result<Vec<i32>>
fn get_integers(&mut self, obj: &JObject<'_>) -> Result<Vec<i32>>
Get integers from Java List
Sourcefn get_strings(&mut self, obj: &JObject<'_>) -> Result<Vec<String>>
fn get_strings(&mut self, obj: &JObject<'_>) -> Result<Vec<String>>
Get strings from Java List
Sourceunsafe fn get_strings_array(&mut self, obj: jobjectArray) -> Result<Vec<String>>
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.
Sourcefn get_string_opt(&mut self, obj: &JObject<'_>) -> Result<Option<String>>
fn get_string_opt(&mut self, obj: &JObject<'_>) -> Result<Option<String>>
Get Option
Sourcefn get_strings_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<String>>>
fn get_strings_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<String>>>
Get Option<Vec
Sourcefn get_int_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i32>>
fn get_int_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i32>>
Get Option
Sourcefn get_ints_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<i32>>>
fn get_ints_opt(&mut self, obj: &JObject<'_>) -> Result<Option<Vec<i32>>>
Get Option<Vec
Sourcefn get_long_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i64>>
fn get_long_opt(&mut self, obj: &JObject<'_>) -> Result<Option<i64>>
Get Option
Sourcefn get_u64_opt(&mut self, obj: &JObject<'_>) -> Result<Option<u64>>
fn get_u64_opt(&mut self, obj: &JObject<'_>) -> Result<Option<u64>>
Get Option
Sourcefn get_bytes_opt(&mut self, obj: &JObject<'_>) -> Result<Option<&[u8]>>
fn get_bytes_opt(&mut self, obj: &JObject<'_>) -> Result<Option<&[u8]>>
Get Option<&u8> from Java Optional
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>>
fn get_optional_from_method<T, F>( &mut self, obj: &JObject<'_>, method_name: &str, f: F, ) -> Result<Option<T>>
fn get_optional<T, F>(&mut self, obj: &JObject<'_>, f: F) -> Result<Option<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.