Struct java_spaghetti::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

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

source

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

unsafe: This assumes the argument belongs to the given Env/VM, which is technically unsound. However, the intended use case of immediately converting any Arg s into ArgRef s 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>>

unsafe: This assumes the argument belongs to the given Env/VM, which is technically unsound. However, the intended use case of immediately converting any Arg s into ArgRef s 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>>

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

Auto Trait Implementations§

§

impl<T> Freeze for Arg<T>
where T: JniType + 'static,

§

impl<T> RefUnwindSafe for Arg<T>
where T: JniType + 'static + RefUnwindSafe,

§

impl<T> !Send for Arg<T>

§

impl<T> !Sync for Arg<T>

§

impl<T> Unpin for Arg<T>
where T: JniType + 'static + Unpin,

§

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

§

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.