Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : add generics check for Machine #12

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/architecture/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl MemoryRegion {
"Invalid memory region, start address is greater than or equal to end address"
));
}

Ok(Self {
region_type,
start_address,
Expand Down Expand Up @@ -157,14 +156,24 @@ impl Machine {
memory_regions: MemorySpace,
dumpfile: PathBuf,
outfolder: PathBuf,
) -> Self {
// TODO: Validate each field

Self {
) -> Result<Self> {
// Check if the dump file exists
if !dumpfile.exists() {
return Err(anyhow::anyhow!("Dump file does not exist"));
}
// Check if the output folder exists
if !outfolder.exists() {
return Err(anyhow::anyhow!("Output folder does not exist"));
}
// Check if the output folder is empty
if outfolder.read_dir()?.next().is_some() {
return Err(anyhow::anyhow!("Output folder is not empty"));
}
Ok(Self {
machine_type,
memory_regions,
dumpfile,
outfolder,
}
})
}
}
Loading