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.

Fields

§instance: Instance
§class_name: String
§serialized: bool
§

Rust

A serialized arg that is created in the Rust world.

Fields

§json: String
§class_name: String
§serialized: bool
§

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.

Fields

§instance: Instance
§class_name: String
§serialized: bool

Implementations§

source§

impl InvocationArg

source

pub fn empty<'a>() -> &'a [InvocationArg; 0]

Return an empty slice of InvocationArgs

source

pub fn new<T>(arg: &T, class_name: &str) -> InvocationArg
where T: Serialize + Any,

Creates a InvocationArg::Rust. This is default for the Args that are created from the Rust code.

source

pub fn new_2<T>( arg: &T, class_name: &str, jni_env: *mut JNIEnv ) -> Result<InvocationArg>
where T: Serialize + Any,

source

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.

source

pub fn as_java_ptr_with_global_ref( &self, jni_env: *mut JNIEnv ) -> Result<jobject>

Creates a jobject from this InvocationArg.

source

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.

source

pub fn instance(self) -> Result<Instance>

Consumes this invocation arg and returns its Instance

source

pub fn class_name(&self) -> &str

source

pub fn create_null(null: Null<'_>) -> Result<InvocationArg>

Creates an InvocationArg that contains null

Trait Implementations§

source§

impl From<Instance> for InvocationArg

source§

fn from(instance: Instance) -> InvocationArg

Converts to this type from the input type.
source§

impl Serialize for InvocationArg

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a> TryFrom<&'a [&'a str]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [&'a str]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [String]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [String]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [bool]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [bool]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [char]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [char]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [f32]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [f32]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [f64]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [f64]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [i16]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [i16]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [i32]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [i32]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [i64]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [i64]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [i8]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [i8]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a [u16]> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: &'a [u16]) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a String> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a String) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a bool> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a bool) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a char> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a char) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a f32> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a f32) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a f64> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a f64) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a i16> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a i16) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a, 'b> TryFrom<&'a i32> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a i32) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a i64> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a i64) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a i8> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a i8) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a str> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a str) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a> TryFrom<&'a u16> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: &'a u16) -> Result<InvocationArg>

Performs the conversion.
source§

impl<'a, T> TryFrom<(&'a [T], &'a str)> for InvocationArg
where T: Serialize + 'static,

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(vec: (&'a [T], &'a str)) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<()> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: ()) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<InvocationArg> for Instance

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(invocation_arg: InvocationArg) -> Result<Instance>

Performs the conversion.
source§

impl<'a> TryFrom<Null<'a>> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(null: Null<'_>) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<Result<Instance, J4RsError>> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(instance_res: Result<Instance, J4RsError>) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<Result<InvocationArg, J4RsError>> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: Result<InvocationArg, J4RsError>) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<String> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: String) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<bool> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: bool) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<char> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: char) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<f32> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: f32) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<f64> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: f64) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<i16> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: i16) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<i32> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: i32) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<i64> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: i64) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<i8> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: i8) -> Result<InvocationArg>

Performs the conversion.
source§

impl TryFrom<u16> for InvocationArg

§

type Error = J4RsError

The type returned in the event of a conversion error.
source§

fn try_from(arg: u16) -> Result<InvocationArg>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.