1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use crate::{errors::*, JNIEnv};

/// Trait for things that can be looked up through the JNI via a descriptor.
/// This will be something like the fully-qualified class name
/// `java/lang/String` or a tuple containing a class descriptor, method name,
/// and method signature. For convenience, this is also implemented for the
/// concrete types themselves in addition to their descriptors.
pub trait Desc<'a, T> {
    /// Look up the concrete type from the JVM.
    fn lookup(self, _: &JNIEnv<'a>) -> Result<T>;
}

impl<'a, T> Desc<'a, T> for T {
    fn lookup(self, _: &JNIEnv<'a>) -> Result<T> {
        Ok(self)
    }
}