droid_wrap_utils

Enum JValueGen

Source
pub enum JValueGen<O> {
    Object(O),
    Byte(i8),
    Char(u16),
    Short(i16),
    Int(i32),
    Long(i64),
    Bool(u8),
    Float(f32),
    Double(f64),
    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(i8)

§

Char(u16)

§

Short(i16)

§

Int(i32)

§

Long(i64)

§

Bool(u8)

§

Float(f32)

§

Double(f64)

§

Void

Implementations§

Source§

impl<O> JValueGen<O>

Source

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

Convert the enum to its jni-compatible equivalent.

Source

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

👎Deprecated: Use as_jni 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, Error>

Try to unwrap to an Object.

Source

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

Try to unwrap to a boolean.

Source

pub fn b(self) -> Result<i8, Error>

Try to unwrap to a byte.

Source

pub fn c(self) -> Result<u16, Error>

Try to unwrap to a char.

Source

pub fn d(self) -> Result<f64, Error>

Try to unwrap to a double.

Source

pub fn f(self) -> Result<f32, Error>

Try to unwrap to a float.

Source

pub fn i(self) -> Result<i32, Error>

Try to unwrap to an int.

Source

pub fn j(self) -> Result<i64, Error>

Try to unwrap to a long.

Source

pub fn s(self) -> Result<i16, Error>

Try to unwrap to a short.

Source

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

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 for JValueGen<O>
where O: Clone,

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 for JValueGen<O>
where O: Debug,

Source§

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

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>) -> JValueGen<&'obj_ref O>

Converts to this type from the input type.
Source§

impl<'local, 'obj_ref, T> From<&'obj_ref T> for JValueGen<&'obj_ref JObject<'local>>
where 'local: 'obj_ref, T: AsRef<JObject<'local>>,

Source§

fn from(other: &'obj_ref T) -> JValueGen<&'obj_ref JObject<'local>>

Converts to this type from the input type.
Source§

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

Source§

fn from(_: ()) -> JValueGen<O>

Converts to this type from the input type.
Source§

impl<'local, T> From<T> for JValueGen<JObject<'local>>
where T: Into<JObject<'local>>,

Source§

fn from(other: T) -> JValueGen<JObject<'local>>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: bool) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: f32) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: f64) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: i16) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: i32) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: i64) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: i8) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: u16) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

fn from(other: u8) -> JValueGen<O>

Converts to this type from the input type.
Source§

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

Source§

type Error = Error

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

fn try_from(value: JValueGen<JObject<'local>>) -> Result<JObject<'local>, Error>

Performs the conversion.
Source§

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

Auto Trait Implementations§

§

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

§

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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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>,

Source§

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.