@@ -3,8 +3,7 @@ use crate::{
33 data_tree:: DataTree ,
44 fs_tree_builder:: FsTreeBuilder ,
55 get_size:: GetSize ,
6- hardlink:: HardlinkListReflection ,
7- hook,
6+ hardlink:: { HardlinkIgnorant , HardlinkListReflection , RecordHardlinks } ,
87 json_data:: { BinaryVersion , JsonData , JsonDataBody , JsonTree , SchemaVersion } ,
98 os_string_display:: OsStringDisplay ,
109 reporter:: ParallelReporter ,
@@ -18,12 +17,12 @@ use serde::Serialize;
1817use std:: { io:: stdout, iter:: once, num:: NonZeroU64 , path:: PathBuf } ;
1918
2019/// The sub program of the main application.
21- pub struct Sub < Size , SizeGetter , Hook , Report >
20+ pub struct Sub < Size , SizeGetter , HardlinksHandler , Report >
2221where
2322 Report : ParallelReporter < Size > + Sync ,
2423 Size : size:: Size + Into < u64 > + Serialize + Send + Sync ,
2524 SizeGetter : GetSize < Size = Size > + Copy + Sync ,
26- Hook : hook :: Hook < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
25+ HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
2726 JsonTree < Size > : Into < JsonDataBody > ,
2827{
2928 /// List of files and/or directories.
@@ -42,10 +41,10 @@ where
4241 pub max_depth : NonZeroU64 ,
4342 /// [Get the size](GetSize) of files/directories.
4443 pub size_getter : SizeGetter ,
45- /// Hook to run after [`Self::size_getter`] .
46- pub hook : Hook ,
44+ /// Handle to detect, record, and deduplicate hardlinks .
45+ pub hardlinks_handler : HardlinksHandler ,
4746 /// Record of detected hardlinks.
48- pub hardlink_record : Hook :: HardlinkRecord ,
47+ pub hardlink_record : HardlinksHandler :: HardlinkRecord ,
4948 /// Reports measurement progress.
5049 pub reporter : Report ,
5150 /// Minimal size proportion required to appear.
@@ -54,12 +53,12 @@ where
5453 pub no_sort : bool ,
5554}
5655
57- impl < Size , SizeGetter , Hook , Report > Sub < Size , SizeGetter , Hook , Report >
56+ impl < Size , SizeGetter , HardlinksHandler , Report > Sub < Size , SizeGetter , HardlinksHandler , Report >
5857where
5958 Size : size:: Size + Into < u64 > + Serialize + Send + Sync ,
6059 Report : ParallelReporter < Size > + Sync ,
6160 SizeGetter : GetSize < Size = Size > + Copy + Sync ,
62- Hook : hook :: Hook < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
61+ HardlinksHandler : RecordHardlinks < Size , Report > + DeduplicateHardlinkSizes < Size > + Copy + Sync ,
6362 JsonTree < Size > : Into < JsonDataBody > ,
6463{
6564 /// Run the sub program.
7372 column_width_distribution,
7473 max_depth,
7574 size_getter,
76- hook ,
75+ hardlinks_handler ,
7776 hardlink_record,
7877 reporter,
7978 min_ratio,
8988 reporter : & reporter,
9089 root,
9190 size_getter,
92- hook ,
91+ hardlinks_recorder : hardlinks_handler ,
9392 max_depth,
9493 }
9594 . into ( )
10099 } else {
101100 return Sub {
102101 files : vec ! [ "." . into( ) ] ,
103- hook ,
102+ hardlinks_handler ,
104103 hardlink_record,
105104 reporter,
106105 ..self
@@ -135,7 +134,7 @@ where
135134 data_tree. par_sort_by ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
136135 }
137136 let deduplication_record =
138- Hook :: deduplicate_hardlink_sizes ( & mut data_tree, hardlink_record) ;
137+ HardlinksHandler :: deduplicate_hardlink_sizes ( & mut data_tree, hardlink_record) ;
139138 ( data_tree, deduplication_record)
140139 } ;
141140
@@ -146,7 +145,8 @@ where
146145 . into_reflection ( ) // I really want to use std::mem::transmute here but can't.
147146 . par_convert_names_to_utf8 ( ) // TODO: allow non-UTF8 somehow.
148147 . expect ( "convert all names from raw string to UTF-8" ) ;
149- let shared = deduplication_record?. pipe ( Hook :: reflect_deduplication_results) ?;
148+ let shared =
149+ deduplication_record?. pipe ( HardlinksHandler :: reflect_deduplication_results) ?;
150150 let json_tree = JsonTree { tree, shared } ;
151151 let json_data = JsonData {
152152 schema_version : SchemaVersion ,
@@ -166,7 +166,7 @@ where
166166 } ;
167167
168168 print ! ( "{visualizer}" ) ; // visualizer already ends with "\n", println! isn't needed here.
169- Hook :: report_deduplication_results ( deduplication_record?, bytes_format) ?;
169+ HardlinksHandler :: report_deduplication_results ( deduplication_record?, bytes_format) ?;
170170 Ok ( ( ) )
171171 }
172172}
@@ -194,7 +194,7 @@ pub trait DeduplicateHardlinkSizes<Size: size::Size> {
194194}
195195
196196#[ cfg( unix) ]
197- impl < ' a , Size > DeduplicateHardlinkSizes < Size > for hook :: RecordHardlink < ' a , Size >
197+ impl < ' a , Size > DeduplicateHardlinkSizes < Size > for crate :: hardlink :: HardlinkAware < ' a , Size >
198198where
199199 DataTree < OsStringDisplay , Size > : Send ,
200200 Size : size:: Size + Sync ,
@@ -256,7 +256,7 @@ where
256256 }
257257}
258258
259- impl < Size > DeduplicateHardlinkSizes < Size > for hook :: DoNothing
259+ impl < Size > DeduplicateHardlinkSizes < Size > for HardlinkIgnorant
260260where
261261 DataTree < OsStringDisplay , Size > : Send ,
262262 Size : size:: Size + Sync ,
0 commit comments