pub struct MergeResolver { /* private fields */ }Expand description
Resolves a DuplicateGroup to a single canonical file using a
configured MergeStrategy and LinkMode.
Two resolution paths are provided:
MergeResolver::resolve— reads filesystem metadata for scoring.MergeResolver::resolve_from_candidates— accepts pre-builtFileCandidatedata (no filesystem access required).
Implementations§
Source§impl MergeResolver
impl MergeResolver
Sourcepub fn new(strategy: MergeStrategy, link_mode: LinkMode) -> Self
pub fn new(strategy: MergeStrategy, link_mode: LinkMode) -> Self
Create a new resolver.
Sourcepub fn default_delete() -> Self
pub fn default_delete() -> Self
Create a resolver that deletes duplicates and keeps with KeepLargest.
Sourcepub fn strategy(&self) -> MergeStrategy
pub fn strategy(&self) -> MergeStrategy
Returns the configured strategy.
Sourcepub fn resolve(&self, group: &DuplicateGroup) -> PathBuf
pub fn resolve(&self, group: &DuplicateGroup) -> PathBuf
Resolve which file to keep by reading filesystem metadata.
For each file in group.files, attempts to read its metadata (size,
mtime). Files whose metadata cannot be read are assigned zero values and
will lose to files with valid metadata under most strategies.
Returns the path of the file to keep. Falls back to the first file when
group.files is empty.
Sourcepub fn resolve_from_candidates(
&self,
candidates: &[FileCandidate],
) -> Option<PathBuf>
pub fn resolve_from_candidates( &self, candidates: &[FileCandidate], ) -> Option<PathBuf>
Resolve from pre-built candidate metadata (no filesystem access).
Returns the path of the winning candidate, or None if candidates
is empty.
Trait Implementations§
Source§impl Clone for MergeResolver
impl Clone for MergeResolver
Source§fn clone(&self) -> MergeResolver
fn clone(&self) -> MergeResolver
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MergeResolver
impl RefUnwindSafe for MergeResolver
impl Send for MergeResolver
impl Sync for MergeResolver
impl Unpin for MergeResolver
impl UnsafeUnpin for MergeResolver
impl UnwindSafe for MergeResolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more