Enum j4rs::InvocationArg
source · 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 empty<'a>() -> &'a [InvocationArg; 0]
pub fn empty<'a>() -> &'a [InvocationArg; 0]
Return an empty slice of InvocationArg
s
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 JNIEnv ) -> Result<InvocationArg>
sourcepub fn into_primitive(self) -> Result<InvocationArg>
pub fn into_primitive(self) -> Result<InvocationArg>
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 JNIEnv
) -> Result<jobject>
pub fn as_java_ptr_with_global_ref( &self, jni_env: *mut JNIEnv ) -> Result<jobject>
Creates a jobject
from this InvocationArg.
sourcepub fn as_java_ptr_with_local_ref(
&self,
jni_env: *mut JNIEnv
) -> Result<jobject>
pub fn as_java_ptr_with_local_ref( &self, jni_env: *mut JNIEnv ) -> Result<jobject>
Creates a jobject
from this InvocationArg. The jobject contains a local reference.
sourcepub fn instance(self) -> Result<Instance>
pub fn instance(self) -> Result<Instance>
Consumes this invocation arg and returns its Instance
pub fn class_name(&self) -> &str
sourcepub fn create_null(null: Null<'_>) -> Result<InvocationArg>
pub fn create_null(null: Null<'_>) -> Result<InvocationArg>
Creates an InvocationArg that contains null