pub enum InvocationArg {
Java {
instance: Instance,
class_name: String,
serialized: bool,
},
Rust {
json: String,
class_name: String,
serialized: bool,
},
RustBasic {
instance: Instance,
class_name: String,
serialized: bool,
},
}Expand description
Struct that carries an argument that is used for method invocations in Java.
Variants§
Java
An arg that is created in the Java world.
Rust
A serialized arg that is created in the Rust world.
RustBasic
An non-serialized arg created in the Rust world, that contains a Java instance.
The instance is a Basic Java type, like Integer, Float, String etc.
Implementations§
Source§impl InvocationArg
impl InvocationArg
Sourcepub fn new<T>(arg: &T, class_name: &str) -> InvocationArg
pub fn new<T>(arg: &T, class_name: &str) -> InvocationArg
Creates a InvocationArg::Rust. This is default for the Args that are created from the Rust code.
pub fn new_2<T>( arg: &T, class_name: &str, jni_env: *mut *const JNINativeInterface_, ) -> Result<InvocationArg, J4RsError>
Sourcepub fn into_primitive(self) -> Result<InvocationArg, J4RsError>
pub fn into_primitive(self) -> Result<InvocationArg, J4RsError>
Consumes this InvocationArg and transforms it to an InvocationArg that contains a Java primitive, leveraging Java’s autoboxing.
This action can be done by calling Jvm::cast of Instances as well (e.g.: jvm.cast(&instance, “int”))
but calling into_primitive is faster, as it does not involve JNI calls.
Sourcepub fn as_java_ptr_with_global_ref(
&self,
jni_env: *mut *const JNINativeInterface_,
) -> Result<*mut _jobject, J4RsError>
pub fn as_java_ptr_with_global_ref( &self, jni_env: *mut *const JNINativeInterface_, ) -> Result<*mut _jobject, J4RsError>
Creates a jobject from this InvocationArg.
Sourcepub fn as_java_ptr_with_local_ref(
&self,
jni_env: *mut *const JNINativeInterface_,
) -> Result<*mut _jobject, J4RsError>
pub fn as_java_ptr_with_local_ref( &self, jni_env: *mut *const JNINativeInterface_, ) -> Result<*mut _jobject, J4RsError>
Creates a jobject from this InvocationArg. The jobject contains a local reference.
Sourcepub fn instance(self) -> Result<Instance, J4RsError>
pub fn instance(self) -> Result<Instance, J4RsError>
Consumes this invocation arg and returns its Instance
pub fn class_name(&self) -> &str
Sourcepub fn create_null(null: Null<'_>) -> Result<InvocationArg, J4RsError>
pub fn create_null(null: Null<'_>) -> Result<InvocationArg, J4RsError>
Creates an InvocationArg that contains null