Arg

Struct Arg 

Source
pub struct Arg<T: ReferenceType> { /* private fields */ }
Expand description

FFI: Use Arg<java::lang::Object> instead of jobject. This represents a (null?) function argument.

Unlike most Java reference types from this library, this can be null.

FFI safe where a jobject is safe, assuming you match your types correctly. Using the wrong type may result in soundness issues, but at least on Android mostly seems to just result in JNI aborting execution for the current process when calling methods on an instance of the wrong type.

Implementations§

Source§

impl<T: ReferenceType> Arg<T>

Source

pub unsafe fn from_raw(object: jobject) -> Self

§Safety

unsafe: There’s no guarantee the jobject being passed is valid or null, nor any means of checking it.

Source

pub fn as_raw(&self) -> jobject

Returns the raw JNI reference pointer.

Source

pub unsafe fn into_ref<'env>(self, env: Env<'env>) -> Option<Ref<'env, T>>

§Safety

unsafe: This assumes the argument belongs to the given Env, which is technically unsound. However, the intended use case of immediately converting any Arg into Ref at the start of a JNI callback, where Java directly invoked your function with an Env + arguments, is sound.

Source

pub unsafe fn into_local<'env>(self, env: Env<'env>) -> Option<Local<'env, T>>

§Safety

unsafe: This assumes the argument belongs to the given Env, which is technically unsound. However, the intended use case of immediately converting any Arg into Local at the start of a JNI callback, where Java directly invoked your function with an Env + arguments, is sound.

Source

pub unsafe fn into_global(self, env: Env<'_>) -> Option<Global<T>>

This equals Arg::into_ref + Ref::as_global.

§Safety

unsafe: The same as Arg::into_ref.

Auto Trait Implementations§

§

impl<T> Freeze for Arg<T>

§

impl<T> RefUnwindSafe for Arg<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Arg<T>

§

impl<T> !Sync for Arg<T>

§

impl<T> Unpin for Arg<T>
where T: Unpin,

§

impl<T> UnwindSafe for Arg<T>
where T: 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> 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>,

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.