#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NativeFnId(pub u32);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NativeTypeId(pub u32);
pub trait NativeProvider: Send + Sync {
fn modules(&self) -> Vec<NativeModule>;
fn expand(&self, path: &[String]) -> NativeModule;
}
impl<T: NativeProvider + ?Sized> NativeProvider for std::sync::Arc<T> {
fn modules(&self) -> Vec<NativeModule> {
(**self).modules()
}
fn expand(&self, path: &[String]) -> NativeModule {
(**self).expand(path)
}
}
impl NativeProvider for Vec<NativeModule> {
fn modules(&self) -> Vec<NativeModule> {
self.clone()
}
fn expand(&self, path: &[String]) -> NativeModule {
panic!("`{}` was not declared lazy", path.join("::"))
}
}
#[derive(Debug, Clone, Default)]
pub struct NativeModule {
pub name: String,
pub lazy: bool,
pub functions: Vec<NativeFnDecl>,
pub types: Vec<NativeTypeDecl>,
pub modules: Vec<NativeModule>,
}
#[derive(Debug, Clone)]
pub struct NativeFnDecl {
pub name: String,
pub id: NativeFnId,
}
#[derive(Debug, Clone)]
pub struct NativeTypeDecl {
pub name: String,
pub id: NativeTypeId,
pub functions: Vec<NativeFnDecl>,
}