Skip to content

Commit

Permalink
Incorporate alias into PathDeconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
kimono-koans committed Jan 5, 2024
1 parent d2a5db9 commit be471d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/data/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl BasicDirEntryInfo {
}

pub trait PathDeconstruction<'a> {
fn alias(&self) -> Option<AliasedPath>;
fn target(&self, proximate_dataset_mount: &Path) -> Option<PathBuf>;
fn source(&self, opt_proximate_dataset_mount: Option<&'a Path>) -> Option<PathBuf>;
fn relative_path(&'a self, proximate_dataset_mount: &'a Path) -> HttmResult<&'a Path>;
Expand Down Expand Up @@ -174,13 +175,12 @@ impl PathData {
HttmError::new(&msg).into()
})
}

pub fn alias(&self) -> Option<AliasedPath> {
AliasedPath::new(&self.path_buf)
}
}

impl<'a> PathDeconstruction<'a> for PathData {
fn alias(&self) -> Option<AliasedPath> {
AliasedPath::new(&self.path_buf)
}
fn relative_path(&'a self, proximate_dataset_mount: &Path) -> HttmResult<&'a Path> {
// path strip, if aliased
// fallback if unable to find an alias or strip a prefix
Expand Down Expand Up @@ -278,6 +278,11 @@ impl<'a> ZfsSnapPathGuard<'a> {
}

impl<'a> PathDeconstruction<'a> for ZfsSnapPathGuard<'_> {
fn alias(&self) -> Option<AliasedPath> {
// aliases aren't allowed for snap paths
None
}

fn target(&self, proximate_dataset_mount: &Path) -> Option<PathBuf> {
self.relative_path(proximate_dataset_mount)
.ok()
Expand Down

0 comments on commit be471d6

Please sign in to comment.