Struct java_spaghetti::Global

source ·
pub struct Global<T: ReferenceType> { /* private fields */ }
Expand description

A Global, non-null, reference to a Java object (+ VM).

Unlike Local, this can be stored statically and shared between threads. This has a few caveats:

  • You must create a Ref before use.
  • The Global can be invalidated if the VM is unloaded.

Not FFI Safe: #[repr(rust)], and exact layout is likely to change - depending on exact features used - in the future. Specifically, on Android, since we’re guaranteed to only have a single ambient VM, we can likely store the *const JavaVM in static and/or thread local storage instead of lugging it around in every Local. Of course, there’s no guarantee that’s actually an optimization

Implementations§

source§

impl<T: ReferenceType> Global<T>

source

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

source

pub fn vm(&self) -> VM

source

pub fn as_raw(&self) -> jobject

source

pub fn into_raw(self) -> jobject

source

pub fn as_local<'env>(&self, env: Env<'env>) -> Local<'env, T>

source

pub fn as_ref<'env>(&'env self, env: Env<'env>) -> Ref<'env, T>

Trait Implementations§

source§

impl<T: ReferenceType, U: AssignableTo<T>> AsArg<T> for Global<U>

source§

impl<T: ReferenceType> Clone for Global<T>

source§

fn clone(&self) -> Self

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<T: ReferenceType> Drop for Global<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'env, T: ReferenceType> From<&Local<'env, T>> for Global<T>

source§

fn from(x: &Local<'env, T>) -> Self

Converts to this type from the input type.
source§

impl<'env, T: ReferenceType> From<&Ref<'env, T>> for Global<T>

source§

fn from(x: &Ref<'env, T>) -> Self

Converts to this type from the input type.
source§

impl<'env, T: ReferenceType> From<Local<'env, T>> for Global<T>

source§

fn from(x: Local<'env, T>) -> Self

Converts to this type from the input type.
source§

impl<'env, T: ReferenceType> From<Ref<'env, T>> for Global<T>

source§

fn from(x: Ref<'env, T>) -> Self

Converts to this type from the input type.
source§

impl<T: ReferenceType> Send for Global<T>

source§

impl<T: ReferenceType> Sync for Global<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<T> UnwindSafe for Global<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> ToOwned for T
where 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 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.