38 lines
797 B
Rust
38 lines
797 B
Rust
use std::collections::BTreeMap;
|
|
use std::fs::File;
|
|
use std::path::PathBuf;
|
|
|
|
pub struct Package {
|
|
name: String,
|
|
path: PathBuf,
|
|
}
|
|
|
|
impl Package {
|
|
pub fn open(&self) -> Result<File, std::io::Error> {
|
|
let filepath = self.path.join("main.hyd");
|
|
File::open(filepath)
|
|
}
|
|
}
|
|
|
|
pub struct PackageRegistry {
|
|
packages: BTreeMap<String, Package>,
|
|
}
|
|
|
|
impl PackageRegistry {
|
|
pub fn new() -> Self {
|
|
let mut packages = BTreeMap::new();
|
|
packages.insert(
|
|
"builtins".to_string(),
|
|
Package {
|
|
name: "builtins".to_string(),
|
|
path: "./lib/builtins/".into(),
|
|
},
|
|
);
|
|
Self { packages }
|
|
}
|
|
|
|
pub fn get(&self, name: &str) -> Option<&Package> {
|
|
self.packages.get(name)
|
|
}
|
|
}
|