Enum jni::objects::JValueGen

source ·
pub enum JValueGen<O> {
    Object(O),
    Byte(jbyte),
    Char(jchar),
    Short(jshort),
    Int(jint),
    Long(jlong),
    Bool(jboolean),
    Float(jfloat),
    Double(jdouble),
    Void,
}
Expand description

Rusty version of the JNI C jvalue enum. Used in Java method call arguments and returns.

JValueGen is a generic type, meant to represent both owned and borrowed JNI values. The type parameter O refers to what kind of object reference the JValueGen can hold, which is either:

  • an owned JObject, used for values returned from a Java method call, or
  • a borrowed &JObject, used for parameters passed to a Java method call.

These two cases are represented by the type aliases JValueOwned and JValue, respectively.

Variants§

§

Object(O)

§

Byte(jbyte)

§

Char(jchar)

§

Short(jshort)

§

Int(jint)

§

Long(jlong)

§

Bool(jboolean)

§

Float(jfloat)

§

Double(jdouble)

§

Void

Implementations§

source§

impl<O> JValueGen<O>

source

pub fn as_jni<'local>(&self) -> jvaluewhere O: AsRef<JObject<'local>> + Debug,

Convert the enum to its jni-compatible equivalent.

source

pub fn to_jni<'local>(self) -> jvaluewhere O: AsRef<JObject<'local>> + Debug,

👎Deprecated: Use <code>as_jni</code> instead.

Convert the enum to its jni-compatible equivalent.

source

pub fn type_name(&self) -> &'static str

Get the type name for the enum variant.

source

pub fn primitive_type(&self) -> Option<Primitive>

Get the primitive type for the enum variant. If it’s not a primitive (i.e. an Object), returns None.

source

pub fn l(self) -> Result<O>

Try to unwrap to an Object.

source

pub fn z(self) -> Result<bool>

Try to unwrap to a boolean.

source

pub fn b(self) -> Result<jbyte>

Try to unwrap to a byte.

source

pub fn c(self) -> Result<jchar>

Try to unwrap to a char.

source

pub fn d(self) -> Result<jdouble>

Try to unwrap to a double.

source

pub fn f(self) -> Result<jfloat>

Try to unwrap to a float.

source

pub fn i(self) -> Result<jint>

Try to unwrap to an int.

source

pub fn j(self) -> Result<jlong>

Try to unwrap to a long.

source

pub fn s(self) -> Result<jshort>

Try to unwrap to a short.

source

pub fn v(self) -> Result<()>

Try to unwrap to a void.

source

pub fn borrow(&self) -> JValueGen<&O>

Copies or borrows the value in this JValue.

If the value is a primitive type, it is copied. If the value is an object reference, it is borrowed.

Trait Implementations§

source§

impl<O: Clone> Clone for JValueGen<O>

source§

fn clone(&self) -> JValueGen<O>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<O: Debug> Debug for JValueGen<O>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'obj_ref, O> From<&'obj_ref JValueGen<O>> for JValueGen<&'obj_ref O>

source§

fn from(other: &'obj_ref JValueGen<O>) -> Self

Converts to this type from the input type.
source§

impl<O> From<()> for JValueGen<O>

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl<O> From<bool> for JValueGen<O>

source§

fn from(other: bool) -> Self

Converts to this type from the input type.
source§

impl<O> From<f32> for JValueGen<O>

source§

fn from(other: jfloat) -> Self

Converts to this type from the input type.
source§

impl<O> From<f64> for JValueGen<O>

source§

fn from(other: jdouble) -> Self

Converts to this type from the input type.
source§

impl<O> From<i16> for JValueGen<O>

source§

fn from(other: jshort) -> Self

Converts to this type from the input type.
source§

impl<O> From<i32> for JValueGen<O>

source§

fn from(other: jint) -> Self

Converts to this type from the input type.
source§

impl<O> From<i64> for JValueGen<O>

source§

fn from(other: jlong) -> Self

Converts to this type from the input type.
source§

impl<O> From<i8> for JValueGen<O>

source§

fn from(other: jbyte) -> Self

Converts to this type from the input type.
source§

impl<O> From<u16> for JValueGen<O>

source§

fn from(other: jchar) -> Self

Converts to this type from the input type.
source§

impl<O> From<u8> for JValueGen<O>

source§

fn from(other: jboolean) -> Self

Converts to this type from the input type.
source§

impl<'local> TryFrom<JValueGen<JObject<'local>>> for JObject<'local>

§

type Error = Error

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

fn try_from(value: JValueOwned<'local>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for ()

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jboolean

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jbyte

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jchar

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jdouble

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jfloat

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jint

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jlong

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O> TryFrom<JValueGen<O>> for jshort

§

type Error = Error

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

fn try_from(value: JValueGen<O>) -> Result<Self>

Performs the conversion.
source§

impl<O: Copy> Copy for JValueGen<O>

Auto Trait Implementations§

§

impl<O> RefUnwindSafe for JValueGen<O>where O: RefUnwindSafe,

§

impl<O> Send for JValueGen<O>where O: Send,

§

impl<O> Sync for JValueGen<O>where O: Sync,

§

impl<O> Unpin for JValueGen<O>where O: Unpin,

§

impl<O> UnwindSafe for JValueGen<O>where O: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.