Skip to main content

lisette_semantics/
loader.rs

1use rustc_hash::FxHashMap as HashMap;
2
3/// Source content plus a cwd-relative display path for diagnostics.
4/// `display_path` matches `name` for loaders that have no notion of cwd
5/// (test/overlay loaders); the CLI's filesystem loader sets it to the path
6/// relative to the process cwd.
7#[derive(Debug, Clone)]
8pub struct FileContent {
9    pub source: String,
10    pub display_path: String,
11}
12
13impl FileContent {
14    pub fn new(source: impl Into<String>, display_path: impl Into<String>) -> Self {
15        Self {
16            source: source.into(),
17            display_path: display_path.into(),
18        }
19    }
20}
21
22pub type Files = HashMap<String, FileContent>;
23
24pub trait Loader {
25    /// Scans a folder and returns all `.lis` files keyed by bare filename.
26    fn scan_folder(&self, folder: &str) -> Files;
27}