From 0b3c4b81439d170b4e1f85f0eee95a582115f694 Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Fri, 29 May 2026 20:33:30 +0200 Subject: [PATCH] Module structure --- crates/mist-api/src/modules.mist | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/mist-api/src/modules.mist b/crates/mist-api/src/modules.mist index fa806cc..c186634 100644 --- a/crates/mist-api/src/modules.mist +++ b/crates/mist-api/src/modules.mist @@ -8,10 +8,9 @@ pub class Module { pub PathBuf path; pub Vec children; - pub constructor(PathBuf mist_path) { + pub constructor(String name, PathBuf mist_path, PathBuf rust_path) { self.children = new Vec(); - self.name = mist_path.file_stem() - .and_then(|var s| s.to_str()).expect("Failed to get module name").to_string(); + self.name = name; self.path = mist_path; if (self.path.is_dir()) { @@ -40,12 +39,32 @@ pub class Module { PathBuf child_path = entry.path(); - self.children.push(new Module(child_path)); + String child_name = child_path.file_stem() + .and_then(|var s| s.to_str()) + .expect("Failed to get module name") + .to_string(); + + PathBuf child_output = rust_path.join(&child_name).with_extension("rs"); + + if (should_skip(&child_path, &child_output)) { + continue; + } + + self.children.push(new Module(child_name, child_path, child_output)); } } } } +pub Module new_package(PathBuf mist_path, PathBuf rust_path) { + String name = mist_path.file_stem() + .and_then(|var s| s.to_str()) + .expect("Failed to get module name") + .to_string(); + + new Module(name, mist_path, rust_path) +} + bool should_skip(Path* source, Path* output) { var src_time = fs::metadata(source) .ok()