2222 Report : ParallelReporter < Size > + Sync ,
2323 Size : size:: Size + Into < u64 > + Serialize + Send + Sync ,
2424 SizeGetter : GetSize < Size = Size > + Copy + Sync ,
25- HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
25+ HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Sync ,
2626 JsonTree < Size > : Into < JsonDataBody > ,
2727{
2828 /// List of files and/or directories.
4343 pub size_getter : SizeGetter ,
4444 /// Handle to detect, record, and deduplicate hardlinks.
4545 pub hardlinks_handler : HardlinksHandler ,
46- /// Record of detected hardlinks.
47- pub hardlink_record : HardlinksHandler :: HardlinkRecord ,
4846 /// Reports measurement progress.
4947 pub reporter : Report ,
5048 /// Minimal size proportion required to appear.
5856 Size : size:: Size + Into < u64 > + Serialize + Send + Sync ,
5957 Report : ParallelReporter < Size > + Sync ,
6058 SizeGetter : GetSize < Size = Size > + Copy + Sync ,
61- HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
59+ HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Sync ,
6260 JsonTree < Size > : Into < JsonDataBody > ,
6361{
6462 /// Run the sub program.
7371 max_depth,
7472 size_getter,
7573 hardlinks_handler,
76- hardlink_record,
7774 reporter,
7875 min_ratio,
7976 no_sort,
8885 reporter : & reporter,
8986 root,
9087 size_getter,
91- hardlinks_recorder : hardlinks_handler,
88+ hardlinks_recorder : & hardlinks_handler,
9289 max_depth,
9390 }
9491 . into ( )
10097 return Sub {
10198 files : vec ! [ "." . into( ) ] ,
10299 hardlinks_handler,
103- hardlink_record,
104100 reporter,
105101 ..self
106102 }
@@ -133,8 +129,7 @@ where
133129 if !no_sort {
134130 data_tree. par_sort_by ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
135131 }
136- let deduplication_record =
137- HardlinksHandler :: deduplicate_hardlink_sizes ( & mut data_tree, hardlink_record) ;
132+ let deduplication_record = hardlinks_handler. deduplicate_hardlink_sizes ( & mut data_tree) ;
138133 ( data_tree, deduplication_record)
139134 } ;
140135
@@ -172,15 +167,13 @@ where
172167}
173168
174169/// Subroutines used by [`Sub`] to deduplicate sizes of detected hardlinks and report about it.
175- pub trait DeduplicateHardlinkSizes < Size : size:: Size > {
176- /// Record of detected hardlinks.
177- type HardlinkRecord ;
170+ pub trait DeduplicateHardlinkSizes < Size : size:: Size > : Sized {
178171 /// Report created by [`DeduplicateHardlinkSizes::deduplicate_hardlink_sizes`].
179172 type DeduplicationReport ;
180173 /// Deduplicate the sizes of detected hardlinks and return a report object.
181174 fn deduplicate_hardlink_sizes (
175+ self ,
182176 data_tree : & mut DataTree < OsStringDisplay , Size > ,
183- record : Self :: HardlinkRecord ,
184177 ) -> Result < Self :: DeduplicationReport , RuntimeError > ;
185178 /// Handle the report.
186179 fn report_deduplication_results (
@@ -194,20 +187,20 @@ pub trait DeduplicateHardlinkSizes<Size: size::Size> {
194187}
195188
196189#[ cfg( unix) ]
197- impl < ' a , Size > DeduplicateHardlinkSizes < Size > for crate :: hardlink:: HardlinkAware < ' a , Size >
190+ impl < Size > DeduplicateHardlinkSizes < Size > for crate :: hardlink:: HardlinkAware < Size >
198191where
199192 DataTree < OsStringDisplay , Size > : Send ,
200193 Size : size:: Size + Sync ,
201194{
202- type HardlinkRecord = & ' a crate :: hardlink:: HardlinkList < Size > ;
203- type DeduplicationReport = & ' a crate :: hardlink:: HardlinkList < Size > ;
195+ type DeduplicationReport = crate :: hardlink:: HardlinkList < Size > ;
204196
205197 fn deduplicate_hardlink_sizes (
198+ self ,
206199 data_tree : & mut DataTree < OsStringDisplay , Size > ,
207- record : Self :: HardlinkRecord ,
208200 ) -> Result < Self :: DeduplicationReport , RuntimeError > {
209201 use crate :: hardlink:: LinkPathList ;
210202 use std:: path:: Path ;
203+ let record: Self :: DeduplicationReport = self . into ( ) ;
211204 let hardlink_info: Box < [ ( Size , LinkPathList ) ] > = record
212205 . iter ( )
213206 . map ( |values| ( * values. size ( ) , values. links ( ) . clone ( ) ) )
@@ -248,11 +241,7 @@ where
248241 fn reflect_deduplication_results (
249242 report : Self :: DeduplicationReport ,
250243 ) -> Result < Option < HardlinkListReflection < Size > > , RuntimeError > {
251- if report. is_empty ( ) {
252- Ok ( None )
253- } else {
254- report. clone ( ) . into_reflection ( ) . pipe ( Some ) . pipe ( Ok )
255- }
244+ report. into_reflection ( ) . pipe ( Some ) . pipe ( Ok )
256245 }
257246}
258247
@@ -261,12 +250,11 @@ where
261250 DataTree < OsStringDisplay , Size > : Send ,
262251 Size : size:: Size + Sync ,
263252{
264- type HardlinkRecord = ( ) ;
265253 type DeduplicationReport = ( ) ;
266254
267255 fn deduplicate_hardlink_sizes (
256+ self ,
268257 _: & mut DataTree < OsStringDisplay , Size > ,
269- _: Self :: HardlinkRecord ,
270258 ) -> Result < Self :: DeduplicationReport , RuntimeError > {
271259 Ok ( ( ) )
272260 }
0 commit comments