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:
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>
impl<T: ReferenceType> Global<T>
pub unsafe fn from_raw(vm: VM, object: jobject) -> Self
pub fn vm(&self) -> VM
pub fn as_raw(&self) -> jobject
pub fn into_raw(self) -> jobject
pub fn as_local<'env>(&self, env: Env<'env>) -> Local<'env, T>
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>
impl<T: ReferenceType, U: AssignableTo<T>> AsArg<T> for Global<U>
impl<T: ReferenceType> Send for Global<T>
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>
impl<T> UnwindSafe for Global<T>where
T: JniType + 'static + UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more