1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::marker::PhantomData;
use crate::sys::jobject;
#[repr(transparent)]
#[derive(Clone, Copy, Debug)]
pub struct JObject<'a> {
internal: jobject,
lifetime: PhantomData<&'a ()>,
}
impl<'a> From<jobject> for JObject<'a> {
fn from(other: jobject) -> Self {
JObject {
internal: other,
lifetime: PhantomData,
}
}
}
impl<'a> ::std::ops::Deref for JObject<'a> {
type Target = jobject;
fn deref(&self) -> &Self::Target {
&self.internal
}
}
impl<'a> JObject<'a> {
pub fn into_inner(self) -> jobject {
self.internal
}
pub fn null() -> JObject<'a> {
(::std::ptr::null_mut() as jobject).into()
}
}