1 use crate::{ 2 objects::JObject, 3 sys::{jobject, jstring}, 4 }; 5 6 /// Lifetime'd representation of a `jstring`. Just a `JObject` wrapped in a new 7 /// class. 8 #[repr(transparent)] 9 #[derive(Clone, Copy)] 10 pub struct JString<'a>(JObject<'a>); 11 12 impl<'a> From<jstring> for JString<'a> { from(other: jstring) -> Self13 fn from(other: jstring) -> Self { 14 JString(From::from(other as jobject)) 15 } 16 } 17 18 impl<'a> ::std::ops::Deref for JString<'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<JString<'a>> for JObject<'a> { from(other: JString) -> JObject27 fn from(other: JString) -> JObject { 28 other.0 29 } 30 } 31 32 impl<'a> From<JObject<'a>> for JString<'a> { from(other: JObject) -> JString33 fn from(other: JObject) -> JString { 34 (other.into_inner() as jstring).into() 35 } 36 } 37