use crate::{
errors::*,
objects::{AutoLocal, JObject},
JNIEnv,
};
#[cfg(doc)]
use crate::objects::{JClass, JMethodID};
pub unsafe trait Desc<'local, T> {
type Output: AsRef<T>;
fn lookup(self, _: &mut JNIEnv<'local>) -> Result<Self::Output>;
}
unsafe impl<'local, T> Desc<'local, T> for T
where
T: AsRef<T>,
{
type Output = Self;
fn lookup(self, _: &mut JNIEnv<'local>) -> Result<T> {
Ok(self)
}
}
unsafe impl<'local, 't_ref, T> Desc<'local, T> for &'t_ref T
where
T: AsRef<T>,
{
type Output = Self;
fn lookup(self, _: &mut JNIEnv<'local>) -> Result<Self::Output> {
Ok(self)
}
}
unsafe impl<'local, 'other_local, T> Desc<'local, T> for AutoLocal<'other_local, T>
where
T: AsRef<T> + Into<JObject<'other_local>>,
{
type Output = Self;
fn lookup(self, _: &mut JNIEnv<'local>) -> Result<Self::Output> {
Ok(self)
}
}
unsafe impl<'local, 'other_local, 'obj_ref, T> Desc<'local, T>
for &'obj_ref AutoLocal<'other_local, T>
where
T: AsRef<T> + Into<JObject<'other_local>>,
{
type Output = Self;
fn lookup(self, _: &mut JNIEnv<'local>) -> Result<Self::Output> {
Ok(self)
}
}