• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::{
2     objects::JObject,
3     sys::{jclass, jobject},
4 };
5 
6 /// Lifetime'd representation of a `jclass`. Just a `JObject` wrapped in a new
7 /// class.
8 #[repr(transparent)]
9 #[derive(Clone, Copy, Debug)]
10 pub struct JClass<'a>(JObject<'a>);
11 
12 impl<'a> From<jclass> for JClass<'a> {
from(other: jclass) -> Self13     fn from(other: jclass) -> Self {
14         JClass(From::from(other as jobject))
15     }
16 }
17 
18 impl<'a> ::std::ops::Deref for JClass<'a> {
19     type Target = JObject<'a>;
20 
deref(&self) -> &Self::Target21     fn deref(&self) -> &Self::Target {
22         &self.0
23     }
24 }
25 
26 impl<'a> From<JClass<'a>> for JObject<'a> {
from(other: JClass) -> JObject27     fn from(other: JClass) -> JObject {
28         other.0
29     }
30 }
31 
32 /// This conversion assumes that the `JObject` is a pointer to a class object.
33 impl<'a> From<JObject<'a>> for JClass<'a> {
from(other: JObject) -> JClass34     fn from(other: JObject) -> JClass {
35         (other.into_inner() as jclass).into()
36     }
37 }
38